event

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package event defines presentation-neutral runtime events.

Event values produced by the engine may contain raw provider text, reasoning, tool arguments, tool results, artifact paths, and diagnostics. Public sinks, trace files, SSE streams, API responses, and host snapshots should pass events through Sanitize or SerialSink with the default policy. Raw inspection is a local debug capability: enabling SinkPolicy.AllowRaw on one sink must not be reused for default/public sinks in the same run.

Recorder is safe for concurrent Emit calls and is intended for tests. Custom sinks should either be internally synchronized or wrapped in SerialSink.

Index

Constants

View Source
const (
	StepStart              = observation.EventTypeStepStart
	ProviderRequest        = observation.EventTypeProviderRequest
	ProviderDelta          = observation.EventTypeProviderDelta
	ProviderReasoning      = observation.EventTypeProviderReasoning
	ProviderToolCallStart  = observation.EventTypeProviderToolCallStart
	ProviderToolCallDelta  = observation.EventTypeProviderToolCallDelta
	ProviderToolCallEnd    = observation.EventTypeProviderToolCallEnd
	ProviderUsage          = observation.EventTypeProviderUsage
	ProviderSources        = observation.EventTypeProviderSources
	ProviderFinish         = observation.EventTypeProviderFinish
	ProviderRetry          = observation.EventTypeProviderRetry
	ToolCall               = observation.EventTypeToolCall
	ToolDispatchStarted    = observation.EventTypeToolDispatchStarted
	ToolActivityUpdated    = observation.EventTypeToolActivityUpdated
	ToolResult             = observation.EventTypeToolResult
	ToolApprovalRequested  = observation.EventTypeToolApprovalRequested
	ToolApprovalApproved   = observation.EventTypeToolApprovalApproved
	ToolApprovalRejected   = observation.EventTypeToolApprovalRejected
	ToolApprovalTimedOut   = observation.EventTypeToolApprovalTimedOut
	ToolApprovalCanceled   = observation.EventTypeToolApprovalCanceled
	HostedToolCall         = observation.EventTypeHostedToolCall
	HostedToolResult       = observation.EventTypeHostedToolResult
	MCPServerConnecting    = observation.EventTypeMCPServerConnecting
	MCPServerReady         = observation.EventTypeMCPServerReady
	MCPServerFailed        = observation.EventTypeMCPServerFailed
	MCPToolsListed         = observation.EventTypeMCPToolsListed
	MCPToolCall            = observation.EventTypeMCPToolCall
	MCPToolResult          = observation.EventTypeMCPToolResult
	SkillDetected          = observation.EventTypeSkillDetected
	SkillLoaded            = observation.EventTypeSkillLoaded
	SkillBlocked           = observation.EventTypeSkillBlocked
	SkillInstallRequired   = observation.EventTypeSkillInstallRequired
	SkillDisclosureApplied = observation.EventTypeSkillDisclosureApplied
	ContextCompact         = observation.EventTypeContextCompact
	ContextCompactDebug    = observation.EventTypeContextCompactDebug
	ContextContinue        = observation.EventTypeContextContinue
	ThreadEntryCommitted   = observation.EventTypeThreadEntryCommitted
	ThreadTitlePending     = observation.EventTypeThreadTitlePending
	ThreadTitleUpdated     = observation.EventTypeThreadTitleUpdated
	ThreadTitleFailed      = observation.EventTypeThreadTitleFailed
	ControlSignal          = observation.EventTypeControlSignal
	BudgetExceeded         = observation.EventTypeBudgetExceeded
	StepEnd                = observation.EventTypeStepEnd
	RunEnd                 = observation.EventTypeRunEnd
)

Variables

This section is empty.

Functions

func Redact

func Redact(value string) string

func SafePathLabel

func SafePathLabel(path string) string

func SafePathRefsText

func SafePathRefsText(value string) string

func StableHash

func StableHash(value string) string

Types

type Artifact

