ExperimentalNarrow to the user_message_chunk variant, validating its payload.
Narrow to the user_message variant, validating its payload.
Narrow to the agent_message_chunk variant, validating its payload.
Narrow to the agent_message variant, validating its payload.
Narrow to the agent_thought_chunk variant, validating its payload.
Narrow to the agent_thought variant, validating its payload.
Narrow to the state_update variant, validating its payload.
Narrow to the tool_call_content_chunk variant, validating its payload.
Narrow to the tool_call_update variant, validating its payload.
Narrow to the terminal_update variant, validating its payload.
Narrow to the terminal_output_chunk variant, validating its payload.
Narrow to the plan_update variant, validating its payload.
Narrow to the plan_removed variant, validating its payload.
Narrow to the available_commands_update variant, validating its payload.
Narrow to the config_option_update variant, validating its payload.
Narrow to the session_info_update variant, validating its payload.
Narrow to the usage_update variant, validating its payload.
Narrow to a custom or future variant: the sessionUpdate tag matches no known variant.
TypeScript keeps the known variants in the narrowed union (they are
structural subtypes of the catch-all), so read vendor payload keys
via a widening cast: (value as Record<string, unknown>).someKey.
Validated type guards for
SessionUpdate's known variants.Each guard validates the variant's payload, not just its discriminant tag: a malformed known variant (right tag, wrong payload) matches no guard — mirroring wire validation, which rejects such values instead of classifying them as custom.
Guards check the value as given: fields that wire deserialization salvages to a default (e.g. a malformed
_meta) are only normalized by parsing, and for ambiguous raw shapes (a known tag combined with another variant's payload) guards are conservative where wire parsing may still accept the value — narrow wire-parsed values when exact parity matters.