Documentation
¶
Index ¶
- Constants
- func TokenCount(count int64) *int64
- func WriteCustom(w io.Writer, name string, value any)
- func WriteMessagesSnapshot(w io.Writer, messages []Message)
- func WriteRunError(w io.Writer, message string)
- type Binding
- type BindingConfig
- type Conn
- type DialConfig
- type FunctionCall
- type Handler
- type Handshake
- type InputContent
- type Interrupt
- type Message
- type Published
- type ResumeEntry
- type ResumeStatus
- type Role
- type Run
- func (r *Run) Activity(messageID, activityType string, content any)
- func (r *Run) CloseMessage()
- func (r *Run) Fail(err error)
- func (r *Run) Finish(result map[string]any, usage []TokenUsage) error
- func (r *Run) Message(role Role, content string)
- func (r *Run) PatchState(key string, value any)
- func (r *Run) Reasoning(delta string)
- func (r *Run) Snapshot(messages []Message)
- func (r *Run) Start(threadID, runID string)
- func (r *Run) State() map[string]any
- func (r *Run) Suspend(interrupts []Interrupt)
- func (r *Run) Text(delta string)
- func (r *Run) ToolCall(id, name, args string)
- func (r *Run) ToolResult(toolCallID, content string)
- type RunAgentInput
- type TokenUsage
- type ToolCall
Constants ¶
const ( InputContentTypeText = aguitypes.InputContentTypeText InputContentTypeImage = aguitypes.InputContentTypeImage )
The content part types of a run input message.
const ( ResumeStatusResolved = aguitypes.ResumeStatusResolved ResumeStatusCancelled = aguitypes.ResumeStatusCancelled )
The statuses a resume entry answers an interrupt with.
const ( InterruptToolCall = "tool_call" InterruptInputRequired = "input_required" )
The interrupt reasons this CLI raises. AG-UI leaves reason open ended.
const ( StateTodos = "todos" StateUsage = "usage" StateBackgroundTasks = "backgroundTasks" StateScreenRecording = "screenRecording" )
The state keys a run publishes. The state is one object: Start seeds every key, so a STATE_SNAPSHOT always carries all of them, and a change patches one key through STATE_DELTA instead of replacing the others.
const OutcomeCancelled = aguievents.RunFinishedOutcomeType("cancelled")
OutcomeCancelled is the cancelled variant of the 1.0 outcome set: a run its caller stopped before it completed, with nothing waited for. The Go SDK names success and interrupt; this names the third variant the spec defines.
Variables ¶
This section is empty.
Functions ¶
func TokenCount ¶ added in v0.221.0
TokenCount returns a pointer to a count, for populating a TokenUsage.
func WriteCustom ¶ added in v0.221.0
WriteCustom writes one CUSTOM event outside any run - the extension point for what the protocol has no event for, today the approval prompt of a panel-initiated tool request. Run-scoped events never take this path.
func WriteMessagesSnapshot ¶ added in v0.221.0
WriteMessagesSnapshot writes one MESSAGES_SNAPSHOT outside any run: the conversation-wide answer to a panel's new_session or resume_conversation, which arrives between runs. A run's own restore goes through Run.Snapshot.
func WriteRunError ¶ added in v0.221.0
WriteRunError writes one RUN_ERROR for a failure outside any run: a refused frame or a process failure before the run starts. No run exists to carry a run id, so the event carries none.
Types ¶
type Binding ¶ added in v0.219.0
type Binding struct {
// contains filtered or unexported fields
}
Binding hosts the localhost AG-UI WebSocket binding. It owns the listener, the Origin check, the token handshake and the connections, and hands every frame to its Handler.
func NewBinding ¶ added in v0.219.0
func NewBinding(cfg BindingConfig, handler Handler) *Binding
NewBinding builds the binding over its handler.
func (*Binding) Addr ¶ added in v0.219.0
Addr returns the actual listen address (useful with port 0 in tests).
type BindingConfig ¶ added in v0.219.0
type BindingConfig struct {
Port int
Token string
Handshake Handshake
AllowOrigin func(origin string) bool
Routes map[string]http.Handler
}
BindingConfig configures the listening end. AllowOrigin decides over requests that carry an Origin header, and without it only requests without one pass. Routes registers optional non-WebSocket HTTP handlers, e.g. static files, which serve under the same loopback listener as /ws.
type Conn ¶ added in v0.219.0
type Conn struct {
// contains filtered or unexported fields
}
Conn is one authenticated connection, on either end of the binding.
func Dial ¶ added in v0.219.0
Dial connects to a binding, performs the handshake and hands every frame the binding sends to handler until the connection dies.
func (*Conn) Close ¶ added in v0.219.0
func (c *Conn) Close()
Close closes the connection. Its read loop then ends and detaches it.
func (*Conn) Deliver ¶ added in v0.219.0
Deliver queues one frame for the connection's writer, so a stalled peer never holds back the others. An overflow closes the connection, since it means the peer stopped reading its socket. A closed connection drops the frame.
func (*Conn) HelloAttr ¶ added in v0.219.0
HelloAttr is one other field the hello declared, empty when the hello omitted it.
type DialConfig ¶ added in v0.219.0
type DialConfig struct {
Addr string
Token string
Kind string
HelloAttrs map[string]string
Handshake Handshake
}
DialConfig configures the dialing end. Kind is the client kind the hello declares, and HelloAttrs the other fields it declares, e.g. a version the host reports on.
type FunctionCall ¶ added in v0.219.0
type FunctionCall = aguitypes.FunctionCall
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Handler ¶ added in v0.219.0
Handler receives what happens on a binding's connections. Attach runs once a connection authenticated and before its first frame, Handle once per frame, and Detach after the connection died.
type Handshake ¶ added in v0.219.0
Handshake names the first frame a client sends and the frame that acks it.
type InputContent ¶ added in v0.221.0
type InputContent = aguitypes.InputContent
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Interrupt ¶ added in v0.221.0
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Message ¶ added in v0.219.0
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Published ¶ added in v0.221.0
type Published struct {
StateKey string
StateValue any
ActivityType string
MessageID string
Content any
}
Published is what an owning context renders into the run for one of its own chat events: a key patch of the run's state object or an ACTIVITY_SNAPSHOT entry. An event that deserves neither reports false on the publish seam and the run drops it.
type ResumeEntry ¶ added in v0.221.0
type ResumeEntry = aguitypes.ResumeEntry
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type ResumeStatus ¶ added in v0.221.0
type ResumeStatus = aguitypes.ResumeStatus
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Role ¶ added in v0.219.0
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type Run ¶ added in v0.219.0
type Run struct {
// contains filtered or unexported fields
}
Run writes one AG-UI run as newline-delimited events: RUN_STARTED at Start, the events its methods name, and exactly one terminal RUN_FINISHED or RUN_ERROR at Finish. Every event lands within the run, one Write per event, so a transport can map one Write to one frame.
func NewContinuationRun ¶ added in v0.221.0
NewContinuationRun builds the writer of a run that continues a suspended one: its STATE_SNAPSHOT seeds the state the suspended run left.
func (*Run) Activity ¶ added in v0.221.0
Activity writes ACTIVITY_SNAPSHOT, the progress or notice of one item of work a client keeps as its own entry: a local agent starting up or a judge verdict. messageId carries the stable identity that replaces the entry.
func (*Run) CloseMessage ¶ added in v0.219.0
func (r *Run) CloseMessage()
CloseMessage ends any open text or reasoning framing, so the next delta starts a fresh message. Safe to call when nothing is open.
func (*Run) Fail ¶ added in v0.219.0
Fail records the failure the run ends with. A later failure replaces it.
func (*Run) Finish ¶ added in v0.219.0
func (r *Run) Finish(result map[string]any, usage []TokenUsage) error
Finish writes the run's one terminal event and returns the failure: a cancelled run ends with outcome cancelled, a failed one with RUN_ERROR, both carrying usage, and a clean run with outcome success carrying the result. Suspend already wrote the terminal, so an interrupted run writes nothing here. A run that failed before it started writes only a RUN_ERROR.
func (*Run) Message ¶ added in v0.221.0
Message writes a complete message with the role it has in the conversation: a note the agent queued or a user message rendered over the run.
func (*Run) PatchState ¶ added in v0.221.0
PatchState updates one key of the run's state object and writes STATE_DELTA patching exactly that key, so state changes never replace the siblings.
func (*Run) Reasoning ¶ added in v0.219.0
Reasoning writes a reasoning delta, opening the turn's reasoning message on the first one. Reasoning precedes text within one assistant message, so reasoning arriving while text is open closes the previous message first.
func (*Run) Start ¶ added in v0.219.0
Start writes RUN_STARTED and seeds the run's state object, so the first STATE_SNAPSHOT of every run carries all state keys.
func (*Run) State ¶ added in v0.219.0
State returns the run's one state object, live, or nil before Start.
func (*Run) Suspend ¶ added in v0.221.0
Suspend ends the run the AG-UI interrupt way: one terminal RUN_FINISHED whose outcome carries the interrupts the run is waiting on. The caller answers with resume entries on the next run, which continues where this one left off.
func (*Run) Text ¶ added in v0.219.0
Text writes a text delta, opening the turn's assistant message on the first one. It closes an open reasoning block, which precedes text.
func (*Run) ToolCall ¶ added in v0.219.0
ToolCall writes one complete tool call: its start, its arguments when it has any, and its end.
func (*Run) ToolResult ¶ added in v0.219.0
ToolResult writes the result of the tool call toolCallID.
type RunAgentInput ¶ added in v0.221.0
type RunAgentInput = aguitypes.RunAgentInput
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.
type TokenUsage ¶ added in v0.221.0
type TokenUsage = aguievents.TokenUsage
The messages of a MESSAGES_SNAPSHOT and the run input and interrupt types a caller bridges between the CLI and the wire.