import { DeepPartial } from "ai";
import type { JSONSchema7 } from "json-schema";
export type Result<T> = {
    ok: false;
    error: string | Error;
} | {
    ok: true;
    value: T;
};
/**
 * A StreamTool is a function that can be called by the LLM.
 * It's similar to a Tool in the Vercel AI SDK, but:
 *
 * - a collection of StreamTools can be wrapped in a single LLM Tool to issue multiple operations (tool calls) at once.
 * - StreamTools can be used in a streaming manner.
 */
export type StreamTool<T extends {
    type: string;
}> = {
    /**
     * The name of the tool
     */
    name: T["type"];
    /**
     * An optional description of the tool that can influence when the tool is picked.
     */
    description?: string;
    /**
     * The schema of the input that the tool expects. The language model will use this to generate the input.
     */
    inputSchema: JSONSchema7;
    /**
     * Validates the input of the tool call
     *
     * @param operation - The operation to validate.
     * This can be a partial object as the LLM may not have completed the operation yet.
     * The object is not guaranteed to be of type DeepPartial<T> as the LLM might not conform to the schema correctly - so this needs to be validated.
     */
    validate: (operation: DeepPartial<T>) => Result<T>;
    /**
     * Executes tool calls.
     *
     * Note that this operates on the full stream of operations (including other StreamTools calls).
     * This way, we can
     *
     * @returns the stream of operations that have not been processed (and should be passed on to execute handlers of other StreamTools)
     */
    executor: () => {
        execute: (chunk: {
            operation: StreamToolCall<StreamTool<{
                type: string;
            }>[]>;
            isUpdateToPreviousOperation: boolean;
            isPossiblyPartial: boolean;
            metadata: any;
        }, abortSignal?: AbortSignal) => Promise<boolean>;
    };
};
export type StreamToolCallSingle<T extends StreamTool<any>> = T extends StreamTool<infer U> ? U : never;
/**
 * A ToolCall represents an invocation of a StreamTool.
 *
 * Its type is the same as what a validated StreamTool returns
 */
export type StreamToolCall<T extends StreamTool<any> | readonly any[]> = T extends StreamTool<infer U> ? U : T extends readonly unknown[] ? {
    [K in keyof T]: T[K] extends StreamTool<infer V> ? V : never;
}[number] : never;
/**
 * Helper function to create a StreamTool.
 *
 * A StreamTool is a function that can be called by the LLM.
 * It's similar to a Tool in the Vercel AI SDK, but:
 *
 * - a collection of StreamTools can be wrapped in a single LLM Tool to issue multiple operations (tool calls) at once.
 * - StreamTools can be used in a streaming manner.
 */
export declare function streamTool<T extends {
    type: string;
}>(config: StreamTool<T>): StreamTool<T>;
