Documentation
¶
Overview ¶
Package agui implements the AG-UI protocol over Server-Sent Events without depending on a protocol SDK.
Index ¶
- func History(input RunAgentInput) ([]*schema.Message, string, error)
- type ContentPart
- type Emitter
- func (e *Emitter) Err() error
- func (e *Emitter) ReasoningContent(delta string)
- func (e *Emitter) ReasoningEnd()
- func (e *Emitter) ReasoningStart()
- func (e *Emitter) RunError(message string)
- func (e *Emitter) RunFinishedInterrupt(interrupts []Interrupt)
- func (e *Emitter) RunFinishedSuccess()
- func (e *Emitter) RunStarted()
- func (e *Emitter) StateSnapshot(snapshot map[string]any)
- func (e *Emitter) TextContent(delta string)
- func (e *Emitter) TextEnd()
- func (e *Emitter) TextStart() string
- func (e *Emitter) ToolResult(callID, content string)
- func (e *Emitter) ToolStart(callID, name, arguments, parentMessageID string)
- type FunctionCall
- type Interrupt
- type Message
- type Resume
- type RunAgentInput
- type Server
- type Tool
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContentPart ¶
type ContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
URL string `json:"url,omitempty"`
}
ContentPart is one part of a multi-part message.
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter writes AG-UI events as SSE frames. It tracks open text and reasoning messages so the server can close them before starting another block or finishing the run.
func NewEmitter ¶
func NewEmitter(w http.ResponseWriter, threadID, runID string, newID func(string) string, onError func()) (*Emitter, error)
NewEmitter starts an SSE response. onError is called once when the client connection can no longer be written to.
func (*Emitter) ReasoningContent ¶
ReasoningContent appends a reasoning delta.
func (*Emitter) ReasoningEnd ¶
func (e *Emitter) ReasoningEnd()
ReasoningEnd closes the reasoning block.
func (*Emitter) ReasoningStart ¶
func (e *Emitter) ReasoningStart()
ReasoningStart opens a reasoning block.
func (*Emitter) RunFinishedInterrupt ¶
RunFinishedInterrupt terminates this connection's stream while leaving the run parked for a later resume.
func (*Emitter) RunFinishedSuccess ¶
func (e *Emitter) RunFinishedSuccess()
RunFinishedSuccess terminates the run successfully.
func (*Emitter) RunStarted ¶
func (e *Emitter) RunStarted()
RunStarted announces a run on this connection.
func (*Emitter) StateSnapshot ¶
StateSnapshot publishes the current todo list as AG-UI state.
func (*Emitter) TextContent ¶
TextContent appends a text delta.
func (*Emitter) ToolResult ¶
ToolResult reports the result of a tool call.
type FunctionCall ¶
FunctionCall is the function name and JSON-encoded arguments.
type Interrupt ¶
type Interrupt struct {
ID string `json:"id"`
Reason string `json:"reason"`
Message string `json:"message,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ResponseSchema map[string]any `json:"responseSchema,omitempty"`
ExpiresAt string `json:"expiresAt,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Interrupt asks the client for input before the run can continue.
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Role string `json:"role"`
Content json.RawMessage `json:"content,omitempty"`
Name string `json:"name,omitempty"`
ToolCalls []ToolCall `json:"toolCalls,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
}
Message is one AG-UI chat message. Content is a string or a list of parts.
type Resume ¶
type Resume struct {
InterruptID string `json:"interruptId"`
Status string `json:"status"`
Payload json.RawMessage `json:"payload,omitempty"`
}
Resume answers one interrupt.
type RunAgentInput ¶
type RunAgentInput struct {
ThreadID string `json:"threadId"`
RunID string `json:"runId"`
Messages []Message `json:"messages"`
Tools []Tool `json:"tools,omitempty"`
Context json.RawMessage `json:"context,omitempty"`
State json.RawMessage `json:"state,omitempty"`
ForwardedProps map[string]any `json:"forwardedProps,omitempty"`
Resume []Resume `json:"resume,omitempty"`
}
RunAgentInput is the body of a POST /agui request.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves an AG-UI endpoint backed by the shared runtime.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters json.RawMessage `json:"parameters,omitempty"`
}
Tool describes a client-side tool. Oni3 uses its configured tools, so the list is accepted for compatibility and not registered with the model.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type,omitempty"`
Function FunctionCall `json:"function"`
}
ToolCall is an OpenAI-compatible assistant tool call.