A11 TypeScript API - v0.7.0
    Preparing search index...

    Class PresentationReducer

    Accumulates one turn's blocks, fed live or from storage.

    The live feeder calls onText/onThought as deltas arrive and onInteraction as whole interactions land on new_interactions; a replay feeder calls only onInteraction.

    const reducer = new PresentationReducer({
    onBlockAppended: (_block, delta) => output.append(delta),
    });
    reducer.onText('The first');
    reducer.onText(' result');
    reducer.endTurn();
    Index
    • Fold in a whole interaction, live or replayed.

      Text already streamed as deltas is not added again: on the live path the same prose arrives twice, once on text_output and once inside the interaction that lands on new_interactions.

      Parameters

      • interaction: {
            action_calls: ActionMessage[];
            action_configs: Record<
                string,
                {
                    header_autofills: Record<string, Uint8Array<ArrayBufferLike>>;
                    peer:
                        | string
                        | {
                            endpoint: string;
                            identity: string;
                            protocol: "a11"
                            | "mcp";
                            scheme: "session" | "rtc" | "http" | "https" | "ws" | "wss";
                        };
                },
            >;
            action_inputs: Record<string, NodeFragment[]>;
            action_outputs: Record<string, NodeFragment[]>;
            backend_specific_metadata: Record<string, Uint8Array<ArrayBufferLike>>;
            content: Chunk[];
            created_at_millis?: number | null;
            id: string;
            model: string;
            previous_interaction_id: string;
            role: "user" | "system" | "model";
            status?: Status;
            system_instructions: Chunk[];
            usage_metadata?:
                | {
                    cache_write_tokens?: number
                    | null;
                    cached_input_tokens?: number | null;
                    input_tokens?: number | null;
                    output_tokens?: number | null;
                    reasoning_tokens?: number | null;
                    total_tokens?: number | null;
                    [key: string]: unknown;
                }
                | null;
            [key: string]: unknown;
        }

      Returns Promise<Status>