• Utility function to collect the complete text from an event stream.

    This helper accumulates all text deltas and returns the final complete text once streaming is finished. Useful when you want streaming behavior but need the full text at the end.

    Parameters

    • events: AsyncIterable<Event, any, any>

      AsyncIterable of Event objects from runner.runAsync()

    Returns Promise<string>

    Promise resolving to the complete text

    import { collectTextFrom } from '@iqai/adk/utils';

    const events = runner.runAsync({
    userId: 'user-123',
    sessionId: 'session-456',
    newMessage: { role: 'user', parts: [{ text: 'Hello' }] }
    });

    const fullText = await collectTextFrom(events);
    console.log(fullText); // Complete response text