type Artifact struct {
	ID        string `json:"id,omitempty"`
	SafeLabel string `json:"safe_label,omitempty"`
	URL       string `json:"url,omitempty"`
	Kind      string `json:"kind,omitempty"`
	MIME      string `json:"mime,omitempty"`
	SizeBytes int64  `json:"size_bytes,omitempty"`
	SHA256    string `json:"sha256,omitempty"`
	Path      string `json:"path,omitempty"`
}

type Event

type Event struct {
	Type          Type   `json:"type"`
	TraceID       string `json:"trace_id,omitempty"`
	RunID         string `json:"run_id"`
	ThreadID      string `json:"thread_id,omitempty"`
	TurnID        string `json:"turn_id,omitempty"`
	PromptScopeID string `json:"prompt_scope_id,omitempty"`
	Step          int    `json:"step,omitempty"`
	Provider      string `json:"provider,omitempty"`
	Model         string `json:"model,omitempty"`
	Message       string `json:"message,omitempty"`
	ToolID        string `json:"tool_id,omitempty"`
	ToolName      string `json:"tool_name,omitempty"`
	ToolKind      string `json:"tool_kind,omitempty"`
	// CanonicalEntryID links an effect result event to the journal entry that
	// the effect authority already committed. It is internal projection state.
	CanonicalEntryID   string                            `json:"-"`
	Args               string                            `json:"args,omitempty"`
	ArgsHash           string                            `json:"args_hash,omitempty"`
	Result             string                            `json:"result,omitempty"`
	Err                string                            `json:"err,omitempty"`
	FinishReason       string                            `json:"finish_reason,omitempty"`
	RawFinishReason    string                            `json:"raw_finish_reason,omitempty"`
	FinishInferred     bool                              `json:"finish_inferred,omitempty"`
	CompletionReason   string                            `json:"completion_reason,omitempty"`
	ContinuationReason string                            `json:"continuation_reason,omitempty"`
	Duration           int64                             `json:"duration_ms,omitempty"`
	Metrics            any                               `json:"metrics,omitempty"`
	Metadata           any                               `json:"metadata,omitempty"`
	Activity           *observation.ActivityPresentation `json:"activity,omitempty"`
	Artifacts          []Artifact                        `json:"artifacts,omitempty"`
	Sources            []SourceRef                       `json:"sources,omitempty"`
	Payload            any                               `json:"-"`
	Timestamp          time.Time                         `json:"timestamp"`
}

func Sanitize

func Sanitize(e Event) Event

func SanitizePathRefs

func SanitizePathRefs(e Event) Event

func SanitizeWithPolicy

func SanitizeWithPolicy(e Event, policy SinkPolicy) Event

type Recorder

type Recorder struct {
	Events []Event
	// contains filtered or unexported fields
}

func (*Recorder) Emit

func (r *Recorder) Emit(e Event)

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() []Event

type Redactor

type Redactor func(string) string

type Sensitivity

type Sensitivity string
const (
	SensitivityPublic Sensitivity = "public"
	SensitivityRaw    Sensitivity = "raw"
)

type SerialSink

type SerialSink struct {
	Inner  Sink
	Policy SinkPolicy
	// contains filtered or unexported fields
}

func NewSerialSink

func NewSerialSink(inner Sink, policy SinkPolicy) *SerialSink

func (*SerialSink) Emit

func (s *SerialSink) Emit(e Event)

type Sink

type Sink interface {
	Emit(Event)
}

type SinkPolicy

type SinkPolicy struct {
	AllowRaw bool
	Redactor Redactor
}

type SourceRef added in v0.3.13

type SourceRef struct {
	Title string `json:"title,omitempty"`
	URL   string `json:"url,omitempty"`
}

type TraceWriter

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

func NewTraceWriter

func NewTraceWriter(w io.Writer) *TraceWriter

func (*TraceWriter) Emit

func (t *TraceWriter) Emit(e Event)

type Type

type Type = observation.EventType

Jump to

Keyboard shortcuts

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