@mastra/deployer 0.10.3 → 0.10.4-alpha.1

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.
@@ -42,9 +42,9 @@ var util__default = /*#__PURE__*/_interopDefault(util);
42
42
 
43
43
  // src/server/index.ts
44
44
  var RequestError = class extends Error {
45
- static name = "RequestError";
46
45
  constructor(message, options) {
47
46
  super(message, options);
47
+ this.name = "RequestError";
48
48
  }
49
49
  };
50
50
  var toRequestError = (e2) => {
@@ -197,6 +197,72 @@ var newRequest = (incoming, defaultHostname) => {
197
197
  req[urlKey] = url.href;
198
198
  return req;
199
199
  };
200
+ var responseCache = Symbol("responseCache");
201
+ var getResponseCache = Symbol("getResponseCache");
202
+ var cacheKey = Symbol("cache");
203
+ var GlobalResponse = global.Response;
204
+ var Response2 = class _Response {
205
+ #body;
206
+ #init;
207
+ [getResponseCache]() {
208
+ delete this[cacheKey];
209
+ return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
210
+ }
211
+ constructor(body, init) {
212
+ let headers;
213
+ this.#body = body;
214
+ if (init instanceof _Response) {
215
+ const cachedGlobalResponse = init[responseCache];
216
+ if (cachedGlobalResponse) {
217
+ this.#init = cachedGlobalResponse;
218
+ this[getResponseCache]();
219
+ return;
220
+ } else {
221
+ this.#init = init.#init;
222
+ headers = new Headers(init.#init.headers);
223
+ }
224
+ } else {
225
+ this.#init = init;
226
+ }
227
+ if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
228
+ headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
229
+ this[cacheKey] = [init?.status || 200, body, headers];
230
+ }
231
+ }
232
+ get headers() {
233
+ const cache = this[cacheKey];
234
+ if (cache) {
235
+ if (!(cache[2] instanceof Headers)) {
236
+ cache[2] = new Headers(cache[2]);
237
+ }
238
+ return cache[2];
239
+ }
240
+ return this[getResponseCache]().headers;
241
+ }
242
+ get status() {
243
+ return this[cacheKey]?.[0] ?? this[getResponseCache]().status;
244
+ }
245
+ get ok() {
246
+ const status = this.status;
247
+ return status >= 200 && status < 300;
248
+ }
249
+ };
250
+ ["body", "bodyUsed", "redirected", "statusText", "trailers", "type", "url"].forEach((k) => {
251
+ Object.defineProperty(Response2.prototype, k, {
252
+ get() {
253
+ return this[getResponseCache]()[k];
254
+ }
255
+ });
256
+ });
257
+ ["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
258
+ Object.defineProperty(Response2.prototype, k, {
259
+ value: function() {
260
+ return this[getResponseCache]()[k]();
261
+ }
262
+ });
263
+ });
264
+ Object.setPrototypeOf(Response2, GlobalResponse);
265
+ Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
200
266
  function writeFromReadableStream(stream4, writable) {
201
267
  if (stream4.locked) {
202
268
  throw new TypeError("ReadableStream is locked.");
@@ -255,83 +321,6 @@ var buildOutgoingHttpHeaders = (headers) => {
255
321
  res["content-type"] ??= "text/plain; charset=UTF-8";
256
322
  return res;
257
323
  };
258
- var responseCache = Symbol("responseCache");
259
- var getResponseCache = Symbol("getResponseCache");
260
- var cacheKey = Symbol("cache");
261
- var GlobalResponse = global.Response;
262
- var Response2 = class _Response {
263
- #body;
264
- #init;
265
- [getResponseCache]() {
266
- delete this[cacheKey];
267
- return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
268
- }
269
- constructor(body, init) {
270
- this.#body = body;
271
- if (init instanceof _Response) {
272
- const cachedGlobalResponse = init[responseCache];
273
- if (cachedGlobalResponse) {
274
- this.#init = cachedGlobalResponse;
275
- this[getResponseCache]();
276
- return;
277
- } else {
278
- this.#init = init.#init;
279
- }
280
- } else {
281
- this.#init = init;
282
- }
283
- if (typeof body === "string" || typeof body?.getReader !== "undefined") {
284
- let headers = init?.headers || { "content-type": "text/plain; charset=UTF-8" };
285
- if (headers instanceof Headers) {
286
- headers = buildOutgoingHttpHeaders(headers);
287
- }
288
- this[cacheKey] = [init?.status || 200, body, headers];
289
- }
290
- }
291
- };
292
- [
293
- "body",
294
- "bodyUsed",
295
- "headers",
296
- "ok",
297
- "redirected",
298
- "status",
299
- "statusText",
300
- "trailers",
301
- "type",
302
- "url"
303
- ].forEach((k) => {
304
- Object.defineProperty(Response2.prototype, k, {
305
- get() {
306
- return this[getResponseCache]()[k];
307
- }
308
- });
309
- });
310
- ["arrayBuffer", "blob", "clone", "formData", "json", "text"].forEach((k) => {
311
- Object.defineProperty(Response2.prototype, k, {
312
- value: function() {
313
- return this[getResponseCache]()[k]();
314
- }
315
- });
316
- });
317
- Object.setPrototypeOf(Response2, GlobalResponse);
318
- Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
319
- var stateKey = Reflect.ownKeys(new GlobalResponse()).find(
320
- (k) => typeof k === "symbol" && k.toString() === "Symbol(state)"
321
- );
322
- if (!stateKey) {
323
- console.warn("Failed to find Response internal state key");
324
- }
325
- function getInternalBody(response) {
326
- if (!stateKey) {
327
- return;
328
- }
329
- if (response instanceof Response2) {
330
- response = response[getResponseCache]();
331
- }
332
- const state = response[stateKey];
333
- return state && state.body || void 0;
334
- }
335
324
  var X_ALREADY_SENT = "x-hono-already-sent";
336
325
  var webFetch = global.fetch;
337
326
  if (typeof global.crypto === "undefined") {
@@ -367,14 +356,24 @@ var handleResponseError = (e2, outgoing) => {
367
356
  outgoing.destroy(err);
368
357
  }
369
358
  };
370
- var responseViaCache = (res, outgoing) => {
371
- const [status, body, header] = res[cacheKey];
359
+ var responseViaCache = async (res, outgoing) => {
360
+ let [status, body, header] = res[cacheKey];
361
+ if (header instanceof Headers) {
362
+ header = buildOutgoingHttpHeaders(header);
363
+ }
372
364
  if (typeof body === "string") {
373
365
  header["Content-Length"] = Buffer.byteLength(body);
374
- outgoing.writeHead(status, header);
366
+ } else if (body instanceof Uint8Array) {
367
+ header["Content-Length"] = body.byteLength;
368
+ } else if (body instanceof Blob) {
369
+ header["Content-Length"] = body.size;
370
+ }
371
+ outgoing.writeHead(status, header);
372
+ if (typeof body === "string" || body instanceof Uint8Array) {
375
373
  outgoing.end(body);
374
+ } else if (body instanceof Blob) {
375
+ outgoing.end(new Uint8Array(await body.arrayBuffer()));
376
376
  } else {
377
- outgoing.writeHead(status, header);
378
377
  return writeFromReadableStream(body, outgoing)?.catch(
379
378
  (e2) => handleResponseError(e2, outgoing)
380
379
  );
@@ -400,24 +399,6 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
400
399
  return responseViaCache(res, outgoing);
401
400
  }
402
401
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
403
- const internalBody = getInternalBody(res);
404
- if (internalBody) {
405
- const { length, source, stream: stream4 } = internalBody;
406
- if (source instanceof Uint8Array && source.byteLength !== length) ; else {
407
- if (length) {
408
- resHeaderRecord["content-length"] = length;
409
- }
410
- outgoing.writeHead(res.status, resHeaderRecord);
411
- if (typeof source === "string" || source instanceof Uint8Array) {
412
- outgoing.end(source);
413
- } else if (source instanceof Blob) {
414
- outgoing.end(new Uint8Array(await source.arrayBuffer()));
415
- } else {
416
- await writeFromReadableStream(stream4, outgoing);
417
- }
418
- return;
419
- }
420
- }
421
402
  if (res.body) {
422
403
  const {
423
404
  "transfer-encoding": transferEncoding,
@@ -748,131 +729,148 @@ var middleware = (options) => async (c2) => {
748
729
  );
749
730
  };
750
731
 
751
- // ../../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
732
+ // ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.7.11_openapi-types@12.1.3_zod@3.25.56/node_modules/hono-openapi/utils.js
752
733
  var e = Symbol("openapi");
753
- var s2 = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
754
- var n = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
734
+ var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
735
+ var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
755
736
  var o = /* @__PURE__ */ new Map();
756
737
  var a = (e2, t2) => {
757
- const s3 = `${e2}:${t2}`;
758
- if (o.has(s3)) return o.get(s3);
738
+ const n2 = `${e2}:${t2}`;
739
+ if (o.has(n2)) return o.get(n2);
759
740
  let a2 = e2;
760
741
  if ("/" === t2) return `${a2}Index`;
761
- for (const e3 of t2.split("/")) 123 === e3.charCodeAt(0) ? a2 += `By${n(e3.slice(1, -1))}` : a2 += n(e3);
762
- return o.set(s3, a2), a2;
742
+ for (const e3 of t2.split("/")) 123 === e3.charCodeAt(0) ? a2 += `By${s2(e3.slice(1, -1))}` : a2 += s2(e3);
743
+ return o.set(n2, a2), a2;
763
744
  };
764
745
  var r = /* @__PURE__ */ new Map();
765
- function c(e2, t2, s3) {
766
- return e2 && t2 in e2 ? e2[t2] ?? s3 : s3;
746
+ function c(e2, t2, n2) {
747
+ return e2 && t2 in e2 ? e2[t2] ?? n2 : n2;
767
748
  }
768
749
  function i(...e2) {
769
750
  return e2.reduce((e3, t2) => {
770
751
  if (!t2) return e3;
771
- let s3;
772
- return ("tags" in e3 && e3.tags || "tags" in t2 && t2.tags) && (s3 = [...c(e3, "tags", []), ...c(t2, "tags", [])]), { ...e3, ...t2, tags: s3, responses: { ...c(e3, "responses", {}), ...c(t2, "responses", {}) }, parameters: m(e3.parameters, t2.parameters) };
752
+ let n2;
753
+ return ("tags" in e3 && e3.tags || "tags" in t2 && t2.tags) && (n2 = Array.from(/* @__PURE__ */ new Set([...c(e3, "tags", []), ...c(t2, "tags", [])]))), { ...e3, ...t2, tags: n2, responses: { ...c(e3, "responses", {}), ...c(t2, "responses", {}) }, parameters: m(e3.parameters, t2.parameters) };
773
754
  }, {});
774
755
  }
775
- function p({ path: e2, method: t2, data: s3, schema: n2 }) {
756
+ function p({ path: e2, method: t2, data: n2, schema: s3 }) {
776
757
  e2 = ((e3) => e3.split("/").map((e4) => {
777
758
  let t3 = e4;
778
- return t3.startsWith(":") && (t3 = t3.slice(1, t3.length), t3.endsWith("?") && (t3 = t3.slice(0, -1)), t3 = `{${t3}}`), t3;
759
+ if (t3.startsWith(":")) {
760
+ const e5 = t3.match(/^:([^{?]+)(?:{(.+)})?(\?)?$/);
761
+ e5 ? t3 = `{${e5[1]}}` : (t3 = t3.slice(1, t3.length), t3.endsWith("?") && (t3 = t3.slice(0, -1)), t3 = `{${t3}}`);
762
+ }
763
+ return t3;
779
764
  }).join("/"))(e2);
780
765
  const o2 = t2.toLowerCase();
781
- if ("all" === o2) if (r.has(e2)) {
782
- const t3 = r.get(e2) ?? {};
783
- r.set(e2, { ...t3, ...s3, parameters: m(t3.parameters, s3.parameters) });
784
- } else r.set(e2, s3);
785
- else {
766
+ if ("all" === o2) {
767
+ if (!n2) return;
768
+ if (r.has(e2)) {
769
+ const t3 = r.get(e2) ?? {};
770
+ r.set(e2, { ...t3, ...n2, parameters: m(t3.parameters, n2.parameters) });
771
+ } else r.set(e2, n2);
772
+ } else {
786
773
  const t3 = function(e3) {
787
774
  const t4 = Array.from(r.keys());
788
- let s4 = {};
789
- for (const n3 of t4) e3.match(n3) && (s4 = i(s4, r.get(n3) ?? {}));
790
- return s4;
775
+ let n3 = {};
776
+ for (const s4 of t4) e3.match(s4) && (n3 = i(n3, r.get(s4) ?? {}));
777
+ return n3;
791
778
  }(e2);
792
- n2[e2] = { ...n2[e2] ? n2[e2] : {}, [o2]: { responses: {}, operationId: a(o2, e2), ...i(t3, n2[e2]?.[o2], s3) } };
779
+ s3[e2] = { ...s3[e2] ? s3[e2] : {}, [o2]: { responses: {}, operationId: a(o2, e2), ...i(t3, s3[e2]?.[o2], n2) } };
793
780
  }
794
781
  }
795
- var l = (e2) => "$ref" in e2 ? e2.$ref : `${e2.in} ${e2.name}`;
782
+ var f = (e2) => "$ref" in e2 ? e2.$ref : `${e2.in} ${e2.name}`;
796
783
  function m(...e2) {
797
- const t2 = e2.flatMap((e3) => e3 ?? []).reduce((e3, t3) => (e3.set(l(t3), t3), e3), /* @__PURE__ */ new Map());
784
+ const t2 = e2.flatMap((e3) => e3 ?? []).reduce((e3, t3) => (e3.set(f(t3), t3), e3), /* @__PURE__ */ new Map());
798
785
  return Array.from(t2.values());
799
786
  }
800
- function u(e2, { excludeStaticFile: t2 = true, exclude: s3 = [] }) {
801
- const n2 = {}, o2 = Array.isArray(s3) ? s3 : [s3];
802
- for (const [s4, a2] of Object.entries(e2)) if (!(o2.some((e3) => "string" == typeof e3 ? s4 === e3 : e3.test(s4)) || s4.includes("*") || t2 && s4.includes("."))) {
787
+ function l(e2, { excludeStaticFile: t2 = true, exclude: n2 = [] }) {
788
+ const s3 = {}, o2 = Array.isArray(n2) ? n2 : [n2];
789
+ for (const [n3, a2] of Object.entries(e2)) if (!o2.some((e3) => "string" == typeof e3 ? n3 === e3 : e3.test(n3)) && (!n3.includes("*") || n3.includes("{")) && (!t2 || (!n3.includes(".") || n3.includes("{")))) {
803
790
  for (const e3 of Object.keys(a2)) {
804
791
  const t3 = a2[e3];
805
- if (s4.includes("{")) {
792
+ if (n3.includes("{")) {
806
793
  t3.parameters || (t3.parameters = []);
807
- const e4 = s4.split("/").filter((e5) => e5.startsWith("{") && !t3.parameters.find((t4) => "path" === t4.in && t4.name === e5.slice(1, e5.length - 1)));
808
- for (const s5 of e4) {
809
- const e5 = s5.slice(1, s5.length - 1), n3 = t3.parameters.findIndex((t4) => "param" === t4.in && t4.name === e5);
810
- -1 !== n3 ? t3.parameters[n3].in = "path" : t3.parameters.push({ schema: { type: "string" }, in: "path", name: e5, required: true });
794
+ const e4 = n3.split("/").filter((e5) => e5.startsWith("{") && !t3.parameters.find((t4) => "path" === t4.in && t4.name === e5.slice(1, e5.length - 1)));
795
+ for (const n4 of e4) {
796
+ const e5 = n4.slice(1, n4.length - 1), s4 = t3.parameters.findIndex((t4) => "param" === t4.in && t4.name === e5);
797
+ -1 !== s4 ? t3.parameters[s4].in = "path" : t3.parameters.push({ schema: { type: "string" }, in: "path", name: e5, required: true });
811
798
  }
812
799
  }
813
800
  t3.responses || (t3.responses = { 200: {} });
814
801
  }
815
- n2[s4] = a2;
802
+ s3[n3] = a2;
816
803
  }
817
- return n2;
804
+ return s3;
818
805
  }
819
- function f(e2, t2) {
820
- const s3 = { version: "3.1.0", components: {} };
821
- let n2 = null;
822
- return async (o2) => (n2 || (n2 = await d(e2, t2, s3, o2)), o2.json(n2));
806
+ var u = { documentation: {}, excludeStaticFile: true, exclude: [], excludeMethods: ["OPTIONS"], excludeTags: [] };
807
+ var d = { version: "3.1.0", components: {} };
808
+ function h(e2, t2) {
809
+ const n2 = { version: "3.1.0", components: {} };
810
+ let s3;
811
+ return async (o2) => (s3 || (s3 = await y(e2, t2, n2, o2)), o2.json(s3));
823
812
  }
824
- async function d(t2, { documentation: n2 = {}, excludeStaticFile: o2 = true, exclude: a2 = [], excludeMethods: r2 = ["OPTIONS"], excludeTags: c2 = [], defaultOptions: i2 } = { documentation: {}, excludeStaticFile: true, exclude: [], excludeMethods: ["OPTIONS"], excludeTags: [] }, { version: l2 = "3.1.0", components: m2 = {} } = { version: "3.1.0", components: {} }, f2) {
825
- const d2 = { version: l2, components: m2 }, h2 = {};
826
- for (const n3 of t2.routes) {
827
- if (!(e in n3.handler)) continue;
828
- if (r2.includes(n3.method)) continue;
829
- if (false === s2.includes(n3.method) && "ALL" !== n3.method) continue;
830
- const { resolver: t3, metadata: o3 = {} } = n3.handler[e], a3 = i2?.[n3.method], { docs: c3, components: l3 } = await t3({ ...d2, ...o3 }, a3);
831
- d2.components = { ...d2.components, ...l3 ?? {} }, p({ method: n3.method, path: n3.path, data: c3, schema: h2 });
832
- }
833
- for (const e2 in h2) for (const t3 in h2[e2]) {
834
- const s3 = h2[e2][t3]?.hide;
835
- s3 && ("boolean" == typeof s3 ? s3 : f2 && s3(f2)) && delete h2[e2][t3];
836
- }
837
- return { openapi: d2.version, ...{ ...n2, tags: n2.tags?.filter((e2) => !c2?.includes(e2?.name)), info: { title: "Hono Documentation", description: "Development documentation", version: "0.0.0", ...n2.info }, paths: { ...u(h2, { excludeStaticFile: o2, exclude: a2 }), ...n2.paths }, components: { ...n2.components, schemas: { ...d2.components, ...n2.components?.schemas } } } };
813
+ async function y(t2, s3 = u, o2 = d, a2) {
814
+ const r2 = { ...u, ...s3 }, c2 = { ...d, ...o2 }, i2 = r2.documentation ?? {}, f2 = await async function(t3, s4, o3) {
815
+ const a3 = {};
816
+ for (const r3 of t3.routes) {
817
+ if (!(e in r3.handler)) {
818
+ s4.includeEmptyPaths && p({ method: r3.method, path: r3.path, schema: a3 });
819
+ continue;
820
+ }
821
+ if (s4.excludeMethods.includes(r3.method)) continue;
822
+ if (false === n.includes(r3.method) && "ALL" !== r3.method) continue;
823
+ const { resolver: t4, metadata: c3 = {} } = r3.handler[e], i3 = s4.defaultOptions?.[r3.method], { docs: f3, components: m2 } = await t4({ ...o3, ...c3 }, i3);
824
+ o3.components = { ...o3.components, ...m2 ?? {} }, p({ method: r3.method, path: r3.path, data: f3, schema: a3 });
825
+ }
826
+ return a3;
827
+ }(t2, r2, c2);
828
+ for (const e2 in f2) for (const t3 in f2[e2]) {
829
+ const n2 = f2[e2][t3]?.hide;
830
+ if (n2) {
831
+ let s4 = false;
832
+ "boolean" == typeof n2 ? s4 = n2 : "function" == typeof n2 && (a2 ? s4 = n2(a2) : console.warn(`'c' is not defined, cannot evaluate hide function for ${t3} ${e2}`)), s4 && delete f2[e2][t3];
833
+ }
834
+ }
835
+ return { openapi: c2.version, ...{ ...i2, tags: i2.tags?.filter((e2) => !r2.excludeTags?.includes(e2?.name)), info: { title: "Hono Documentation", description: "Development documentation", version: "0.0.0", ...i2.info }, paths: { ...l(f2, r2), ...i2.paths }, components: { ...i2.components, schemas: { ...c2.components, ...i2.components?.schemas } } } };
838
836
  }
839
- function h(s3) {
840
- const { validateResponse: n2, ...o2 } = s3;
837
+ function w(n2) {
838
+ const { validateResponse: s3, ...o2 } = n2;
841
839
  return Object.assign(async (e2, o3) => {
842
- if (await o3(), n2 && s3.responses) {
840
+ if (await o3(), s3 && n2.responses) {
843
841
  const o4 = e2.res.status, a2 = e2.res.headers.get("content-type");
844
842
  if (o4 && a2) {
845
- const r2 = s3.responses[o4];
843
+ const r2 = n2.responses[o4];
846
844
  if (r2 && "content" in r2 && r2.content) {
847
- const s4 = a2.split(";")[0], o5 = r2.content[s4];
845
+ const n3 = a2.split(";")[0], o5 = r2.content[n3];
848
846
  if (o5?.schema && "validator" in o5.schema) try {
849
847
  let t2;
850
- const n3 = e2.res.clone();
851
- if ("application/json" === s4 ? t2 = await n3.json() : "text/plain" === s4 && (t2 = await n3.text()), !t2) throw new Error("No data to validate!");
848
+ const s4 = e2.res.clone();
849
+ if ("application/json" === n3 ? t2 = await s4.json() : "text/plain" === n3 && (t2 = await s4.text()), !t2) throw new Error("No data to validate!");
852
850
  await o5.schema.validator(t2);
853
851
  } catch (e3) {
854
- let s5 = { status: 500, message: "Response validation failed!" };
855
- throw "object" == typeof n2 && (s5 = { ...s5, ...n2 }), new httpException.HTTPException(s5.status, { message: s5.message, cause: e3 });
852
+ let n4 = { status: 500, message: "Response validation failed!" };
853
+ throw "object" == typeof s3 && (n4 = { ...n4, ...s3 }), new httpException.HTTPException(n4.status, { message: n4.message, cause: e3 });
856
854
  }
857
855
  }
858
856
  }
859
857
  }
860
858
  }, { [e]: { resolver: (e2, t2) => x(e2, o2, t2) } });
861
859
  }
862
- async function x(e2, t2, s3 = {}) {
863
- let n2 = {};
864
- const o2 = { ...s3, ...t2, responses: { ...s3?.responses, ...t2.responses } };
860
+ async function x(e2, t2, n2 = {}) {
861
+ let s3 = {};
862
+ const o2 = { ...n2, ...t2, responses: { ...n2?.responses, ...t2.responses } };
865
863
  if (o2.responses) for (const t3 of Object.keys(o2.responses)) {
866
- const s4 = o2.responses[t3];
867
- if (s4 && "content" in s4) for (const t4 of Object.keys(s4.content ?? {})) {
868
- const o3 = s4.content?.[t4];
864
+ const n3 = o2.responses[t3];
865
+ if (n3 && "content" in n3) for (const t4 of Object.keys(n3.content ?? {})) {
866
+ const o3 = n3.content?.[t4];
869
867
  if (o3 && (o3.schema && "builder" in o3.schema)) {
870
868
  const t5 = await o3.schema.builder(e2);
871
- o3.schema = t5.schema, t5.components && (n2 = { ...n2, ...t5.components });
869
+ o3.schema = t5.schema, t5.components && (s3 = { ...s3, ...t5.components });
872
870
  }
873
871
  }
874
872
  }
875
- return { docs: o2, components: n2 };
873
+ return { docs: o2, components: s3 };
876
874
  }
877
875
  async function getAgentCardByIdHandler(c2) {
878
876
  const mastra = c2.get("mastra");
@@ -953,10 +951,12 @@ async function getAgentByIdHandler(c2) {
953
951
  const mastra = c2.get("mastra");
954
952
  const agentId = c2.req.param("agentId");
955
953
  const runtimeContext = c2.get("runtimeContext");
954
+ const isPlayground = c2.req.header("x-mastra-dev-playground") === "true";
956
955
  const result = await agents.getAgentByIdHandler({
957
956
  mastra,
958
957
  agentId,
959
- runtimeContext
958
+ runtimeContext,
959
+ isPlayground
960
960
  });
961
961
  return c2.json(result);
962
962
  }
@@ -1452,10 +1452,19 @@ async function getLegacyWorkflowRunsHandler(c2) {
1452
1452
  async function getLogsHandler(c2) {
1453
1453
  try {
1454
1454
  const mastra = c2.get("mastra");
1455
- const transportId = c2.req.query("transportId");
1455
+ const { transportId, fromDate, toDate, logLevel, page, perPage } = c2.req.query();
1456
+ const filters = c2.req.queries("filters");
1456
1457
  const logs$1 = await logs.getLogsHandler({
1457
1458
  mastra,
1458
- transportId
1459
+ transportId,
1460
+ params: {
1461
+ fromDate: fromDate ? new Date(fromDate) : void 0,
1462
+ toDate: toDate ? new Date(toDate) : void 0,
1463
+ logLevel: logLevel ? logLevel : void 0,
1464
+ filters,
1465
+ page: page ? Number(page) : void 0,
1466
+ perPage: perPage ? Number(perPage) : void 0
1467
+ }
1459
1468
  });
1460
1469
  return c2.json(logs$1);
1461
1470
  } catch (error) {
@@ -1466,11 +1475,20 @@ async function getLogsByRunIdHandler(c2) {
1466
1475
  try {
1467
1476
  const mastra = c2.get("mastra");
1468
1477
  const runId = c2.req.param("runId");
1469
- const transportId = c2.req.query("transportId");
1478
+ const { transportId, fromDate, toDate, logLevel, page, perPage } = c2.req.query();
1479
+ const filters = c2.req.queries("filters");
1470
1480
  const logs$1 = await logs.getLogsByRunIdHandler({
1471
1481
  mastra,
1472
1482
  runId,
1473
- transportId
1483
+ transportId,
1484
+ params: {
1485
+ fromDate: fromDate ? new Date(fromDate) : void 0,
1486
+ toDate: toDate ? new Date(toDate) : void 0,
1487
+ logLevel: logLevel ? logLevel : void 0,
1488
+ filters,
1489
+ page: page ? Number(page) : void 0,
1490
+ perPage: perPage ? Number(perPage) : void 0
1491
+ }
1474
1492
  });
1475
1493
  return c2.json(logs$1);
1476
1494
  } catch (error) {
@@ -3906,14 +3924,13 @@ function executeToolHandler(tools$1) {
3906
3924
  const runtimeContext = c2.get("runtimeContext");
3907
3925
  const toolId = decodeURIComponent(c2.req.param("toolId"));
3908
3926
  const runId = c2.req.query("runId");
3909
- const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
3927
+ const { data } = await c2.req.json();
3910
3928
  const result = await tools.executeToolHandler(tools$1)({
3911
3929
  mastra,
3912
3930
  toolId,
3913
3931
  data,
3914
3932
  runtimeContext,
3915
- runId,
3916
- runtimeContextFromRequest
3933
+ runId
3917
3934
  });
3918
3935
  return c2.json(result);
3919
3936
  } catch (error) {
@@ -3927,14 +3944,13 @@ async function executeAgentToolHandler(c2) {
3927
3944
  const runtimeContext = c2.get("runtimeContext");
3928
3945
  const agentId = c2.req.param("agentId");
3929
3946
  const toolId = c2.req.param("toolId");
3930
- const { data, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
3947
+ const { data } = await c2.req.json();
3931
3948
  const result = await tools.executeAgentToolHandler({
3932
3949
  mastra,
3933
3950
  agentId,
3934
3951
  toolId,
3935
3952
  data,
3936
- runtimeContext,
3937
- runtimeContextFromRequest
3953
+ runtimeContext
3938
3954
  });
3939
3955
  return c2.json(result);
3940
3956
  } catch (error) {
@@ -4155,12 +4171,11 @@ async function startAsyncWorkflowHandler(c2) {
4155
4171
  const mastra = c2.get("mastra");
4156
4172
  const workflowId = c2.req.param("workflowId");
4157
4173
  const runtimeContext = c2.get("runtimeContext");
4158
- const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
4174
+ const { inputData } = await c2.req.json();
4159
4175
  const runId = c2.req.query("runId");
4160
4176
  const result = await workflows.startAsyncWorkflowHandler({
4161
4177
  mastra,
4162
4178
  runtimeContext,
4163
- runtimeContextFromRequest,
4164
4179
  workflowId,
4165
4180
  runId,
4166
4181
  inputData
@@ -4175,12 +4190,11 @@ async function startWorkflowRunHandler(c2) {
4175
4190
  const mastra = c2.get("mastra");
4176
4191
  const workflowId = c2.req.param("workflowId");
4177
4192
  const runtimeContext = c2.get("runtimeContext");
4178
- const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
4193
+ const { inputData } = await c2.req.json();
4179
4194
  const runId = c2.req.query("runId");
4180
4195
  await workflows.startWorkflowRunHandler({
4181
4196
  mastra,
4182
4197
  runtimeContext,
4183
- runtimeContextFromRequest,
4184
4198
  workflowId,
4185
4199
  runId,
4186
4200
  inputData
@@ -4234,7 +4248,7 @@ async function streamWorkflowHandler(c2) {
4234
4248
  const logger2 = mastra.getLogger();
4235
4249
  const workflowId = c2.req.param("workflowId");
4236
4250
  const runtimeContext = c2.get("runtimeContext");
4237
- const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
4251
+ const { inputData } = await c2.req.json();
4238
4252
  const runId = c2.req.query("runId");
4239
4253
  return streaming.stream(
4240
4254
  c2,
@@ -4245,8 +4259,7 @@ async function streamWorkflowHandler(c2) {
4245
4259
  workflowId,
4246
4260
  runId,
4247
4261
  inputData,
4248
- runtimeContext,
4249
- runtimeContextFromRequest
4262
+ runtimeContext
4250
4263
  });
4251
4264
  const reader = result.stream.getReader();
4252
4265
  stream4.onAbort(() => {
@@ -4274,14 +4287,13 @@ async function resumeAsyncWorkflowHandler(c2) {
4274
4287
  const workflowId = c2.req.param("workflowId");
4275
4288
  const runId = c2.req.query("runId");
4276
4289
  const runtimeContext = c2.get("runtimeContext");
4277
- const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
4290
+ const { step, resumeData } = await c2.req.json();
4278
4291
  if (!runId) {
4279
4292
  throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
4280
4293
  }
4281
4294
  const result = await workflows.resumeAsyncWorkflowHandler({
4282
4295
  mastra,
4283
4296
  runtimeContext,
4284
- runtimeContextFromRequest,
4285
4297
  workflowId,
4286
4298
  runId,
4287
4299
  body: { step, resumeData }
@@ -4459,8 +4471,14 @@ async function createHonoServer(mastra, options = {}) {
4459
4471
  });
4460
4472
  return acc;
4461
4473
  }, {});
4462
- } catch {
4463
- console.error("Failed to import tools");
4474
+ } catch (err) {
4475
+ console.error(
4476
+ `Failed to import tools
4477
+ reason: ${err.message}
4478
+ ${err.stack.split("\n").slice(1).join("\n")}
4479
+ `,
4480
+ err
4481
+ );
4464
4482
  }
4465
4483
  app.use("*", async function setTelemetryInfo(c2, next) {
4466
4484
  const requestId = c2.req.header("x-request-id") ?? crypto.randomUUID();
@@ -4482,20 +4500,21 @@ async function createHonoServer(mastra, options = {}) {
4482
4500
  }
4483
4501
  });
4484
4502
  app.onError(errorHandler);
4485
- app.use("*", function setContext(c2, next) {
4486
- const runtimeContext$1 = new runtimeContext.RuntimeContext();
4487
- const proxyRuntimeContext = new Proxy(runtimeContext$1, {
4488
- get(target, prop) {
4489
- if (prop === "get") {
4490
- return function(key) {
4491
- const value = target.get(key);
4492
- return value ?? `<${key}>`;
4493
- };
4494
- }
4495
- return Reflect.get(target, prop);
4503
+ app.use("*", async function setContext(c2, next) {
4504
+ let runtimeContext$1 = new runtimeContext.RuntimeContext();
4505
+ if (c2.req.method === "POST" || c2.req.method === "PUT") {
4506
+ const contentType = c2.req.header("content-type");
4507
+ if (contentType?.includes("application/json")) {
4508
+ try {
4509
+ const body = await c2.req.json();
4510
+ if (body.runtimeContext) {
4511
+ runtimeContext$1 = new runtimeContext.RuntimeContext(Object.entries(body.runtimeContext));
4512
+ }
4513
+ } catch {
4514
+ }
4496
4515
  }
4497
- });
4498
- c2.set("runtimeContext", proxyRuntimeContext);
4516
+ }
4517
+ c2.set("runtimeContext", runtimeContext$1);
4499
4518
  c2.set("mastra", mastra);
4500
4519
  c2.set("tools", tools);
4501
4520
  c2.set("playground", options.playground === true);
@@ -4552,7 +4571,7 @@ async function createHonoServer(mastra, options = {}) {
4552
4571
  middlewares.push(...Array.isArray(route.middleware) ? route.middleware : [route.middleware]);
4553
4572
  }
4554
4573
  if (route.openapi) {
4555
- middlewares.push(h(route.openapi));
4574
+ middlewares.push(w(route.openapi));
4556
4575
  }
4557
4576
  const handler = "handler" in route ? route.handler : await route.createHandler({ mastra });
4558
4577
  if (route.method === "GET") {
@@ -4573,7 +4592,7 @@ async function createHonoServer(mastra, options = {}) {
4573
4592
  }
4574
4593
  app.get(
4575
4594
  "/.well-known/:agentId/agent.json",
4576
- h({
4595
+ w({
4577
4596
  description: "Get agent configuration",
4578
4597
  tags: ["agents"],
4579
4598
  parameters: [
@@ -4594,7 +4613,7 @@ async function createHonoServer(mastra, options = {}) {
4594
4613
  );
4595
4614
  app.post(
4596
4615
  "/a2a/:agentId",
4597
- h({
4616
+ w({
4598
4617
  description: "Execute agent via A2A protocol",
4599
4618
  tags: ["agents"],
4600
4619
  parameters: [
@@ -4709,7 +4728,7 @@ async function createHonoServer(mastra, options = {}) {
4709
4728
  );
4710
4729
  app.get(
4711
4730
  "/api",
4712
- h({
4731
+ w({
4713
4732
  description: "Get API status",
4714
4733
  tags: ["system"],
4715
4734
  responses: {
@@ -4722,7 +4741,7 @@ async function createHonoServer(mastra, options = {}) {
4722
4741
  );
4723
4742
  app.get(
4724
4743
  "/api/agents",
4725
- h({
4744
+ w({
4726
4745
  description: "Get all available agents",
4727
4746
  tags: ["agents"],
4728
4747
  responses: {
@@ -4735,7 +4754,7 @@ async function createHonoServer(mastra, options = {}) {
4735
4754
  );
4736
4755
  app.get(
4737
4756
  "/api/networks",
4738
- h({
4757
+ w({
4739
4758
  description: "Get all available networks",
4740
4759
  tags: ["networks"],
4741
4760
  responses: {
@@ -4748,7 +4767,7 @@ async function createHonoServer(mastra, options = {}) {
4748
4767
  );
4749
4768
  app.get(
4750
4769
  "/api/networks/:networkId",
4751
- h({
4770
+ w({
4752
4771
  description: "Get network by ID",
4753
4772
  tags: ["networks"],
4754
4773
  parameters: [
@@ -4773,7 +4792,7 @@ async function createHonoServer(mastra, options = {}) {
4773
4792
  app.post(
4774
4793
  "/api/networks/:networkId/generate",
4775
4794
  bodyLimit.bodyLimit(bodyLimitOptions),
4776
- h({
4795
+ w({
4777
4796
  description: "Generate a response from a network",
4778
4797
  tags: ["networks"],
4779
4798
  parameters: [
@@ -4821,7 +4840,7 @@ async function createHonoServer(mastra, options = {}) {
4821
4840
  app.post(
4822
4841
  "/api/networks/:networkId/stream",
4823
4842
  bodyLimit.bodyLimit(bodyLimitOptions),
4824
- h({
4843
+ w({
4825
4844
  description: "Generate a response from a network",
4826
4845
  tags: ["networks"],
4827
4846
  parameters: [
@@ -4868,7 +4887,7 @@ async function createHonoServer(mastra, options = {}) {
4868
4887
  );
4869
4888
  app.get(
4870
4889
  "/api/agents/:agentId",
4871
- h({
4890
+ w({
4872
4891
  description: "Get agent by ID",
4873
4892
  tags: ["agents"],
4874
4893
  parameters: [
@@ -4892,7 +4911,7 @@ async function createHonoServer(mastra, options = {}) {
4892
4911
  );
4893
4912
  app.get(
4894
4913
  "/api/agents/:agentId/evals/ci",
4895
- h({
4914
+ w({
4896
4915
  description: "Get CI evals by agent ID",
4897
4916
  tags: ["agents"],
4898
4917
  parameters: [
@@ -4913,7 +4932,7 @@ async function createHonoServer(mastra, options = {}) {
4913
4932
  );
4914
4933
  app.get(
4915
4934
  "/api/agents/:agentId/evals/live",
4916
- h({
4935
+ w({
4917
4936
  description: "Get live evals by agent ID",
4918
4937
  tags: ["agents"],
4919
4938
  parameters: [
@@ -4935,7 +4954,7 @@ async function createHonoServer(mastra, options = {}) {
4935
4954
  app.post(
4936
4955
  "/api/agents/:agentId/generate",
4937
4956
  bodyLimit.bodyLimit(bodyLimitOptions),
4938
- h({
4957
+ w({
4939
4958
  description: "Generate a response from an agent",
4940
4959
  tags: ["agents"],
4941
4960
  parameters: [
@@ -4986,7 +5005,7 @@ async function createHonoServer(mastra, options = {}) {
4986
5005
  app.post(
4987
5006
  "/api/agents/:agentId/stream",
4988
5007
  bodyLimit.bodyLimit(bodyLimitOptions),
4989
- h({
5008
+ w({
4990
5009
  description: "Stream a response from an agent",
4991
5010
  tags: ["agents"],
4992
5011
  parameters: [
@@ -5038,7 +5057,7 @@ async function createHonoServer(mastra, options = {}) {
5038
5057
  app.post(
5039
5058
  "/api/agents/:agentId/instructions",
5040
5059
  bodyLimit.bodyLimit(bodyLimitOptions),
5041
- h({
5060
+ w({
5042
5061
  description: "Update an agent's instructions",
5043
5062
  tags: ["agents"],
5044
5063
  parameters: [
@@ -5083,7 +5102,7 @@ async function createHonoServer(mastra, options = {}) {
5083
5102
  app.post(
5084
5103
  "/api/agents/:agentId/instructions/enhance",
5085
5104
  bodyLimit.bodyLimit(bodyLimitOptions),
5086
- h({
5105
+ w({
5087
5106
  description: "Generate an improved system prompt from instructions",
5088
5107
  tags: ["agents"],
5089
5108
  parameters: [
@@ -5159,7 +5178,7 @@ async function createHonoServer(mastra, options = {}) {
5159
5178
  c2.header("Link", '</api/agents/:agentId/voice/speakers>; rel="successor-version"');
5160
5179
  return next();
5161
5180
  },
5162
- h({
5181
+ w({
5163
5182
  description: "[DEPRECATED] Use /api/agents/:agentId/voice/speakers instead. Get available speakers for an agent",
5164
5183
  tags: ["agents"],
5165
5184
  parameters: [
@@ -5201,7 +5220,7 @@ async function createHonoServer(mastra, options = {}) {
5201
5220
  );
5202
5221
  app.get(
5203
5222
  "/api/agents/:agentId/voice/speakers",
5204
- h({
5223
+ w({
5205
5224
  description: "Get available speakers for an agent",
5206
5225
  tags: ["agents"],
5207
5226
  parameters: [
@@ -5250,7 +5269,7 @@ async function createHonoServer(mastra, options = {}) {
5250
5269
  c2.header("Link", '</api/agents/:agentId/voice/speak>; rel="successor-version"');
5251
5270
  return next();
5252
5271
  },
5253
- h({
5272
+ w({
5254
5273
  description: "[DEPRECATED] Use /api/agents/:agentId/voice/speak instead. Convert text to speech using the agent's voice provider",
5255
5274
  tags: ["agents"],
5256
5275
  parameters: [
@@ -5320,7 +5339,7 @@ async function createHonoServer(mastra, options = {}) {
5320
5339
  app.post(
5321
5340
  "/api/agents/:agentId/voice/speak",
5322
5341
  bodyLimit.bodyLimit(bodyLimitOptions),
5323
- h({
5342
+ w({
5324
5343
  description: "Convert text to speech using the agent's voice provider",
5325
5344
  tags: ["agents"],
5326
5345
  parameters: [
@@ -5394,7 +5413,7 @@ async function createHonoServer(mastra, options = {}) {
5394
5413
  );
5395
5414
  app.get(
5396
5415
  "/api/agents/:agentId/voice/listener",
5397
- h({
5416
+ w({
5398
5417
  description: "Get available listener for an agent",
5399
5418
  tags: ["agents"],
5400
5419
  parameters: [
@@ -5444,7 +5463,7 @@ async function createHonoServer(mastra, options = {}) {
5444
5463
  c2.header("Link", '</api/agents/:agentId/voice/listen>; rel="successor-version"');
5445
5464
  return next();
5446
5465
  },
5447
- h({
5466
+ w({
5448
5467
  description: "[DEPRECATED] Use /api/agents/:agentId/voice/listen instead. Convert speech to text using the agent's voice provider. Additional provider-specific options can be passed as query parameters.",
5449
5468
  tags: ["agents"],
5450
5469
  parameters: [
@@ -5500,7 +5519,7 @@ async function createHonoServer(mastra, options = {}) {
5500
5519
  maxSize: 10 * 1024 * 1024
5501
5520
  // 10 MB for audio files
5502
5521
  }),
5503
- h({
5522
+ w({
5504
5523
  description: "Convert speech to text using the agent's voice provider. Additional provider-specific options can be passed as query parameters.",
5505
5524
  tags: ["agents"],
5506
5525
  parameters: [
@@ -5564,7 +5583,7 @@ async function createHonoServer(mastra, options = {}) {
5564
5583
  app.post(
5565
5584
  "/api/agents/:agentId/tools/:toolId/execute",
5566
5585
  bodyLimit.bodyLimit(bodyLimitOptions),
5567
- h({
5586
+ w({
5568
5587
  description: "Execute a tool through an agent",
5569
5588
  tags: ["agents"],
5570
5589
  parameters: [
@@ -5610,7 +5629,7 @@ async function createHonoServer(mastra, options = {}) {
5610
5629
  app.post(
5611
5630
  "/api/mcp/:serverId/mcp",
5612
5631
  bodyLimit.bodyLimit(bodyLimitOptions),
5613
- h({
5632
+ w({
5614
5633
  description: "Send a message to an MCP server using Streamable HTTP",
5615
5634
  tags: ["mcp"],
5616
5635
  parameters: [
@@ -5639,7 +5658,7 @@ async function createHonoServer(mastra, options = {}) {
5639
5658
  const mcpSseMessagePath = "/api/mcp/:serverId/messages";
5640
5659
  app.get(
5641
5660
  mcpSseBasePath,
5642
- h({
5661
+ w({
5643
5662
  description: "Establish an MCP Server-Sent Events (SSE) connection with a server instance.",
5644
5663
  tags: ["mcp"],
5645
5664
  parameters: [
@@ -5665,7 +5684,7 @@ async function createHonoServer(mastra, options = {}) {
5665
5684
  mcpSseMessagePath,
5666
5685
  bodyLimit.bodyLimit(bodyLimitOptions),
5667
5686
  // Apply body limit for messages
5668
- h({
5687
+ w({
5669
5688
  description: "Send a message to an MCP server over an established SSE connection.",
5670
5689
  tags: ["mcp"],
5671
5690
  parameters: [
@@ -5696,7 +5715,7 @@ async function createHonoServer(mastra, options = {}) {
5696
5715
  );
5697
5716
  app.get(
5698
5717
  "/api/mcp/v0/servers",
5699
- h({
5718
+ w({
5700
5719
  description: "List all available MCP server instances with basic information.",
5701
5720
  tags: ["mcp"],
5702
5721
  parameters: [
@@ -5773,7 +5792,7 @@ async function createHonoServer(mastra, options = {}) {
5773
5792
  );
5774
5793
  app.get(
5775
5794
  "/api/mcp/v0/servers/:id",
5776
- h({
5795
+ w({
5777
5796
  description: "Get detailed information about a specific MCP server instance.",
5778
5797
  tags: ["mcp"],
5779
5798
  parameters: [
@@ -5914,7 +5933,7 @@ async function createHonoServer(mastra, options = {}) {
5914
5933
  );
5915
5934
  app.get(
5916
5935
  "/api/mcp/:serverId/tools",
5917
- h({
5936
+ w({
5918
5937
  description: "List all tools available on a specific MCP server instance.",
5919
5938
  tags: ["mcp"],
5920
5939
  parameters: [
@@ -5937,7 +5956,7 @@ async function createHonoServer(mastra, options = {}) {
5937
5956
  );
5938
5957
  app.get(
5939
5958
  "/api/mcp/:serverId/tools/:toolId",
5940
- h({
5959
+ w({
5941
5960
  description: "Get details for a specific tool on an MCP server.",
5942
5961
  tags: ["mcp"],
5943
5962
  parameters: [
@@ -5956,7 +5975,7 @@ async function createHonoServer(mastra, options = {}) {
5956
5975
  app.post(
5957
5976
  "/api/mcp/:serverId/tools/:toolId/execute",
5958
5977
  bodyLimit.bodyLimit(bodyLimitOptions),
5959
- h({
5978
+ w({
5960
5979
  description: "Execute a specific tool on an MCP server.",
5961
5980
  tags: ["mcp"],
5962
5981
  parameters: [
@@ -5989,7 +6008,7 @@ async function createHonoServer(mastra, options = {}) {
5989
6008
  );
5990
6009
  app.get(
5991
6010
  "/api/memory/status",
5992
- h({
6011
+ w({
5993
6012
  description: "Get memory status",
5994
6013
  tags: ["memory"],
5995
6014
  parameters: [
@@ -6010,7 +6029,7 @@ async function createHonoServer(mastra, options = {}) {
6010
6029
  );
6011
6030
  app.get(
6012
6031
  "/api/memory/threads",
6013
- h({
6032
+ w({
6014
6033
  description: "Get all threads",
6015
6034
  tags: ["memory"],
6016
6035
  parameters: [
@@ -6037,7 +6056,7 @@ async function createHonoServer(mastra, options = {}) {
6037
6056
  );
6038
6057
  app.get(
6039
6058
  "/api/memory/threads/:threadId",
6040
- h({
6059
+ w({
6041
6060
  description: "Get thread by ID",
6042
6061
  tags: ["memory"],
6043
6062
  parameters: [
@@ -6067,7 +6086,7 @@ async function createHonoServer(mastra, options = {}) {
6067
6086
  );
6068
6087
  app.get(
6069
6088
  "/api/memory/threads/:threadId/messages",
6070
- h({
6089
+ w({
6071
6090
  description: "Get messages for a thread",
6072
6091
  tags: ["memory"],
6073
6092
  parameters: [
@@ -6102,7 +6121,7 @@ async function createHonoServer(mastra, options = {}) {
6102
6121
  app.post(
6103
6122
  "/api/memory/threads",
6104
6123
  bodyLimit.bodyLimit(bodyLimitOptions),
6105
- h({
6124
+ w({
6106
6125
  description: "Create a new thread",
6107
6126
  tags: ["memory"],
6108
6127
  parameters: [
@@ -6139,7 +6158,7 @@ async function createHonoServer(mastra, options = {}) {
6139
6158
  );
6140
6159
  app.patch(
6141
6160
  "/api/memory/threads/:threadId",
6142
- h({
6161
+ w({
6143
6162
  description: "Update a thread",
6144
6163
  tags: ["memory"],
6145
6164
  parameters: [
@@ -6177,7 +6196,7 @@ async function createHonoServer(mastra, options = {}) {
6177
6196
  );
6178
6197
  app.delete(
6179
6198
  "/api/memory/threads/:threadId",
6180
- h({
6199
+ w({
6181
6200
  description: "Delete a thread",
6182
6201
  tags: ["memory"],
6183
6202
  parameters: [
@@ -6208,7 +6227,7 @@ async function createHonoServer(mastra, options = {}) {
6208
6227
  app.post(
6209
6228
  "/api/memory/save-messages",
6210
6229
  bodyLimit.bodyLimit(bodyLimitOptions),
6211
- h({
6230
+ w({
6212
6231
  description: "Save messages",
6213
6232
  tags: ["memory"],
6214
6233
  parameters: [
@@ -6246,7 +6265,7 @@ async function createHonoServer(mastra, options = {}) {
6246
6265
  );
6247
6266
  app.get(
6248
6267
  "/api/telemetry",
6249
- h({
6268
+ w({
6250
6269
  description: "Get all traces",
6251
6270
  tags: ["telemetry"],
6252
6271
  responses: {
@@ -6259,7 +6278,7 @@ async function createHonoServer(mastra, options = {}) {
6259
6278
  );
6260
6279
  app.post(
6261
6280
  "/api/telemetry",
6262
- h({
6281
+ w({
6263
6282
  description: "Store telemetry",
6264
6283
  tags: ["telemetry"],
6265
6284
  responses: {
@@ -6272,7 +6291,7 @@ async function createHonoServer(mastra, options = {}) {
6272
6291
  );
6273
6292
  app.get(
6274
6293
  "/api/workflows/legacy",
6275
- h({
6294
+ w({
6276
6295
  description: "Get all legacy workflows",
6277
6296
  tags: ["legacyWorkflows"],
6278
6297
  responses: {
@@ -6285,7 +6304,7 @@ async function createHonoServer(mastra, options = {}) {
6285
6304
  );
6286
6305
  app.get(
6287
6306
  "/api/workflows/legacy/:workflowId",
6288
- h({
6307
+ w({
6289
6308
  description: "Get legacy workflow by ID",
6290
6309
  tags: ["legacyWorkflows"],
6291
6310
  parameters: [
@@ -6309,7 +6328,7 @@ async function createHonoServer(mastra, options = {}) {
6309
6328
  );
6310
6329
  app.get(
6311
6330
  "/api/workflows/legacy/:workflowId/runs",
6312
- h({
6331
+ w({
6313
6332
  description: "Get all runs for a legacy workflow",
6314
6333
  tags: ["legacyWorkflows"],
6315
6334
  parameters: [
@@ -6335,7 +6354,7 @@ async function createHonoServer(mastra, options = {}) {
6335
6354
  );
6336
6355
  app.post(
6337
6356
  "/api/workflows/legacy/:workflowId/resume",
6338
- h({
6357
+ w({
6339
6358
  description: "Resume a suspended legacy workflow step",
6340
6359
  tags: ["legacyWorkflows"],
6341
6360
  parameters: [
@@ -6372,7 +6391,7 @@ async function createHonoServer(mastra, options = {}) {
6372
6391
  app.post(
6373
6392
  "/api/workflows/legacy/:workflowId/resume-async",
6374
6393
  bodyLimit.bodyLimit(bodyLimitOptions),
6375
- h({
6394
+ w({
6376
6395
  description: "Resume a suspended legacy workflow step",
6377
6396
  tags: ["legacyWorkflows"],
6378
6397
  parameters: [
@@ -6408,7 +6427,7 @@ async function createHonoServer(mastra, options = {}) {
6408
6427
  );
6409
6428
  app.post(
6410
6429
  "/api/workflows/legacy/:workflowId/create-run",
6411
- h({
6430
+ w({
6412
6431
  description: "Create a new legacy workflow run",
6413
6432
  tags: ["legacyWorkflows"],
6414
6433
  parameters: [
@@ -6436,7 +6455,7 @@ async function createHonoServer(mastra, options = {}) {
6436
6455
  app.post(
6437
6456
  "/api/workflows/legacy/:workflowId/start-async",
6438
6457
  bodyLimit.bodyLimit(bodyLimitOptions),
6439
- h({
6458
+ w({
6440
6459
  description: "Execute/Start a legacy workflow",
6441
6460
  tags: ["legacyWorkflows"],
6442
6461
  parameters: [
@@ -6479,7 +6498,7 @@ async function createHonoServer(mastra, options = {}) {
6479
6498
  );
6480
6499
  app.post(
6481
6500
  "/api/workflows/legacy/:workflowId/start",
6482
- h({
6501
+ w({
6483
6502
  description: "Create and start a new legacy workflow run",
6484
6503
  tags: ["legacyWorkflows"],
6485
6504
  parameters: [
@@ -6522,7 +6541,7 @@ async function createHonoServer(mastra, options = {}) {
6522
6541
  );
6523
6542
  app.get(
6524
6543
  "/api/workflows/legacy/:workflowId/watch",
6525
- h({
6544
+ w({
6526
6545
  description: "Watch legacy workflow transitions in real-time",
6527
6546
  parameters: [
6528
6547
  {
@@ -6549,7 +6568,7 @@ async function createHonoServer(mastra, options = {}) {
6549
6568
  );
6550
6569
  app.post(
6551
6570
  "/api/workflows/:workflowId/stream",
6552
- h({
6571
+ w({
6553
6572
  description: "Stream workflow in real-time",
6554
6573
  parameters: [
6555
6574
  {
@@ -6596,7 +6615,7 @@ async function createHonoServer(mastra, options = {}) {
6596
6615
  );
6597
6616
  app.get(
6598
6617
  "/api/workflows",
6599
- h({
6618
+ w({
6600
6619
  description: "Get all workflows",
6601
6620
  tags: ["workflows"],
6602
6621
  responses: {
@@ -6609,7 +6628,7 @@ async function createHonoServer(mastra, options = {}) {
6609
6628
  );
6610
6629
  app.get(
6611
6630
  "/api/workflows/:workflowId",
6612
- h({
6631
+ w({
6613
6632
  description: "Get workflow by ID",
6614
6633
  tags: ["workflows"],
6615
6634
  parameters: [
@@ -6633,7 +6652,7 @@ async function createHonoServer(mastra, options = {}) {
6633
6652
  );
6634
6653
  app.get(
6635
6654
  "/api/workflows/:workflowId/runs",
6636
- h({
6655
+ w({
6637
6656
  description: "Get all runs for a workflow",
6638
6657
  tags: ["workflows"],
6639
6658
  parameters: [
@@ -6659,7 +6678,7 @@ async function createHonoServer(mastra, options = {}) {
6659
6678
  );
6660
6679
  app.post(
6661
6680
  "/api/workflows/:workflowId/resume",
6662
- h({
6681
+ w({
6663
6682
  description: "Resume a suspended workflow step",
6664
6683
  tags: ["workflows"],
6665
6684
  parameters: [
@@ -6703,7 +6722,7 @@ async function createHonoServer(mastra, options = {}) {
6703
6722
  app.post(
6704
6723
  "/api/workflows/:workflowId/resume-async",
6705
6724
  bodyLimit.bodyLimit(bodyLimitOptions),
6706
- h({
6725
+ w({
6707
6726
  description: "Resume a suspended workflow step",
6708
6727
  tags: ["workflows"],
6709
6728
  parameters: [
@@ -6747,7 +6766,7 @@ async function createHonoServer(mastra, options = {}) {
6747
6766
  app.post(
6748
6767
  "/api/workflows/:workflowId/create-run",
6749
6768
  bodyLimit.bodyLimit(bodyLimitOptions),
6750
- h({
6769
+ w({
6751
6770
  description: "Create a new workflow run",
6752
6771
  tags: ["workflows"],
6753
6772
  parameters: [
@@ -6775,7 +6794,7 @@ async function createHonoServer(mastra, options = {}) {
6775
6794
  app.post(
6776
6795
  "/api/workflows/:workflowId/start-async",
6777
6796
  bodyLimit.bodyLimit(bodyLimitOptions),
6778
- h({
6797
+ w({
6779
6798
  description: "Execute/Start a workflow",
6780
6799
  tags: ["workflows"],
6781
6800
  parameters: [
@@ -6822,7 +6841,7 @@ async function createHonoServer(mastra, options = {}) {
6822
6841
  );
6823
6842
  app.post(
6824
6843
  "/api/workflows/:workflowId/start",
6825
- h({
6844
+ w({
6826
6845
  description: "Create and start a new workflow run",
6827
6846
  tags: ["workflows"],
6828
6847
  parameters: [
@@ -6869,7 +6888,7 @@ async function createHonoServer(mastra, options = {}) {
6869
6888
  );
6870
6889
  app.get(
6871
6890
  "/api/workflows/:workflowId/watch",
6872
- h({
6891
+ w({
6873
6892
  description: "Watch workflow transitions in real-time",
6874
6893
  parameters: [
6875
6894
  {
@@ -6896,7 +6915,7 @@ async function createHonoServer(mastra, options = {}) {
6896
6915
  );
6897
6916
  app.get(
6898
6917
  "/api/logs",
6899
- h({
6918
+ w({
6900
6919
  description: "Get all logs",
6901
6920
  tags: ["logs"],
6902
6921
  parameters: [
@@ -6905,11 +6924,47 @@ async function createHonoServer(mastra, options = {}) {
6905
6924
  in: "query",
6906
6925
  required: true,
6907
6926
  schema: { type: "string" }
6927
+ },
6928
+ {
6929
+ name: "fromDate",
6930
+ in: "query",
6931
+ required: false,
6932
+ schema: { type: "string" }
6933
+ },
6934
+ {
6935
+ name: "toDate",
6936
+ in: "query",
6937
+ required: false,
6938
+ schema: { type: "string" }
6939
+ },
6940
+ {
6941
+ name: "logLevel",
6942
+ in: "query",
6943
+ required: false,
6944
+ schema: { type: "string" }
6945
+ },
6946
+ {
6947
+ name: "filters",
6948
+ in: "query",
6949
+ required: false,
6950
+ schema: { type: "string" }
6951
+ },
6952
+ {
6953
+ name: "page",
6954
+ in: "query",
6955
+ required: false,
6956
+ schema: { type: "number" }
6957
+ },
6958
+ {
6959
+ name: "perPage",
6960
+ in: "query",
6961
+ required: false,
6962
+ schema: { type: "number" }
6908
6963
  }
6909
6964
  ],
6910
6965
  responses: {
6911
6966
  200: {
6912
- description: "List of all logs"
6967
+ description: "Paginated list of all logs"
6913
6968
  }
6914
6969
  }
6915
6970
  }),
@@ -6917,7 +6972,7 @@ async function createHonoServer(mastra, options = {}) {
6917
6972
  );
6918
6973
  app.get(
6919
6974
  "/api/logs/transports",
6920
- h({
6975
+ w({
6921
6976
  description: "List of all log transports",
6922
6977
  tags: ["logs"],
6923
6978
  responses: {
@@ -6930,7 +6985,7 @@ async function createHonoServer(mastra, options = {}) {
6930
6985
  );
6931
6986
  app.get(
6932
6987
  "/api/logs/:runId",
6933
- h({
6988
+ w({
6934
6989
  description: "Get logs by run ID",
6935
6990
  tags: ["logs"],
6936
6991
  parameters: [
@@ -6945,11 +7000,47 @@ async function createHonoServer(mastra, options = {}) {
6945
7000
  in: "query",
6946
7001
  required: true,
6947
7002
  schema: { type: "string" }
7003
+ },
7004
+ {
7005
+ name: "fromDate",
7006
+ in: "query",
7007
+ required: false,
7008
+ schema: { type: "string" }
7009
+ },
7010
+ {
7011
+ name: "toDate",
7012
+ in: "query",
7013
+ required: false,
7014
+ schema: { type: "string" }
7015
+ },
7016
+ {
7017
+ name: "logLevel",
7018
+ in: "query",
7019
+ required: false,
7020
+ schema: { type: "string" }
7021
+ },
7022
+ {
7023
+ name: "filters",
7024
+ in: "query",
7025
+ required: false,
7026
+ schema: { type: "string" }
7027
+ },
7028
+ {
7029
+ name: "page",
7030
+ in: "query",
7031
+ required: false,
7032
+ schema: { type: "number" }
7033
+ },
7034
+ {
7035
+ name: "perPage",
7036
+ in: "query",
7037
+ required: false,
7038
+ schema: { type: "number" }
6948
7039
  }
6949
7040
  ],
6950
7041
  responses: {
6951
7042
  200: {
6952
- description: "List of logs for run ID"
7043
+ description: "Paginated list of logs for run ID"
6953
7044
  }
6954
7045
  }
6955
7046
  }),
@@ -6957,7 +7048,7 @@ async function createHonoServer(mastra, options = {}) {
6957
7048
  );
6958
7049
  app.get(
6959
7050
  "/api/tools",
6960
- h({
7051
+ w({
6961
7052
  description: "Get all tools",
6962
7053
  tags: ["tools"],
6963
7054
  responses: {
@@ -6970,7 +7061,7 @@ async function createHonoServer(mastra, options = {}) {
6970
7061
  );
6971
7062
  app.get(
6972
7063
  "/api/tools/:toolId",
6973
- h({
7064
+ w({
6974
7065
  description: "Get tool by ID",
6975
7066
  tags: ["tools"],
6976
7067
  parameters: [
@@ -6995,7 +7086,7 @@ async function createHonoServer(mastra, options = {}) {
6995
7086
  app.post(
6996
7087
  "/api/tools/:toolId/execute",
6997
7088
  bodyLimit.bodyLimit(bodyLimitOptions),
6998
- h({
7089
+ w({
6999
7090
  description: "Execute a tool",
7000
7091
  tags: ["tools"],
7001
7092
  parameters: [
@@ -7041,7 +7132,7 @@ async function createHonoServer(mastra, options = {}) {
7041
7132
  app.post(
7042
7133
  "/api/vector/:vectorName/upsert",
7043
7134
  bodyLimit.bodyLimit(bodyLimitOptions),
7044
- h({
7135
+ w({
7045
7136
  description: "Upsert vectors into an index",
7046
7137
  tags: ["vector"],
7047
7138
  parameters: [
@@ -7092,7 +7183,7 @@ async function createHonoServer(mastra, options = {}) {
7092
7183
  app.post(
7093
7184
  "/api/vector/:vectorName/create-index",
7094
7185
  bodyLimit.bodyLimit(bodyLimitOptions),
7095
- h({
7186
+ w({
7096
7187
  description: "Create a new vector index",
7097
7188
  tags: ["vector"],
7098
7189
  parameters: [
@@ -7133,7 +7224,7 @@ async function createHonoServer(mastra, options = {}) {
7133
7224
  app.post(
7134
7225
  "/api/vector/:vectorName/query",
7135
7226
  bodyLimit.bodyLimit(bodyLimitOptions),
7136
- h({
7227
+ w({
7137
7228
  description: "Query vectors from an index",
7138
7229
  tags: ["vector"],
7139
7230
  parameters: [
@@ -7175,7 +7266,7 @@ async function createHonoServer(mastra, options = {}) {
7175
7266
  );
7176
7267
  app.get(
7177
7268
  "/api/vector/:vectorName/indexes",
7178
- h({
7269
+ w({
7179
7270
  description: "List all indexes for a vector store",
7180
7271
  tags: ["vector"],
7181
7272
  parameters: [
@@ -7196,7 +7287,7 @@ async function createHonoServer(mastra, options = {}) {
7196
7287
  );
7197
7288
  app.get(
7198
7289
  "/api/vector/:vectorName/indexes/:indexName",
7199
- h({
7290
+ w({
7200
7291
  description: "Get details about a specific index",
7201
7292
  tags: ["vector"],
7202
7293
  parameters: [
@@ -7223,7 +7314,7 @@ async function createHonoServer(mastra, options = {}) {
7223
7314
  );
7224
7315
  app.delete(
7225
7316
  "/api/vector/:vectorName/indexes/:indexName",
7226
- h({
7317
+ w({
7227
7318
  description: "Delete a specific index",
7228
7319
  tags: ["vector"],
7229
7320
  parameters: [
@@ -7251,7 +7342,7 @@ async function createHonoServer(mastra, options = {}) {
7251
7342
  if (options?.isDev || server?.build?.openAPIDocs || server?.build?.swaggerUI) {
7252
7343
  app.get(
7253
7344
  "/openapi.json",
7254
- f(app, {
7345
+ h(app, {
7255
7346
  documentation: {
7256
7347
  info: { title: "Mastra API", version: "1.0.0", description: "Mastra API" }
7257
7348
  }
@@ -7325,6 +7416,13 @@ async function createNodeServer(mastra, options = {}) {
7325
7416
  if (options?.playground) {
7326
7417
  logger2.info(`\u{1F468}\u200D\u{1F4BB} Playground available at http://${host}:${port}/`);
7327
7418
  }
7419
+ if (process.send) {
7420
+ process.send({
7421
+ type: "server-ready",
7422
+ port,
7423
+ host
7424
+ });
7425
+ }
7328
7426
  }
7329
7427
  );
7330
7428
  return server;