Skip to content

AssistantEvent

AssistantEvent = { state: AssistantState; type: "state"; } | { message: AssistantMessage; type: "message"; } | { messageId: string; part: AssistantPart; type: "part"; } | { placeholder?: string | null; replying?: boolean; status?: string | null; type: "patch"; }

Defined in: packages/schema/src/assistant/protocol.ts:160

What the event stream sends. state replaces everything and always comes first on a connection; message adds a message or replaces the one with its id; part adds a part to a message or replaces the one with its id; patch changes the top-level fields, null clearing one. A backend in place of the built-in one sends these; see Another backend.

{ state: AssistantState; type: "state"; }

state: AssistantState

The new state.

type: "state"

Replaces the whole state.


{ message: AssistantMessage; type: "message"; }

message: AssistantMessage

The message.

type: "message"

Adds or replaces a message.


{ messageId: string; part: AssistantPart; type: "part"; }

messageId: string

The id of the message the part belongs to.

part: AssistantPart

The part.

type: "part"

Adds or replaces a part of a message.


{ placeholder?: string | null; replying?: boolean; status?: string | null; type: "patch"; }

optional placeholder?: string | null

The new placeholder, or null to clear it.

optional replying?: boolean

The new replying, when it changes.

optional status?: string | null

The new status, or null to clear it.

type: "patch"

Changes the state’s top-level fields.