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.
| Name | Type | Description | Notes |
|---|---|---|---|
| type | String | Emitted 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] |
| message | AiThreadMessageLike | The message the event is about, in the state it has reached. | [optional] |
| messageId | String | The storage identifier of that message. | [optional] [example: 22222222-2222-2222-2222-222222222222] |
| idx | BigDecimal | The zero-based position of the pending tool call within the message. | [optional] |
| threadId | String | The thread the event belongs to. | [optional] [example: 11111111-1111-1111-1111-111111111111] |
| autoAllow | Boolean | The 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] |
| serverExecuted | Boolean | Set 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] |
| title | String | The generated thread title. | [optional] |
| profileId | String | The profile that generated the title, when one was used. | [optional] |