/**
 * Shared types for the MCP tool provider.
 */
export interface CallApiContextParams {
    prompt?: {
        raw: string;
        label?: string;
    };
    vars?: Record<string, object | string>;
}
export interface ProviderOptions {
    config?: Record<string, unknown>;
    id?: string;
}
export interface ProviderResponse {
    cached?: boolean;
    cost?: number;
    error?: string;
    metadata?: Record<string, unknown>;
    output?: object | string;
    tokenUsage?: {
        total?: number;
        prompt?: number;
        completion?: number;
        cached?: number;
    };
}
export interface MCPTool {
    name: string;
    description?: string;
    inputSchema?: Record<string, unknown>;
}
export interface MCPClient {
    getAllTools: () => MCPTool[];
    callTool: (name: string, args: Record<string, unknown>) => Promise<{
        content: string;
        error?: string;
    }>;
    cleanup: () => Promise<void>;
}
export interface ToolCallEntry {
    name: string;
    input: unknown;
    output: string;
}
/** Configuration passed from the provider to an LLM backend's tool loop */
export interface ToolLoopConfig {
    /** The user's prompt */
    prompt: string;
    /** MCP tools available (already filtered by capabilities) */
    tools: MCPTool[];
    /** Function to call an MCP tool by name */
    callTool: (name: string, args: Record<string, unknown>) => Promise<{
        content: string;
        error?: string;
    }>;
    /** Max rounds of tool calls before forcing a final answer */
    maxToolRounds: number;
    /** LLM model name (provider-specific, e.g., "claude-opus-4-6") */
    model: string;
    /** Sampling temperature */
    temperature: number;
    /** Max output tokens */
    maxTokens: number;
    /** API key for the LLM provider */
    apiKey: string;
    /**
     * OpenAI API variant — determines which endpoint to call.
     * - `"chat"` → `/v1/chat/completions` (default)
     * - `"responses"` → `/v1/responses`
     *
     * Extracted from model ID: `openai:responses:gpt-5.4` → `"responses"`
     */
    apiVariant?: "chat" | "responses";
    /** Additional model-specific config passed through from the provider */
    providerConfig?: Record<string, unknown>;
}
/** Result returned from an LLM backend's tool loop */
export interface ToolLoopResult {
    /** The LLM's final text output */
    output: string;
    /** Log of all tool calls made during the loop */
    toolCallLog: ToolCallEntry[];
    /** Token usage stats */
    tokenUsage: {
        prompt: number;
        completion: number;
        total: number;
    };
    /** Number of tool rounds completed */
    toolRounds: number;
    /** Whether the loop exhausted maxToolRounds */
    exhaustedRounds?: boolean;
    /** Wall-clock duration in ms */
    latencyMs: number;
}
/**
 * An LLM backend that can run a multi-turn tool loop.
 *
 * Each backend (Anthropic, OpenAI) implements this function signature.
 * The provider selects the appropriate backend based on the model ID prefix.
 */
export type RunToolLoop = (config: ToolLoopConfig) => Promise<ToolLoopResult>;
