Skip to main content

AiChatEvent

Discriminated event emitted by the streaming methods of AIEngine. The engine never invokes user-supplied middleware or callbacks directly — every observable side-effect is encoded as a ChatEvent so the same stream can be replayed over SSE, WebSocket, or in-process. Pause point: tool-call-pending is the only stop. The UI must execute the tool itself (consulting autoAllow to decide between the silent path and the approve dialog) and resume via AIEngine.approveToolCall or AIEngine.denyToolCall. Other variants are pure data: - message-start / message-delta / message-end — assistant reply lifecycle. - message-incomplete — the provider returned an error or incomplete status. - thread-title — auto-generated title ready for a new thread.

NameTypeDescriptionNotes
typeStringEmitted once per sendWithStream call, immediately after the user message has been persisted by storage and before the assistant stream starts. Carries the storage-assigned id and createdAt. The UI uses it to render the user bubble — no client-side optimistic placeholder is needed, which keeps the runtime tree free of phantom nodes from index-fallback ids.[required] [example: message-delta] [enum: user-message-stored, message-start, message-delta, message-end, message-incomplete, tool-call-pending, thread-title]
messageAiThreadMessageLikeThe message the event is about, in the state it has reached.[optional]
messageIdStringThe storage identifier of that message.[optional] [example: 22222222-2222-2222-2222-222222222222]
idxBigDecimalThe zero-based position of the pending tool call within the message.[optional]
threadIdStringThe thread the event belongs to.[optional] [example: 11111111-1111-1111-1111-111111111111]
autoAllowBooleanThe consumer should execute the tool without prompting the user. Decided by the tool permission mode (resolveAutoAllow): under ask never; under auto a tool in the persisted always-allow list or one that opts in via TMCPItem.requireApproval === false (host tools default to this); under allow every tool. For a client-side tool with a server-side engine, this lets the engine return the pending call already flagged auto-allow so the client runs it and streams the result back without a dialog round-trip.[optional]
serverExecutedBooleanSet when the tool is served by a server-side system source: the consumer must NOT execute it locally — only show the approval UI (unless autoAllow) and resume via approveToolCall (no result needed) / denyToolCall. The engine runs it in-engine.[optional]
titleStringThe generated thread title.[optional]
profileIdStringThe profile that generated the title, when one was used.[optional]