events

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCustomEvent

type AgentCustomEvent struct {
	*BaseEvent
	Name  string `json:"name"`
	Value any    `json:"value,omitempty"`
}

CUSTOM

func NewAgentCustomEvent

func NewAgentCustomEvent(name string, value any) *AgentCustomEvent

func (*AgentCustomEvent) ToJSON

func (e *AgentCustomEvent) ToJSON() ([]byte, error)

type AgentCustomEventApprovalValue

type AgentCustomEventApprovalValue struct {
	AgentName       string         `json:"agentName,omitempty"`
	ToolCallID      string         `json:"toolCallId,omitempty"`
	ToolName        string         `json:"toolName"`
	ToolDisplayName string         `json:"toolDisplayName,omitempty"`
	Args            map[string]any `json:"args,omitempty"`
	ApprovalToken   string         `json:"approvalToken,omitempty"`
}

AgentCustomEventApprovalValue is the JSON shape for CUSTOM name=approval (tool or delegation; use Kind).

func NewAgentCustomEventApprovalValue

func NewAgentCustomEventApprovalValue(toolName, approvalToken string) *AgentCustomEventApprovalValue

func ParseCustomEventApproval

func ParseCustomEventApproval(ev *AgentCustomEvent) (AgentCustomEventApprovalValue, error)

ParseCustomEventApproval returns the typed value field for CUSTOM events with name "approval" (after EventFromJSON or bus decode, Value is often map[string]any).

func (*AgentCustomEventApprovalValue) ToJSON

func (v *AgentCustomEventApprovalValue) ToJSON() ([]byte, error)

type AgentCustomEventDelegationValue

type AgentCustomEventDelegationValue struct {
	AgentName     string         `json:"agentName,omitempty"`
	SubAgentName  string         `json:"subAgentName,omitempty"`
	Args          map[string]any `json:"args,omitempty"`
	ApprovalToken string         `json:"approvalToken,omitempty"`
}

AgentCustomEventDelegationValue is the JSON shape for CUSTOM name=delegation (subset when using a dedicated name).

func NewAgentCustomEventDelegationValue

func NewAgentCustomEventDelegationValue(subAgentName, approvalToken string) *AgentCustomEventDelegationValue

func ParseCustomEventDelegation

func ParseCustomEventDelegation(ev *AgentCustomEvent) (AgentCustomEventDelegationValue, error)

ParseCustomEventDelegation returns the typed value field for CUSTOM events with name "delegation".

func (*AgentCustomEventDelegationValue) ToJSON

func (v *AgentCustomEventDelegationValue) ToJSON() ([]byte, error)

type AgentCustomEventName

type AgentCustomEventName string

AgentCustomEventName is the CUSTOM event name discriminator (value is JSON-specific).

const (
	AgentCustomEventNameToolApproval       AgentCustomEventName = "tool_approval"
	AgentCustomEventNameSubAgentDelegation AgentCustomEventName = "sub_agent_delegation"
)

type AgentEvent

type AgentEvent interface {
	Type() AgentEventType    // for Go switch
	Timestamp() *int64       // for ordering
	ToJSON() ([]byte, error) // for cross-language transport
}

AgentEvent is the interface for all agent events.

func EventFromJSON

func EventFromJSON(data []byte) (AgentEvent, error)

type AgentEventType

type AgentEventType string

AgentEventType is the AG-UI protocol discriminator used on the wire.

const (
	// Lifecycle (supported now)
	// --- AG-UI lifecycle events ---
	AgentEventTypeRunStarted   AgentEventType = "RUN_STARTED"
	AgentEventTypeRunFinished  AgentEventType = "RUN_FINISHED"
	AgentEventTypeRunError     AgentEventType = "RUN_ERROR"
	AgentEventTypeStepStarted  AgentEventType = "STEP_STARTED"
	AgentEventTypeStepFinished AgentEventType = "STEP_FINISHED"

	// Text messages (supported now)
	// --- AG-UI text events ---
	AgentEventTypeTextMessageStart   AgentEventType = "TEXT_MESSAGE_START"
	AgentEventTypeTextMessageContent AgentEventType = "TEXT_MESSAGE_CONTENT"
	AgentEventTypeTextMessageEnd     AgentEventType = "TEXT_MESSAGE_END"

	// Tool calls (supported now)
	// --- AG-UI tool events ---
	AgentEventTypeToolCallStart  AgentEventType = "TOOL_CALL_START"
	AgentEventTypeToolCallArgs   AgentEventType = "TOOL_CALL_ARGS"
	AgentEventTypeToolCallEnd    AgentEventType = "TOOL_CALL_END"
	AgentEventTypeToolCallResult AgentEventType = "TOOL_CALL_RESULT"

	// Reasoning
	// --- AG-UI reasoning events ---
	AgentEventTypeReasoningStart          AgentEventType = "REASONING_START"
	AgentEventTypeReasoningMessageStart   AgentEventType = "REASONING_MESSAGE_START"
	AgentEventTypeReasoningMessageContent AgentEventType = "REASONING_MESSAGE_CONTENT"
	AgentEventTypeReasoningMessageEnd     AgentEventType = "REASONING_MESSAGE_END"
	//AgentEventTypeReasoningMessageChunk   AgentEventType = "REASONING_MESSAGE_CHUNK"   // reserved for later
	AgentEventTypeReasoningEnd AgentEventType = "REASONING_END" // reserved for later

	// Raw & custom events
	// --- AG-UI custom events ---
	AgentEventTypeRaw    AgentEventType = "RAW"
	AgentEventTypeCustom AgentEventType = "CUSTOM"
)

