/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { Event } from '../events/event.js'; import { BaseAgent, BaseAgentConfig } from './base_agent.js'; import { InvocationContext } from './invocation_context.js'; /** * A unique symbol to identify ADK agent classes. * Defined once and shared by all RoutedAgent instances. */ declare const ROUTED_AGENT_SIGNATURE_SYMBOL: unique symbol; /** * Type guard to check if an object is an instance of RoutedAgent. * @param obj The object to check. * @returns True if the object is an instance of RoutedAgent, false otherwise. */ export declare function isRoutedAgent(obj: unknown): obj is RoutedAgent; /** * Type definition for a function that selects an agent based on the invocation context. */ export type AgentRouter = (agents: Readonly>, context: InvocationContext, errorContext?: { failedKeys: ReadonlySet; lastError: unknown; }) => Promise | string | undefined; /** * Configuration for the RoutingAgent. */ export interface RoutedAgentConfig extends BaseAgentConfig { /** * The set of agents to route to. Can be an array of agents or a Record of keys to agents. * If an array is provided, the agent names will be used as keys. */ agents: Readonly> | BaseAgent[]; /** * The function to select which agent to run. */ router: AgentRouter; } /** * A BaseAgent implementation that delegates to one of multiple agents based on a router function. * Routing is strictly limited to the agents passed in the config. * * @remarks * Cloning is supported: {@link RoutedAgent.clone} deep-clones the routing * targets from `config.agents` and re-parents the fresh copies onto the clone, * so the clone is a detached root that routes identically to the original while * leaving the original agent tree untouched. */ export declare class RoutedAgent extends BaseAgent { readonly [ROUTED_AGENT_SIGNATURE_SYMBOL] = true; private readonly agents; private readonly router; constructor(config: RoutedAgentConfig); /** * Creates a detached copy of this routed agent. * * The inherited {@link BaseAgent.clone} only deep-clones `subAgents`, but a * `RoutedAgent` derives its routing targets from `config.agents`. Rebuilding * through the base clone alone would re-read the already-parented original * agents and throw "already has a parent agent". This override deep-clones the * routing targets (unless the caller overrides `agents`) so the rebuilt * constructor re-parents fresh, detached copies. The array-vs-record shape * and, for records, the keys are preserved so the router keeps selecting the * same targets. * * @param overrides Config fields to override on the clone. Overriding * `parentAgent` is rejected by the base implementation. * @returns A new detached `RoutedAgent` of the same concrete class. */ clone(overrides?: Partial): this; /** * Runs the selected agent via text-based conversation. */ protected runAsyncImpl(context: InvocationContext): AsyncGenerator; /** * Runs the selected agent via video/audio-based conversation. */ protected runLiveImpl(context: InvocationContext): AsyncGenerator; } export {};