/** * Test message model provider for simplified agent testing. * This module provides a content-focused test model that generates appropriate * ModelStreamEvents from ContentBlock objects, eliminating the need to manually * construct events in tests. */ import { Model } from '../models/model.js'; import type { Message, StopReason } from '../types/messages.js'; import type { ModelStreamEvent, Usage } from '../models/streaming.js'; import type { BaseModelConfig, StreamOptions } from '../models/model.js'; import type { PlainContentBlock } from './slim-types.js'; /** * Input type for addTurn - accepts plain objects or class instances. */ type ContentBlockInput = PlainContentBlock | PlainContentBlock[] | Error; /** * Test model provider that operates at the content block level. * Simplifies agent loop tests by allowing specification of content blocks * instead of manually yielding individual ModelStreamEvents. */ export declare class MockMessageModel extends Model { private _turns; private _currentTurnIndex; private _config; /** * Creates a new MockMessageModel. */ constructor(); /** * The number of turns that have been invoked thus far. */ get callCount(): number; /** * Adds a turn to the test sequence. * Returns this for method chaining. * * @param turn - ContentBlock, ContentBlock[], or Error to add * @param options - Optional stop reason and token usage * @returns This provider for chaining * * @example * ```typescript * provider * .addTurn({ type: 'textBlock', text: 'Hello' }) // Single block * .addTurn([{ type: 'toolUseBlock', ... }]) // Array of blocks * .addTurn({ type: 'textBlock', text: 'Done' }, { stopReason: 'maxTokens' }) // Explicit stopReason * .addTurn({ type: 'textBlock', text: 'Hi' }, { usage: { inputTokens: 10, outputTokens: 5, totalTokens: 15 } }) * .addTurn(new Error('Failed')) // Error turn * ``` */ addTurn(turn: ContentBlockInput, options?: { stopReason?: StopReason; usage?: Usage; }): this; /** * Updates the model configuration. * * @param modelConfig - Configuration to merge with existing config */ updateConfig(modelConfig: BaseModelConfig): void; /** * Retrieves the current model configuration. * * @returns Current configuration object */ getConfig(): BaseModelConfig; /** * Streams a conversation with the model. * Generates appropriate ModelStreamEvents from the content blocks. * * Single-turn behavior: Reuses the same turn indefinitely * Multi-turn behavior: Advances through turns and throws when exhausted * * @param _messages - Conversation messages (ignored by test provider) * @param _options - Streaming options (ignored by test provider) * @returns Async iterable of ModelStreamEvents */ stream(_messages: Message[], _options?: StreamOptions): AsyncGenerator; /** * Generates appropriate ModelStreamEvents for content blocks. * All messages have role 'assistant' since this is for testing model responses. */ private _generateEventsForContent; /** * Creates a Turn object from ContentBlock(s) or Error. */ private _createTurn; /** * Auto-derives stopReason from content blocks. * Returns 'toolUse' if content contains any ToolUseBlock, otherwise 'endTurn'. */ private _deriveStopReason; /** * Generates appropriate ModelStreamEvents for a message. */ private _generateEventsForMessage; /** * Generates appropriate ModelStreamEvents for a content block. */ private _generateEventsForBlock; } export {}; //# sourceMappingURL=mock-message-model.d.ts.map