Documentation
¶
Index ¶
- type Binding
- type BindingConfig
- type Conn
- type CustomEvent
- type DialConfig
- type FunctionCall
- type Handler
- type Handshake
- type Message
- type Role
- type Run
- func (r *Run) CloseMessage()
- func (r *Run) Custom(name string, value any)
- func (r *Run) Fail(err error)
- func (r *Run) Finish(result map[string]any) error
- func (r *Run) Publish(event CustomEvent)
- func (r *Run) Reasoning(delta string)
- func (r *Run) Snapshot(messages []Message)
- func (r *Run) Start(threadID, runID string)
- func (r *Run) State(snapshot any)
- func (r *Run) Text(delta string)
- func (r *Run) ToolCall(id, name, args string)
- func (r *Run) ToolResult(toolCallID, content string)
- func (r *Run) UserMessage(content string)
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 CustomEvent ¶ added in v0.219.0
CustomEvent is one AG-UI CUSTOM event. Resumes marks a run that carries on after an interruption, which discards the failure the interruption left.
type DialConfig ¶ added in v0.219.0
DialConfig configures the dialing end. Kind is the client kind the hello declares.
type FunctionCall ¶ added in v0.219.0
type FunctionCall = aguitypes.FunctionCall
The messages of a MESSAGES_SNAPSHOT.
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 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 is written with exactly one Write, so a transport can map one Write to one frame.
func NewRun ¶ added in v0.219.0
NewRun builds the writer of one run over w. The methods that need no run, such as Custom and Snapshot, also work on a run that never starts.
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
Finish closes open framing and writes the run's one terminal event: RUN_FINISHED carrying result, RUN_FINISHED with outcome cancelled for a cancelled run, or RUN_ERROR for a failed one. It returns the failure.
func (*Run) Publish ¶ added in v0.219.0
func (r *Run) Publish(event CustomEvent)
Publish writes a CUSTOM event and lets it resume the run.
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) 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.
func (*Run) UserMessage ¶ added in v0.219.0
UserMessage writes a complete user message as its own text message, closing anything the assistant had open first.