/** * Tool execution configuration (Python parity: `Agent(tool_config=...)` / * `ToolConfig`, `tools/retry.py` `RetryPolicy`). * * Governs how a single tool call is run: a wall-clock timeout, a retry * policy with exponential backoff, output truncation beyond a byte/line * budget, and whether unknown tool names may be resolved from the * process-global tool registry. */ /** Python `RetryPolicy` (the subset the Agent honours). */ export interface ToolRetryPolicy { /** Total attempts including the first (Python `max_attempts`, default 3). */ maxAttempts: number; /** Seconds before the first retry (Python `initial_delay`, default 1). */ initialDelay: number; /** Multiplier per retry (Python `backoff_factor`, default 2). */ backoffFactor: number; /** Cap on a single delay in seconds (Python `max_delay`, default 30). */ maxDelay: number; /** Retry only when this returns true (default: every error). */ shouldRetry?: (error: unknown) => boolean; } export type ToolOutputDirection = 'head' | 'tail' | 'both'; /** Python `DEFAULT_TOOL_OUTPUT_LIMIT` (bytes before spilling/truncating). */ export declare const DEFAULT_TOOL_OUTPUT_LIMIT = 16000; export interface ToolConfig { /** Seconds a tool may run before it is failed (Python `timeout`). */ timeout?: number; retryPolicy?: ToolRetryPolicy; /** Maximum bytes of tool output kept (Python `output_limit`). */ outputLimit: number; /** Maximum lines of tool output kept (Python `output_max_lines`). */ outputMaxLines?: number; /** Which end(s) survive truncation (Python `output_direction`). */ outputDirection: ToolOutputDirection; /** Resolve a tool name missing from the agent's tools via the global registry (Python `allow_global_tools`). */ allowGlobalTools: boolean; /** Run a round's tool calls concurrently (Python `parallel`; `undefined` = not set here). */ parallel?: boolean; } export declare function resolveToolRetryPolicy(input: unknown): ToolRetryPolicy | undefined; /** Resolve the constructor option; `true` means Python's defaults. */ export declare function resolveToolConfig(input: boolean | Record | undefined | null): ToolConfig | undefined; export declare class ToolTimeoutError extends Error { constructor(toolName: string, seconds: number); } /** * Run `fn` under the config's timeout and retry policy. `sleep` is * injectable so tests need not wait for real backoff. */ export declare function executeWithToolConfig(config: ToolConfig, toolName: string, fn: () => Promise, sleep?: (ms: number) => Promise): Promise; /** Truncate tool output to the configured byte and line budgets, keeping the configured end(s). */ export declare function truncateToolOutput(config: ToolConfig, output: string): string;