/** * MockProvider - A test-friendly LLM provider for unit testing * * This provider allows you to define responses in advance, making it * perfect for testing agent behavior without making API calls. * * @example * ```typescript * const mock = new MockProvider(); * * // Simple text response * mock.addResponse('Hello, world!'); * * // Response with tool call * mock.addResponse({ * text: 'Let me read that file.', * toolCalls: [{ * id: 'call_1', * name: 'read_file', * input: { path: '/test.txt' }, * }], * }); * * const agent = new Agent({ provider: mock }); * ``` */ import type { LLMProvider, Message, ChatOptions, StreamChunk } from './types.js'; /** * A tool call in a mock response */ export interface MockToolCall { id: string; name: string; input: Record; } /** * A mock thinking block for extended thinking simulation */ export interface MockThinking { /** The thinking content */ thinking: string; /** Optional signature (for verification simulation) */ signature?: string; } /** * A mock response definition */ export interface MockResponse { /** Text content of the response */ text?: string; /** Tool calls to include in the response */ toolCalls?: MockToolCall[]; /** Extended thinking content (Claude-specific) */ thinking?: MockThinking; /** If set, throw this error instead of responding */ error?: Error; /** Delay in ms before responding (simulates network latency) */ delay?: number; } /** * Configuration for MockProvider */ export interface MockProviderConfig { /** Default delay for all responses (ms) */ defaultDelay?: number; /** Throw if no responses are queued */ throwOnEmpty?: boolean; } /** * MockProvider for testing agents without API calls. * * Responses are consumed in order (FIFO queue). */ export declare class MockProvider implements LLMProvider { readonly name = "mock"; private readonly responses; private readonly defaultDelay; private readonly throwOnEmpty; private callCount; private readonly callHistory; private mockModel; constructor(config?: MockProviderConfig); getModel(): string; setModel(modelId: string): void; /** * Add a response (text string or structured response with tool calls) */ addResponse(response: string | MockResponse): this; /** * Add multiple responses at once */ addResponses(responses: Array): this; /** * Queue an error to be thrown on the next call */ addError(error: Error): this; /** * Get number of times chat() was called */ getCallCount(): number; /** * Get the history of all calls made */ getCallHistory(): ReadonlyArray<{ messages: Message[]; options?: ChatOptions; }>; /** * Get the last call made */ getLastCall(): { messages: Message[]; options?: ChatOptions; } | undefined; /** * Clear all queued responses and call history */ reset(): this; /** * Check if there are any queued responses */ hasResponses(): boolean; /** * Stream chat response */ chat(messages: Message[], options?: ChatOptions): AsyncIterable; /** * Count tokens using tiktoken (cl100k_base encoding) */ countTokens(messages: Message[]): Promise; private sleep; } /** * Create a MockProvider with initial responses */ export declare function createMockProvider(responses?: Array, config?: MockProviderConfig): MockProvider;