/**
 * Unified Agent Wrapper
 *
 * Provides a single API surface for running agents regardless of backend:
 * - AI SDK v6 (existing ContractSpec implementation)
 * - Claude Agent SDK (@anthropic-ai/claude-agent-sdk)
 * - OpenCode SDK (@opencode-ai/sdk)
 *
 * @example
 * ```typescript
 * import { createUnifiedAgent } from '@contractspec/lib.ai-agent';
 *
 * // Create agent with AI SDK backend (default)
 * const agent = createUnifiedAgent(mySpec, {
 *   backend: 'ai-sdk',
 * });
 *
 * // Create agent with Claude Agent SDK backend
 * const claudeAgent = createUnifiedAgent(mySpec, {
 *   backend: 'claude-agent-sdk',
 *   config: { extendedThinking: true },
 * });
 *
 * // All agents use the same API
 * const response = await agent.run('Hello');
 * ```
 */
import type { ModelSelectionContext, ModelSelector } from '@contractspec/lib.ai-providers/selector-types';
import type { ProviderConfig } from '@contractspec/lib.ai-providers/types';
import type { AgentSpec } from '@contractspec/lib.contracts-spec/agent';
import type { LanguageModel } from 'ai';
import type { ClaudeAgentSDKConfig, OpenCodeSDKConfig } from '../providers/types';
import type { McpClientConfig } from '../tools/mcp-client';
import type { AgentCallOptions, AgentGenerateResult, ToolHandler } from '../types';
/** Supported backend types */
export type UnifiedAgentBackend = 'ai-sdk' | 'claude-agent-sdk' | 'opencode-sdk';
/** Backend-specific configuration */
export interface UnifiedAgentBackendConfig {
    'ai-sdk'?: {
        model?: string;
        modelInstance?: LanguageModel;
        provider?: ProviderConfig;
        temperature?: number;
        maxTokens?: number;
        mcpServers?: McpClientConfig[];
        modelSelector?: ModelSelector;
        selectionContext?: ModelSelectionContext;
    };
    'claude-agent-sdk'?: ClaudeAgentSDKConfig;
    'opencode-sdk'?: OpenCodeSDKConfig;
}
/** Unified agent configuration */
export interface UnifiedAgentConfig {
    /** Backend to use */
    backend: UnifiedAgentBackend;
    /** Backend-specific configuration */
    config?: UnifiedAgentBackendConfig[UnifiedAgentBackend];
    /** Tool handlers for the agent */
    tools?: Map<string, ToolHandler>;
    /** Fallback backend if primary fails */
    fallbackBackend?: UnifiedAgentBackend;
    /** Enable verbose logging */
    verbose?: boolean;
    /** Locale for i18n (BCP 47). Falls back to spec.locale, then 'en'. */
    locale?: string;
}
/** Unified agent run options */
export interface UnifiedAgentRunOptions extends AgentCallOptions {
    /** Override backend for this call */
    backend?: UnifiedAgentBackend;
}
/** Unified agent state */
export interface UnifiedAgentState {
    backend: UnifiedAgentBackend;
    isReady: boolean;
    sessionId?: string;
    messageCount: number;
    lastError?: Error;
}
/**
 * Unified agent that works across multiple backends.
 */
export declare class UnifiedAgent {
    private readonly spec;
    private readonly config;
    private readonly tools;
    private provider?;
    private context?;
    private state;
    constructor(spec: AgentSpec, config: UnifiedAgentConfig);
    /** Resolve i18n from config.locale > spec.locale > 'en' */
    private i18n;
    /**
     * Initialize the agent with its backend.
     */
    initialize(): Promise<void>;
    private initializeClaudeAgentSDK;
    private initializeOpenCodeSDK;
    /**
     * Run the agent with a message.
     */
    run(message: string, options?: UnifiedAgentRunOptions): Promise<AgentGenerateResult>;
    private runWithAISDK;
    private runWithExternalProvider;
    private convertExternalResult;
    private getAISDKConfig;
    private resolveAISDKModel;
    private applyModelSettings;
    /**
     * Get agent state.
     */
    getState(): UnifiedAgentState;
    /**
     * Get the agent spec.
     */
    getSpec(): AgentSpec;
    /**
     * Get the current backend.
     */
    getBackend(): UnifiedAgentBackend;
    /**
     * Check if a specific backend is available.
     */
    isBackendAvailable(backend: UnifiedAgentBackend): Promise<boolean>;
    /**
     * Switch to a different backend.
     */
    switchBackend(backend: UnifiedAgentBackend): Promise<void>;
    /**
     * Reset the agent state.
     */
    reset(): void;
    private cleanupProviderContext;
    /**
     * Add a tool handler.
     */
    addTool(name: string, handler: ToolHandler): void;
    /**
     * Remove a tool handler.
     */
    removeTool(name: string): boolean;
}
/**
 * Create a unified agent.
 */
export declare function createUnifiedAgent(spec: AgentSpec, config: UnifiedAgentConfig): UnifiedAgent;
/**
 * Create a unified agent with AI SDK backend (default).
 */
export declare function createAISDKAgent(spec: AgentSpec, options?: {
    tools?: Map<string, ToolHandler>;
    model?: string;
    modelInstance?: LanguageModel;
    provider?: ProviderConfig;
    temperature?: number;
    maxTokens?: number;
    mcpServers?: McpClientConfig[];
}): UnifiedAgent;
/**
 * Create a unified agent with Claude Agent SDK backend.
 */
export declare function createClaudeAgentSDKAgent(spec: AgentSpec, config?: ClaudeAgentSDKConfig & {
    tools?: Map<string, ToolHandler>;
}): UnifiedAgent;
/**
 * Create a unified agent with OpenCode SDK backend.
 */
export declare function createOpenCodeSDKAgent(spec: AgentSpec, config?: OpenCodeSDKConfig & {
    tools?: Map<string, ToolHandler>;
}): UnifiedAgent;
/**
 * Get available backends.
 */
export declare function getAvailableBackends(): Promise<UnifiedAgentBackend[]>;
