/** * AgentNetwork - Multi-Agent Orchestration for NeuroLink * * Uses the ai SDK's built-in tool loop: each agent is wrapped as an ai SDK * tool, and the network's router is a single neurolink.generate() call with * maxSteps. The SDK iterates automatically (tool call → execute → feed result * → next call) until the model stops or maxSteps is reached. */ import type { NeuroLink } from "../neurolink.js"; import type { AgentNetworkConfig, NetworkExecutionInput, NetworkExecutionOptions, NetworkExecutionResult, NetworkStreamChunk, Primitive } from "../types/index.js"; import { Agent } from "./agent.js"; /** * AgentNetwork - Multi-agent orchestration using the ai SDK tool loop * * Each agent in the network is registered as an ai SDK `tool()`. A single * `neurolink.generate()` call with `maxSteps` acts as the router: the model * picks which agent tool(s) to call, the SDK executes them and feeds results * back, and the loop continues until the model emits `finishReason: "stop"` or * maxSteps is exhausted. * * @example * ```typescript * const network = neurolink.createNetwork({ * name: 'Content Team', * agents: [researchAgent, writerAgent, reviewerAgent], * router: { model: 'gpt-4o' } * }); * * const result = await network.execute({ * message: 'Write an article about AI trends' * }); * ``` */ export declare class AgentNetwork { readonly id: string; readonly name: string; readonly description?: string; private neurolink; private agents; private workflows; private primitives; private emitter; private config; private toolsInitialized; private toolsInitPromise; constructor(config: AgentNetworkConfig, neurolink: NeuroLink); private initializeAgents; private initializeWorkflows; private initializeTools; private ensureToolsInitialized; /** * Build a Record of ai SDK tools — one per agent in the network. * The router model calls these tools to delegate subtasks. */ private buildAgentTools; /** * Build the router system prompt that describes all available agents and * instructs the model to delegate tasks via agent tools. */ private buildRouterSystemPrompt; /** * Build NetworkExecutionTrace steps from generate() toolExecutions. */ private buildTrace; /** * Execute the network with intelligent routing via the ai SDK tool loop. * * A single `neurolink.generate()` call is issued. The model decides which * agent tool(s) to call; the SDK executes them and loops until `stop` or * `maxSteps` is reached. */ execute(input: NetworkExecutionInput, options?: NetworkExecutionOptions): Promise; /** * Stream network execution using the ai SDK tool loop. * * Calls `neurolink.stream()` with agent tools. Text chunks, tool calls, and * tool results are forwarded as typed NetworkStreamChunk events. */ stream(input: NetworkExecutionInput, options?: NetworkExecutionOptions): AsyncIterable; getAgent(id: string): Agent | undefined; getAllAgents(): Agent[]; getAllPrimitives(): Primitive[]; on(event: string, handler: (...args: unknown[]) => void): void; off(event: string, handler: (...args: unknown[]) => void): void; private extractMessageContent; private emit; }