UNPKG

@mastra/core

Version:

Mastra is the Typescript framework for building AI agents and assistants. It’s used by some of the largest companies in the world to build internal AI automation tooling and customer-facing agents.

30 lines 1.52 kB
import type { Context, Handler, MiddlewareHandler } from 'hono'; import type { DescribeRouteOptions } from 'hono-openapi'; import type { Mastra } from '../mastra/index.js'; import type { ApiRoute, MastraAuthConfig, Methods } from './types.js'; export type { MastraAuthConfig, ContextWithMastra, ApiRoute } from './types.js'; export { MastraAuthProvider } from './auth.js'; export type { MastraAuthProviderOptions } from './auth.js'; type ParamsFromPath<P extends string> = { [K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string; }; type RegisterApiRoutePathError = `Param 'path' must not start with '/api', it is reserved for internal API routes.`; type ValidatePath<P extends string, T> = P extends `/api/${string}` ? RegisterApiRoutePathError : T; type RegisterApiRouteOptions<P extends string> = { method: Methods; openapi?: DescribeRouteOptions; handler?: Handler<{ Variables: { mastra: Mastra; }; }, P, ParamsFromPath<P>>; createHandler?: (c: Context) => Promise<Handler<{ Variables: { mastra: Mastra; }; }, P, ParamsFromPath<P>>>; middleware?: MiddlewareHandler | MiddlewareHandler[]; }; export declare function registerApiRoute<P extends string>(path: P, options: ValidatePath<P, RegisterApiRouteOptions<P>>): ValidatePath<P, ApiRoute>; export declare function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser>; //# sourceMappingURL=index.d.ts.map