import type { ZodType, ZodTypeDef } from "zod";
import type { Tool, Schema } from "ai";
import type { AIProviderName, AnalyticsData, EvaluationData } from "../core/types.js";
import type { UnknownRecord, JsonValue } from "./common.js";
/**
 * Interface for tool execution calls (AI SDK compatible)
 */
export interface ToolCall {
    type?: "tool-call";
    toolCallId?: string;
    toolName: string;
    parameters?: UnknownRecord;
    args?: UnknownRecord;
    id?: string;
}
/**
 * Interface for tool execution results - Enhanced for type safety
 */
export interface ToolResult {
    toolName: string;
    status: "success" | "failure";
    output?: JsonValue;
    error?: string;
    id?: string;
    executionTime?: number;
    metadata?: {
        [key: string]: JsonValue;
    } & {
        serverId?: string;
        toolCategory?: string;
        isExternal?: boolean;
    };
}
/**
 * Tool Call Results Array - High Reusability
 */
export type ToolCallResults = Array<ToolResult>;
/**
 * Tool Calls Array - High Reusability
 */
export type ToolCalls = Array<ToolCall>;
/**
 * Stream Analytics Data - Enhanced for performance tracking
 */
export interface StreamAnalyticsData {
    /** Tool execution results with timing */
    toolResults?: Promise<ToolCallResults>;
    /** Tool calls made during stream */
    toolCalls?: Promise<ToolCalls>;
    /** Stream performance metrics */
    performance?: {
        startTime: number;
        endTime?: number;
        chunkCount: number;
        avgChunkSize: number;
        totalBytes: number;
    };
    /** Provider analytics */
    providerAnalytics?: AnalyticsData;
}
/**
 * Stream function options interface - Primary method for streaming content
 * Future-ready for multi-modal capabilities while maintaining text focus
 */
export interface StreamOptions {
    input: {
        text: string;
    };
    output?: {
        format?: "text" | "structured" | "json";
        streaming?: {
            chunkSize?: number;
            bufferSize?: number;
            enableProgress?: boolean;
        };
    };
    provider?: AIProviderName | string;
    model?: string;
    temperature?: number;
    maxTokens?: number;
    systemPrompt?: string;
    schema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>;
    tools?: Record<string, Tool>;
    timeout?: number | string;
    disableTools?: boolean;
    maxSteps?: number;
    enableEvaluation?: boolean;
    enableAnalytics?: boolean;
    context?: UnknownRecord;
    evaluationDomain?: string;
    toolUsageContext?: string;
    conversationHistory?: Array<{
        role: string;
        content: string;
    }>;
}
/**
 * Stream function result interface - Primary output format for streaming
 * Future-ready for multi-modal outputs while maintaining text focus
 */
export interface StreamResult {
    stream: AsyncIterable<{
        content: string;
    }>;
    provider?: string;
    model?: string;
    usage?: {
        inputTokens?: number;
        outputTokens?: number;
        totalTokens?: number;
    };
    finishReason?: string;
    toolCalls?: ToolCall[];
    toolResults?: ToolResult[];
    metadata?: {
        streamId?: string;
        startTime?: number;
        totalChunks?: number;
        estimatedDuration?: number;
        responseTime?: number;
        fallback?: boolean;
    };
    analytics?: AnalyticsData | Promise<AnalyticsData>;
    evaluation?: EvaluationData | Promise<EvaluationData>;
}
/**
 * Enhanced provider interface with stream method
 */
export interface EnhancedStreamProvider {
    stream(options: StreamOptions): Promise<StreamResult>;
    getName(): string;
    isAvailable(): Promise<boolean>;
}