AgentEventType values are the AG-UI protocol discriminator used on the wire. Ref: https://docs.ag-ui.com/sdk/js/core/events#events

const AgentEventAll AgentEventType = "*"

AgentEventAll is the EventTypes filter sentinel meaning emit every event kind (JSON "*"). Internal use only.

func EventTypeFromJSON

func EventTypeFromJSON(data []byte) (AgentEventType, error)

type AgentRawEvent

type AgentRawEvent struct {
	*BaseEvent
	Event  any    `json:"event"`
	Source string `json:"source,omitempty"`
}

RAW

func NewAgentRawEvent

func NewAgentRawEvent(event any, source ...string) *AgentRawEvent

func (*AgentRawEvent) ToJSON

func (e *AgentRawEvent) ToJSON() ([]byte, error)

type AgentReasoningEndEvent

type AgentReasoningEndEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
}

REASONING_END

func NewAgentReasoningEndEvent

func NewAgentReasoningEndEvent(messageID string) *AgentReasoningEndEvent

func (*AgentReasoningEndEvent) ToJSON

func (e *AgentReasoningEndEvent) ToJSON() ([]byte, error)

type AgentReasoningMessageContentEvent

type AgentReasoningMessageContentEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
	Delta     string `json:"delta"`
}

REASONING_MESSAGE_CONTENT

func NewAgentReasoningMessageContentEvent

func NewAgentReasoningMessageContentEvent(messageID, delta string) *AgentReasoningMessageContentEvent

func (*AgentReasoningMessageContentEvent) ToJSON

func (e *AgentReasoningMessageContentEvent) ToJSON() ([]byte, error)

type AgentReasoningMessageEndEvent

type AgentReasoningMessageEndEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
}

REASONING_MESSAGE_END

func NewAgentReasoningMessageEndEvent

func NewAgentReasoningMessageEndEvent(messageID string) *AgentReasoningMessageEndEvent

func (*AgentReasoningMessageEndEvent) ToJSON

func (e *AgentReasoningMessageEndEvent) ToJSON() ([]byte, error)

type AgentReasoningMessageStartEvent

type AgentReasoningMessageStartEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
	Role      string `json:"role"` // reasoning
}

REASONING_MESSAGE_START

func NewAgentReasoningMessageStartEvent

func NewAgentReasoningMessageStartEvent(messageID, role string) *AgentReasoningMessageStartEvent

func (*AgentReasoningMessageStartEvent) ToJSON

func (e *AgentReasoningMessageStartEvent) ToJSON() ([]byte, error)

type AgentReasoningStartEvent

type AgentReasoningStartEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
}

REASONING_START

func NewAgentReasoningStartEvent

func NewAgentReasoningStartEvent(messageID string) *AgentReasoningStartEvent

func (*AgentReasoningStartEvent) ToJSON

func (e *AgentReasoningStartEvent) ToJSON() ([]byte, error)

type AgentRunErrorEvent

type AgentRunErrorEvent struct {
	*BaseEvent
	Message string  `json:"message"`
	Code    *string `json:"code,omitempty"` // ← *string not string
}

RUN_ERROR

func NewAgentRunErrorEvent

func NewAgentRunErrorEvent(message string, code ...string) *AgentRunErrorEvent

func (*AgentRunErrorEvent) ToJSON

func (e *AgentRunErrorEvent) ToJSON() ([]byte, error)

type AgentRunFinishedEvent

type AgentRunFinishedEvent struct {
	*BaseEvent
	ThreadID string                `json:"threadId"`
	RunID    string                `json:"runId"`
	Result   *types.AgentRunResult `json:"result,omitempty"`
}

RUN_FINISHED

func NewAgentRunFinishedEvent

func NewAgentRunFinishedEvent(threadID, runID string, result *types.AgentRunResult) *AgentRunFinishedEvent

func (*AgentRunFinishedEvent) ToJSON

func (e *AgentRunFinishedEvent) ToJSON() ([]byte, error)

type AgentRunStartedEvent

type AgentRunStartedEvent struct {
	*BaseEvent
	ThreadID    string `json:"threadId"`
	RunID       string `json:"runId"`
	ParentRunID string `json:"parentRunId,omitempty"`
}

RUN_STARTED

func NewAgentRunStartedEvent

func NewAgentRunStartedEvent(threadID, runID string, parentRunID ...string) *AgentRunStartedEvent

func (*AgentRunStartedEvent) ToJSON

func (e *AgentRunStartedEvent) ToJSON() ([]byte, error)

