import type { TokenUsage } from '../common/index.js' import type { LLMProvider } from '../provider/index.js' import type { BaseAgentConfig, BaseAgentResult } from './base.js' import type { Agent } from './core.js' export type RoutingDecisionSource = 'provider' | 'fallback' | 'hard_fail' export interface RoutingDecision { agentId: string confidence: number reasoning?: string routingSource: RoutingDecisionSource /** * Tokens the routing call itself spent, summed over any retries. * * Routing runs before the delegate's run exists, so it has no * `TurnRecorder` to accumulate into. Reporting it here lets the * router report its own model usage. The separate budget summary includes * both routing and every delegated descendant. */ usage?: TokenUsage } export interface RouteDefinition { agentId: string agent: Agent description: string matchPatterns?: string[] } export interface RouterAgentConfig extends BaseAgentConfig { routes: RouteDefinition[] provider: LLMProvider routingPrompt?: string fallbackAgentId?: string minConfidence?: number maxRoutingRetries?: number } export interface RouterAgentResult extends BaseAgentResult { selectedRoute: string routingDecision: RoutingDecision delegateResult: BaseAgentResult }