/** * ChunkCapture - Utility for capturing and validating streaming chunks * * @example * ```typescript * const capture = new ChunkCapture(); * * await tool.useSelf({ * method: 'stream_data', * params: {}, * onChunk: capture.onChunk.bind(capture) * }); * * expect(capture.chunkCount).to.equal(5); * expect(capture.lastChunk).to.deep.equal({ done: true }); * ``` */ export declare class ChunkCapture { /** * All captured chunks in order */ allChunks: T[]; /** * Total number of chunks captured */ get chunkCount(): number; /** * Last chunk received (undefined if no chunks) */ get lastChunk(): T | undefined; /** * First chunk received (undefined if no chunks) */ get firstChunk(): T | undefined; /** * Callback to capture chunks * * @param chunk - Chunk data */ onChunk(chunk: T): void; /** * Clear all captured chunks */ clear(): void; /** * Wait for a specific number of chunks * * @param count - Expected chunk count * @param timeoutMs - Maximum wait time (default: 5000ms) * @returns Promise that resolves when count is reached * * @example * ```typescript * await capture.waitForChunks(10); * ``` */ waitForChunks(count: number, timeoutMs?: number): Promise; /** * Wait for chunks to stop arriving * * @param quietMs - Milliseconds of no new chunks (default: 500ms) * @param timeoutMs - Maximum wait time (default: 10000ms) * @returns Promise that resolves when streaming appears complete * * @example * ```typescript * await capture.waitForComplete(); * ``` */ waitForComplete(quietMs?: number, timeoutMs?: number): Promise; /** * Find chunks matching a predicate * * @param predicate - Filter function * @returns Array of matching chunks * * @example * ```typescript * const errors = capture.findChunks(chunk => chunk.type === 'error'); * ``` */ findChunks(predicate: (chunk: T) => boolean): T[]; /** * Check if any chunk matches a predicate * * @param predicate - Test function * @returns True if any chunk matches * * @example * ```typescript * const hasError = capture.hasChunk(chunk => chunk.error); * ``` */ hasChunk(predicate: (chunk: T) => boolean): boolean; /** * Get chunks as a string (useful for text streams) * * @param separator - String to join chunks (default: '') * @returns Concatenated string * * @example * ```typescript * const fullText = capture.asString(); * ``` */ asString(separator?: string): string; } //# sourceMappingURL=chunk-capture.d.ts.map