import { z } from "zod";
import { Chat, AskOptions } from "../chat/Chat.js";
import { ChatOptions } from "../chat/ChatOptions.js";
import { ChatResponseString } from "../chat/ChatResponse.js";
import { ToolResolvable } from "../chat/Tool.js";
import { ThinkingConfig, ThinkingResult } from "../providers/Provider.js";
import { Schema } from "../schema/Schema.js";
import { NodeLLMCore } from "../llm.js";
import { Middleware } from "../types/Middleware.js";
/**
 * A value that can be a static T or a function that returns T based on inputs.
 */
export type LazyValue<T, I = Record<string, any>> = T | ((inputs: I) => T);
/**
 * Configuration options for Agent.
 */
export interface AgentConfig<I = Record<string, any>> {
    /** The model ID to use (e.g., "gpt-4o") */
    model?: string;
    /** The provider to use (e.g., "openai") */
    provider?: string;
    /** System instructions for the agent (can be lazy) */
    instructions?: LazyValue<string, I>;
    /** Tools available to the agent (can be lazy) */
    tools?: LazyValue<ToolResolvable[], I>;
    /** Temperature for response generation (0.0 - 1.0) */
    temperature?: number;
    /** Extended thinking configuration */
    thinking?: ThinkingConfig;
    /** Output schema for structured responses */
    schema?: z.ZodType | Schema | Record<string, unknown>;
    /** Provider-specific parameters */
    params?: Record<string, unknown>;
    /** Custom headers for requests */
    headers?: Record<string, string>;
    /** Maximum tokens in response */
    maxTokens?: number;
    /** Maximum tool call iterations */
    maxToolCalls?: number;
    /** Assume model exists without validation */
    assumeModelExists?: boolean;
    /** Optional LLM instance to use instead of global NodeLLM */
    llm?: NodeLLMCore;
    /** Optional initial inputs to resolve lazy config immediately */
    inputs?: I;
    /** Middlewares for the agent's chat instance */
    middlewares?: Middleware[];
}
/**
 * Base class for creating reusable, class-configured agents.
 */
export declare abstract class Agent<I extends Record<string, any> = Record<string, any>, S extends Record<string, unknown> = Record<string, unknown>> {
    static model?: string;
    static provider?: string;
    static instructions?: LazyValue<string, Record<string, any>>;
    static tools?: LazyValue<ToolResolvable[], Record<string, any>>;
    static temperature?: number;
    static thinking?: ThinkingConfig;
    static schema?: z.ZodType | Schema | Record<string, unknown>;
    static params?: Record<string, unknown>;
    static headers?: Record<string, string>;
    static maxTokens?: number;
    static maxToolCalls?: number;
    static assumeModelExists?: boolean;
    static middlewares?: Middleware[];
    /**
     * Explicitly declare which inputs this agent expects.
     * Useful for introspection and validation.
     */
    static inputs?: string[];
    /**
     * Hook called when the agent starts a new session (ask/stream).
     */
    static onStart(_context: {
        messages: unknown[];
    }): void | Promise<void>;
    static onThinking(_thinking: ThinkingResult, _result: ChatResponseString): void | Promise<void>;
    static onToolStart(_toolCall: unknown): void | Promise<void>;
    static onToolEnd(_toolCall: unknown, _result: unknown): void | Promise<void>;
    static onToolError(_toolCall: unknown, _error: Error): void | Promise<void>;
    static onComplete(_result: ChatResponseString): void | Promise<void>;
    /**
     * Run the agent immediately with a prompt.
     */
    static ask<I extends Record<string, any>, S extends Record<string, any>>(this: new (overrides?: Partial<AgentConfig<I> & ChatOptions>) => Agent<I, S>, message: string, options?: AskOptions & {
        inputs?: I;
    }): Promise<ChatResponseString>;
    /**
     * Stream the agent response immediately.
     */
    static stream<I extends Record<string, any>, S extends Record<string, any>>(this: new (overrides?: Partial<AgentConfig<I> & ChatOptions>) => Agent<I, S>, message: string, options?: AskOptions & {
        inputs?: I;
    }): import("../index.js").Stream<import("../providers/Provider.js").ChatChunk>;
    /** The underlying Chat instance */
    protected readonly chat: Chat<S>;
    /** Private reference to configuration overrides for lazy resolution */
    private readonly config;
    /**
     * Create a new agent instance.
     * @param overrides - Optional configuration to override static properties
     */
    constructor(overrides?: Partial<AgentConfig<I> & ChatOptions>);
    /**
     * Helper to resolve lazy instructions and tools based on inputs.
     */
    private resolveLazyConfig;
    /**
     * Add instructions to the agent (replaces or appends).
     */
    withInstructions(instructions: string, options?: {
        replace?: boolean;
    }): this;
    /**
     * Add tools to the agent.
     */
    withTools(tools: ToolResolvable[], options?: {
        replace?: boolean;
    }): this;
    /**
     * Alias for withTools([tool]).
     */
    use(tool: ToolResolvable): this;
    /**
     * Send a message to the agent and get a response.
     */
    ask(message: string, options?: AskOptions & {
        inputs?: I;
    }): Promise<ChatResponseString>;
    /**
     * Hook called when a tool call starts.
     */
    onToolCallStart(handler: (toolCall: unknown) => void | Promise<void>): this;
    /**
     * Hook called when a tool call ends.
     */
    onToolCallEnd(handler: (toolCall: unknown, result: unknown) => void | Promise<void>): this;
    /**
     * Hook called when a tool call errors.
     */
    onToolCallError(handler: (toolCall: unknown, error: Error) => "STOP" | "CONTINUE" | "RETRY" | void | Promise<"STOP" | "CONTINUE" | "RETRY" | void>): this;
    /**
     * Hook called before a request.
     */
    beforeRequest(handler: (messages: unknown[]) => Promise<unknown[] | void>): this;
    /**
     * Hook called after a response.
     */
    afterResponse(handler: (response: ChatResponseString) => Promise<ChatResponseString | void>): this;
    /**
     * Alias for ask()
     */
    say(message: string, options?: AskOptions & {
        inputs?: I;
    }): Promise<ChatResponseString>;
    /**
     * Stream a response from the agent.
     */
    stream(message: string, options?: AskOptions & {
        inputs?: I;
    }): import("../index.js").Stream<import("../providers/Provider.js").ChatChunk>;
    /**
     * Get the conversation history.
     */
    get history(): readonly import("../index.js").Message[];
    /**
     * Get the model ID being used.
     */
    get modelId(): string;
    /**
     * Get aggregate token usage across the conversation.
     */
    get totalUsage(): import("../providers/Provider.js").Usage;
    /**
     * Access the underlying Chat instance for advanced operations.
     */
    get underlyingChat(): Chat<S>;
}
/**
 * Helper function to define an agent inline without creating a class.
 */
export declare function defineAgent<I extends Record<string, any> = Record<string, any>, S extends Record<string, unknown> = Record<string, unknown>>(config: AgentConfig<I>): new (overrides?: Partial<AgentConfig<I> & ChatOptions>) => Agent<I, S>;
//# sourceMappingURL=Agent.d.ts.map