/** * Router Agent - Route requests to specialized agents * * @example Simple usage (5 lines) * ```typescript * import { Agent, Router } from 'praisonai'; * * const router = new Router({ * math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] }, * code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] } * }); * await router.chat('Calculate 2+2'); // Routes to math agent * ``` */ import type { EnhancedAgent } from './enhanced'; import { Agent } from './simple'; type AnyAgent = Agent | EnhancedAgent; export interface RouteConfig { agent: AnyAgent; condition: (input: string, context?: RouteContext) => boolean | Promise; priority?: number; } /** Simplified route definition */ export interface SimpleRouteConfig { agent: AnyAgent; keywords?: string[]; pattern?: RegExp; priority?: number; } export interface RouteContext { history?: string[]; metadata?: Record; } export interface RouterConfig { name?: string; routes: RouteConfig[]; defaultAgent?: AnyAgent; verbose?: boolean; } /** Simplified router config - just a map of route name to config */ export type SimpleRouterConfig = Record; /** * Router Agent - Routes requests to the most appropriate agent */ export declare class RouterAgent { readonly name: string; private routes; private defaultAgent?; private verbose; constructor(config: RouterConfig); /** * Route a request to the appropriate agent */ route(input: string, context?: RouteContext): Promise<{ agent: AnyAgent; response: string; } | null>; /** * Simplified chat method - routes and returns just the response */ chat(input: string, context?: RouteContext): Promise; /** * Add a route */ addRoute(config: RouteConfig): this; /** * Get all routes */ getRoutes(): RouteConfig[]; } /** * Route condition helpers */ export declare const routeConditions: { /** * Match by keywords */ keywords: (keywords: string | string[]) => (input: string) => boolean; /** * Match by regex */ pattern: (regex: RegExp) => (input: string) => boolean; /** * Match by metadata */ metadata: (key: string, value: any) => (_input: string, context?: RouteContext) => boolean; /** * Always match (for default routes) */ always: () => () => boolean; /** * Combine conditions with AND */ and: (...conditions: Array<(input: string, context?: RouteContext) => boolean>) => (input: string, context?: RouteContext) => boolean; /** * Combine conditions with OR */ or: (...conditions: Array<(input: string, context?: RouteContext) => boolean>) => (input: string, context?: RouteContext) => boolean; }; /** * Create a router agent (legacy API) */ export declare function createRouter(config: RouterConfig): RouterAgent; /** * Simplified Router class - uses keyword/pattern-based routing * * @example Simple usage (5 lines) * ```typescript * import { Agent, Router } from 'praisonai'; * * const router = new Router({ * math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] }, * code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] } * }); * await router.chat('Calculate 2+2'); // Routes to math agent * ``` */ export declare class Router { private routerAgent; private agentMap; constructor(config: SimpleRouterConfig, options?: { default?: string; verbose?: boolean; }); /** * Route and get response */ chat(input: string): Promise; /** * Route and get full result with agent info */ route(input: string): Promise<{ agent: AnyAgent; response: string; } | null>; /** * Get agent by name */ getAgent(name: string): AnyAgent | undefined; } export {};