@mastra/core 0.16.1-alpha.3 → 0.16.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # @mastra/core
2
2
 
3
+ ## 0.16.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Export server types ([#7657](https://github.com/mastra-ai/mastra/pull/7657))
8
+
9
+ ## 0.16.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixed ai tracing for workflows nested directly in agents ([#7599](https://github.com/mastra-ai/mastra/pull/7599))
14
+
15
+ - Fixed provider defined tools for stream/generate vnext ([#7642](https://github.com/mastra-ai/mastra/pull/7642))
16
+
17
+ - Made tracing context optional on tool execute() ([#7532](https://github.com/mastra-ai/mastra/pull/7532))
18
+
19
+ - Fixed ai tracing context propagation in tool calls ([#7531](https://github.com/mastra-ai/mastra/pull/7531))
20
+
21
+ - Call getMemoryMessages even during first turn in a thread when semantic recall scope is resource ([#7529](https://github.com/mastra-ai/mastra/pull/7529))
22
+
23
+ - add usage and total usage to streamVNext onFinish callback ([#7598](https://github.com/mastra-ai/mastra/pull/7598))
24
+
25
+ - Add prepareStep to generate/stream VNext options. ([#7646](https://github.com/mastra-ai/mastra/pull/7646))
26
+
27
+ - Change to createRunAsync ([#7632](https://github.com/mastra-ai/mastra/pull/7632))
28
+
29
+ - Fix type in worfklow ([#7519](https://github.com/mastra-ai/mastra/pull/7519))
30
+
31
+ - Execute tool calls in parallel in generate/stream VNext methods ([#7524](https://github.com/mastra-ai/mastra/pull/7524))
32
+
33
+ - Allow streamVNext and generateVNext to use structuredOutputs from the MastraClient ([#7597](https://github.com/mastra-ai/mastra/pull/7597))
34
+
35
+ - Use workflow streamVNext in playground ([#7575](https://github.com/mastra-ai/mastra/pull/7575))
36
+
37
+ - Revert "feat(mcp): add createMCPTool helper for proper execute types" ([#7513](https://github.com/mastra-ai/mastra/pull/7513))
38
+
39
+ - Fix InvalidDataContentError when using image messages with AI SDK ([#7542](https://github.com/mastra-ai/mastra/pull/7542))
40
+
41
+ Resolves an issue where passing image content in messages would throw an InvalidDataContentError. The fix properly handles multi-part content arrays containing both text and image parts when converting between Mastra and AI SDK message formats.
42
+
43
+ - Flatten loop config in stream options and pass to loop options ([#7643](https://github.com/mastra-ai/mastra/pull/7643))
44
+
45
+ - Pass mastra instance into MCP Server tools ([#7520](https://github.com/mastra-ai/mastra/pull/7520))
46
+
47
+ - Fix image input handling for Google Gemini models in AI SDK V5 ([#7490](https://github.com/mastra-ai/mastra/pull/7490))
48
+
49
+ Resolves issue #7362 where Gemini threw `AI_InvalidDataContentError` when receiving URLs in image parts. The fix properly handles V3 message file parts that contain both URL and data fields, ensuring URLs are passed as URLs rather than being incorrectly treated as base64 data.
50
+
51
+ - Vnext output schema injection ([#6990](https://github.com/mastra-ai/mastra/pull/6990))
52
+
53
+ - removed duplicate 'float' switch case ([#7516](https://github.com/mastra-ai/mastra/pull/7516))
54
+
55
+ - Fix issue with response message id consistency between stream/generate response and the message ids saveed in the DB. Also fixed the custom generatorId implementation to work with this. ([#7606](https://github.com/mastra-ai/mastra/pull/7606))
56
+
3
57
  ## 0.16.1-alpha.3
4
58
 
5
59
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/auth.ts","../../src/server/index.ts"],"names":["MastraAuthProvider","__decorateElement","__runInitializers","MastraError"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,KAAA,CAAA;AASA,IAAA,IAAA,OAAA,EAAA,aAAA,EAAA;AAAiB,MACf,IAAQ,CAAA,aAAA,GAAA,OAAA,CAAA,aAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AAAA,IACR;AACF,EAAC;AACM,EAAA,eAAe,CAAA,IAAA,EAAA;AAAuD,cAC/D,aAA4C,EAAA;AACtD,MAAA,IAAM,cAAa,GAAA,IAAQ,CAAA,aAAM,CAAS,KAAK,IAAC,CAAA;AAEhD,IAA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AA,IAAA,CAAA,UAAA,CAAA,OAAA,CAAA,EAAA;AACF,IAAA,MAAA,IAAAA,6BAAA,CAAA;AAEO,MAAA,EAAA,EAAS,iCAGa;AAC3B,MAAI,IAAA,EAAK,CAAA,sEAAqB,CAAA;AAC5B,MAAA,QAAU,eAAY;AAAA,MACpB,QAAI,EAAA,MAAA;AAAA,KAAA,CACJ;AAAM,EAAA;AACN,EAAA,eACA,CAAA,IAAA,EAAA,OAAA,CAAA;AAAA,EAAA,OACD;AAAA,IACH,IAAA;AAEA,IAAA,MAAA,EAAA,cAAsB;AAEtB,IAAA,OAAO,EAAA,OAAA,CAAA,OAAA;AAAA,IACL,aAAA,EAAA,OAAA,CAAA,aAAA;AAAA,IACA,SAAQ,OAAQ,CAAA,OAAA;AAAA,IAChB,UAAS,EAAA,OAAQ,CAAA;AAAA,GAAA;AACM;AACN,mBACL,CAAA,MAAQ,EAAA;AAAA,EACtB,OAAA,MAAA;AACF","file":"index.cjs","sourcesContent":["import type { HonoRequest } from 'hono';\nimport { MastraBase } from '../base';\nimport { InstrumentClass } from '../telemetry';\n\nexport interface MastraAuthProviderOptions<TUser = unknown> {\n name?: string;\n authorizeUser?: (user: TUser, request: HonoRequest) => Promise<boolean> | boolean;\n}\n\n@InstrumentClass({\n prefix: 'auth',\n excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log'],\n})\nexport abstract class MastraAuthProvider<TUser = unknown> extends MastraBase {\n constructor(options?: MastraAuthProviderOptions<TUser>) {\n super({ component: 'AUTH', name: options?.name });\n\n if (options?.authorizeUser) {\n this.authorizeUser = options.authorizeUser.bind(this);\n }\n }\n\n /**\n * Authenticate a token and return the payload\n * @param token - The token to authenticate\n * @param request - The request\n * @returns The payload\n */\n abstract authenticateToken(token: string, request: HonoRequest): Promise<TUser | null>;\n\n /**\n * Authorize a user for a path and method\n * @param user - The user to authorize\n * @param request - The request\n * @returns The authorization result\n */\n abstract authorizeUser(user: TUser, request: HonoRequest): Promise<boolean> | boolean;\n\n protected registerOptions(opts?: MastraAuthProviderOptions<TUser>) {\n if (opts?.authorizeUser) {\n this.authorizeUser = opts.authorizeUser.bind(this);\n }\n }\n}\n","import type { Context, Handler, MiddlewareHandler } from 'hono';\nimport type { DescribeRouteOptions } from 'hono-openapi';\nimport { MastraError, ErrorDomain, ErrorCategory } from '../error';\nimport type { Mastra } from '../mastra';\nimport type { ApiRoute, MastraAuthConfig, Methods } from './types';\n\nexport type { MastraAuthConfig, ContextWithMastra } from './types';\nexport { MastraAuthProvider } from './auth';\nexport type { MastraAuthProviderOptions } from './auth';\n\n// Helper type for inferring parameters from a path\n// Thank you Claude!\ntype ParamsFromPath<P extends string> = {\n [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string;\n};\n\ntype RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`;\ntype ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T;\n\ntype RegisterApiRouteOptions<P extends string> = {\n method: Methods;\n openapi?: DescribeRouteOptions;\n handler?: Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >;\n createHandler?: (c: Context) => Promise<\n Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >\n >;\n middleware?: MiddlewareHandler | MiddlewareHandler[];\n};\n\nfunction validateOptions<P extends string>(\n path: P,\n options: RegisterApiRoutePathError | RegisterApiRouteOptions<P>,\n): asserts options is RegisterApiRouteOptions<P> {\n const opts = options as RegisterApiRouteOptions<P>;\n\n if (opts.method === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", missing \"method\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler === undefined && opts.createHandler === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you must define a \"handler\" or \"createHandler\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler !== undefined && opts.createHandler !== undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you can only define one of the following properties: \"handler\" or \"createHandler\"`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n}\n\nexport function registerApiRoute<P extends string>(\n path: P,\n options: ValidatePath<P, RegisterApiRouteOptions<P>>,\n): ValidatePath<P, ApiRoute> {\n if (path.startsWith('/api/')) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_PATH_RESERVED',\n text: 'Path must not start with \"/api\", it\\'s reserved for internal API routes',\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n validateOptions(path, options);\n\n return {\n path,\n method: options.method,\n handler: options.handler,\n createHandler: options.createHandler,\n openapi: options.openapi,\n middleware: options.middleware,\n } as unknown as ValidatePath<P, ApiRoute>;\n}\n\nexport function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser> {\n return config;\n}\n"]}
1
+ {"version":3,"sources":["../../src/server/auth.ts","../../src/server/index.ts"],"names":["MastraAuthProvider","__decorateElement","__runInitializers","MastraError"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,KAAA,CAAA;AASA,IAAA,IAAA,OAAA,EAAA,aAAA,EAAA;AAAiB,MACf,IAAQ,CAAA,aAAA,GAAA,OAAA,CAAA,aAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AAAA,IACR;AACF,EAAC;AACM,EAAA,eAAe,CAAA,IAAA,EAAA;AAAuD,cAC/D,aAA4C,EAAA;AACtD,MAAA,IAAM,cAAa,GAAA,IAAQ,CAAA,aAAM,CAAS,KAAK,IAAC,CAAA;AAEhD,IAAA;AACE,EAAA;AAAoD;AACtDA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,OAAA,CAAA,EAAA;AACF,IAAA,MAAA,IAAAA,6BAAA,CAAA;AAEO,MAAA,EAAA,EAAS,iCAGa;AAC3B,MAAI,IAAA,EAAK,CAAA,sEAAqB,CAAA;AAC5B,MAAA,QAAU,eAAY;AAAA,MACpB,QAAI,EAAA,MAAA;AAAA,KAAA,CACJ;AAAM,EAAA;AACN,EAAA,eACA,CAAA,IAAA,EAAA,OAAA,CAAA;AAAA,EAAA,OACD;AAAA,IACH,IAAA;AAEA,IAAA,MAAA,EAAA,cAAsB;AAEtB,IAAA,OAAO,EAAA,OAAA,CAAA,OAAA;AAAA,IACL,aAAA,EAAA,OAAA,CAAA,aAAA;AAAA,IACA,SAAQ,OAAQ,CAAA,OAAA;AAAA,IAChB,UAAS,EAAA,OAAQ,CAAA;AAAA,GAAA;AACM;AACN,mBACL,CAAA,MAAQ,EAAA;AAAA,EACtB,OAAA,MAAA;AACF","file":"index.cjs","sourcesContent":["import type { HonoRequest } from 'hono';\nimport { MastraBase } from '../base';\nimport { InstrumentClass } from '../telemetry';\n\nexport interface MastraAuthProviderOptions<TUser = unknown> {\n name?: string;\n authorizeUser?: (user: TUser, request: HonoRequest) => Promise<boolean> | boolean;\n}\n\n@InstrumentClass({\n prefix: 'auth',\n excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log'],\n})\nexport abstract class MastraAuthProvider<TUser = unknown> extends MastraBase {\n constructor(options?: MastraAuthProviderOptions<TUser>) {\n super({ component: 'AUTH', name: options?.name });\n\n if (options?.authorizeUser) {\n this.authorizeUser = options.authorizeUser.bind(this);\n }\n }\n\n /**\n * Authenticate a token and return the payload\n * @param token - The token to authenticate\n * @param request - The request\n * @returns The payload\n */\n abstract authenticateToken(token: string, request: HonoRequest): Promise<TUser | null>;\n\n /**\n * Authorize a user for a path and method\n * @param user - The user to authorize\n * @param request - The request\n * @returns The authorization result\n */\n abstract authorizeUser(user: TUser, request: HonoRequest): Promise<boolean> | boolean;\n\n protected registerOptions(opts?: MastraAuthProviderOptions<TUser>) {\n if (opts?.authorizeUser) {\n this.authorizeUser = opts.authorizeUser.bind(this);\n }\n }\n}\n","import type { Context, Handler, MiddlewareHandler } from 'hono';\nimport type { DescribeRouteOptions } from 'hono-openapi';\nimport { MastraError, ErrorDomain, ErrorCategory } from '../error';\nimport type { Mastra } from '../mastra';\nimport type { ApiRoute, MastraAuthConfig, Methods } from './types';\n\nexport type { MastraAuthConfig, ContextWithMastra, ApiRoute } from './types';\nexport { MastraAuthProvider } from './auth';\nexport type { MastraAuthProviderOptions } from './auth';\n\n// Helper type for inferring parameters from a path\n// Thank you Claude!\ntype ParamsFromPath<P extends string> = {\n [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string;\n};\n\ntype RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`;\ntype ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T;\n\ntype RegisterApiRouteOptions<P extends string> = {\n method: Methods;\n openapi?: DescribeRouteOptions;\n handler?: Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >;\n createHandler?: (c: Context) => Promise<\n Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >\n >;\n middleware?: MiddlewareHandler | MiddlewareHandler[];\n};\n\nfunction validateOptions<P extends string>(\n path: P,\n options: RegisterApiRoutePathError | RegisterApiRouteOptions<P>,\n): asserts options is RegisterApiRouteOptions<P> {\n const opts = options as RegisterApiRouteOptions<P>;\n\n if (opts.method === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", missing \"method\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler === undefined && opts.createHandler === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you must define a \"handler\" or \"createHandler\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler !== undefined && opts.createHandler !== undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you can only define one of the following properties: \"handler\" or \"createHandler\"`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n}\n\nexport function registerApiRoute<P extends string>(\n path: P,\n options: ValidatePath<P, RegisterApiRouteOptions<P>>,\n): ValidatePath<P, ApiRoute> {\n if (path.startsWith('/api/')) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_PATH_RESERVED',\n text: 'Path must not start with \"/api\", it\\'s reserved for internal API routes',\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n validateOptions(path, options);\n\n return {\n path,\n method: options.method,\n handler: options.handler,\n createHandler: options.createHandler,\n openapi: options.openapi,\n middleware: options.middleware,\n } as unknown as ValidatePath<P, ApiRoute>;\n}\n\nexport function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser> {\n return config;\n}\n"]}
@@ -2,7 +2,7 @@ import type { Context, Handler, MiddlewareHandler } from 'hono';
2
2
  import type { DescribeRouteOptions } from 'hono-openapi';
3
3
  import type { Mastra } from '../mastra/index.js';
4
4
  import type { ApiRoute, MastraAuthConfig, Methods } from './types.js';
5
- export type { MastraAuthConfig, ContextWithMastra } from './types.js';
5
+ export type { MastraAuthConfig, ContextWithMastra, ApiRoute } from './types.js';
6
6
  export { MastraAuthProvider } from './auth.js';
7
7
  export type { MastraAuthProviderOptions } from './auth.js';
8
8
  type ParamsFromPath<P extends string> = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,iB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AA,CACJ;AAAwC,EAAA;AACxC;AACA,SACD,gBAAA,CAAA,IAAA,EAAA,OAAA,EAAA;AAAA,EACH,IAAA,IAAA,CAAA,UAAA,CAAA,OAAA,CAAA,EAAA;AACF,IAAA,MAAA,IAAA,WAAA,CAAA;AAEO,MAAA,EAAA,EAAS,iCAGa;AAC3B,MAAI,IAAA,EAAK,CAAA,sEAAqB,CAAA;AAC5B,MAAA,QAAU,eAAY;AAAA,MACpB,QAAI,EAAA,MAAA;AAAA,KAAA,CACJ;AAAM,EAAA;AACN,EAAA,eACA,CAAA,IAAA,EAAA,OAAA,CAAA;AAAA,EAAA,OACD;AAAA,IACH,IAAA;AAEA,IAAA,MAAA,EAAA,cAAsB;AAEtB,IAAA,OAAO,EAAA,OAAA,CAAA,OAAA;AAAA,IACL,aAAA,EAAA,OAAA,CAAA,aAAA;AAAA,IACA,SAAQ,OAAQ,CAAA,OAAA;AAAA,IAChB,UAAS,EAAA,OAAQ,CAAA;AAAA,GAAA;AACM;AACN,mBACL,CAAA,MAAQ,EAAA;AAAA,EACtB,OAAA,MAAA;AACF","file":"index.js","sourcesContent":["import type { HonoRequest } from 'hono';\nimport { MastraBase } from '../base';\nimport { InstrumentClass } from '../telemetry';\n\nexport interface MastraAuthProviderOptions<TUser = unknown> {\n name?: string;\n authorizeUser?: (user: TUser, request: HonoRequest) => Promise<boolean> | boolean;\n}\n\n@InstrumentClass({\n prefix: 'auth',\n excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log'],\n})\nexport abstract class MastraAuthProvider<TUser = unknown> extends MastraBase {\n constructor(options?: MastraAuthProviderOptions<TUser>) {\n super({ component: 'AUTH', name: options?.name });\n\n if (options?.authorizeUser) {\n this.authorizeUser = options.authorizeUser.bind(this);\n }\n }\n\n /**\n * Authenticate a token and return the payload\n * @param token - The token to authenticate\n * @param request - The request\n * @returns The payload\n */\n abstract authenticateToken(token: string, request: HonoRequest): Promise<TUser | null>;\n\n /**\n * Authorize a user for a path and method\n * @param user - The user to authorize\n * @param request - The request\n * @returns The authorization result\n */\n abstract authorizeUser(user: TUser, request: HonoRequest): Promise<boolean> | boolean;\n\n protected registerOptions(opts?: MastraAuthProviderOptions<TUser>) {\n if (opts?.authorizeUser) {\n this.authorizeUser = opts.authorizeUser.bind(this);\n }\n }\n}\n","import type { Context, Handler, MiddlewareHandler } from 'hono';\nimport type { DescribeRouteOptions } from 'hono-openapi';\nimport { MastraError, ErrorDomain, ErrorCategory } from '../error';\nimport type { Mastra } from '../mastra';\nimport type { ApiRoute, MastraAuthConfig, Methods } from './types';\n\nexport type { MastraAuthConfig, ContextWithMastra } from './types';\nexport { MastraAuthProvider } from './auth';\nexport type { MastraAuthProviderOptions } from './auth';\n\n// Helper type for inferring parameters from a path\n// Thank you Claude!\ntype ParamsFromPath<P extends string> = {\n [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string;\n};\n\ntype RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`;\ntype ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T;\n\ntype RegisterApiRouteOptions<P extends string> = {\n method: Methods;\n openapi?: DescribeRouteOptions;\n handler?: Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >;\n createHandler?: (c: Context) => Promise<\n Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >\n >;\n middleware?: MiddlewareHandler | MiddlewareHandler[];\n};\n\nfunction validateOptions<P extends string>(\n path: P,\n options: RegisterApiRoutePathError | RegisterApiRouteOptions<P>,\n): asserts options is RegisterApiRouteOptions<P> {\n const opts = options as RegisterApiRouteOptions<P>;\n\n if (opts.method === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", missing \"method\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler === undefined && opts.createHandler === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you must define a \"handler\" or \"createHandler\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler !== undefined && opts.createHandler !== undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you can only define one of the following properties: \"handler\" or \"createHandler\"`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n}\n\nexport function registerApiRoute<P extends string>(\n path: P,\n options: ValidatePath<P, RegisterApiRouteOptions<P>>,\n): ValidatePath<P, ApiRoute> {\n if (path.startsWith('/api/')) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_PATH_RESERVED',\n text: 'Path must not start with \"/api\", it\\'s reserved for internal API routes',\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n validateOptions(path, options);\n\n return {\n path,\n method: options.method,\n handler: options.handler,\n createHandler: options.createHandler,\n openapi: options.openapi,\n middleware: options.middleware,\n } as unknown as ValidatePath<P, ApiRoute>;\n}\n\nexport function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser> {\n return config;\n}\n"]}
1
+ {"version":3,"sources":["../../src/server/auth.ts","../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,KAAA,CAAA;AASA,IAAA,IAAA,OAAA,EAAA,aAAA,EAAA;AAAiB,MACf,IAAQ,CAAA,aAAA,GAAA,OAAA,CAAA,aAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AAAA,IACR;AACF,EAAC;AACM,EAAA,eAAe,CAAA,IAAA,EAAA;AAAuD,cAC/D,aAA4C,EAAA;AACtD,MAAA,IAAM,cAAa,GAAA,IAAQ,CAAA,aAAM,CAAS,KAAK,IA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H,IAAA,IAAA,CAAA,UAAA,CAAA,OAAA,CAAA,EAAA;AACF,IAAA,MAAA,IAAA,WAAA,CAAA;AAEO,MAAA,EAAA,EAAS,iCAGa;AAC3B,MAAI,IAAA,EAAK,CAAA,sEAAqB,CAAA;AAC5B,MAAA,QAAU,eAAY;AAAA,MACpB,QAAI,EAAA,MAAA;AAAA,KAAA,CACJ;AAAM,EAAA;AACN,EAAA,eACA,CAAA,IAAA,EAAA,OAAA,CAAA;AAAA,EAAA,OACD;AAAA,IACH,IAAA;AAEA,IAAA,MAAA,EAAA,cAAsB;AAEtB,IAAA,OAAO,EAAA,OAAA,CAAA,OAAA;AAAA,IACL,aAAA,EAAA,OAAA,CAAA,aAAA;AAAA,IACA,SAAQ,OAAQ,CAAA,OAAA;AAAA,IAChB,UAAS,EAAA,OAAQ,CAAA;AAAA,GAAA;AACM;AACN,mBACL,CAAA,MAAQ,EAAA;AAAA,EACtB,OAAA,MAAA;AACF","file":"index.js","sourcesContent":["import type { HonoRequest } from 'hono';\nimport { MastraBase } from '../base';\nimport { InstrumentClass } from '../telemetry';\n\nexport interface MastraAuthProviderOptions<TUser = unknown> {\n name?: string;\n authorizeUser?: (user: TUser, request: HonoRequest) => Promise<boolean> | boolean;\n}\n\n@InstrumentClass({\n prefix: 'auth',\n excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log'],\n})\nexport abstract class MastraAuthProvider<TUser = unknown> extends MastraBase {\n constructor(options?: MastraAuthProviderOptions<TUser>) {\n super({ component: 'AUTH', name: options?.name });\n\n if (options?.authorizeUser) {\n this.authorizeUser = options.authorizeUser.bind(this);\n }\n }\n\n /**\n * Authenticate a token and return the payload\n * @param token - The token to authenticate\n * @param request - The request\n * @returns The payload\n */\n abstract authenticateToken(token: string, request: HonoRequest): Promise<TUser | null>;\n\n /**\n * Authorize a user for a path and method\n * @param user - The user to authorize\n * @param request - The request\n * @returns The authorization result\n */\n abstract authorizeUser(user: TUser, request: HonoRequest): Promise<boolean> | boolean;\n\n protected registerOptions(opts?: MastraAuthProviderOptions<TUser>) {\n if (opts?.authorizeUser) {\n this.authorizeUser = opts.authorizeUser.bind(this);\n }\n }\n}\n","import type { Context, Handler, MiddlewareHandler } from 'hono';\nimport type { DescribeRouteOptions } from 'hono-openapi';\nimport { MastraError, ErrorDomain, ErrorCategory } from '../error';\nimport type { Mastra } from '../mastra';\nimport type { ApiRoute, MastraAuthConfig, Methods } from './types';\n\nexport type { MastraAuthConfig, ContextWithMastra, ApiRoute } from './types';\nexport { MastraAuthProvider } from './auth';\nexport type { MastraAuthProviderOptions } from './auth';\n\n// Helper type for inferring parameters from a path\n// Thank you Claude!\ntype ParamsFromPath<P extends string> = {\n [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string;\n};\n\ntype RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`;\ntype ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T;\n\ntype RegisterApiRouteOptions<P extends string> = {\n method: Methods;\n openapi?: DescribeRouteOptions;\n handler?: Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >;\n createHandler?: (c: Context) => Promise<\n Handler<\n {\n Variables: {\n mastra: Mastra;\n };\n },\n P,\n ParamsFromPath<P>\n >\n >;\n middleware?: MiddlewareHandler | MiddlewareHandler[];\n};\n\nfunction validateOptions<P extends string>(\n path: P,\n options: RegisterApiRoutePathError | RegisterApiRouteOptions<P>,\n): asserts options is RegisterApiRouteOptions<P> {\n const opts = options as RegisterApiRouteOptions<P>;\n\n if (opts.method === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", missing \"method\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler === undefined && opts.createHandler === undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you must define a \"handler\" or \"createHandler\" property`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n if (opts.handler !== undefined && opts.createHandler !== undefined) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_INVALID_ROUTE_OPTIONS',\n text: `Invalid options for route \"${path}\", you can only define one of the following properties: \"handler\" or \"createHandler\"`,\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n}\n\nexport function registerApiRoute<P extends string>(\n path: P,\n options: ValidatePath<P, RegisterApiRouteOptions<P>>,\n): ValidatePath<P, ApiRoute> {\n if (path.startsWith('/api/')) {\n throw new MastraError({\n id: 'MASTRA_SERVER_API_PATH_RESERVED',\n text: 'Path must not start with \"/api\", it\\'s reserved for internal API routes',\n domain: ErrorDomain.MASTRA_SERVER,\n category: ErrorCategory.USER,\n });\n }\n\n validateOptions(path, options);\n\n return {\n path,\n method: options.method,\n handler: options.handler,\n createHandler: options.createHandler,\n openapi: options.openapi,\n middleware: options.middleware,\n } as unknown as ValidatePath<P, ApiRoute>;\n}\n\nexport function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser> {\n return config;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "0.16.1-alpha.3",
3
+ "version": "0.16.2-alpha.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -227,8 +227,8 @@
227
227
  "typescript": "^5.8.3",
228
228
  "vitest": "^3.2.4",
229
229
  "zod": "^3.25.76",
230
- "@internal/lint": "0.0.36",
231
- "@internal/types-builder": "0.0.11"
230
+ "@internal/lint": "0.0.37",
231
+ "@internal/types-builder": "0.0.12"
232
232
  },
233
233
  "engines": {
234
234
  "node": ">=20"