import { type RunState } from './run-state';
import { type ClientToolCall, type ClientToolName, type CodebuffToolOutput } from '@codebuff/common/tools/list';
import type { CustomToolDefinition } from './custom-tool';
import type { AgentDefinition } from '@codebuff/common/templates/initial-agents-dir/types/agent-definition';
import type { PublishedToolName } from '@codebuff/common/tools/constants';
import type { ToolResultPart } from '@codebuff/common/types/messages/content-part';
import type { PrintModeEvent } from '@codebuff/common/types/print-mode';
export type CodebuffClientOptions = {
    apiKey?: string;
    cwd?: string;
    onError: (error: {
        message: string;
    }) => void;
    overrideTools?: Partial<{
        [K in ClientToolName & PublishedToolName]: (input: ClientToolCall<K>['input']) => Promise<CodebuffToolOutput<K>>;
    } & {
        read_files: (input: {
            filePaths: string[];
        }) => Promise<Record<string, string | null>>;
    }>;
};
export declare class CodebuffClient {
    cwd: string;
    private readonly websocketHandler;
    private readonly overrideTools;
    private readonly fingerprintId;
    private readonly promptIdToHandlers;
    constructor({ apiKey, cwd, onError, overrideTools }: CodebuffClientOptions);
    closeConnection(): void;
    /**
     * Run a Codebuff agent with the specified options.
     *
     * @param agent - The agent to run. Use 'base' for the default agent, or specify a custom agent ID if you made your own agent config.
     * @param prompt - The user prompt describing what you want the agent to do.
     * @param params - (Optional) Additional parameters for the agent. Most agents don't use this, but some custom agents can take a JSON object as input in addition to the user prompt string.
     * @param handleEvent - (Optional) Callback function that receives every event during execution (assistant messages, tool calls, etc.). This allows you to stream the agent's progress in real-time. We will likely add a token-by-token streaming callback in the future.
     * @param previousRun - (Optional) JSON state returned from a previous run() call. Use this to continue a conversation or session with the agent, maintaining context from previous interactions.
     * @param projectFiles - (Optional) All the files in your project as a plain JavaScript object. Keys should be the full path from your current directory to each file, and values should be the string contents of the file. Example: { "src/index.ts": "console.log('hi')" }. This helps Codebuff pick good source files for context.
     * @param knowledgeFiles - (Optional) Knowledge files to inject into every run() call. Uses the same schema as projectFiles - keys are file paths and values are file contents. These files are added directly to the agent's context.
     * @param agentDefinitions - (Optional) Array of custom agent definitions. Each object should satisfy the AgentDefinition type. You can input the agent's id field into the agent parameter to run that agent.
     * @param customToolDefinitions - (Optional) Array of custom tool definitions that extend the agent's capabilities. Each tool definition includes a name, Zod schema for input validation, and a handler function. These tools can be called by the agent during execution.
     * @param maxAgentSteps - (Optional) Maximum number of steps the agent can take before stopping. Use this as a safety measure in case your agent starts going off the rails. A reasonable number is around 20.
     *
     * @returns A Promise that resolves to a RunState JSON object which you can pass to a subsequent run() call to continue the run. Use result.output to get the agent's output.
     */
    run<A extends string = string, B = any, C = any>({ agent, prompt, params, handleEvent, handleStreamChunk, previousRun, projectFiles, knowledgeFiles, agentDefinitions, customToolDefinitions, maxAgentSteps, extraToolResults, }: {
        agent: string;
        prompt: string;
        params?: Record<string, any>;
        handleEvent?: (event: PrintModeEvent) => void;
        handleStreamChunk?: (chunk: string) => void;
        previousRun?: RunState;
        projectFiles?: Record<string, string>;
        knowledgeFiles?: Record<string, string>;
        agentDefinitions?: AgentDefinition[];
        customToolDefinitions?: CustomToolDefinition<A, B, C>[];
        maxAgentSteps?: number;
        extraToolResults?: ToolResultPart[];
    }): Promise<RunState>;
    private handlePromptResponse;
    private readFiles;
    private handleToolCall;
}
//# sourceMappingURL=client.d.ts.map