type AgentStepFinishedEvent

type AgentStepFinishedEvent struct {
	*BaseEvent
	StepName string `json:"stepName"`
}

STEP_FINISHED

func NewAgentStepFinishedEvent

func NewAgentStepFinishedEvent(stepName string) *AgentStepFinishedEvent

func (*AgentStepFinishedEvent) ToJSON

func (e *AgentStepFinishedEvent) ToJSON() ([]byte, error)

type AgentStepStartedEvent

type AgentStepStartedEvent struct {
	*BaseEvent
	StepName string `json:"stepName"`
}

STEP_STARTED

func NewAgentStepStartedEvent

func NewAgentStepStartedEvent(stepName string) *AgentStepStartedEvent

func (*AgentStepStartedEvent) ToJSON

func (e *AgentStepStartedEvent) ToJSON() ([]byte, error)

type AgentTextMessageContentEvent

type AgentTextMessageContentEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
	Delta     string `json:"delta"`
}

TEXT_MESSAGE_CONTENT

func NewAgentTextMessageContentEvent

func NewAgentTextMessageContentEvent(messageID, delta string) *AgentTextMessageContentEvent

func (*AgentTextMessageContentEvent) ToJSON

func (e *AgentTextMessageContentEvent) ToJSON() ([]byte, error)

type AgentTextMessageEndEvent

type AgentTextMessageEndEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
}

TEXT_MESSAGE_END

func NewAgentTextMessageEndEvent

func NewAgentTextMessageEndEvent(messageID string) *AgentTextMessageEndEvent

func (*AgentTextMessageEndEvent) ToJSON

func (e *AgentTextMessageEndEvent) ToJSON() ([]byte, error)

type AgentTextMessageStartEvent

type AgentTextMessageStartEvent struct {
	*BaseEvent
	MessageID string `json:"messageId"`
	Role      string `json:"role"` // assistant
}

TEXT_MESSAGE_START

func NewAgentTextMessageStartEvent

func NewAgentTextMessageStartEvent(messageID, role string) *AgentTextMessageStartEvent

func (*AgentTextMessageStartEvent) ToJSON

func (e *AgentTextMessageStartEvent) ToJSON() ([]byte, error)

type AgentToolCallArgsEvent

type AgentToolCallArgsEvent struct {
	*BaseEvent
	ToolCallID string `json:"toolCallId"`
	Delta      string `json:"delta"`
}

TOOL_CALL_ARGS

func NewAgentToolCallArgsEvent

func NewAgentToolCallArgsEvent(toolCallID, delta string) *AgentToolCallArgsEvent

func (*AgentToolCallArgsEvent) ToJSON

func (e *AgentToolCallArgsEvent) ToJSON() ([]byte, error)

type AgentToolCallEndEvent

type AgentToolCallEndEvent struct {
	*BaseEvent
	ToolCallID string `json:"toolCallId"`
}

TOOL_CALL_END

func NewAgentToolCallEndEvent

func NewAgentToolCallEndEvent(toolCallID string) *AgentToolCallEndEvent

func (*AgentToolCallEndEvent) ToJSON

func (e *AgentToolCallEndEvent) ToJSON() ([]byte, error)

type AgentToolCallResultEvent

type AgentToolCallResultEvent struct {
	*BaseEvent
	MessageID  string `json:"messageId"`
	ToolCallID string `json:"toolCallId"`
	Content    string `json:"content"`
	Role       string `json:"role,omitempty"` // tool
}

TOOL_CALL_RESULT

func NewAgentToolCallResultEvent

func NewAgentToolCallResultEvent(messageID, toolCallID, content string, role ...string) *AgentToolCallResultEvent

func (*AgentToolCallResultEvent) ToJSON

func (e *AgentToolCallResultEvent) ToJSON() ([]byte, error)

type AgentToolCallStartEvent

type AgentToolCallStartEvent struct {
	*BaseEvent
	ToolCallID      string `json:"toolCallId"`
	ToolCallName    string `json:"toolCallName"`
	ParentMessageID string `json:"parentMessageId,omitempty"`
}

TOOL_CALL_START

func NewAgentToolCallStartEvent

func NewAgentToolCallStartEvent(toolCallID, toolCallName string, parentMessageID ...string) *AgentToolCallStartEvent

func (*AgentToolCallStartEvent) ToJSON

func (e *AgentToolCallStartEvent) ToJSON() ([]byte, error)

type BaseEvent

type BaseEvent struct {
	EventType      AgentEventType `json:"type"`
	EventTimestamp *int64         `json:"timestamp,omitempty"`
}

BaseEvent is AG-UI BaseEvent; RawEvent maps to JSON rawEvent when present.

func NewBaseEvent

func NewBaseEvent(t AgentEventType) *BaseEvent

func (*BaseEvent) Timestamp

func (b *BaseEvent) Timestamp() *int64

func (*BaseEvent) ToJSON

func (b *BaseEvent) ToJSON() ([]byte, error)

func (*BaseEvent) Type

func (b *BaseEvent) Type() AgentEventType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL