import { type LanguageModel, type Schema } from "ai";
import type { ZodType } from "zod";
import { type AIProviderName } from "../constants/enums.js";
import { BaseProvider } from "../core/baseProvider.js";
import type { EnhancedGenerateResult, TextGenerationOptions, NeurolinkCredentials, StreamOptions, StreamResult } from "../types/index.js";
/**
 * Resolve the correct Vertex AI location for a given model.
 *
 * Google-published models (gemini-*) require the global endpoint
 * (`aiplatform.googleapis.com`), not regional endpoints like
 * `us-east5-aiplatform.googleapis.com`. Regional endpoints return
 * "model not found" for these models.
 *
 * Anthropic-on-Vertex models (claude-*) require regional endpoints
 * and are handled separately by `createVertexAnthropicSettings`.
 *
 * Embedding models and custom models use the configured location as-is.
 */
export declare const resolveVertexLocation: (modelName: string | undefined, configuredLocation: string) => string;
/**
 * Vertex Model Aliases
 *
 * Maps shorthand model names to their full versioned IDs required by the
 * Vertex AI API. This allows users to pass convenient names like
 * "claude-sonnet-4-5" instead of "claude-sonnet-4-5@20250929".
 *
 * Alias resolution runs at the very start of getModel() so that all
 * downstream code (isAnthropicModel, validateAnthropicModelName, etc.)
 * sees the canonical versioned name.
 *
 * To add a new model: simply add an entry mapping the shorthand to the
 * full versioned string. No other changes are needed.
 */
export declare const VERTEX_MODEL_ALIASES: Record<string, string>;
/**
 * Google Vertex AI Provider v2 - BaseProvider Implementation
 *
 * Features:
 * - Extends BaseProvider for shared functionality
 * - Preserves existing Google Cloud authentication
 * - Maintains Anthropic model support via dynamic imports
 * - Fresh model creation for each request
 * - Enhanced error handling with setup guidance
 * - Tool registration and context management
 *
 * @important Structured Output Limitation (Gemini Models Only)
 * Google Gemini models on Vertex AI cannot combine function calling (tools) with
 * structured output (JSON schema). When using schemas, you MUST set disableTools: true.
 *
 * Error without disableTools:
 * "Function calling with a response mime type: 'application/json' is unsupported"
 *
 * This limitation ONLY affects Gemini models. Anthropic Claude models via Vertex
 * AI do NOT have this limitation and support both tools + schemas simultaneously.
 *
 * @example Gemini models with schemas
 * ```typescript
 * const provider = new GoogleVertexProvider("gemini-2.5-flash");
 * const result = await provider.generate({
 *   input: { text: "Analyze data" },
 *   schema: MySchema,
 *   output: { format: "json" },
 *   disableTools: true  // Required for Gemini models
 * });
 * ```
 *
 * @example Claude models (no limitation)
 * ```typescript
 * const provider = new GoogleVertexProvider("claude-3-5-sonnet-20241022");
 * const result = await provider.generate({
 *   input: { text: "Analyze data" },
 *   schema: MySchema,
 *   output: { format: "json" }
 *   // No disableTools needed - Claude supports both
 * });
 * ```
 *
 * @note Gemini 3 Pro Preview (November 2025) will support combining tools + schemas
 * @see https://cloud.google.com/vertex-ai/docs/generative-ai/learn/models
 */
