AgentUserInteraction
class AgentUserInteraction
The Agent User Interaction (AG-UI) protocol's input side.
Methods
Create messages from a list of AG-UI messages.
Create a message from a single AG-UI message.
Create approval decisions from a RunAgentInput's resume entries.
Convert messages or conversation message models into state for hydrating an AG-UI client.
Convert conversation history into AG-UI messages.
Get the open interrupts held by stored conversation messages.
Get the interrupt that represents a pending tool approval.
Get the AG-UI tool message that represents a stored tool result.
Get the AG-UI content that represents a stored message's text and attachments.
Get the AG-UI content parts that represent a stored message's attachments.
Get the AG-UI tool calls that represent a stored message's tool calls.
Append a tool result message for the given buffered tool results.
Create a tool result from an AG-UI tool message, naming it from the tool call it settles.
Get the tool calls declared on an AG-UI assistant message.
Decode an AG-UI tool call's JSON encoded arguments.
Get the text held by AG-UI message content.
Get the attachments held by AG-UI message content.
Create a file instance from an AG-UI multimodal content part.
Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.
Details
at line 47
static Chat
chat(Request|array $input)
Create a chat instance from a RunAgentInput request or its array representation.
at line 58
static array
fromMessages(iterable $messages)
Create messages from a list of AG-UI messages.
at line 105
static Message
fromMessage(array $message)
Create a message from a single AG-UI message.
at line 122
static Decisions|null
decisionsFrom(iterable $resume)
Create approval decisions from a RunAgentInput's resume entries.
at line 154
static array
toClientState(iterable $messages)
Convert messages or conversation message models into state for hydrating an AG-UI client.
at line 170
static protected array
uiMessagesFrom(iterable $messages)
Convert conversation history into AG-UI messages.
at line 223
static array
toInterrupts(iterable $messages)
Get the open interrupts held by stored conversation messages.
at line 255
static array
interrupt(string $id, string|null $reason = null, string|null $tool = null, array $arguments = [])
Get the interrupt that represents a pending tool approval.
at line 281
static protected array
toolMessageFrom(array $toolResult, string|null $messageId = null)
Get the AG-UI tool message that represents a stored tool result.
at line 307
static protected string|array
hydratedContent(Message|ConversationMessage $message)
Get the AG-UI content that represents a stored message's text and attachments.
at line 326
static protected array
attachmentPartsFrom(Message|ConversationMessage $message)
Get the AG-UI content parts that represent a stored message's attachments.
at line 348
static protected array|null
contentPartFrom(File $file)
Get the AG-UI content part that represents the given file.
at line 382
static protected array
hydratedToolCalls(Message|ConversationMessage $message)
Get the AG-UI tool calls that represent a stored message's tool calls.
at line 410
static protected array
flushToolResults(array $messages, array $toolResults)
Append a tool result message for the given buffered tool results.
at line 423
static protected ToolResult|null
toolResultFrom(array $message, array $calls = [])
Create a tool result from an AG-UI tool message, naming it from the tool call it settles.
at line 451
static protected Collection
toolCallsFrom(array $message)
Get the tool calls declared on an AG-UI assistant message.
at line 469
static protected array
arguments(mixed $arguments)
Decode an AG-UI tool call's JSON encoded arguments.
at line 481
static protected string
textFrom(mixed $content)
Get the text held by AG-UI message content.
at line 498
static protected Collection
attachmentsFrom(mixed $content)
Get the attachments held by AG-UI message content.
at line 512
static protected File|null
fileFrom(array $part)
Create a file instance from an AG-UI multimodal content part.
at line 547
static protected string
json(mixed $value)
Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.