Package-level declarations

Types

Link copied to clipboard
@Serializable
data class ApprovalAnswers(val reason: Boolean = true, val editInput: Boolean = true)

What a backend's approval can carry back besides approve / deny: a reason (AI SDK approval.reason, AG-UI resume reason) and editInput, arguments the user changed (AG-UI editedArgs, the on-device loop). The UI offers only these.

Link copied to clipboard

Chat lifecycle, mirroring the AI SDK useChat().status.

Link copied to clipboard
@Serializable
@SerialName(value = "data")
data class DataPart(val id: String, val name: String, val data: JsonElement) : Part

Structured, app-defined data streamed by the agent — the AI SDK data-* parts (e.g. data-plan, data-task). A later part with the same id replaces the earlier one, so agents can update it live.

Link copied to clipboard
@Serializable
@SerialName(value = "file")
data class FilePart(val id: String, val mediaType: String, val url: String, val filename: String? = null) : Part

A file: a user attachment or a model-generated file. url is an https: URL or a data: URL (base64), as in the AI SDK FileUIPart.

Link copied to clipboard
@Serializable
data class Message(val id: String, val role: Role, val parts: List<Part> = emptyList(), val createdAt: Long = 0, val usage: Usage? = null, val alternatives: List<Message> = emptyList(), val metadata: JsonObject? = null)

A chat message: an ordered list of Parts, the same shape as the AI SDK UIMessage. Assistant messages usually interleave reasoning, tool calls and text across several agent steps.

Link copied to clipboard
@Serializable
sealed interface Part

One piece of a Message: text, reasoning, a tool call, a file, a source or custom data.

Link copied to clipboard
@Serializable
@SerialName(value = "reasoning")
data class ReasoningPart(val id: String, val text: String, val isStreaming: Boolean = false, val startedAt: Long = 0, val durationMs: Long? = null) : Part

The model's reasoning; durationMs is how long it thought, once finished.

Link copied to clipboard
@Serializable
enum Role : Enum<Role>

Who produced a Message. Mirrors the AI SDK UIMessage.role.

Link copied to clipboard
@Serializable
@SerialName(value = "source")
data class SourcePart(val id: String, val url: String, val title: String = url) : Part

A cited source (URL and title), shown by the UI Sources element and inline citations.

Link copied to clipboard
data class Suggestion(val text: String, val label: String = text)

A prompt suggestion chip.

Link copied to clipboard

Output written for a terminal, as a terminal shows it: the control functions of ECMA-48 (ISO/IEC 6429, "ANSI escape codes") in the subset xterm-compatible programs use for their output, applied to a screen of lines with a cursor.

Link copied to clipboard
@Serializable
@SerialName(value = "text")
data class TextPart(val id: String, val text: String, val isStreaming: Boolean = false) : Part

Answer text (Markdown); isStreaming while tokens are still arriving.

Link copied to clipboard
@Serializable
enum ToolCategory : Enum<ToolCategory>

What a tool call does, in the vocabulary of the Agent Client Protocol's ToolKind (read, edit, delete, move, search, execute, think, fetch, switch_mode, other), which Pydantic AI Harness also uses for its file-system and shell tools. Elements pick a step's view from it: a terminal for EXECUTE, a diff for EDIT, a browser frame for FETCH.

Link copied to clipboard
@Serializable
sealed interface ToolKind

The protocol-independent meaning of a tool call. Backends map their protocol onto it (an on-device tool declares it, AG-UI SUBAGENT_* runs and the Pydantic AI Harness tool conventions are translated in core), so UI elements only ever look at this.

Link copied to clipboard
@Serializable
@SerialName(value = "tool")
data class ToolPart(val id: String, val name: String, val state: ToolState = ToolState.INPUT_STREAMING, val input: String = "", val output: String? = null, val errorText: String? = null, val title: String? = null, val preliminary: Boolean = false, val subagent: Message? = null, val kind: ToolKind = ToolKind.Function, val source: String? = null, val category: ToolCategory? = null, val location: String? = null, val approvalAnswers: ApprovalAnswers = ApprovalAnswers.All) : Part

One tool invocation. id is the tool call id; input is the raw JSON arguments and output the tool result as text.

Link copied to clipboard
@Serializable
enum ToolState : Enum<ToolState>

Life cycle of a tool call: input streaming → available → (approval) → output / error / denied.

Link copied to clipboard
@Serializable
data class Usage(val inputTokens: Int = 0, val outputTokens: Int = 0)

Token usage of one assistant turn (summed across agent steps).