/**
 * Orchestration step for the research pipeline
 * Uses AI-powered agents to make decisions about which tools to use
 */
import { createStep } from '../utils/steps.js';
import { ResearchState, ResearchStep } from '../types/pipeline.js';
import { LanguageModel } from 'ai';
/**
 * Options for the orchestration step
 */
export interface OrchestrateOptions {
    /** LLM model to use for orchestration (from the AI library) */
    model: LanguageModel;
    /** Default search provider to use for search-dependent steps */
    searchProvider?: any;
    /** Map of tool names to step functions that can be used by the agent */
    tools?: Record<string, ResearchStep>;
    /** Custom prompt for the orchestration agent */
    customPrompt?: string;
    /** Maximum number of iterations */
    maxIterations?: number;
    /** Optional function that determines when to exit orchestration */
    exitCriteria?: (state: ResearchState) => boolean | Promise<boolean>;
    /** Whether to include the orchestration results in the final output */
    includeInResults?: boolean;
    /** Whether to continue if a tool execution fails */
    continueOnError?: boolean;
    /** Custom tool selection function (if provided, uses this instead of LLM) */
    toolSelectorFn?: (state: ResearchState, availableTools: string[]) => Promise<{
        toolName: string;
        reasoning: string;
    }>;
    /** Retry configuration */
    retry?: {
        /** Maximum number of retries */
        maxRetries?: number;
        /** Base delay between retries in ms */
        baseDelay?: number;
    };
}
/**
 * Iteration record for orchestration
 */
export interface OrchestrationIteration {
    iteration: number;
    toolChosen: string;
    reasoning: string;
    timestamp: string;
    error?: string;
    result?: string;
}
/**
 * Creates an orchestration step that uses agents to make decisions
 *
 * This step uses an LLM to dynamically select and execute research tools based on the current state.
 * It can handle an entire research process from start to finish by adaptively choosing the right tools.
 *
 * @param options - Configuration for the orchestration
 * @param options.model - The language model to use for orchestration decisions (required)
 * @param options.searchProvider - Search provider for web searches (recommended)
 * @param options.tools - Optional map of custom tools to make available to the agent
 * @param options.customPrompt - Custom system prompt for the orchestration agent
 * @param options.maxIterations - Maximum number of tool executions to perform (default: 10)
 * @param options.exitCriteria - Optional function to determine when to exit orchestration
 * @param options.includeInResults - Whether to include orchestration results in output (default: true)
 * @param options.continueOnError - Whether to continue if a tool execution fails (default: false)
 * @param options.toolSelectorFn - Optional custom function for tool selection instead of using LLM
 * @param options.retry - Configuration for retry behavior
 *
 * @returns An orchestration step for the research pipeline
 *
 * @example
 * ```typescript
 * import { research, orchestrate } from '@plust/datasleuth';
 * import { openai } from '@ai-sdk/openai';
 * import { google } from '@plust/search-sdk';
 *
 * const results = await research({
 *   query: 'Impact of climate change on agriculture',
 *   outputSchema: schema,
 *   steps: [
 *     orchestrate({
 *       model: openai('gpt-4o'),
 *       searchProvider: google.configure({ apiKey: process.env.GOOGLE_API_KEY }),
 *       maxIterations: 15,
 *       continueOnError: true,
 *       exitCriteria: (state) => state.data.summary !== undefined
 *     })
 *   ]
 * });
 * ```
 */
export declare function orchestrate(options: OrchestrateOptions): ReturnType<typeof createStep>;