export declare class GoogleVertexProvider extends BaseProvider {
    private projectId;
    private location;
    private registeredTools;
    private toolContext;
    private credentials;
    private static modelConfigCache;
    private static modelConfigCacheTime;
    private static readonly CACHE_DURATION;
    private static readonly MAX_CACHE_SIZE;
    private static maxTokensCache;
    private static maxTokensCacheTime;
    constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string, credentials?: NeurolinkCredentials["vertex"]);
    protected getProviderName(): AIProviderName;
    protected getDefaultModel(): string;
    /**
     * Get the default embedding model for Google Vertex
     * @returns The default Vertex AI embedding model name
     */
    protected getDefaultEmbeddingModel(): string;
    /**
     * Returns the Vercel AI SDK model instance for Google Vertex
     * Creates fresh model instances for each request
     */
    protected getAISDKModel(): Promise<LanguageModel>;
    /**
     * Resolve a raw model name through the alias map.
     * Used internally to normalize model names before any API calls.
     */
    private resolveAlias;
    /**
     * Initialize model creation tracking
     */
    private initializeModelCreationLogging;
    /**
     * Check if model is Anthropic-based and attempt creation
     */
    private attemptAnthropicModelCreation;
    /**
     * Create Google Vertex model with comprehensive logging and error handling
     */
    private createGoogleVertexModel;
    /**
     * Create Vertex AI instance and model with comprehensive logging
     */
    private createVertexInstance;
    /**
     * Gets the appropriate model instance (Google or Anthropic)
     * Uses dual provider architecture for proper model routing
     * Creates fresh instances for each request to ensure proper authentication
     */
    private getModel;
    /**
     * Validate stream options
     */
    private validateStreamOptionsOnly;
    protected executeStream(options: StreamOptions, analysisSchema?: ZodType | Schema<unknown>): Promise<StreamResult>;
    private maybeExecuteNativeGemini3ToolStream;
    private executeAISDKStream;
    private resolveAISDKStreamTools;
    private buildAISDKStreamOptions;
    private captureAISDKStreamToolStep;
    private startObservedAISDKStream;
    private attachAISDKStreamObservers;
    private observeAISDKStreamResult;
    /**
     * Create @google/genai client configured for Vertex AI
     */
    private createVertexGenAIClient;
    /**
     * Build multimodal content parts (user message) from input text, PDFs, and images.
     * Shared by both stream and generate native Gemini 3 paths.
     */
    private buildNativeContentParts;
    /**
     * Convert conversationMessages from NeuroLink's ChatMessage format into
     * the @google/genai contents format and prepend them before the current
     * user message. This gives the native Gemini 3 path multi-turn context
     * that was previously dropped (only the current prompt was sent).
     */
    private prependConversationHistory;
    /**
     * Execute stream using native @google/genai SDK for Gemini 3 models on Vertex AI
     * This bypasses @ai-sdk/google-vertex to properly handle thought_signature
     */
    private executeNativeGemini3Stream;
    private executeNativeGemini3StreamWithSpan;
    private runNativeGemini3StreamLoop;
    /**
     * Execute generate using native @google/genai SDK for Gemini 3 models on Vertex AI
     * This bypasses @ai-sdk/google-vertex to properly handle thought_signature
     */
    private executeNativeGemini3Generate;
    /**
     * Process CSV files and append content to options.input.text
     * This ensures CSV data is available in the prompt for native Gemini 3 SDK calls
     * Returns a new options object with modified input (immutable pattern)
     */
    private processCSVFilesForNativeSDK;
    /**
     * Override generate to route Gemini 3 models with tools to native SDK
     */
    generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>;
    protected formatProviderError(error: unknown): Error;
    /**
     * Memory-safe cache management for model configurations
     * Implements LRU eviction to prevent memory leaks in long-running processes
     */
    private static evictLRUCacheEntries;
    /**
     * Access and refresh cache entry (moves to end for LRU)
     */
    private static accessCacheEntry;
    /**
     * Memory-safe cached check for whether maxTokens should be set for the given model
     * Optimized for streaming performance with LRU eviction to prevent memory leaks
     */
    private shouldSetMaxTokensCached;
    /**
     * Memory-safe check if model has maxTokens issues using configuration-based approach
     * This replaces hardcoded model-specific logic with configurable behavior
     * Includes LRU caching to avoid repeated configuration lookups during streaming
     */
    private modelHasMaxTokensIssues;
    /**
     * Check if Anthropic models are available
     * @returns Promise<boolean> indicating if Anthropic support is available
     */
    hasAnthropicSupport(): Promise<boolean>;
    /**
     * Resolve a shorthand model name to its full versioned Vertex AI identifier.
     * Returns the original name unchanged if no alias exists.
     *
     * @param modelName - A model name, possibly a shorthand alias
     * @returns The resolved full versioned model name
     *
     * @example
     * ```typescript
     * provider.resolveModelAlias("claude-sonnet-4-5"); // "claude-sonnet-4-5@20250929"
     * provider.resolveModelAlias("gemini-3-pro");      // "gemini-3.1-pro-preview"
     * provider.resolveModelAlias("gemini-2.5-flash");  // "gemini-2.5-flash" (unchanged)
     * ```
     */
    resolveModelAlias(modelName: string): string;
    /**
     * Create an Anthropic model instance using vertexAnthropic provider
     * Uses fresh vertex settings for each request with comprehensive validation
     * @param modelName Anthropic model name (e.g., 'claude-3-sonnet@20240229')
     * @returns LanguageModel instance or null if not available
     */
    createAnthropicModel(modelName: string): Promise<LanguageModel | null>;
    /**
     * Validate Vertex AI authentication configuration
     */
    private validateVertexAuthentication;
    /**
     * Validate Vertex AI project configuration
     */
    private validateVertexProjectConfiguration;
    /**
     * Check if the specified region supports Anthropic models
     */
    private checkVertexRegionalSupport;
    /**
     * Validate Anthropic model name format and availability
     */
    private validateAnthropicModelName;
    /**
     * Analyze Anthropic model creation errors for detailed troubleshooting
     */
    private analyzeAnthropicCreationError;
    /**
     * Get detailed troubleshooting steps based on error analysis
     */
    private getAnthropicTroubleshootingSteps;
    /**
     * Register a tool with the AI provider
     * @param name The name of the tool
     * @param schema The Zod schema defining the tool's parameters
     * @param description A description of what the tool does
     * @param handler The function to execute when the tool is called
     */
    registerTool(name: string, schema: ZodType<unknown>, description: string, handler: (params: Record<string, unknown>) => Promise<unknown>): void;
    /**
     * Set the context for tool execution
     * @param context The context to use for tool execution
     */
    setToolContext(context: Record<string, unknown>): void;
    /**
     * Get the current tool execution context
     * @returns The current tool execution context
     */
    getToolContext(): Record<string, unknown>;
    /**
     * Set the tool executor function for custom tool execution
     * This method is called by BaseProvider.setupToolExecutor()
     * @param executor Function to execute tools by name
     */
    setToolExecutor(executor: (toolName: string, params: unknown) => Promise<unknown>): void;
    /**
     * Clear all static caches - useful for testing and memory cleanup
     * Public method to allow external cache management
     */
    static clearCaches(): void;
    /**
     * Get cache statistics for monitoring and debugging
     */
    static getCacheStats(): {
        modelConfigCacheSize: number;
        maxTokensCacheSize: number;
        maxCacheSize: number;
        cacheAge: {
            modelConfig: number;
            maxTokens: number;
        };
    };
    /**
     * Detect image MIME type from buffer
     */
    private detectImageType;
    /**
     * Estimate token count from text using centralized estimation with provider multipliers
     */
    private estimateTokenCount;
    /**
     * Obtain a Google Auth access token for Vertex AI REST API calls.
     */
    private getImageGenerationAccessToken;
    /**
     * Build request parts for image generation from prompt, PDFs, and images.
     */
    private buildImageGenerationParts;
    /**
     * Parse the Vertex AI image generation REST API response.
     *
     * Dual-mode image models (gemini-3.1-flash-image-preview, gemini-2.5-flash-image,
     * gemini-3-pro-image-preview) decide per-request whether to emit an image or text.
     * When the response contains text parts but no image part, surface the text via
     * `textFallback` so the caller can return a normal text result instead of throwing
     * "model returned text instead of image data" and burning retries on a query that
     * the model has already answered.
     */
    private parseImageGenerationResponse;
    /**
     * Overrides the BaseProvider's image generation method to implement it for Vertex AI.
     * Uses REST API approach with google-auth-library for authentication.
     * Supports PDF input for image generation with gemini-3-pro-image-preview (Nano Banana Pro).
     * @param options The generation options containing the prompt and optional PDF files.
     * @returns A promise that resolves to the generation result, including the image data.
     */
    protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
    /**
     * Generate embeddings for text using Google Vertex AI text-embedding models
     * @param text - The text to embed
     * @param modelName - The embedding model to use (default: text-embedding-004)
     * @returns Promise resolving to the embedding vector
     */
    embed(text: string, modelName?: string): Promise<number[]>;
    /**
     * Generate embeddings for multiple texts in a single batch
     * @param texts - The texts to embed
     * @param modelName - The embedding model to use (default: text-embedding-004)
     * @returns Promise resolving to an array of embedding vectors
     */
    embedMany(texts: string[], modelName?: string): Promise<number[][]>;
    /**
     * Get model suggestions when a model is not found
     */
    private getModelSuggestions;
}
export default GoogleVertexProvider;
export { GoogleVertexProvider as GoogleVertexAI };
