• Utility function to extract text-only deltas from an event stream.

    This is a convenience helper for simple use cases where you only need the streaming text output without full Event objects. For more complex use cases requiring tool calls, metadata, or usage tracking, use the full Event stream from runAsync() directly.

    Parameters

    • events: AsyncIterable<Event, any, any>

      AsyncIterable of Event objects from runner.runAsync()

    Returns AsyncGenerator<string, void, unknown>

    AsyncGenerator yielding only text deltas as strings

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

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

    // Simple text-only streaming
    for await (const text of textStreamFrom(events)) {
    process.stdout.write(text);
    }