import type { Agent } from './agent.js'; import type { HandoffSpec } from './handoff.js'; import type { AgentPromptOptions, AgentResponse, AgentStep, AiMessage, TokenUsage } from './types.js'; /** * Hard ceiling for the number of agent-to-agent handoffs in a single * `prompt()` / `stream()` call. Most workflows hop once or twice (triage → * specialist). Anything beyond this almost certainly means the agents are * cycling — surfacing a clear error beats silently looping until token * budgets explode. */ export declare const MAX_HANDOFFS = 5; /** * Internal record of a pending handoff carried from the loop to the * handoff-aware wrapper. Not part of the public surface. */ export interface PendingHandoff { spec: HandoffSpec; transitionMessage: string; parentToolCallId: string; } /** * Signature of `runAgentLoopOnce` from `agent.ts`, injected so this module * doesn't import its caller and create a runtime cycle. */ export type RunOnce = (a: Agent, input: string, options?: AgentPromptOptions) => Promise; /** * Iteratively drive pending handoffs, carrying steps + usage forward. * Used by the non-streaming path. (Streaming has its own iterative driver * inline so chunks can flow as each hop's loop runs.) */ export declare function driveHandoffs(rootName: string, rootResult: AgentResponse & { _pendingHandoff?: PendingHandoff; _carriedMessages?: AiMessage[]; }, pending: PendingHandoff, carriedMessages: AiMessage[], origOptions: AgentPromptOptions | undefined, startHopCount: number, runOnce: RunOnce): Promise; /** Merge the terminal hop's response with carried steps / usage / path. */ export declare function mergeFinalHandoff(terminal: AgentResponse, mergedSteps: AgentStep[], mergedUsage: TokenUsage, pathPrefix: string[], terminalName: string): AgentResponse; /** * Build the {@link AgentPromptOptions} for a child agent invoked via * handoff. The parent's carried message log replaces the child's input * (so the child sees the full conversation up to the handoff point) but * the child still prepends its own `instructions()` as the system message * during initialization, so we drop the parent's leading system message * to avoid double-prefixing. * * Per-call options that make sense to carry across (signal, attachments, * tool/middleware overrides) are preserved; `messages` and `history` are * deliberately overridden. */ export declare function buildHandoffChildOptions(parentOptions: AgentPromptOptions | undefined, carriedMessages: AiMessage[]): AgentPromptOptions; /** Strip the internal `_pendingHandoff` / `_carriedMessages` fields before surfacing the response to public callers. */ export declare function stripInternal(r: AgentResponse & { _pendingHandoff?: PendingHandoff; _carriedMessages?: AiMessage[]; }): AgentResponse; //# sourceMappingURL=handoffs-driver.d.ts.map