import type { Mastra } from '@mastra/core/mastra'; import type { TracingOptions } from '@mastra/core/observability'; import type { RequestContext } from '@mastra/core/request-context'; import { registerApiRoute } from '@mastra/core/server'; import type { V5UIMessage, V5UIMessageStream, V6UIMessage, V6UIMessageStream } from './public-types.js'; export type WorkflowStreamHandlerParams = { runId?: string; resourceId?: string; inputData?: Record; initialState?: Record; resumeData?: Record; requestContext?: RequestContext; tracingOptions?: TracingOptions; step?: string; }; export type WorkflowStreamHandlerOptions = { mastra: Mastra; workflowId: string; params: WorkflowStreamHandlerParams; version?: 'v5' | 'v6'; includeTextStreamParts?: boolean; sendReasoning?: boolean; sendSources?: boolean; }; type WorkflowStreamHandlerOptionsV5 = Omit & { version?: 'v5'; }; type WorkflowStreamHandlerOptionsV6 = Omit & { version: 'v6'; }; /** * Framework-agnostic handler for streaming workflow execution in AI SDK-compatible format. * Use this function directly when you need to handle workflow streaming outside of Hono or Mastra's own apiRoutes feature. * * @example * ```ts * // Next.js App Router * import { handleWorkflowStream } from '@mastra/ai-sdk'; * import { createUIMessageStreamResponse } from 'ai'; * import { mastra } from '@/src/mastra'; * * export async function POST(req: Request) { * const params = await req.json(); * const stream = await handleWorkflowStream({ * mastra, * workflowId: 'weatherWorkflow', * params, * }); * return createUIMessageStreamResponse({ stream }); * } * ``` */ export declare function handleWorkflowStream(options: WorkflowStreamHandlerOptionsV5): Promise>; export declare function handleWorkflowStream(options: WorkflowStreamHandlerOptionsV6): Promise>; export type WorkflowRouteOptions = { version?: 'v5' | 'v6'; sendReasoning?: boolean; sendSources?: boolean; } & ({ path: `${string}:workflowId${string}`; workflow?: never; includeTextStreamParts?: boolean; } | { path: string; workflow: string; includeTextStreamParts?: boolean; }); /** * Creates a workflow route handler for streaming workflow execution using the AI SDK format. * * This function registers an HTTP POST endpoint that accepts input data, executes a workflow, and streams the response back to the client in AI SDK-compatible format. * * @param {WorkflowRouteOptions} options - Configuration options for the workflow route * @param {string} [options.path='/api/workflows/:workflowId/stream'] - The route path. Include `:workflowId` for dynamic routing * @param {string} [options.workflow] - Fixed workflow ID when not using dynamic routing * @param {boolean} [options.includeTextStreamParts=true] - Whether to include text stream parts in the output * * @example * // Dynamic workflow routing * workflowRoute({ * path: '/api/workflows/:workflowId/stream', * }); * * @example * // Fixed workflow with custom path * workflowRoute({ * path: '/api/data-pipeline/stream', * workflow: 'data-processing-workflow', * }); */ export declare function workflowRoute({ path, workflow, version, includeTextStreamParts, sendReasoning, sendSources, }: WorkflowRouteOptions): ReturnType; export {}; //# sourceMappingURL=workflow-route.d.ts.map