events

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 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 "tool_approval" (after EventFromJSON or bus decode, Value is often map[string]any).

func (*AgentCustomEventApprovalValue) ToJSON

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

type AgentCustomEventBudgetValue added in v0.3.5

type AgentCustomEventBudgetValue struct {
	AgentName     string  `json:"agentName,omitempty"`
	Detail        string  `json:"detail,omitempty"`
	TotalTokens   int64   `json:"totalTokens,omitempty"`
	CostUSD       float64 `json:"costUsd,omitempty"`
	ApprovalToken string  `json:"approvalToken,omitempty"`
}

AgentCustomEventBudgetValue is the JSON shape for CUSTOM name=budget_approval.

func ParseCustomEventBudget added in v0.3.5

func ParseCustomEventBudget(ev *AgentCustomEvent) (AgentCustomEventBudgetValue, error)

ParseCustomEventBudget returns the typed value field for CUSTOM events with name "budget_approval".

func (*AgentCustomEventBudgetValue) ToJSON added in v0.3.5

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

type AgentCustomEventDelegationValue

type AgentCustomEventDelegationValue struct {
	AgentName     string         `json:"agentName,omitempty"`
	SubAgentName  string         `json:"subAgentName,omitempty"`
	ToolCallID    string         `json:"toolCallId,omitempty"` // workflow-side ID; used for pending-approval tracking on Events/reconnect
	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 "sub_agent_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"
	AgentCustomEventNameBudget             AgentCustomEventName = "budget_approval"
	// AgentCustomEventNameStepReplayed is emitted once per already-completed durable-go
	// step when a LocalRuntime durable stream reconnects (GetStreamHandle) after a
	// process restart. It is a coarse, step-granularity replay marker — not the original
	// token-by-token content — see AgentCustomEventStepReplayedValue and
	// [github.com/agenticenv/agent-sdk-go/internal/runtime/local]'s stream-reconnect docs.
	AgentCustomEventNameStepReplayed AgentCustomEventName = "step_replayed"
)

type AgentCustomEventStepReplayedValue added in v0.3.6

type AgentCustomEventStepReplayedValue struct {
	StepID      string          `json:"stepId"`
	Status      string          `json:"status"`
	Result      json.RawMessage `json:"result,omitempty"`
	StartedAt   string          `json:"startedAt,omitempty"`
	CompletedAt string          `json:"completedAt,omitempty"`
}

AgentCustomEventStepReplayedValue is the JSON shape for CUSTOM name=step_replayed. Result is the step's raw cached JSON result (shape depends on the step: an LLM-call step's result differs from a tool-exec step's), included as best-effort context, not a stable schema callers should depend on.

func ParseCustomEventStepReplayed added in v0.3.6

func ParseCustomEventStepReplayed(ev *AgentCustomEvent) (AgentCustomEventStepReplayedValue, error)

ParseCustomEventStepReplayed returns the typed value field for CUSTOM events with name "step_replayed" (LocalRuntime durable stream reconnect — see AgentCustomEventNameStepReplayed).

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"`
	// contains filtered or unexported fields
}

BaseEvent is AG-UI BaseEvent; RawEvent maps to JSON rawEvent when present. The offset fields are NOT serialised to JSON to preserve wire compatibility with the AG-UI protocol; they carry the workflowstreams global offset for reconnect support (see Agent.GetAgentStream / AgentStream.Events with WithOffset) and are set by the stream forwarder after decode.

func NewBaseEvent

func NewBaseEvent(t AgentEventType) *BaseEvent

func (*BaseEvent) Offset added in v0.3.0

func (b *BaseEvent) Offset() (int64, bool)

Offset returns the workflowstreams offset and whether it was set. Pass the returned offset to AgentStream.Events(WithOffset) to resume the stream from this point.

func (*BaseEvent) SetOffset added in v0.3.0

func (b *BaseEvent) SetOffset(v int64)

SetOffset records the workflowstreams global offset for this event. Called by the stream forwarder after decoding a subscribed item.

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