import { Message } from "./Message.js";
import { ContentPart, MessageContent } from "./Content.js";
import { ChatOptions } from "./ChatOptions.js";
import { Provider, Usage, ChatChunk, ThinkingConfig } from "../providers/Provider.js";
import { Stream } from "../streaming/Stream.js";
import { ToolResolvable } from "./Tool.js";
import { Schema } from "../schema/Schema.js";
import { z } from "zod";
import { ToolExecutionMode } from "../constants.js";
export interface AskOptions {
    images?: string[];
    files?: string[];
    temperature?: number;
    maxTokens?: number;
    headers?: Record<string, string>;
    maxToolCalls?: number;
    requestTimeout?: number;
    thinking?: ThinkingConfig;
    prediction?: string | ContentPart[];
    signal?: AbortSignal;
    inputs?: Record<string, any>;
}
import { ChatResponseString } from "./ChatResponse.js";
export declare class Chat<S = unknown> {
    private readonly provider;
    private model;
    private readonly options;
    private messages;
    private systemMessages;
    private executor;
    private middlewares;
    constructor(provider: Provider, model: string, options?: ChatOptions, retryConfig?: {
        attempts: number;
        delayMs: number;
    });
    /**
     * Read-only access to message history
     */
    get history(): readonly Message[];
    get modelId(): string;
    /**
     * Aggregate usage across the entire conversation
     */
    get totalUsage(): Usage;
    /**
     * Add a tool to the chat session (fluent API)
     * Supports passing a tool instance or a tool class (which will be instantiated).
     */
    withTool(tool: ToolResolvable): this;
    /**
     * Add multiple tools to the chat session.
     * Supports passing Tool classes (which will be instantiated) or instances.
     * Can replace existing tools if options.replace is true.
     *
     * @example
     * chat.withTools([WeatherTool, new CalculatorTool()], { replace: true });
     */
    withTools(tools: ToolResolvable[], options?: {
        replace?: boolean;
    }): this;
    /**
     * Add instructions (system prompt) to the chat.
     * By default, it appends a new system message.
     * If { replace: true } is passed, it removes all previous system messages first.
     */
    withInstructions(instruction: string, options?: {
        replace?: boolean;
    }): this;
    /**
     * Alias for withInstructions
     */
    withSystemPrompt(instruction: string, options?: {
        replace?: boolean;
    }): this;
    /**
     * Alias for withInstructions
     */
    system(instruction: string, options?: {
        replace?: boolean;
    }): this;
    /**
     * Add a message manually to the chat history.
     * Useful for rehydrating sessions from a database.
     */
    add(role: "user" | "assistant" | "system" | "developer" | "tool", content: string | MessageContent): this;
    /**
     * Add a raw Message object to the chat history.
     */
    addMessage(message: Message): this;
    /**
     * Set the temperature for the chat session.
     * Controls randomness: 0.0 (deterministic) to 1.0 (creative).
     */
    withTemperature(temp: number): this;
    /**
     * Switch the model used for this chat session.
     */
    withModel(model: string): this;
    /**
     * Set custom headers for the chat session.
     * Merges with existing headers.
     */
    withRequestOptions(options: {
        headers?: Record<string, string>;
        responseFormat?: unknown;
    }): this;
    /**
     * Set provider-specific parameters.
     * These will be merged into the final request payload.
     */
    withParams(params: Record<string, unknown>): this;
    /**
     * Enforce a specific schema for the output.
     * Can accept a Schema object or a Zod schema/JSON Schema directly.
     */
    withSchema<T>(schema: Schema | z.ZodType<T> | Record<string, unknown> | null): Chat<T>;
    /**
     * Provide a prediction of the expected output to reduce latency.
     * Particularly useful for code-editing agents modifying existing text.
     */
    withPrediction(prediction: string | ContentPart[] | null): this;
    /**
     * Enable and configure extended thinking for reasoning models.
     */
    withThinking(config: ThinkingConfig): this;
    /**
     * Shortcut to set thinking effort.
     */
    withEffort(effort: "low" | "medium" | "high" | "none"): this;
    onNewMessage(handler: () => void): this;
    onEndMessage(handler: (message: ChatResponseString) => void): this;
    onToolCall(handler: (toolCall: unknown) => void): this;
    onToolResult(handler: (result: unknown) => void): this;
    /**
     * Called when a tool call starts.
     */
    onToolCallStart(handler: (toolCall: unknown) => void): this;
    /**
     * Called when a tool call ends successfully.
     */
    onToolCallEnd(handler: (toolCall: unknown, result: unknown) => void): this;
    onToolCallError(handler: (toolCall: unknown, error: Error) => "STOP" | "CONTINUE" | "RETRY" | void | Promise<"STOP" | "CONTINUE" | "RETRY" | void>): this;
    /**
     * Set the tool execution mode.
     * - "auto": (Default) Automatically execute all tool calls.
     * - "confirm": Call onConfirmToolCall before executing each tool.
     * - "dry-run": Propose tool calls but do not execute them.
     */
    withToolExecution(mode: ToolExecutionMode): this;
    /**
     * Hook for confirming tool execution in "confirm" mode.
     * Return true to proceed, false to cancel the specific call.
     */
    onConfirmToolCall(handler: (toolCall: unknown) => Promise<boolean> | boolean): this;
    /**
     * Add a hook to process messages before sending to the LLM.
     * Useful for PII detection, redaction, and input moderation.
     */
    beforeRequest(handler: (messages: Message[]) => Promise<Message[] | void>): this;
    /**
     * Add a hook to process the response before returning it.
     * Useful for output redaction, compliance, and post-moderation.
     */
    afterResponse(handler: (response: ChatResponseString) => Promise<ChatResponseString | void>): this;
    /**
     * Ask the model a question
     */
    ask(content: string | ContentPart[], options?: AskOptions): Promise<ChatResponseString>;
    /**
     * Streams the model's response to a user question.
     */
    stream(content: string | ContentPart[], options?: AskOptions): Stream<ChatChunk>;
    /**
     * Normalizes a ToolResolvable into a ToolDefinition.
     */
    private normalizeTool;
}
//# sourceMappingURL=Chat.d.ts.map