import type { Mastra } from '@mastra/core';
import type { ToolsInput } from '@mastra/core/agent';
import type { RequestContext } from '@mastra/core/request-context';
import type { ApiRoute, ValidationErrorHook } from '@mastra/core/server';
import type z from 'zod';
import type { InMemoryTaskStore } from '../../a2a/store.js';
import type { OpenAPIRoute } from '../openapi-utils.js';
import { A2A_ROUTES } from './a2a.js';
import { AGENT_BUILDER_ROUTES } from './agent-builder.js';
import type { AgentRoutes } from './agents.js';
import { AUTH_ROUTES } from './auth.js';
import { DATASETS_ROUTES } from './datasets.js';
import { LEGACY_ROUTES } from './legacy.js';
import { LOGS_ROUTES } from './logs.js';
import { MCP_ROUTES } from './mcp.js';
import { MEMORY_ROUTES } from './memory.js';
import { OBSERVABILITY_ROUTES } from './observability.js';
import { PROCESSOR_PROVIDER_ROUTES } from './processor-providers.js';
import { PROCESSORS_ROUTES } from './processors.js';
import { SCORES_ROUTES } from './scorers.js';
import type { StoredAgentRoutes } from './stored-agents.js';
import { STORED_MCP_CLIENTS_ROUTES } from './stored-mcp-clients.js';
import { STORED_PROMPT_BLOCKS_ROUTES } from './stored-prompt-blocks.js';
import { STORED_SCORERS_ROUTES } from './stored-scorers.js';
import { STORED_SKILLS_ROUTES } from './stored-skills.js';
import { STORED_WORKSPACES_ROUTES } from './stored-workspaces.js';
import type { MastraStreamReturn } from './stream-types.js';
import { SYSTEM_ROUTES } from './system.js';
import { TOOL_PROVIDER_ROUTES } from './tool-providers.js';
import { TOOLS_ROUTES } from './tools.js';
import { VECTORS_ROUTES } from './vectors.js';
import { WORKFLOWS_ROUTES } from './workflows.js';
import { WORKSPACE_ROUTES } from './workspace.js';
/**
 * Server context fields that are available to route handlers.
 * These are injected by the server adapters (Express, Hono, etc.)
 * Fields other than `mastra` are optional to allow direct handler testing.
 */
export type ServerContext = {
    mastra: Mastra;
    requestContext: RequestContext;
    registeredTools?: ToolsInput;
    taskStore?: InMemoryTaskStore;
    abortSignal: AbortSignal;
    /** The route prefix configured for the server (e.g., '/api') */
    routePrefix?: string;
};
/**
 * Utility type to infer parameters from Zod schemas.
 * Merges path params, query params, and body params into a single type.
 */
export type InferParams<TPathSchema extends z.ZodTypeAny | undefined, TQuerySchema extends z.ZodTypeAny | undefined, TBodySchema extends z.ZodTypeAny | undefined> = (TPathSchema extends z.ZodTypeAny ? z.infer<TPathSchema> : {}) & (TQuerySchema extends z.ZodTypeAny ? z.infer<TQuerySchema> : {}) & (TBodySchema extends z.ZodTypeAny ? z.infer<TBodySchema> : {});
/**
 * All supported response types for server routes.
 * - 'json': Standard JSON response
 * - 'stream': Streaming response (SSE or raw stream)
 * - 'datastream-response': Pre-built Response object for data streams
 * - 'mcp-http': MCP Streamable HTTP transport (handled by adapter)
 * - 'mcp-sse': MCP SSE transport (handled by adapter)
 */
export type ResponseType = 'stream' | 'json' | 'datastream-response' | 'mcp-http' | 'mcp-sse';
export type ServerRouteHandler<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = 'json'> = (params: TParams & ServerContext) => Promise<TResponseType extends 'stream' ? MastraStreamReturn : TResponseType extends 'datastream-response' ? Response : TResponse>;
/**
 * Phantom type for preserving Zod schema types on routes.
 * Not present at runtime — used only for type-level inference via RouteMap.
 */
export interface RouteSchemas<TPathSchema = unknown, TQuerySchema = unknown, TBodySchema = unknown, TResponseSchema = unknown> {
    readonly pathParams: TPathSchema;
    readonly queryParams: TQuerySchema;
    readonly body: TBodySchema;
    readonly response: TResponseSchema;
}
export type ServerRoute<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = ResponseType, TSchemas extends RouteSchemas = RouteSchemas, TMethod extends string = string, TPath extends string = string> = Omit<ApiRoute, 'handler' | 'createHandler' | 'method' | 'path' | 'openapi'> & {
    method: TMethod;
    path: TPath;
    responseType: TResponseType;
    streamFormat?: 'sse' | 'stream';
    handler(params: TParams & ServerContext): ReturnType<ServerRouteHandler<TParams, TResponse, TResponseType>>;
    pathParamSchema?: z.ZodSchema;
    queryParamSchema?: z.ZodSchema;
    bodySchema?: z.ZodSchema;
    responseSchema?: z.ZodSchema;
    openapi?: OpenAPIRoute;
    maxBodySize?: number;
    deprecated?: boolean;
    /**
     * Permission required to access this route (EE feature).
     * If set, the user must have this permission to access the route.
     * Uses the format: `resource:action` or `resource:action:resourceId`
     *
     * @example
     * requiresPermission: 'agents:read'
     * requiresPermission: 'workflows:execute'
     */
    requiresPermission?: string;
    onValidationError?: ValidationErrorHook;
    /** @internal Phantom type — not present at runtime. Used for type-level schema inference. */
    readonly __schemas?: TSchemas;
};
export declare const SERVER_ROUTES: readonly ServerRoute[];
/**
 * Union type of all individual route arrays.
 * Built from the per-domain `as const` tuples to preserve each route's specific schema types.
 */
export type ServerRoutes = readonly [
    ...AgentRoutes,
    ...typeof AUTH_ROUTES,
    ...typeof WORKFLOWS_ROUTES,
    ...typeof TOOLS_ROUTES,
    ...typeof PROCESSORS_ROUTES,
    ...typeof MEMORY_ROUTES,
    ...typeof SCORES_ROUTES,
    ...typeof OBSERVABILITY_ROUTES,
    ...typeof LOGS_ROUTES,
    ...typeof VECTORS_ROUTES,
    ...typeof A2A_ROUTES,
    ...typeof AGENT_BUILDER_ROUTES,
    ...typeof WORKSPACE_ROUTES,
    ...typeof LEGACY_ROUTES,
    ...typeof MCP_ROUTES,
    ...StoredAgentRoutes,
    ...typeof STORED_MCP_CLIENTS_ROUTES,
    ...typeof STORED_PROMPT_BLOCKS_ROUTES,
    ...typeof STORED_SCORERS_ROUTES,
    ...typeof STORED_WORKSPACES_ROUTES,
    ...typeof STORED_SKILLS_ROUTES,
    ...typeof TOOL_PROVIDER_ROUTES,
    ...typeof PROCESSOR_PROVIDER_ROUTES,
    ...typeof SYSTEM_ROUTES,
    ...typeof DATASETS_ROUTES
];
export { createRoute, createPublicRoute, pickParams, jsonQueryParam, wrapSchemaForQueryParams } from './route-builder.js';
export { generateOpenAPIDocument } from '../openapi-utils.js';
export { derivePermission, extractResource, deriveAction, getEffectivePermission } from './permissions.js';
//# sourceMappingURL=index.d.ts.map