import type { AgentExecutionOptions, NetworkOptions } from '@mastra/core/agent'; import type { Mastra } from '@mastra/core/mastra'; import { registerApiRoute } from '@mastra/core/server'; import type { AgentVersionOptions } from './chat-route.js'; import type { SupportedUIMessage, V5UIMessage, V5UIMessageStream, V6UIMessage, V6UIMessageStream } from './public-types.js'; export type NetworkStreamHandlerParams = AgentExecutionOptions & { messages: UI_MESSAGE[]; }; export type NetworkStreamHandlerOptions = { mastra: Mastra; agentId: string; agentVersion?: AgentVersionOptions; params: NetworkStreamHandlerParams; defaultOptions?: NetworkOptions; version?: 'v5' | 'v6'; }; type NetworkStreamHandlerOptionsV5 = Omit, 'version'> & { version?: 'v5'; }; type NetworkStreamHandlerOptionsV6 = Omit, 'version'> & { version: 'v6'; }; /** * Framework-agnostic handler for streaming agent network execution in AI SDK-compatible format. * Use this function directly when you need to handle network streaming outside of Hono or Mastra's own apiRoutes feature. * * @example * ```ts * // Next.js App Router * import { handleNetworkStream } 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 handleNetworkStream({ * mastra, * agentId: 'routingAgent', * params, * }); * return createUIMessageStreamResponse({ stream }); * } * ``` */ export declare function handleNetworkStream(options: NetworkStreamHandlerOptionsV5): Promise>; export declare function handleNetworkStream(options: NetworkStreamHandlerOptionsV6): Promise>; export type NetworkRouteOptions = { path: `${string}:agentId${string}`; agent?: never; defaultOptions?: NetworkOptions; version?: 'v5' | 'v6'; agentVersion?: AgentVersionOptions; } | { path: string; agent: string; defaultOptions?: NetworkOptions; version?: 'v5' | 'v6'; agentVersion?: AgentVersionOptions; }; /** * Creates a network route handler for streaming agent network execution using the AI SDK-compatible format. * * This function registers an HTTP POST endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents. * * @param {NetworkRouteOptions} options - Configuration options for the network route * @param {string} [options.path='/network/:agentId'] - The route path. Include `:agentId` for dynamic routing * @param {string} [options.agent] - Fixed agent ID when not using dynamic routing * @param {AgentExecutionOptions} [options.defaultOptions] - Default options passed to agent execution * * @example * // Dynamic agent routing * networkRoute({ * path: '/network/:agentId', * }); * * @example * // Fixed agent with custom path * networkRoute({ * path: '/api/orchestrator', * agent: 'router-agent', * defaultOptions: { * maxSteps: 10, * }, * }); */ export declare function networkRoute({ path, agent, defaultOptions, version, agentVersion, }: NetworkRouteOptions): ReturnType; export {}; //# sourceMappingURL=network-route.d.ts.map