@mastra/hono 0.0.0-scorers-logs-20251208123838 → 0.0.0-testing-cloud-studios-20260114234039

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,36 +1,54 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
1
2
  import type { Mastra } from '@mastra/core/mastra';
2
3
  import type { RequestContext } from '@mastra/core/request-context';
3
- import type { Tool } from '@mastra/core/tools';
4
4
  import type { InMemoryTaskStore } from '@mastra/server/a2a/store';
5
+ import type { ParsedRequestParams, ServerRoute } from '@mastra/server/server-adapter';
5
6
  import { MastraServer as MastraServerBase } from '@mastra/server/server-adapter';
6
- import type { ServerRoute } from '@mastra/server/server-adapter';
7
- import type { Context, Env, Hono, HonoRequest, MiddlewareHandler } from 'hono';
7
+ import type { Context, HonoRequest, MiddlewareHandler } from 'hono';
8
8
  export type HonoVariables = {
9
9
  mastra: Mastra;
10
10
  requestContext: RequestContext;
11
- tools: Record<string, Tool>;
11
+ tools: ToolsInput;
12
12
  abortSignal: AbortSignal;
13
13
  taskStore: InMemoryTaskStore;
14
14
  customRouteAuthConfig?: Map<string, boolean>;
15
- playground?: boolean;
16
- isDev?: boolean;
17
15
  };
18
16
  export type HonoBindings = {};
