event

package
v0.3.33 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 11 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

This section is empty.

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"`
	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"`
	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 string
const (
	StepStart              Type = "step_start"
	ProviderRequest        Type = "provider_request"
	ProviderDelta          Type = "provider_delta"
	ProviderReasoning      Type = "provider_reasoning"
	ProviderToolCallStart  Type = "provider_tool_call_start"
	ProviderToolCallDelta  Type = "provider_tool_call_delta"
	ProviderToolCallEnd    Type = "provider_tool_call_end"
	ProviderUsage          Type = "provider_usage"
	ProviderSources        Type = "provider_sources"
	ProviderFinish         Type = "provider_finish"
	ProviderRetry          Type = "provider_retry"
	ToolCall               Type = "tool_call"
	ToolResult             Type = "tool_result"
	ToolApprovalRequested  Type = "tool_approval_requested"
	ToolApprovalApproved   Type = "tool_approval_approved"
	ToolApprovalRejected   Type = "tool_approval_rejected"
	ToolApprovalTimedOut   Type = "tool_approval_timed_out"
	ToolApprovalCanceled   Type = "tool_approval_canceled"
	HostedToolCall         Type = "hosted_tool_call"
	HostedToolResult       Type = "hosted_tool_result"
	MCPServerConnecting    Type = "mcp_server_connecting"
	MCPServerReady         Type = "mcp_server_ready"
	MCPServerFailed        Type = "mcp_server_failed"
	MCPToolsListed         Type = "mcp_tools_listed"
	MCPToolCall            Type = "mcp_tool_call"
	MCPToolResult          Type = "mcp_tool_result"
	SkillDetected          Type = "skill_detected"
	SkillLoaded            Type = "skill_loaded"
	SkillBlocked           Type = "skill_blocked"
	SkillInstallRequired   Type = "skill_install_required"
	SkillDisclosureApplied Type = "skill_disclosure_applied"
	ContextCompact         Type = "context_compact"
	ContextCompactDebug    Type = "context_compact_debug"
	ContextContinue        Type = "context_continue"
	ControlSignal          Type = "control_signal"
	BudgetExceeded         Type = "budget_exceeded"
	StepEnd                Type = "step_end"
	RunEnd                 Type = "run_end"
)

Jump to

Keyboard shortcuts

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