@mastra/next 0.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var hono$1 = require('@mastra/hono');
4
+ var store = require('@mastra/server/a2a/store');
5
+ var hono = require('hono');
6
+ var vercel = require('hono/vercel');
7
+
8
+ // src/index.ts
9
+ function createNextRouteHandler(options) {
10
+ const { mastra, tools = {}, prefix = "/api" } = options;
11
+ let appPromise;
12
+ function getApp() {
13
+ if (!appPromise) {
14
+ appPromise = initApp(mastra, tools, prefix);
15
+ }
16
+ return appPromise;
17
+ }
18
+ const handler = async (req) => {
19
+ const app = await getApp();
20
+ const honoHandler = vercel.handle(app);
21
+ return honoHandler(req);
22
+ };
23
+ return {
24
+ GET: handler,
25
+ POST: handler,
26
+ PUT: handler,
27
+ DELETE: handler,
28
+ PATCH: handler,
29
+ OPTIONS: handler,
30
+ HEAD: handler
31
+ };
32
+ }
33
+ async function initApp(mastra, tools, prefix) {
34
+ const app = new hono.Hono();
35
+ const serverConfig = mastra.getServer();
36
+ const apiRoutes = serverConfig?.apiRoutes;
37
+ const customRouteAuthConfig = /* @__PURE__ */ new Map();
38
+ if (apiRoutes) {
39
+ for (const route of apiRoutes) {
40
+ const requiresAuth = route.requiresAuth !== false;
41
+ const routeKey = `${route.method}:${route.path}`;
42
+ customRouteAuthConfig.set(routeKey, requiresAuth);
43
+ }
44
+ }
45
+ const taskStore = new store.InMemoryTaskStore();
46
+ const bodySizeLimit = serverConfig?.bodySizeLimit ?? 4.5 * 1024 * 1024;
47
+ const honoServerAdapter = new hono$1.MastraServer({
48
+ app,
49
+ mastra,
50
+ tools,
51
+ taskStore,
52
+ bodyLimitOptions: {
53
+ maxSize: bodySizeLimit,
54
+ onError: (_err) => ({ error: "Request body too large" })
55
+ },
56
+ customRouteAuthConfig,
57
+ customApiRoutes: apiRoutes,
58
+ prefix,
59
+ mcpOptions: serverConfig?.mcpOptions
60
+ });
61
+ await honoServerAdapter.init();
62
+ return app;
63
+ }
64
+
65
+ exports.createNextRouteHandler = createNextRouteHandler;
66
+ //# sourceMappingURL=index.cjs.map
67
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["handle","Hono","InMemoryTaskStore","MastraServer"],"mappings":";;;;;;;;AA6DO,SAAS,uBAAuB,OAAA,EAAqD;AAC1F,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,GAAQ,EAAC,EAAG,MAAA,GAAS,QAAO,GAAI,OAAA;AAGhD,EAAA,IAAI,UAAA;AAEJ,EAAA,SAAS,MAAA,GAAwB;AAC/B,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,UAAA,GAAa,OAAA,CAAQ,MAAA,EAAQ,KAAA,EAAO,MAAM,CAAA;AAAA,IAC5C;AACA,IAAA,OAAO,UAAA;AAAA,EACT;AAGA,EAAA,MAAM,OAAA,GAA4B,OAAM,GAAA,KAAO;AAC7C,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,EAAO;AACzB,IAAA,MAAM,WAAA,GAAcA,cAAO,GAAG,CAAA;AAC9B,IAAA,OAAO,YAAY,GAAG,CAAA;AAAA,EACxB,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,OAAA;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,GAAA,EAAK,OAAA;AAAA,IACL,MAAA,EAAQ,OAAA;AAAA,IACR,KAAA,EAAO,OAAA;AAAA,IACP,OAAA,EAAS,OAAA;AAAA,IACT,IAAA,EAAM;AAAA,GACR;AACF;AAEA,eAAe,OAAA,CAAQ,MAAA,EAAgB,KAAA,EAAmB,MAAA,EAA+B;AACvF,EAAA,MAAM,GAAA,GAAM,IAAIC,SAAA,EAAK;AAErB,EAAA,MAAM,YAAA,GAAe,OAAO,SAAA,EAAU;AACtC,EAAA,MAAM,YAAoC,YAAA,EAAc,SAAA;AAGxD,EAAA,MAAM,qBAAA,uBAA4B,GAAA,EAAqB;AACvD,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,KAAA,MAAW,SAAS,SAAA,EAAW;AAC7B,MAAA,MAAM,YAAA,GAAe,MAAM,YAAA,KAAiB,KAAA;AAC5C,MAAA,MAAM,WAAW,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAA,EAAI,MAAM,IAAI,CAAA,CAAA;AAC9C,MAAA,qBAAA,CAAsB,GAAA,CAAI,UAAU,YAAY,CAAA;AAAA,IAClD;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,IAAIC,uBAAA,EAAkB;AAExC,EAAA,MAAM,aAAA,GAAgB,YAAA,EAAc,aAAA,IAAiB,GAAA,GAAM,IAAA,GAAO,IAAA;AAGlE,EAAA,MAAM,iBAAA,GAAoB,IAAIC,mBAAA,CAAa;AAAA,IACzC,GAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,gBAAA,EAAkB;AAAA,MAChB,OAAA,EAAS,aAAA;AAAA,MACT,OAAA,EAAS,CAAC,IAAA,MAAmB,EAAE,OAAO,wBAAA,EAAyB;AAAA,KACjE;AAAA,IACA,qBAAA;AAAA,IACA,eAAA,EAAiB,SAAA;AAAA,IACjB,MAAA;AAAA,IACA,YAAY,YAAA,EAAc;AAAA,GAC3B,CAAA;AAGD,EAAA,MAAM,kBAAkB,IAAA,EAAK;AAE7B,EAAA,OAAO,GAAA;AACT","file":"index.cjs","sourcesContent":["import type { ToolsInput } from '@mastra/core/agent';\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { ApiRoute } from '@mastra/core/server';\nimport { MastraServer } from '@mastra/hono';\nimport type { HonoApp } from '@mastra/hono';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { Hono } from 'hono';\nimport { handle } from 'hono/vercel';\n\nexport interface NextRouteHandlerOptions {\n /**\n * The Mastra instance to serve.\n */\n mastra: Mastra;\n\n /**\n * Tools to register with the server.\n * @default {}\n */\n tools?: ToolsInput;\n\n /**\n * API route prefix. Should match the path where the catch-all route is mounted.\n * For example, if you mount at `app/api/[...mastra]/route.ts`, set this to `/api`.\n * @default '/api'\n */\n prefix?: string;\n}\n\n/**\n * A Next.js route handler function compatible with App Router.\n */\nexport type NextRouteHandler = (req: Request) => Response | Promise<Response>;\n\nexport interface NextRouteHandlers {\n GET: NextRouteHandler;\n POST: NextRouteHandler;\n PUT: NextRouteHandler;\n DELETE: NextRouteHandler;\n PATCH: NextRouteHandler;\n OPTIONS: NextRouteHandler;\n HEAD: NextRouteHandler;\n}\n\n/**\n * Creates Next.js App Router route handlers for a Mastra instance.\n *\n * Mount this in a catch-all route file such as:\n * `app/api/[...mastra]/route.ts`\n *\n * @example\n * ```ts\n * // app/api/[...mastra]/route.ts\n * import { createNextRouteHandler } from '@mastra/next';\n * import { mastra } from '../../../mastra';\n *\n * export const { GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD } = createNextRouteHandler({\n * mastra,\n * });\n * ```\n */\nexport function createNextRouteHandler(options: NextRouteHandlerOptions): NextRouteHandlers {\n const { mastra, tools = {}, prefix = '/api' } = options;\n\n // Lazily initialize the Hono app so the module-level export works synchronously\n let appPromise: Promise<Hono> | undefined;\n\n function getApp(): Promise<Hono> {\n if (!appPromise) {\n appPromise = initApp(mastra, tools, prefix);\n }\n return appPromise;\n }\n\n // Build a handler for each HTTP method\n const handler: NextRouteHandler = async req => {\n const app = await getApp();\n const honoHandler = handle(app);\n return honoHandler(req);\n };\n\n return {\n GET: handler,\n POST: handler,\n PUT: handler,\n DELETE: handler,\n PATCH: handler,\n OPTIONS: handler,\n HEAD: handler,\n };\n}\n\nasync function initApp(mastra: Mastra, tools: ToolsInput, prefix: string): Promise<Hono> {\n const app = new Hono();\n\n const serverConfig = mastra.getServer();\n const apiRoutes: ApiRoute[] | undefined = serverConfig?.apiRoutes;\n\n // Store custom route auth configurations\n const customRouteAuthConfig = new Map<string, boolean>();\n if (apiRoutes) {\n for (const route of apiRoutes) {\n const requiresAuth = route.requiresAuth !== false;\n const routeKey = `${route.method}:${route.path}`;\n customRouteAuthConfig.set(routeKey, requiresAuth);\n }\n }\n\n const taskStore = new InMemoryTaskStore();\n\n const bodySizeLimit = serverConfig?.bodySizeLimit ?? 4.5 * 1024 * 1024;\n\n // Create the MastraServer adapter\n const honoServerAdapter = new MastraServer({\n app: app as unknown as HonoApp,\n mastra,\n tools,\n taskStore,\n bodyLimitOptions: {\n maxSize: bodySizeLimit,\n onError: (_err: unknown) => ({ error: 'Request body too large' }),\n },\n customRouteAuthConfig,\n customApiRoutes: apiRoutes,\n prefix,\n mcpOptions: serverConfig?.mcpOptions,\n });\n\n // Initialize: registers context middleware, auth, routes, etc.\n await honoServerAdapter.init();\n\n return app;\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
2
+ import type { Mastra } from '@mastra/core/mastra';
3
+ export interface NextRouteHandlerOptions {
4
+ /**
5
+ * The Mastra instance to serve.
6
+ */
7
+ mastra: Mastra;
8
+ /**
9
+ * Tools to register with the server.
10
+ * @default {}
11
+ */
12
+ tools?: ToolsInput;
13
+ /**
14
+ * API route prefix. Should match the path where the catch-all route is mounted.
15
+ * For example, if you mount at `app/api/[...mastra]/route.ts`, set this to `/api`.
16
+ * @default '/api'
17
+ */
18
+ prefix?: string;
19
+ }
20
+ /**
21
+ * A Next.js route handler function compatible with App Router.
22
+ */
23
+ export type NextRouteHandler = (req: Request) => Response | Promise<Response>;
24
+ export interface NextRouteHandlers {
25
+ GET: NextRouteHandler;
26
+ POST: NextRouteHandler;
27
+ PUT: NextRouteHandler;
28
+ DELETE: NextRouteHandler;
29
+ PATCH: NextRouteHandler;
30
+ OPTIONS: NextRouteHandler;
31
+ HEAD: NextRouteHandler;
32
+ }
33
+ /**
34
+ * Creates Next.js App Router route handlers for a Mastra instance.
35
+ *
36
+ * Mount this in a catch-all route file such as:
37
+ * `app/api/[...mastra]/route.ts`
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * // app/api/[...mastra]/route.ts
42
+ * import { createNextRouteHandler } from '@mastra/next';
43
+ * import { mastra } from '../../../mastra.js';
44
+ *
45
+ * export const { GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD } = createNextRouteHandler({
46
+ * mastra,
47
+ * });
48
+ * ```
49
+ */
50
+ export declare function createNextRouteHandler(options: NextRouteHandlerOptions): NextRouteHandlers;
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAQlD,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE9E,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,gBAAgB,CAAC;IACtB,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;IACtB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6B1F"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ import { MastraServer } from '@mastra/hono';
2
+ import { InMemoryTaskStore } from '@mastra/server/a2a/store';
3
+ import { Hono } from 'hono';
4
+ import { handle } from 'hono/vercel';
5
+
6
+ // src/index.ts
7
+ function createNextRouteHandler(options) {
8
+ const { mastra, tools = {}, prefix = "/api" } = options;
9
+ let appPromise;
10
+ function getApp() {
11
+ if (!appPromise) {
12
+ appPromise = initApp(mastra, tools, prefix);
13
+ }
14
+ return appPromise;
15
+ }
16
+ const handler = async (req) => {
17
+ const app = await getApp();
18
+ const honoHandler = handle(app);
19
+ return honoHandler(req);
20
+ };
21
+ return {
22
+ GET: handler,
23
+ POST: handler,
24
+ PUT: handler,
25
+ DELETE: handler,
26
+ PATCH: handler,
27
+ OPTIONS: handler,
28
+ HEAD: handler
29
+ };
30
+ }
31
+ async function initApp(mastra, tools, prefix) {
32
+ const app = new Hono();
33
+ const serverConfig = mastra.getServer();
34
+ const apiRoutes = serverConfig?.apiRoutes;
35
+ const customRouteAuthConfig = /* @__PURE__ */ new Map();
36
+ if (apiRoutes) {
37
+ for (const route of apiRoutes) {
38
+ const requiresAuth = route.requiresAuth !== false;
39
+ const routeKey = `${route.method}:${route.path}`;
40
+ customRouteAuthConfig.set(routeKey, requiresAuth);
41
+ }
42
+ }
43
+ const taskStore = new InMemoryTaskStore();
44
+ const bodySizeLimit = serverConfig?.bodySizeLimit ?? 4.5 * 1024 * 1024;
45
+ const honoServerAdapter = new MastraServer({
46
+ app,
47
+ mastra,
48
+ tools,
49
+ taskStore,
50
+ bodyLimitOptions: {
51
+ maxSize: bodySizeLimit,
52
+ onError: (_err) => ({ error: "Request body too large" })
53
+ },
54
+ customRouteAuthConfig,
55
+ customApiRoutes: apiRoutes,
56
+ prefix,
57
+ mcpOptions: serverConfig?.mcpOptions
58
+ });
59
+ await honoServerAdapter.init();
60
+ return app;
61
+ }
62
+
63
+ export { createNextRouteHandler };
64
+ //# sourceMappingURL=index.js.map
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA6DO,SAAS,uBAAuB,OAAA,EAAqD;AAC1F,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,GAAQ,EAAC,EAAG,MAAA,GAAS,QAAO,GAAI,OAAA;AAGhD,EAAA,IAAI,UAAA;AAEJ,EAAA,SAAS,MAAA,GAAwB;AAC/B,IAAA,IAAI,CAAC,UAAA,EAAY;AACf,MAAA,UAAA,GAAa,OAAA,CAAQ,MAAA,EAAQ,KAAA,EAAO,MAAM,CAAA;AAAA,IAC5C;AACA,IAAA,OAAO,UAAA;AAAA,EACT;AAGA,EAAA,MAAM,OAAA,GAA4B,OAAM,GAAA,KAAO;AAC7C,IAAA,MAAM,GAAA,GAAM,MAAM,MAAA,EAAO;AACzB,IAAA,MAAM,WAAA,GAAc,OAAO,GAAG,CAAA;AAC9B,IAAA,OAAO,YAAY,GAAG,CAAA;AAAA,EACxB,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,OAAA;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,GAAA,EAAK,OAAA;AAAA,IACL,MAAA,EAAQ,OAAA;AAAA,IACR,KAAA,EAAO,OAAA;AAAA,IACP,OAAA,EAAS,OAAA;AAAA,IACT,IAAA,EAAM;AAAA,GACR;AACF;AAEA,eAAe,OAAA,CAAQ,MAAA,EAAgB,KAAA,EAAmB,MAAA,EAA+B;AACvF,EAAA,MAAM,GAAA,GAAM,IAAI,IAAA,EAAK;AAErB,EAAA,MAAM,YAAA,GAAe,OAAO,SAAA,EAAU;AACtC,EAAA,MAAM,YAAoC,YAAA,EAAc,SAAA;AAGxD,EAAA,MAAM,qBAAA,uBAA4B,GAAA,EAAqB;AACvD,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,KAAA,MAAW,SAAS,SAAA,EAAW;AAC7B,MAAA,MAAM,YAAA,GAAe,MAAM,YAAA,KAAiB,KAAA;AAC5C,MAAA,MAAM,WAAW,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAA,EAAI,MAAM,IAAI,CAAA,CAAA;AAC9C,MAAA,qBAAA,CAAsB,GAAA,CAAI,UAAU,YAAY,CAAA;AAAA,IAClD;AAAA,EACF;AAEA,EAAA,MAAM,SAAA,GAAY,IAAI,iBAAA,EAAkB;AAExC,EAAA,MAAM,aAAA,GAAgB,YAAA,EAAc,aAAA,IAAiB,GAAA,GAAM,IAAA,GAAO,IAAA;AAGlE,EAAA,MAAM,iBAAA,GAAoB,IAAI,YAAA,CAAa;AAAA,IACzC,GAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,gBAAA,EAAkB;AAAA,MAChB,OAAA,EAAS,aAAA;AAAA,MACT,OAAA,EAAS,CAAC,IAAA,MAAmB,EAAE,OAAO,wBAAA,EAAyB;AAAA,KACjE;AAAA,IACA,qBAAA;AAAA,IACA,eAAA,EAAiB,SAAA;AAAA,IACjB,MAAA;AAAA,IACA,YAAY,YAAA,EAAc;AAAA,GAC3B,CAAA;AAGD,EAAA,MAAM,kBAAkB,IAAA,EAAK;AAE7B,EAAA,OAAO,GAAA;AACT","file":"index.js","sourcesContent":["import type { ToolsInput } from '@mastra/core/agent';\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { ApiRoute } from '@mastra/core/server';\nimport { MastraServer } from '@mastra/hono';\nimport type { HonoApp } from '@mastra/hono';\nimport { InMemoryTaskStore } from '@mastra/server/a2a/store';\nimport { Hono } from 'hono';\nimport { handle } from 'hono/vercel';\n\nexport interface NextRouteHandlerOptions {\n /**\n * The Mastra instance to serve.\n */\n mastra: Mastra;\n\n /**\n * Tools to register with the server.\n * @default {}\n */\n tools?: ToolsInput;\n\n /**\n * API route prefix. Should match the path where the catch-all route is mounted.\n * For example, if you mount at `app/api/[...mastra]/route.ts`, set this to `/api`.\n * @default '/api'\n */\n prefix?: string;\n}\n\n/**\n * A Next.js route handler function compatible with App Router.\n */\nexport type NextRouteHandler = (req: Request) => Response | Promise<Response>;\n\nexport interface NextRouteHandlers {\n GET: NextRouteHandler;\n POST: NextRouteHandler;\n PUT: NextRouteHandler;\n DELETE: NextRouteHandler;\n PATCH: NextRouteHandler;\n OPTIONS: NextRouteHandler;\n HEAD: NextRouteHandler;\n}\n\n/**\n * Creates Next.js App Router route handlers for a Mastra instance.\n *\n * Mount this in a catch-all route file such as:\n * `app/api/[...mastra]/route.ts`\n *\n * @example\n * ```ts\n * // app/api/[...mastra]/route.ts\n * import { createNextRouteHandler } from '@mastra/next';\n * import { mastra } from '../../../mastra';\n *\n * export const { GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD } = createNextRouteHandler({\n * mastra,\n * });\n * ```\n */\nexport function createNextRouteHandler(options: NextRouteHandlerOptions): NextRouteHandlers {\n const { mastra, tools = {}, prefix = '/api' } = options;\n\n // Lazily initialize the Hono app so the module-level export works synchronously\n let appPromise: Promise<Hono> | undefined;\n\n function getApp(): Promise<Hono> {\n if (!appPromise) {\n appPromise = initApp(mastra, tools, prefix);\n }\n return appPromise;\n }\n\n // Build a handler for each HTTP method\n const handler: NextRouteHandler = async req => {\n const app = await getApp();\n const honoHandler = handle(app);\n return honoHandler(req);\n };\n\n return {\n GET: handler,\n POST: handler,\n PUT: handler,\n DELETE: handler,\n PATCH: handler,\n OPTIONS: handler,\n HEAD: handler,\n };\n}\n\nasync function initApp(mastra: Mastra, tools: ToolsInput, prefix: string): Promise<Hono> {\n const app = new Hono();\n\n const serverConfig = mastra.getServer();\n const apiRoutes: ApiRoute[] | undefined = serverConfig?.apiRoutes;\n\n // Store custom route auth configurations\n const customRouteAuthConfig = new Map<string, boolean>();\n if (apiRoutes) {\n for (const route of apiRoutes) {\n const requiresAuth = route.requiresAuth !== false;\n const routeKey = `${route.method}:${route.path}`;\n customRouteAuthConfig.set(routeKey, requiresAuth);\n }\n }\n\n const taskStore = new InMemoryTaskStore();\n\n const bodySizeLimit = serverConfig?.bodySizeLimit ?? 4.5 * 1024 * 1024;\n\n // Create the MastraServer adapter\n const honoServerAdapter = new MastraServer({\n app: app as unknown as HonoApp,\n mastra,\n tools,\n taskStore,\n bodyLimitOptions: {\n maxSize: bodySizeLimit,\n onError: (_err: unknown) => ({ error: 'Request body too large' }),\n },\n customRouteAuthConfig,\n customApiRoutes: apiRoutes,\n prefix,\n mcpOptions: serverConfig?.mcpOptions,\n });\n\n // Initialize: registers context middleware, auth, routes, etc.\n await honoServerAdapter.init();\n\n return app;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@mastra/next",
3
+ "version": "0.0.0",
4
+ "description": "Mastra Next.js server adapter — drop your Mastra instance into a Next.js app",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "scripts": {
22
+ "build": "tsup --silent --config tsup.config.ts",
23
+ "build:watch": "pnpm build --watch",
24
+ "test": "vitest run",
25
+ "lint": "eslint ."
26
+ },
27
+ "license": "Apache-2.0",
28
+ "dependencies": {
29
+ "@mastra/server": "workspace:*",
30
+ "@mastra/hono": "workspace:*"
31
+ },
32
+ "devDependencies": {
33
+ "@internal/lint": "workspace:*",
34
+ "@internal/types-builder": "workspace:*",
35
+ "@mastra/core": "workspace:*",
36
+ "@types/node": "22.19.21",
37
+ "eslint": "^10.4.1",
38
+ "hono": "^4.12.8",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "catalog:",
41
+ "vitest": "catalog:"
42
+ },
43
+ "peerDependencies": {
44
+ "@mastra/core": ">=1.34.0-0 <2.0.0-0",
45
+ "hono": "^4.12.8"
46
+ },
47
+ "engines": {
48
+ "node": ">=22.13.0"
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "CHANGELOG.md"
53
+ ],
54
+ "homepage": "https://mastra.ai",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/mastra-ai/mastra.git",
58
+ "directory": "server-adapters/next"
59
+ },
60
+ "bugs": {
61
+ "url": "https://github.com/mastra-ai/mastra/issues"
62
+ }
63
+ }