19
- export declare class MastraServer extends MastraServerBase<Hono<any, any, any>, HonoRequest, Context> {
17
+ /**
18
+ * Generic handler function type compatible across Hono versions.
19
+ * Uses a minimal signature that all Hono middleware handlers satisfy.
20
+ */
21
+ type HonoRouteHandler = (...args: any[]) => any;
22
+ /**
23
+ * Minimal interface representing what MastraServer needs from a Hono app.
24
+ * This allows any Hono app instance to be passed without strict generic matching,
25
+ * avoiding the version mismatch issues that occur with Hono's strict generic types.
26
+ */
27
+ export interface HonoApp {
28
+ use(path: string, ...handlers: HonoRouteHandler[]): unknown;
29
+ get(path: string, ...handlers: HonoRouteHandler[]): unknown;
30
+ post(path: string, ...handlers: HonoRouteHandler[]): unknown;
31
+ put(path: string, ...handlers: HonoRouteHandler[]): unknown;
32
+ delete(path: string, ...handlers: HonoRouteHandler[]): unknown;
33
+ patch(path: string, ...handlers: HonoRouteHandler[]): unknown;
34
+ all(path: string, ...handlers: HonoRouteHandler[]): unknown;
35
+ }
36
+ export declare class MastraServer extends MastraServerBase<HonoApp, HonoRequest, Context> {
20
37
  createContextMiddleware(): MiddlewareHandler;
21
38
  stream(route: ServerRoute, res: Context, result: {
22
39
  fullStream: ReadableStream;
23
40
  }): Promise<any>;
24
- getParams(route: ServerRoute, request: HonoRequest): Promise<{
25
- urlParams: Record<string, string>;
26
- queryParams: Record<string, string>;
27
- body: unknown;
28
- }>;
41
+ getParams(route: ServerRoute, request: HonoRequest): Promise<ParsedRequestParams>;
42
+ /**
43
+ * Parse FormData into a plain object, converting File objects to Buffers.
44
+ */
45
+ private parseFormData;
29
46
  sendResponse(route: ServerRoute, response: Context, result: unknown): Promise<any>;
30
- registerRoute<E extends Env = any>(app: Hono<E, any, any>, route: ServerRoute, { prefix }: {
47
+ registerRoute(app: HonoApp, route: ServerRoute, { prefix }: {
31
48
  prefix?: string;
32
49
  }): Promise<void>;
33
50
  registerContextMiddleware(): void;
34
51
  registerAuthMiddleware(): void;
35
52
  }
53
+ export {};
36
54
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAqB,MAAM,+BAA+B,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA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,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkGrG,yBAAyB,IAAI,IAAI;IAIjC,sBAAsB,IAAI,IAAI;CAU/B"}
package/dist/index.js CHANGED
@@ -1,18 +1,29 @@
1
- import { MastraServer as MastraServer$1, redactStreamChunk } from '@mastra/server/server-adapter';
1
+ import { formatZodError } from '@mastra/server/handlers/error';
2
+ import { MastraServer as MastraServer$1, normalizeQueryParams, redactStreamChunk } from '@mastra/server/server-adapter';
2
3
  import { toReqRes, toFetchResponse } from 'fetch-to-node';
3
4
  import { isDevPlaygroundRequest, isProtectedPath, canAccessPublicly, checkRules, defaultAuthConfig } from '@mastra/server/auth';
4
5
 
5
6
  // src/index.ts
6
7
 
7
- // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/http-exception.js
8
+ // ../../node_modules/.pnpm/hono@4.11.3/node_modules/hono/dist/http-exception.js
8
9
  var HTTPException = class extends Error {
9
10
  res;
10
11
  status;
12
+ /**
13
+ * Creates an instance of `HTTPException`.
14
+ * @param status - HTTP status code for the exception. Defaults to 500.
15
+ * @param options - Additional options for the exception.
16
+ */
11
17
  constructor(status = 500, options) {
12
18
  super(options?.message, { cause: options?.cause });
13
19
  this.res = options?.res;
14
20
  this.status = status;
15
21
  }
22
+ /**
23
+ * Returns the response object associated with the exception.
24
+ * If a response object is not provided, a new response is created with the error message and status code.
25
+ * @returns The response object.
26
+ */
16
27
  getResponse() {
17
28
  if (this.res) {
18
29
  const newResponse = new Response(this.res.body, {
@@ -27,7 +38,7 @@ var HTTPException = class extends Error {
27
38
  }
28
39
  };
29
40
 
30
- // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/middleware/body-limit/index.js
41
+ // ../../node_modules/.pnpm/hono@4.11.3/node_modules/hono/dist/middleware/body-limit/index.js
31
42
  var ERROR_MESSAGE = "Payload Too Large";
32
43
  var BodyLimitError = class extends Error {
33
44
  constructor(message) {
@@ -84,14 +95,20 @@ var bodyLimit = (options) => {
84
95
  };
85
96
  };
86
97
 
87
- // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/utils/stream.js
98
+ // ../../node_modules/.pnpm/hono@4.11.3/node_modules/hono/dist/utils/stream.js
88
99
  var StreamingApi = class {
89
100
  writer;
90
101
  encoder;
91
102
  writable;
92
103
  abortSubscribers = [];
93
104
  responseReadable;
105
+ /**
106
+ * Whether the stream has been aborted.
107
+ */
94
108
  aborted = false;
109
+ /**
110
+ * Whether the stream has been closed normally.
111
+ */
95
112
  closed = false;
96
113
  constructor(writable, _readable) {
97
114
  this.writable = writable;
@@ -143,6 +160,10 @@ var StreamingApi = class {
143
160
  onAbort(listener) {
144
161
  this.abortSubscribers.push(listener);
145
162
  }
163
+ /**
164
+ * Abort the stream.
165
+ * You can call this method when stream is aborted by external event.
166
+ */
146
167
  abort() {
147
168
  if (!this.aborted) {
148
169
  this.aborted = true;
@@ -151,7 +172,7 @@ var StreamingApi = class {
151
172
  }
152
173
  };
153
174
 
154
- // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/utils.js
175
+ // ../../node_modules/.pnpm/hono@4.11.3/node_modules/hono/dist/helper/streaming/utils.js
155
176
  var isOldBunVersion = () => {
156
177
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
157
178
  if (version === void 0) {
@@ -162,7 +183,7 @@ var isOldBunVersion = () => {
162
183
  return result;
163
184
  };
164
185
 
165
- // ../../node_modules/.pnpm/hono@4.10.6/node_modules/hono/dist/helper/streaming/stream.js
186
+ // ../../node_modules/.pnpm/hono@4.11.3/node_modules/hono/dist/helper/streaming/stream.js
166
187
  var contextStash = /* @__PURE__ */ new WeakMap();
167
188
  var stream = (c, cb, onError) => {
168
189
  const { readable, writable } = new TransformStream();
@@ -190,6 +211,213 @@ var stream = (c, cb, onError) => {
190
211
  })();
191
212
  return c.newResponse(stream2.responseReadable);
192
213
  };
214
+
215
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
216
+ var util;
217
+ (function(util2) {
218
+ util2.assertEqual = (_) => {
219
+ };
220
+ function assertIs(_arg) {
221
+ }
222
+ util2.assertIs = assertIs;
223
+ function assertNever(_x) {
224
+ throw new Error();
225
+ }
226
+ util2.assertNever = assertNever;
227
+ util2.arrayToEnum = (items) => {
228
+ const obj = {};
229
+ for (const item of items) {
230
+ obj[item] = item;
231
+ }
232
+ return obj;
233
+ };
234
+ util2.getValidEnumValues = (obj) => {
235
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
236
+ const filtered = {};
237
+ for (const k of validKeys) {
238
+ filtered[k] = obj[k];
239
+ }
240
+ return util2.objectValues(filtered);
241
+ };
242
+ util2.objectValues = (obj) => {
243
+ return util2.objectKeys(obj).map(function(e) {
244
+ return obj[e];
245
+ });
246
+ };
247
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
248
+ const keys = [];
249
+ for (const key in object) {
250
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
251
+ keys.push(key);
252
+ }
253
+ }
254
+ return keys;
255
+ };
256
+ util2.find = (arr, checker) => {
257
+ for (const item of arr) {
258
+ if (checker(item))
259
+ return item;
260
+ }
261
+ return void 0;
262
+ };
263
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
264
+ function joinValues(array, separator = " | ") {
265
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
266
+ }
267
+ util2.joinValues = joinValues;
268
+ util2.jsonStringifyReplacer = (_, value) => {
269
+ if (typeof value === "bigint") {
270
+ return value.toString();
271
+ }
272
+ return value;
273
+ };
274
+ })(util || (util = {}));
275
+ var objectUtil;
276
+ (function(objectUtil2) {
277
+ objectUtil2.mergeShapes = (first, second) => {
278
+ return {
279
+ ...first,
280
+ ...second
281
+ // second overwrites first
282
+ };
283
+ };
284
+ })(objectUtil || (objectUtil = {}));
285
+ util.arrayToEnum([
286
+ "string",
287
+ "nan",
288
+ "number",
289
+ "integer",
290
+ "float",
291
+ "boolean",
292
+ "date",
293
+ "bigint",
294
+ "symbol",
295
+ "function",
296
+ "undefined",
297
+ "null",
298
+ "array",
299
+ "object",
300
+ "unknown",
301
+ "promise",
302
+ "void",
303
+ "never",
304
+ "map",
305
+ "set"
306
+ ]);
307
+
308
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
309
+ util.arrayToEnum([
310
+ "invalid_type",
311
+ "invalid_literal",
312
+ "custom",
313
+ "invalid_union",
314
+ "invalid_union_discriminator",
315
+ "invalid_enum_value",
316
+ "unrecognized_keys",
317
+ "invalid_arguments",
318
+ "invalid_return_type",
319
+ "invalid_date",
320
+ "invalid_string",
321
+ "too_small",
322
+ "too_big",
323
+ "invalid_intersection_types",
324
+ "not_multiple_of",
325
+ "not_finite"
326
+ ]);
327
+ var ZodError = class _ZodError extends Error {
328
+ get errors() {
329
+ return this.issues;
330
+ }
331
+ constructor(issues) {
332
+ super();
333
+ this.issues = [];
334
+ this.addIssue = (sub) => {
335
+ this.issues = [...this.issues, sub];
336
+ };
337
+ this.addIssues = (subs = []) => {
338
+ this.issues = [...this.issues, ...subs];
339
+ };
340
+ const actualProto = new.target.prototype;
341
+ if (Object.setPrototypeOf) {
342
+ Object.setPrototypeOf(this, actualProto);
343
+ } else {
344
+ this.__proto__ = actualProto;
345
+ }
346
+ this.name = "ZodError";
347
+ this.issues = issues;
348
+ }
349
+ format(_mapper) {
350
+ const mapper = _mapper || function(issue) {
351
+ return issue.message;
352
+ };
353
+ const fieldErrors = { _errors: [] };
354
+ const processError = (error) => {
355
+ for (const issue of error.issues) {
356
+ if (issue.code === "invalid_union") {
357
+ issue.unionErrors.map(processError);
358
+ } else if (issue.code === "invalid_return_type") {
359
+ processError(issue.returnTypeError);
360
+ } else if (issue.code === "invalid_arguments") {
361
+ processError(issue.argumentsError);
362
+ } else if (issue.path.length === 0) {
363
+ fieldErrors._errors.push(mapper(issue));
364
+ } else {
365
+ let curr = fieldErrors;
366
+ let i = 0;
367
+ while (i < issue.path.length) {
368
+ const el = issue.path[i];
369
+ const terminal = i === issue.path.length - 1;
370
+ if (!terminal) {
371
+ curr[el] = curr[el] || { _errors: [] };
372
+ } else {
373
+ curr[el] = curr[el] || { _errors: [] };
374
+ curr[el]._errors.push(mapper(issue));
375
+ }
376
+ curr = curr[el];
377
+ i++;
378
+ }
379
+ }
380
+ }
381
+ };
382
+ processError(this);
383
+ return fieldErrors;
384
+ }
385
+ static assert(value) {
386
+ if (!(value instanceof _ZodError)) {
387
+ throw new Error(`Not a ZodError: ${value}`);
388
+ }
389
+ }
390
+ toString() {
391
+ return this.message;
392
+ }
393
+ get message() {
394
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
395
+ }
396
+ get isEmpty() {
397
+ return this.issues.length === 0;
398
+ }
399
+ flatten(mapper = (issue) => issue.message) {
400
+ const fieldErrors = {};
401
+ const formErrors = [];
402
+ for (const sub of this.issues) {
403
+ if (sub.path.length > 0) {
404
+ const firstEl = sub.path[0];
405
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
406
+ fieldErrors[firstEl].push(mapper(sub));
407
+ } else {
408
+ formErrors.push(mapper(sub));
409
+ }
410
+ }
411
+ return { formErrors, fieldErrors };
412
+ }
413
+ get formErrors() {
414
+ return this.flatten();
415
+ }
416
+ };
417
+ ZodError.create = (issues) => {
418
+ const error = new ZodError(issues);
419
+ return error;
420
+ };
193
421
  var authenticationMiddleware = async (c, next) => {
194
422
  const mastra = c.get("mastra");
195
423
  const authConfig = mastra.getServer()?.auth;
@@ -335,8 +563,6 @@ var MastraServer = class extends MastraServer$1 {
335
563
  c.set("mastra", this.mastra);
336
564
  c.set("tools", this.tools || {});
337
565
  c.set("taskStore", this.taskStore);
338
- c.set("playground", this.playground === true);
339
- c.set("isDev", this.isDev === true);
340
566
  c.set("abortSignal", c.req.raw.signal);
341
567
  c.set("customRouteAuthConfig", this.customRouteAuthConfig);
342
568
  return next();
@@ -384,16 +610,51 @@ var MastraServer = class extends MastraServer$1 {
384
610
  }
385
611
  async getParams(route, request) {
386
612
  const urlParams = request.param();
387
- const queryParams = request.query();
613
+ const queryParams = normalizeQueryParams(request.queries());
388
614
  let body;
389
615
  if (route.method === "POST" || route.method === "PUT" || route.method === "PATCH") {
390
- try {
391
- body = await request.json();
392
- } catch {
616
+ const contentType = request.header("content-type") || "";
617
+ if (contentType.includes("multipart/form-data")) {
618
+ try {
619
+ const formData = await request.formData();
620
+ body = await this.parseFormData(formData);
621
+ } catch (error) {
622
+ console.error("Failed to parse multipart form data:", error);
623
+ if (error instanceof Error && error.message.toLowerCase().includes("size")) {
624
+ throw error;
625
+ }
626
+ }
627
+ } else {
628
+ try {
629
+ body = await request.json();
630
+ } catch (error) {
631
+ console.error("Failed to parse JSON body:", error);
632
+ }
393
633
  }
394
634
  }
395
635
  return { urlParams, queryParams, body };
396
636
  }
637
+ /**
638
+ * Parse FormData into a plain object, converting File objects to Buffers.
639
+ */
640
+ async parseFormData(formData) {
641
+ const result = {};
642
+ for (const [key, value] of formData.entries()) {
643
+ if (value instanceof File) {
644
+ const arrayBuffer = await value.arrayBuffer();
645
+ result[key] = Buffer.from(arrayBuffer);
646
+ } else if (typeof value === "string") {
647
+ try {
648
+ result[key] = JSON.parse(value);
649
+ } catch {
650
+ result[key] = value;
651
+ }
652
+ } else {
653
+ result[key] = value;
654
+ }
655
+ }
656
+ return result;
657
+ }
397
658
  async sendResponse(route, response, result) {
398
659
  if (route.responseType === "json") {
399
660
  return response.json(result, 200);
@@ -465,10 +726,13 @@ var MastraServer = class extends MastraServer$1 {
465
726
  params.queryParams = await this.parseQueryParams(route, params.queryParams);
466
727
  } catch (error) {
467
728
  console.error("Error parsing query params", error);
729
+ if (error instanceof ZodError) {
730
+ return c.json(formatZodError(error, "query parameters"), 400);
731
+ }
468
732
  return c.json(
469
733
  {
470
734
  error: "Invalid query parameters",
471
- details: error instanceof Error ? error.message : "Unknown error"
735
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
472
736
  },
473
737
  400
474
738
  );
@@ -479,10 +743,13 @@ var MastraServer = class extends MastraServer$1 {
479
743
  params.body = await this.parseBody(route, params.body);
480
744
  } catch (error) {
481
745
  console.error("Error parsing body:", error instanceof Error ? error.message : String(error));
746
+ if (error instanceof ZodError) {
747
+ return c.json(formatZodError(error, "request body"), 400);
748
+ }
482
749
  return c.json(
483
750
  {
484
751
  error: "Invalid request body",
485
- details: error instanceof Error ? error.message : "Unknown error"
752
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
486
753
  },
487
754
  400
488
755
  );