import { ChatChunk, ToolCall, ModerationResult, ThinkingResult } from "@node-llm/core"; export interface MockResponse { content?: string | null; tool_calls?: ToolCall[]; usage?: { input_tokens: number; output_tokens: number; total_tokens: number; }; error?: Error; finish_reason?: string | null; chunks?: string[] | ChatChunk[]; vectors?: number[][]; url?: string; data?: string; text?: string; results?: ModerationResult[]; revised_prompt?: string; id?: string; thinking?: ThinkingResult; reasoning?: string | null; metadata?: Record; } export type MockMatcher = (request: unknown) => boolean; export interface MockDefinition { method: string; match: MockMatcher; response: MockResponse | ((request: unknown) => MockResponse); } /** * Debug information about defined mocks. */ export interface MockerDebugInfo { totalMocks: number; methods: string[]; } export interface MockerOptions { /** * Enforce that every LLM call must have a corresponding mock. * If true, unmocked calls throw an error. */ strict?: boolean; } export interface MockCall { method: string; args: unknown[]; timestamp: number; /** * Convenience accessor for the primary input "prompt" of the call. * - chat/stream: `messages` * - embed/moderate: `input` * - paint: `prompt` * - transcribe: `file` */ prompt?: unknown; } export declare class Mocker { private mocks; private _history; strict: boolean; constructor(options?: MockerOptions); get history(): MockCall[]; getCalls(method?: string): MockCall[]; getLastCall(method?: string): MockCall | undefined; resetHistory(): void; chat(query?: string | RegExp): this; stream(chunks: string[] | ChatChunk[]): this; placeholder(query: string | RegExp): this; callsTool(name: string, args?: Record, content?: string | null): this; /** * Chain multiple tool calls in a single response. * Useful for testing agents that invoke multiple tools at once. * * @example * mocker.chat(/book flight/).callsTools([ * { name: "search_flights", args: { from: "NYC", to: "LAX" } }, * { name: "check_weather", args: { city: "LAX" } } * ]); */ callsTools(tools: Array<{ name: string; args?: Record; }>, content?: string | null): this; /** * Define a sequence of responses for multi-turn conversations. * Each call consumes the next response in the sequence. * * @example * mocker.chat(/help/).sequence([ * "What do you need help with?", * "I can help with that. Here's the answer...", * "Is there anything else?" * ]); */ sequence(responses: Array): this; /** * Limit how many times this mock can match. * After exhausted, falls through to next matching mock or strict mode error. * * @example * mocker.chat(/retry/).times(2).respond("Try again"); * mocker.chat(/retry/).respond("Giving up"); */ times(n: number): this; embed(input?: string | string[]): this; paint(prompt?: string | RegExp): this; transcribe(file?: string | RegExp): this; moderate(input?: string | string[] | RegExp): this; respond(response: string | MockResponse | ((req: unknown) => MockResponse)): this; /** * Immediately throw an error when this mock is executed. * Useful for chaos engineering (testing retries, failovers, rate-limit handling). * * @example * mocker.chat(/crash/).throws("429 Too Many Requests"); */ throws(error: Error | string): this; /** * Returns debug information about defined mocks. * Useful for troubleshooting what mocks are defined. */ getDebugInfo(): MockerDebugInfo; clear(): void; private addMock; private getContentString; private setupInterceptor; } export declare function mockLLM(options?: MockerOptions): Mocker; //# sourceMappingURL=Mocker.d.ts.map