trace

package
v1.0.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventRunStarted       = "run.started"
	EventRunCompleted     = "run.completed"
	EventRunFailed        = "run.failed"
	EventRunCancelled     = "run.cancelled"
	EventRunInterrupted   = "run.interrupted"
	EventRunResumed       = "run.resumed"
	EventNodeStarted      = "node.started"
	EventNodeCompleted    = "node.completed"
	EventNodeFailed       = "node.failed"
	EventEdgeSelected     = "edge.selected"
	EventCheckpointSaved  = "checkpoint.saved"
	EventPromptRendered   = "prompt.rendered"
	EventPromptEstimated  = "prompt.estimated"
	EventPromptAdjusted   = "prompt.adjusted"
	EventLLMStarted       = "llm.started"
	EventLLMDelta         = "llm.delta"
	EventLLMCompleted     = "llm.completed"
	EventLLMFailed        = "llm.failed"
	EventToolStarted      = "tool.started"
	EventToolProgress     = "tool.progress"
	EventToolCompleted    = "tool.completed"
	EventToolFailed       = "tool.failed"
	EventMessageRead      = "message.read"
	EventMessageWritten   = "message.written"
	EventInterruptCreated = "interrupt.created"
)

Variables

This section is empty.

Functions

func Payload

func Payload(value any) json.RawMessage

func WithEmitter

func WithEmitter(ctx context.Context, emit EmitFunc) context.Context

func WithEventContext

func WithEventContext(ctx context.Context, eventContext *EventContext) context.Context

Types

type ContextChange

type ContextChange struct {
	Before json.RawMessage `json:"before,omitempty"`
	After  json.RawMessage `json:"after,omitempty"`
	Ops    json.RawMessage `json:"ops,omitempty"`
}

type ContextSnapshot

type ContextSnapshot struct {
	State      json.RawMessage `json:"state,omitempty"`
	Messages   json.RawMessage `json:"messages,omitempty"`
	Prompt     json.RawMessage `json:"prompt,omitempty"`
	LLMRequest json.RawMessage `json:"llm_request,omitempty"`
	ToolCall   json.RawMessage `json:"tool_call,omitempty"`
	ToolResult json.RawMessage `json:"tool_result,omitempty"`
}

type EmitFunc

type EmitFunc func(context.Context, string, any) (Event, error)

type Event

type Event struct {
	ID         string          `json:"id"`
	Type       string          `json:"type"`
	ProjectID  string          `json:"project_id,omitempty"`
	WorkflowID string          `json:"workflow_id"`
	SessionID  string          `json:"session_id,omitempty"`
	RunID      string          `json:"run_id"`
	ParentID   string          `json:"parent_id,omitempty"`
	NodeID     string          `json:"node_id,omitempty"`
	Sequence   int64           `json:"sequence"`
	Time       time.Time       `json:"time"`
	Payload    json.RawMessage `json:"payload,omitempty"`
	Context    *EventContext   `json:"context,omitempty"`
}

func Emit

func Emit(ctx context.Context, eventType string, payload any) (Event, error)

type EventContext

type EventContext struct {
	Current ContextSnapshot `json:"current"`
	Change  *ContextChange  `json:"change,omitempty"`
}

func EventContextFromContext

func EventContextFromContext(ctx context.Context) (*EventContext, bool)

type MemoryRecorder

type MemoryRecorder struct {
	// contains filtered or unexported fields
}

func NewMemoryRecorder

func NewMemoryRecorder() *MemoryRecorder

func (*MemoryRecorder) List

func (r *MemoryRecorder) List(_ context.Context, runID string, afterSequence int64) ([]Event, error)

func (*MemoryRecorder) Record

func (r *MemoryRecorder) Record(_ context.Context, event Event) (Event, error)

type Recorder

type Recorder interface {
	Record(context.Context, Event) (Event, error)
	List(context.Context, string, int64) ([]Event, error)
}

Jump to

Keyboard shortcuts

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