events

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package events defines durable session events, replay storage, and projection.

Index

Constants

View Source
const (
	HistoryDecisionStatusActive                      = "active"
	HistoryDecisionStatusSuperseded                  = "superseded"
	HistoryOpenThreadStatusPending                   = "pending"
	HistoryOpenThreadStatusBlocked                   = "blocked"
	HistoryOpenThreadStatusDeferred                  = "deferred"
	HistoryOpenThreadOwnerAgent                      = "agent"
	HistoryOpenThreadOwnerUser                       = "user"
	HistoryOpenThreadOwnerShared                     = "shared"
	HistoryPageInMatchKindAudit                      = "audit"
	HistoryPageInMatchKindUserWording                = "user_wording"
	HistoryPageInMatchKindToolOutput                 = "tool_output"
	HistoryPageInMatchKindToolError                  = "tool_error"
	HistoryPageInMatchKindToolCommand                = "tool_command"
	HistoryPageInMatchKindPathContext                = "path_context"
	HistoryVerificationKindToolResult                = "tool_result"
	HistoryVerificationKindRuntimeNote               = "runtime_note"
	HistoryVerificationKindTurnStatus                = "turn_status"
	HistoryContinuationUpdateReasonSemanticClosure   = "semantic_closure"
	HistoryContinuationUpdateReasonTokenPressure     = "token_pressure"
	HistoryContinuationUpdateReasonRebuild           = "rebuild"
	HistoryContinuationUpdateReasonCheckpointRestore = "checkpoint_restore"
	HistoryContinuationUpdateReasonManualRequest     = "manual_request"
)
View Source
const (
	QuestionPurposeTurnLoopResolution  = "turn_loop_resolution"
	QuestionPurposePlannerSavePlan     = "planner_save_plan"
	QuestionPurposePlannerPlanDecision = "planner_plan_decision"
)
View Source
const (
	ReviewSeverityP0 = "P0"
	ReviewSeverityP1 = "P1"
	ReviewSeverityP2 = "P2"
	ReviewSeverityP3 = "P3"

	ReviewOverallCorrectnessCorrect   = "correct"
	ReviewOverallCorrectnessIncorrect = "incorrect"
)
View Source
const (
	TaskStatusPending    = "pending"
	TaskStatusInProgress = "in_progress"
	TaskStatusBlocked    = "blocked"
	TaskStatusCompleted  = "completed"
)
View Source
const (
	TaskReviewStatusPass     = "pass"
	TaskReviewStatusConcern  = "concern"
	TaskReviewStatusFail     = "fail"
	TaskReviewStatusAccepted = "accepted"
)
View Source
const (
	TurnContinuationReasonContextLimit   = "context_limit"
	TurnContinuationReasonQuestionAnswer = "question_answer"
)

Variables

View Source
var (
	ErrSessionRequired      = errors.New("session_id is required")
	ErrAfterSequenceInvalid = errors.New("after_sequence must be >= -1")
)
View Source
var ErrTaskNotFound = errors.New("task not found")

Functions

func SnapshotRetainsToolBody

func SnapshotRetainsToolBody(call *ToolCallState) bool

func ValidateReviewRecordedPayload

func ValidateReviewRecordedPayload(payload ReviewRecordedPayload) error

Types

type AgentHandoffExplorationEntry

type AgentHandoffExplorationEntry struct {
	ToolName string
	Target   string
	Summary  string
}

type AgentHandoffPayload

type AgentHandoffPayload struct {
	HandoffID          string
	ToolCallID         string
	ParentSessionID    string
	ParentTurnID       string
	ParentAgentID      string
	ChildSessionID     string
	ChildTurnID        string
	ChildAgentID       string
	Task               string
	ContextSummary     string
	SourceHandoffIDs   []string
	ProvidedKinds      []string
	ExplorationEntries []AgentHandoffExplorationEntry
	Model              string
	AllowedTools       []string
}

type AgentHandoffPreviewPayload

type AgentHandoffPreviewPayload struct {
	HandoffID      string
	ChildSessionID string
	ChildTurnID    string
	Active         bool
	ToolName       string
	Action         string
	AssistantText  string
}

type AgentHandoffState

type AgentHandoffState struct {
	HandoffID            string
	ToolCallID           string
	ParentSessionID      string
	ParentTurnID         string
	ParentAgentID        string
	ChildSessionID       string
	ChildTurnID          string
	ChildAgentID         string
	Task                 string
	ContextSummary       string
	SourceHandoffIDs     []string
	ProvidedKinds        []string
	ExplorationEntries   []AgentHandoffExplorationEntry
	Model                string
	AllowedTools         []string
	PreviewActive        bool
	PreviewToolName      string
	PreviewAction        string
	PreviewAssistantText string
	Status               AgentResultStatus
	AssistantText        string
	Error                string
	PermissionRequestID  string
	PermissionKind       PermissionRequestKind
	PermissionToolName   string
	PermissionAccess     string
	PermissionPath       string
	PermissionDir        string
	PermissionCommand    string
	PermissionReason     string
	ExecutionApproval    *ExecutionApprovalState
	QuestionRequestID    string
	QuestionToolName     string
	QuestionText         string
	QuestionOptions      []string
	Reused               bool
	ReusedContent        string
}

type AgentResultPayload

type AgentResultPayload struct {
	HandoffID           string
	ChildSessionID      string
	ChildTurnID         string
	Status              AgentResultStatus
	AssistantText       string
	Error               string
	PermissionRequestID string
	PermissionKind      PermissionRequestKind
	PermissionToolName  string
	PermissionAccess    string
	PermissionPath      string
	PermissionDir       string
	PermissionCommand   string
	PermissionReason    string
	ExecutionApproval   *ExecutionApprovalState
	QuestionRequestID   string
	QuestionToolName    string
	QuestionText        string
	QuestionOptions     []string
}

type AgentResultReusedPayload

type AgentResultReusedPayload struct {
	HandoffID      string
	ChildSessionID string
	ChildTurnID    string
	Content        string
}

type AgentResultStatus

type AgentResultStatus string
const (
	AgentResultStatusCompleted         AgentResultStatus = "completed"
	AgentResultStatusPendingPermission AgentResultStatus = "pending_permission"
	AgentResultStatusPendingQuestion   AgentResultStatus = "pending_question"
	AgentResultStatusFailed            AgentResultStatus = "failed"
)

type AnthropicThinkingCommittedPayload

type AnthropicThinkingCommittedPayload struct {
	Type      string
	Thinking  string
	Signature string
	Data      string
}

type Appender

type Appender interface {
	Append(context.Context, Draft) (Event, error)
}

type ApprovedExecutionState

type ApprovedExecutionState struct {
	RequestID            string
	ExecutionID          string
	TurnID               string
	ToolCallID           string
	ToolName             string
	Command              string
	WorkingDirectory     string
	Decision             ExecutionApprovalDecision
	AppliedExecPolicy    *ExecutionPolicyAmendment
	AppliedNetworkPolicy *ExecutionNetworkPolicyAmendment
	ApprovedAtSeq        int64
}

type ArtifactPurgeResult

type ArtifactPurgeResult struct {
	ToolResultBlobs int64
	BackgroundLogs  int64
}

type AssistantCommitPayload

type AssistantCommitPayload struct {
	Content string
}

type AssistantPreviewDeltaPayload

type AssistantPreviewDeltaPayload struct {
	Content string
}

type AssistantPreviewResetPayload

type AssistantPreviewResetPayload struct{}

type AssistantWorklogCommitPayload

type AssistantWorklogCommitPayload struct {
	Content string
}

type CompactionAttemptState

type CompactionAttemptState = ContextCompactionStartedPayload

type CompactionFailureState

type CompactionFailureState = ContextCompactionFailedPayload

type CompactionScope

type CompactionScope string
const (
	CompactionScopeHistory CompactionScope = "history"
)

type ContextCompactionFailedPayload

type ContextCompactionFailedPayload struct {
	Scope                  CompactionScope `json:"scope"`
	Reason                 string          `json:"reason"`
	Detail                 string          `json:"detail"`
	InputLimitTokens       int             `json:"input_limit_tokens"`
	TriggerTokens          int             `json:"trigger_tokens"`
	TargetTokens           int             `json:"target_tokens"`
	EstimatedRequestTokens int             `json:"estimated_request_tokens"`
}

type ContextCompactionStartedPayload

type ContextCompactionStartedPayload struct {
	Scope                  CompactionScope `json:"scope"`
	InputLimitTokens       int             `json:"input_limit_tokens"`
	TriggerTokens          int             `json:"trigger_tokens"`
	TargetTokens           int             `json:"target_tokens"`
	EstimatedRequestTokens int             `json:"estimated_request_tokens"`
}

type ContextPrunedPayload

type ContextPrunedPayload struct {
	PriorTurns          int
	PriorInputBytes     int
	RawPriorTurns       int
	RawInputBytes       int
	CompactedPriorTurns int
	CompactedInputBytes int
	OmittedPriorTurns   int
	OmittedInputBytes   int
}

type Draft

type Draft struct {
	SessionID string
	TurnID    string
	Type      Type
	Payload   Payload
}

func (Draft) Validate

func (d Draft) Validate() error

type Event

type Event struct {
	ID        string
	SessionID string
	TurnID    string
	Sequence  int64
	Time      time.Time
	Type      Type
	Payload   Payload
	Ephemeral bool
}

func ReadSessionConfigured

func ReadSessionConfigured(path string) (Event, error)

func (Event) Validate

func (e Event) Validate() error

type ExecutionApprovalDecision

type ExecutionApprovalDecision string
const (
	ExecutionApprovalDecisionAccept               ExecutionApprovalDecision = "accept"
	ExecutionApprovalDecisionAcceptForSession     ExecutionApprovalDecision = "acceptForSession"
	ExecutionApprovalDecisionAcceptWithExecPolicy ExecutionApprovalDecision = "acceptWithExecpolicyAmendment"
	ExecutionApprovalDecisionApplyNetworkPolicy   ExecutionApprovalDecision = "applyNetworkPolicyAmendment"
	ExecutionApprovalDecisionDecline              ExecutionApprovalDecision = "decline"
	ExecutionApprovalDecisionCancel               ExecutionApprovalDecision = "cancel"
)

type ExecutionApprovalRequestedPayload

type ExecutionApprovalRequestedPayload struct {
	RequestID             string
	ExecutionID           string
	ToolCallID            string
	ToolName              string
	Command               string
	WorkingDirectory      string
	Reason                string
	PrefixRule            []string
	SessionGrantPaths     []string
	NetworkTargets        []string
	AvailableDecisions    []ExecutionApprovalDecision
	ProposedExecPolicy    *ExecutionPolicyAmendment
	ProposedNetworkPolicy *ExecutionNetworkPolicyAmendment
}

type ExecutionApprovalResolvedPayload

type ExecutionApprovalResolvedPayload struct {
	RequestID            string
	Decision             ExecutionApprovalDecision
	GrantPaths           []string
	GrantPrefixRule      []string
	GrantNetworkTargets  []string
	AppliedExecPolicy    *ExecutionPolicyAmendment
	AppliedNetworkPolicy *ExecutionNetworkPolicyAmendment
}

type ExecutionApprovalState

type ExecutionApprovalState struct {
	RequestID             string
	ExecutionID           string
	TurnID                string
	ToolCallID            string
	ToolName              string
	Command               string
	WorkingDirectory      string
	Reason                string
	PrefixRule            []string
	SessionGrantPaths     []string
	NetworkTargets        []string
	AvailableDecisions    []ExecutionApprovalDecision
	ProposedExecPolicy    *ExecutionPolicyAmendment
	ProposedNetworkPolicy *ExecutionNetworkPolicyAmendment
	RequestedAtSeq        int64
}

type ExecutionBackgroundExitedPayload

type ExecutionBackgroundExitedPayload struct {
	ExecutionID string
	ToolCallID  string
	ToolName    string
	ExitCode    *int
	Error       string
}

type ExecutionBackgroundLostPayload

type ExecutionBackgroundLostPayload struct {
	ExecutionID string
	ToolCallID  string
	ToolName    string
	Error       string
}

type ExecutionBackgroundObservedPayload

type ExecutionBackgroundObservedPayload struct {
	ExecutionID string
	ToolCallID  string
	ToolName    string
	OutputTail  string
	OutputBytes int64
}

type ExecutionBackgroundReadyPayload

type ExecutionBackgroundReadyPayload struct {
	ExecutionID string
	ToolCallID  string
	ToolName    string
	Message     string
	Port        int
}

type ExecutionBackgroundStartedPayload

type ExecutionBackgroundStartedPayload struct {
	ExecutionID     string
	ToolCallID      string
	ToolName        string
	PID             int
	ProcessIdentity string
	SupervisorID    string
	LogRef          string
	ReadyPatterns   []string
}

type ExecutionBackgroundState

type ExecutionBackgroundState struct {
	PID             int
	ProcessIdentity string
	SupervisorID    string
	Status          ExecutionBackgroundStatus
	LogRef          string
	ReadyPatterns   []string
	Started         bool
	StartedAtSeq    int64
	Ready           bool
	ReadyAtSeq      int64
	ReadyMessage    string
	Port            int
	OutputTail      string
	OutputBytes     int64
	Exited          bool
	ExitedAtSeq     int64
	ExitCode        *int
	Error           string
}

type ExecutionBackgroundStatus

type ExecutionBackgroundStatus string
const (
	ExecutionBackgroundStatusStarting        ExecutionBackgroundStatus = "starting"
	ExecutionBackgroundStatusRunning         ExecutionBackgroundStatus = "running"
	ExecutionBackgroundStatusReady           ExecutionBackgroundStatus = "ready"
	ExecutionBackgroundStatusExited          ExecutionBackgroundStatus = "exited"
	ExecutionBackgroundStatusSupervisionLost ExecutionBackgroundStatus = "supervisionLost"
)

type ExecutionDeclaredPayload

type ExecutionDeclaredPayload struct {
	ExecutionID      string
	ToolCallID       string
	ToolName         string
	Kind             string
	Intent           string
	Effect           string
	Command          []string
	CommandPreview   string
	WorkingDirectory string
	TimeoutMS        int64
	OutputLimit      int
}

type ExecutionGrantState

type ExecutionGrantState struct {
	PrefixRule     []string
	SessionPaths   []string
	NetworkTargets []string
}

type ExecutionNetworkPolicyAmendment

type ExecutionNetworkPolicyAmendment struct {
	Enabled bool `json:"enabled"`
}

type ExecutionOutputPayload

type ExecutionOutputPayload struct {
	ExecutionID string
	ToolCallID  string
	Stream      string
	Chunk       string
}

type ExecutionPolicyAmendment

type ExecutionPolicyAmendment struct {
	AllowLoginShell *bool `json:"allow_login_shell,omitempty"`
}

type ExecutionStartedPayload

type ExecutionStartedPayload struct {
	ExecutionID string
	ToolCallID  string
	ToolName    string
	Input       string
}

type ExecutionState

type ExecutionState struct {
	ExecutionID      string
	ToolCallID       string
	ToolName         string
	Kind             string
	Intent           string
	Effect           string
	Command          []string
	CommandPreview   string
	WorkingDirectory string
	TimeoutMS        int64
	OutputLimit      int
	Status           ExecutionStatus
	Input            string
	Output           string
	Error            string
	OutputBlob       *ToolResultBlobRef
	ErrorBlob        *ToolResultBlobRef
	OutputTruncated  bool
	ErrorTruncated   bool
	ExitCode         *int
	DurationMS       int64
	CommandActions   []string
	Executing        bool
	Completed        bool
	Runtime          *ToolExecRuntimeState
	Background       *ExecutionBackgroundState
}

type ExecutionStatus

type ExecutionStatus string
const (
	ExecutionStatusPendingApproval ExecutionStatus = "pendingApproval"
	ExecutionStatusInProgress      ExecutionStatus = "inProgress"
	ExecutionStatusCompleted       ExecutionStatus = "completed"
	ExecutionStatusFailed          ExecutionStatus = "failed"
	ExecutionStatusDeclined        ExecutionStatus = "declined"
)

type HistoryCompactionUIState

type HistoryCompactionUIState struct {
	Scope             CompactionScope
	StartedAtSeq      int64
	SummaryReadyAtSeq int64
	ResumedAtSeq      int64
	SourceTurnID      string
}

type HistoryContinuationArtifact

type HistoryContinuationArtifact struct {
	SessionObjective  string                        `json:"session_objective,omitempty"`
	Constraints       []string                      `json:"constraints,omitempty"`
	SettledDecisions  []HistoryDecisionPayload      `json:"settled_decisions,omitempty"`
	CompletedEpisodes []HistoryEpisodePayload       `json:"completed_episodes,omitempty"`
	OpenThreads       []HistoryOpenThreadPayload    `json:"open_threads,omitempty"`
	WorkspaceFacts    []HistoryWorkspaceFactPayload `json:"workspace_facts,omitempty"`
	PageInHints       []HistoryPageInHintPayload    `json:"page_in_hints,omitempty"`
}

type HistoryContinuationAttribution

type HistoryContinuationAttribution struct {
	Model             string `json:"model,omitempty"`
	InputLimitSource  string `json:"input_limit_source,omitempty"`
	MeasurementSource string `json:"measurement_source,omitempty"`
	SummarySource     string `json:"summary_source,omitempty"`
	Algorithm         string `json:"algorithm,omitempty"`
	DurationMS        int64  `json:"duration_ms,omitempty"`
}

type HistoryDecisionPayload

type HistoryDecisionPayload struct {
	Decision     string `json:"decision"`
	Rationale    string `json:"rationale,omitempty"`
	Status       string `json:"status"`
	SourceTurnID string `json:"source_turn_id"`
}

type HistoryEpisodePayload

type HistoryEpisodePayload struct {
	EpisodeID     string                       `json:"episode_id"`
	Summary       string                       `json:"summary"`
	TouchedPaths  []string                     `json:"touched_paths,omitempty"`
	Verification  []HistoryVerificationPayload `json:"verification,omitempty"`
	SourceTurnIDs []string                     `json:"source_turn_ids"`
}

type HistoryInputBudgetPayload

type HistoryInputBudgetPayload struct {
	InputLimitTokens          int `json:"input_limit_tokens"`
	TriggerTokens             int `json:"trigger_tokens"`
	TargetTokens              int `json:"target_tokens"`
	EstimatedRequestTokens    int `json:"estimated_request_tokens"`
	ConsolidatedRequestTokens int `json:"consolidated_request_tokens"`
}

type HistoryOpenThreadPayload

type HistoryOpenThreadPayload struct {
	Item         string `json:"item"`
	Status       string `json:"status"`
	Blocking     bool   `json:"blocking,omitempty"`
	Owner        string `json:"owner,omitempty"`
	SourceTurnID string `json:"source_turn_id"`
}

type HistoryPageInHintPayload

type HistoryPageInHintPayload struct {
	When          string   `json:"when"`
	MatchKinds    []string `json:"match_kinds,omitempty"`
	ToolNames     []string `json:"tool_names,omitempty"`
	Paths         []string `json:"paths,omitempty"`
	CallIDs       []string `json:"call_ids,omitempty"`
	SourceTurnIDs []string `json:"source_turn_ids"`
}

type HistoryVerificationPayload

type HistoryVerificationPayload struct {
	Kind      string `json:"kind"`
	Value     string `json:"value"`
	Succeeded bool   `json:"succeeded"`
}

type HistoryWorkspaceFactPayload

type HistoryWorkspaceFactPayload struct {
	Path         string `json:"path"`
	Fact         string `json:"fact"`
	SourceTurnID string `json:"source_turn_id"`
}

type LatestQuery

type LatestQuery struct {
	SessionID string
	Types     []Type
}

func (LatestQuery) Validate

func (q LatestQuery) Validate() error

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Append

func (s *MemoryStore) Append(_ context.Context, draft Draft) (Event, error)

func (*MemoryStore) DeleteSession

func (s *MemoryStore) DeleteSession(_ context.Context, sessionID string) error

func (*MemoryStore) Latest

func (s *MemoryStore) Latest(_ context.Context, query LatestQuery) (Event, bool, error)

func (*MemoryStore) ListSessions

func (s *MemoryStore) ListSessions(_ context.Context) ([]SessionIndexEntry, error)

func (*MemoryStore) ListWorkspaceSessions

func (s *MemoryStore) ListWorkspaceSessions(_ context.Context, workspaceRoot string) ([]SessionIndexEntry, error)

func (*MemoryStore) Replay

func (s *MemoryStore) Replay(_ context.Context, query Query) ([]Event, error)

func (*MemoryStore) Watch

func (s *MemoryStore) Watch(ctx context.Context, query Query) (<-chan Event, error)

type MutationRange

type MutationRange struct {
	OldStartLine int `json:"old_start_line,omitempty"`
	NewStartLine int `json:"new_start_line,omitempty"`
}

type NetworkGrantState

type NetworkGrantState struct {
	Target string
}

type ObservedResource

type ObservedResource struct {
	Kind       string `json:"kind,omitempty"`
	Path       string `json:"path,omitempty"`
	Version    string `json:"version,omitempty"`
	State      string `json:"state,omitempty"`
	Complete   bool   `json:"complete,omitempty"`
	StartLine  int    `json:"start_line,omitempty"`
	EndLine    int    `json:"end_line,omitempty"`
	TotalLines int    `json:"total_lines,omitempty"`
}

type OpenAIReasoningCommittedPayload

type OpenAIReasoningCommittedPayload struct {
	Item json.RawMessage
}

type Payload

type Payload interface {
	// contains filtered or unexported methods
}

type PermissionDecision

type PermissionDecision string
const (
	PermissionDecisionApproved PermissionDecision = "approved"
	PermissionDecisionDenied   PermissionDecision = "denied"
)

type PermissionRequestKind

type PermissionRequestKind string
const (
	PermissionRequestKindPath      PermissionRequestKind = "path"
	PermissionRequestKindExecution PermissionRequestKind = "execution"
	PermissionRequestKindNetwork   PermissionRequestKind = "network"
)

type PermissionRequestState

type PermissionRequestState struct {
	Kind             PermissionRequestKind
	RequestID        string
	ExecutionID      string
	TurnID           string
	ToolCallID       string
	Access           string
	Path             string
	WorkingDirectory string
	ToolName         string
	Command          string
	Reason           string
	RequestedAtSeq   int64
}

type PermissionRequestedPayload

type PermissionRequestedPayload struct {
	Kind             PermissionRequestKind
	RequestID        string
	ExecutionID      string
	ToolCallID       string
	Access           string
	Path             string
	WorkingDirectory string
	ToolName         string
	Command          string
	Reason           string
}

type PermissionResolvedPayload

type PermissionResolvedPayload struct {
	RequestID  string
	Decision   PermissionDecision
	Scope      PermissionScope
	GrantPath  string
	GrantPaths []string
	Recursive  bool
}

type PermissionScope

type PermissionScope string
const (
	PermissionScopeOnce    PermissionScope = "once"
	PermissionScopeSession PermissionScope = "session"
)

type PlanRecordedPayload

type PlanRecordedPayload struct {
	PlanID          string `json:"plan_id"`
	SourceHandoffID string `json:"source_handoff_id,omitempty"`
	SourceTurnID    string `json:"source_turn_id,omitempty"`
	Title           string `json:"title"`
	Markdown        string `json:"markdown"`
	CreatedByAgent  string `json:"created_by_agent"`
}

type PlanState

type PlanState struct {
	PlanID          string
	SourceHandoffID string
	SourceTurnID    string
	Title           string
	Markdown        string
	CreatedByAgent  string
}

type Projector

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

func NewProjector

func NewProjector(sessionID string) *Projector

func NewProjectorFromOwnedSnapshot

func NewProjectorFromOwnedSnapshot(state SessionState) *Projector

NewProjectorFromOwnedSnapshot transfers ownership of state into the projector. Callers must not retain or mutate maps, slices, or nested pointers from state after passing it here.

func NewProjectorFromSnapshot

func NewProjectorFromSnapshot(state SessionState) *Projector

func NewProjectorFromSnapshotAt

func NewProjectorFromSnapshotAt(state SessionState, lastSequence int64) *Projector

func (*Projector) Apply

func (p *Projector) Apply(event Event) error

func (*Projector) CurrentState

func (p *Projector) CurrentState() SessionState

CurrentState returns the projector's current state for read-only inspection. Callers must not mutate the returned maps, slices, or nested pointers.

func (*Projector) Snapshot

func (p *Projector) Snapshot() SessionState

func (*Projector) ToolCall

func (p *Projector) ToolCall(callID string) *ToolCallState

type PromptCompiledPayload

type PromptCompiledPayload struct {
	Shape            string
	BaseInstructions string
	Instructions     string
	CacheablePrefix  string
	DynamicSuffix    string
	Fragments        []PromptFragmentPayload
}

type PromptFragmentPayload

type PromptFragmentPayload struct {
	Kind      string
	Source    string
	Stability string
	Key       string
	Label     string
	Bytes     int
	Tokens    int
}

type PromptFragmentState

type PromptFragmentState struct {
	Kind      string
	Source    string
	Stability string
	Key       string
	Label     string
	Bytes     int
	Tokens    int
}

type PromptState

type PromptState struct {
	Shape            string
	BaseInstructions string
	Instructions     string
	CacheablePrefix  string
	DynamicSuffix    string
	Fragments        []PromptFragmentState
}

type PruningState

type PruningState struct {
	PriorTurns          int
	PriorInputBytes     int
	RawPriorTurns       int
	RawInputBytes       int
	CompactedPriorTurns int
	CompactedInputBytes int
	OmittedPriorTurns   int
	OmittedInputBytes   int
}

type Query

type Query struct {
	SessionID     string
	AfterSequence int64
	ExcludeTypes  []Type
}

func (Query) Validate

func (q Query) Validate() error

type QuestionAnswerState

type QuestionAnswerState struct {
	QuestionID    string
	TurnID        string
	ToolCallID    string
	ToolName      string
	PlanID        string
	Question      string
	Purpose       string
	Answer        string
	AnsweredAtSeq int64
}

type QuestionAnsweredPayload

type QuestionAnsweredPayload struct {
	QuestionID string
	ToolCallID string
	PlanID     string
	Answer     string
}

type QuestionRequestState

type QuestionRequestState struct {
	QuestionID     string
	TurnID         string
	ToolCallID     string
	ToolName       string
	PlanID         string
	Question       string
	Options        []string
	Multiple       bool
	Purpose        string
	RequestedAtSeq int64
}

type QuestionRequestedPayload

type QuestionRequestedPayload struct {
	QuestionID string
	ToolCallID string
	ToolName   string
	PlanID     string
	Question   string
	Options    []string
	Multiple   bool
	Purpose    string
}

type ReasoningDeltaPayload

type ReasoningDeltaPayload struct {
	Content   string
	SegmentID string
}

type ReplayStore

type ReplayStore interface {
	Appender
	WatchStore
	Replay(context.Context, Query) ([]Event, error)
	Latest(context.Context, LatestQuery) (Event, bool, error)
}

type ReviewFindingPayload

type ReviewFindingPayload struct {
	Severity    string `json:"severity"`
	Path        string `json:"path"`
	Line        int    `json:"line"`
	Title       string `json:"title"`
	Explanation string `json:"explanation"`
}

type ReviewFindingState

type ReviewFindingState struct {
	Severity    string
	Path        string
	Line        int
	Title       string
	Explanation string
}

type ReviewRecordedPayload

type ReviewRecordedPayload struct {
	ReviewID           string                 `json:"review_id,omitempty"`
	SourceHandoffID    string                 `json:"source_handoff_id,omitempty"`
	Title              string                 `json:"title"`
	Findings           []ReviewFindingPayload `json:"findings"`
	OverallCorrectness string                 `json:"overall_correctness"`
	OverallSummary     string                 `json:"overall_summary"`
}

type ReviewState

type ReviewState struct {
	ReviewID           string
	SourceHandoffID    string
	Title              string
	Findings           []ReviewFindingState
	OverallCorrectness string
	OverallSummary     string
}

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(path string) (*SQLiteStore, error)

func (*SQLiteStore) Append

func (s *SQLiteStore) Append(ctx context.Context, draft Draft) (Event, error)

func (*SQLiteStore) AppendBackgroundLogChunk

func (s *SQLiteStore) AppendBackgroundLogChunk(ctx context.Context, ref string, chunk []byte) error

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) CreateBackgroundLog

func (s *SQLiteStore) CreateBackgroundLog(ctx context.Context, ref, sessionID, turnID, executionID string) error

func (*SQLiteStore) DeleteSession

func (s *SQLiteStore) DeleteSession(ctx context.Context, sessionID string) error

func (*SQLiteStore) Latest

func (s *SQLiteStore) Latest(ctx context.Context, query LatestQuery) (Event, bool, error)

func (*SQLiteStore) LatestWorkspaceSessionID

func (s *SQLiteStore) LatestWorkspaceSessionID(ctx context.Context, workspaceRoot string) (string, bool, error)

func (*SQLiteStore) ListSessions

func (s *SQLiteStore) ListSessions(ctx context.Context) ([]SessionIndexEntry, error)

func (*SQLiteStore) ListWorkspaceSessions

func (s *SQLiteStore) ListWorkspaceSessions(ctx context.Context, workspaceRoot string) ([]SessionIndexEntry, error)

func (*SQLiteStore) LoadToolResultBlob

func (s *SQLiteStore) LoadToolResultBlob(ctx context.Context, ref string) (string, error)

func (*SQLiteStore) PurgeArtifactsBefore

func (s *SQLiteStore) PurgeArtifactsBefore(ctx context.Context, cutoff time.Time) (ArtifactPurgeResult, error)

func (*SQLiteStore) ReadBackgroundLogFrom

func (s *SQLiteStore) ReadBackgroundLogFrom(ctx context.Context, ref string, offset int64, limit int) (string, int64, error)

func (*SQLiteStore) ReadBackgroundLogPrefix

func (s *SQLiteStore) ReadBackgroundLogPrefix(ctx context.Context, ref string, limit int) (string, int64, error)

func (*SQLiteStore) ReadBackgroundLogTail

func (s *SQLiteStore) ReadBackgroundLogTail(ctx context.Context, ref string, limit int) (string, int64, error)

func (*SQLiteStore) Replay

func (s *SQLiteStore) Replay(ctx context.Context, query Query) ([]Event, error)

func (*SQLiteStore) SaveToolResultBlob

func (s *SQLiteStore) SaveToolResultBlob(
	ctx context.Context,
	ref string,
	sessionID string,
	turnID string,
	callID string,
	stream string,
	text string,
) (*ToolResultBlobRef, error)

func (*SQLiteStore) Watch

func (s *SQLiteStore) Watch(ctx context.Context, query Query) (<-chan Event, error)

type SessionConfiguredPayload

type SessionConfiguredPayload struct {
	WorkspaceRoot            string
	AdditionalWorkspaceRoots []string
	PermissionMode           string
}

type SessionGrantDecisionSource

type SessionGrantDecisionSource string
const (
	SessionGrantDecisionSourcePermission        SessionGrantDecisionSource = "permission"
	SessionGrantDecisionSourceExecutionApproval SessionGrantDecisionSource = "execution_approval"
)

type SessionGrantDecisionState

type SessionGrantDecisionState struct {
	Source           SessionGrantDecisionSource
	PermissionKind   PermissionRequestKind
	ToolName         string
	Command          string
	Path             string
	WorkingDirectory string
	ResolvedAtSeq    int64
}

type SessionHistoryAnthropicThinkingPayload

type SessionHistoryAnthropicThinkingPayload struct {
	Type      string
	Thinking  string
	Signature string
	Data      string
}

type SessionHistoryAssistantEntryPayload

type SessionHistoryAssistantEntryPayload struct {
	Content string
	Reused  bool
}

type SessionHistoryAttachmentPayload

type SessionHistoryAttachmentPayload struct {
	Name     string
	MIMEType string
	DataURL  string
}

type SessionHistoryCheckpointPayload

type SessionHistoryCheckpointPayload struct {
	ThroughSequence  int64
	Continuation     *SessionHistoryContinuationUpdatedPayload
	CompletedTurnIDs []string
	Turns            []SessionHistoryTurnPayload
}

type SessionHistoryContinuationUpdatedPayload

type SessionHistoryContinuationUpdatedPayload struct {
	EventVersion               int                            `json:"event_version"`
	ArtifactVersion            int                            `json:"artifact_version"`
	RendererVersion            int                            `json:"renderer_version"`
	FrontierTurnID             string                         `json:"frontier_turn_id,omitempty"`
	ConsolidatedTurnCount      int                            `json:"consolidated_turn_count"`
	NewlyConsolidatedTurnCount int                            `json:"newly_consolidated_turn_count"`
	UpdateReason               string                         `json:"update_reason"`
	ActivityText               string                         `json:"activity_text,omitempty"`
	Artifact                   HistoryContinuationArtifact    `json:"artifact"`
	RenderedSummary            string                         `json:"rendered_summary"`
	InputBudget                *HistoryInputBudgetPayload     `json:"input_budget,omitempty"`
	Attribution                HistoryContinuationAttribution `json:"attribution"`
}

func (SessionHistoryContinuationUpdatedPayload) MarshalJSON

func (*SessionHistoryContinuationUpdatedPayload) UnmarshalJSON

func (p *SessionHistoryContinuationUpdatedPayload) UnmarshalJSON(data []byte) error

type SessionHistoryEntryPayload

type SessionHistoryEntryPayload struct {
	Kind  string
	Index int
}

type SessionHistoryExecutionPayload

type SessionHistoryExecutionPayload struct {
	CallID           string
	ToolName         string
	Intent           string
	Effect           string
	CommandPreview   string
	WorkingDirectory string
}

type SessionHistoryOpenAIReasoningPayload

type SessionHistoryOpenAIReasoningPayload struct {
	Item json.RawMessage
}

type SessionHistoryRuntimeNotePayload

type SessionHistoryRuntimeNotePayload struct {
	Sequence int64
	Content  string
}

type SessionHistoryToolCallPayload

type SessionHistoryToolCallPayload struct {
	CallID                 string
	ToolName               string
	ToolKind               string
	Arguments              string
	GoogleThoughtSignature []byte
	OpenAIReasoningContent string
}

type SessionHistoryToolResultPayload

type SessionHistoryToolResultPayload struct {
	CallID              string
	ToolName            string
	ToolKind            string
	ReusedFromCallID    string
	ReusedFromSessionID string
	ReusedFromTurnID    string
	RetryOfCallID       string
	Succeeded           bool
	Output              string
	Error               string
	StructuredResult    json.RawMessage
	OutputBlob          *ToolResultBlobRef
	ErrorBlob           *ToolResultBlobRef
}

func (SessionHistoryToolResultPayload) Successful

func (p SessionHistoryToolResultPayload) Successful() bool

type SessionHistoryTurnPayload

type SessionHistoryTurnPayload struct {
	TurnID              string
	UserText            string
	UserAttachments     []SessionHistoryAttachmentPayload
	AssistantText       string
	ReasoningText       string
	WorkspacePaths      []string
	RuntimeNotes        []SessionHistoryRuntimeNotePayload
	AssistantEntries    []SessionHistoryAssistantEntryPayload
	AnthropicThinking   []SessionHistoryAnthropicThinkingPayload
	OpenAIReasoning     []SessionHistoryOpenAIReasoningPayload
	ToolCalls           []SessionHistoryToolCallPayload
	ToolResults         []SessionHistoryToolResultPayload
	Executions          []SessionHistoryExecutionPayload
	EntryOrder          []SessionHistoryEntryPayload
	ToolCallCount       int
	TerminalStatus      string
	TerminalSequence    int64
	TerminalError       string
	TerminalRetryable   bool
	SuccessfulToolCalls int
	FailedToolCalls     int
	ToolNames           []string
	FailedToolNames     []string
}

type SessionIndexEntry

type SessionIndexEntry struct {
	SessionID     string
	WorkspaceRoot string
	UpdatedAt     time.Time
}

type SessionMCPCatalogUpdatedPayload

type SessionMCPCatalogUpdatedPayload struct {
	WorkspaceTrusted bool
	Servers          []SessionMCPServerPayload
	Tools            []SessionMCPToolPayload
}

type SessionMCPServerPayload

type SessionMCPServerPayload struct {
	Name        string
	Type        string
	Fingerprint string
	Trusted     bool
	Active      bool
}

type SessionMCPState

type SessionMCPState struct {
	WorkspaceTrusted bool
	Servers          []SessionMCPServerPayload
	Tools            []SessionMCPToolPayload
}

type SessionMCPToolPayload

type SessionMCPToolPayload struct {
	Name        string
	Description string
	InputSchema string
	ServerName  string
	RemoteName  string
}

type SessionModelRouteUpdatedPayload

type SessionModelRouteUpdatedPayload struct {
	Model string
}

type SessionPermissionModeUpdatedPayload

type SessionPermissionModeUpdatedPayload struct {
	PermissionMode string
}

type SessionProviderLimitUpdatedPayload

type SessionProviderLimitUpdatedPayload struct {
	ProviderRequestLimitDisabled bool `json:"provider_request_limit_disabled"`
}

type SessionState

type SessionState struct {
	SessionID                    string
	WorkspaceRoot                string
	AdditionalWorkspaceRoots     []string
	PermissionMode               string
	ProviderRequestLimitDisabled bool
	MCP                          *SessionMCPState
	Model                        string
	Title                        string
	SessionGrantDecisions        []SessionGrantDecisionState
	WorkspaceGrants              []WorkspaceGrantState
	ExecutionGrants              []ExecutionGrantState
	NetworkGrants                []NetworkGrantState
	TaskOrder                    []string
	Tasks                        map[string]*TaskState
	ReviewOrder                  []string
	Reviews                      map[string]*ReviewState
	PlanOrder                    []string
	Plans                        map[string]*PlanState
	ApprovedExecutions           map[string]*ApprovedExecutionState
	PendingExecutionOrder        []string
	PendingExecutions            map[string]*ExecutionApprovalState
	PendingPermissionOrder       []string
	PendingPermissions           map[string]*PermissionRequestState
	PendingQuestionOrder         []string
	PendingQuestions             map[string]*QuestionRequestState
	QuestionAnswers              map[string]*QuestionAnswerState
	LastSequence                 int64
	TurnOrder                    []string
	Turns                        map[string]*TurnState
}

func SnapshotSessionState

func SnapshotSessionState(state SessionState) SessionState

type SessionStateSnapshotPayload

type SessionStateSnapshotPayload struct {
	BaseSequence int64
	State        SessionState
}

type SessionTitleUpdatedPayload

type SessionTitleUpdatedPayload struct {
	Title string
}

type SessionWorkspaceRootsAddedPayload

type SessionWorkspaceRootsAddedPayload struct {
	WorkspaceRoots []string
}

type TaskBlockedPayload

type TaskBlockedPayload struct {
	TaskID      string `json:"task_id"`
	BlockReason string `json:"block_reason"`
	Notes       string `json:"notes"`
}

type TaskCompletedPayload

type TaskCompletedPayload struct {
	TaskID  string `json:"task_id"`
	Summary string `json:"summary"`
}

type TaskCreatedPayload

type TaskCreatedPayload struct {
	TaskID       string `json:"task_id"`
	ParentTaskID string `json:"parent_task_id"`
	Title        string `json:"title"`
	Kind         string `json:"kind"`
	Status       string `json:"status"`
	Notes        string `json:"notes"`
}

type TaskProgressUpdatedPayload

type TaskProgressUpdatedPayload struct {
	TaskID   string `json:"task_id"`
	Status   string `json:"status"`
	Progress string `json:"progress"`
	Notes    string `json:"notes"`
}

type TaskReviewedPayload

type TaskReviewedPayload struct {
	TaskID        string `json:"task_id"`
	ReviewStatus  string `json:"review_status"`
	ReviewSummary string `json:"review_summary"`
}

type TaskState

type TaskState struct {
	TaskID         string
	ParentTaskID   string
	Title          string
	Kind           string
	Status         string
	Notes          string
	Progress       string
	BlockReason    string
	ReviewStatus   string
	ReviewSummary  string
	CreatedAtSeq   int64
	UpdatedAtSeq   int64
	CompletedAtSeq int64
}

type ToolCallBatchPayload

type ToolCallBatchPayload struct {
	CallIDs []string
}

type ToolCallBatchState

type ToolCallBatchState struct {
	CallIDs  []string
	Sequence int64
}

type ToolCallDeclaredPayload

type ToolCallDeclaredPayload struct {
	CallID                 string
	ToolName               string
	ToolKind               string
	Input                  string
	GoogleThoughtSignature []byte
	OpenAIReasoningContent string
}

type ToolCallDeltaPayload

type ToolCallDeltaPayload struct {
	CallID     string
	ToolName   string
	ToolKind   string
	InputDelta string
}

type ToolCallState

type ToolCallState struct {
	CallID              string
	ToolName            string
	ReusedFromCallID    string
	ReusedFromSessionID string
	ReusedFromTurnID    string
	RetryOfCallID       string
	HandoffID           string
	Execution           *ExecutionState
	Runtime             *ToolExecRuntimeState
	FailureClass        string
	Succeeded           bool
	Input               string
	Output              string
	Error               string
	ErrorDetail         *ToolErrorDetail
	StructuredResult    json.RawMessage
	MutationRanges      []MutationRange
	WriteMutation       *WriteMutation
	WriteMutations      []WriteMutation
	ObservedResources   []ObservedResource
	OutputBlob          *ToolResultBlobRef
	ErrorBlob           *ToolResultBlobRef
	OutputTruncated     bool
	ErrorTruncated      bool
	Declared            bool
	Executing           bool
	Completed           bool
	LastUpdatedSeq      int64
}

type ToolErrorDetail

type ToolErrorDetail struct {
	Code      string
	Message   string
	Retryable bool
	Recovery  string
	Fields    map[string]string
}

type ToolExecEndPayload

type ToolExecEndPayload struct {
	CallID              string
	ToolName            string
	ToolKind            string
	ReusedFromCallID    string
	ReusedFromSessionID string
	ReusedFromTurnID    string
	RetryOfCallID       string
	HandoffID           string
	ExecutionID         string
	ExecutionStatus     string
	FailureClass        string
	Succeeded           bool
	Output              string
	Error               string
	ErrorDetail         *ToolErrorDetail
	StructuredResult    json.RawMessage
	MutationRanges      []MutationRange
	WriteMutation       *WriteMutation
	WriteMutations      []WriteMutation
	ObservedResources   []ObservedResource
	OutputBlob          *ToolResultBlobRef
	ErrorBlob           *ToolResultBlobRef
	OutputTruncated     bool
	ErrorTruncated      bool
	ExitCode            *int
	DurationMS          int64
	CommandActions      []string
	Backend             string
}

func (ToolExecEndPayload) Successful

func (p ToolExecEndPayload) Successful() bool

type ToolExecOutputPayload

type ToolExecOutputPayload struct {
	CallID string
	Chunk  string
	Stream string
}

type ToolExecRuntimeState

type ToolExecRuntimeState struct {
	Backend string
}

type ToolExecStartPayload

type ToolExecStartPayload struct {
	CallID   string
	ToolName string
	ToolKind string
	Input    string
}

type ToolResultBlobRef

type ToolResultBlobRef struct {
	Ref   string
	Bytes int
}

type TranscriptEntryKind

type TranscriptEntryKind string
const (
	TranscriptEntryUser       TranscriptEntryKind = "user"
	TranscriptEntryAssistant  TranscriptEntryKind = "assistant"
	TranscriptEntryReview     TranscriptEntryKind = "review"
	TranscriptEntryWorklog    TranscriptEntryKind = "worklog"
	TranscriptEntryCompaction TranscriptEntryKind = "compaction"
	TranscriptEntryReasoning  TranscriptEntryKind = "reasoning"
	TranscriptEntryTool       TranscriptEntryKind = "tool"
	TranscriptEntryError      TranscriptEntryKind = "error"
)

type TranscriptEntryState

type TranscriptEntryState struct {
	Kind      TranscriptEntryKind
	Sequence  int64
	Text      string
	CallID    string
	SegmentID string
}

type TurnCanceledPayload

type TurnCanceledPayload struct {
	Message string
}

type TurnConfigState

type TurnConfigState struct {
	AgentID                   string
	SkillIDs                  []string
	SelectedSkillIDs          []string
	Model                     string
	PreserveSessionModel      bool
	ThinkingEnabled           bool
	ThinkingMode              string
	ResponseStyle             string
	AllowedTools              []string
	SupportsReasoningVariants bool
	SupportsThinkingOutput    bool
	HideAssistantPreview      bool
}

type TurnConfiguredPayload

type TurnConfiguredPayload struct {
	AgentID                   string
	SkillIDs                  []string
	SelectedSkillIDs          []string
	Model                     string
	PreserveSessionModel      bool
	ThinkingEnabled           bool
	ThinkingMode              string
	ResponseStyle             string
	AllowedTools              []string
	SupportsReasoningVariants bool
	SupportsThinkingOutput    bool
	HideAssistantPreview      bool
}

type TurnContextUsageState

type TurnContextUsageState struct {
	Tokens int
	Limit  int
	Source string
}

func DisplayTurnContextUsage

func DisplayTurnContextUsage(turn *TurnState) (TurnContextUsageState, bool)

type TurnContinuationStartedPayload

type TurnContinuationStartedPayload struct {
	PreviousTurnID string
	Reason         string
	Summary        TurnWorkStateSummaryPayload
}

type TurnContinuationState

type TurnContinuationState struct {
	PreviousTurnID string
	Reason         string
	Summary        TurnWorkStateSummaryState
}

type TurnDonePayload

type TurnDonePayload struct{}

type TurnErrorPayload

type TurnErrorPayload struct {
	Message   string
	Retryable bool
	Code      TurnFailureCode
}

type TurnFailureCode

type TurnFailureCode string
const (
	TurnFailureCodeUnknown              TurnFailureCode = ""
	TurnFailureCodeProviderRequestLimit TurnFailureCode = "provider_request_limit"
	TurnFailureCodeNoProgress           TurnFailureCode = "no_progress"
	TurnFailureCodeBudgetExceeded       TurnFailureCode = "budget_exceeded"
)

type TurnNativeContinuationPayload

type TurnNativeContinuationPayload struct {
	Contract string
	Slice    SessionHistoryTurnPayload
}

type TurnNativeContinuationState

type TurnNativeContinuationState struct {
	Contract string
	Slice    SessionHistoryTurnPayload
}

type TurnProviderAttemptState

type TurnProviderAttemptState struct {
	Model                             string
	Kind                              string
	RequestedModel                    string
	Step                              int
	Attempt                           int
	DurationMillis                    int
	RequestStarted                    bool
	RequestAPIMode                    string
	RequestParallelToolCalls          bool
	RouteAttempts                     []TurnProviderRouteAttemptState
	RequestTokens                     int
	PromptTokens                      int
	ConversationTokens                int
	ToolNameTokens                    int
	ToolDescriptionTokens             int
	ToolSchemaTokens                  int
	PromptCompactionTokensSaved       int
	HistoryCompactionTokensSaved      int
	CurrentTurnProjectionTokensSaved  int
	ToolDescriptionTokensSaved        int
	ToolSchemaTokensSaved             int
	DeterministicContextTokens        int
	DeterministicContextOmittedTokens int
	EstimatedInputSavingsCost         float64
	ToolCount                         int
	RequestTokenSource                string
	InputLimitTokens                  int
	CompletionTokens                  int
	EstimatedInputCost                float64
	EstimatedOutputCost               float64
	Error                             string
	Retryable                         bool
	RetrySkippedReason                string
	FinishReason                      string
	DurableProgress                   bool
	ExecutedTools                     int
	ReusedTools                       int
	ReportedModel                     string
	ReportedRequestID                 string
	ReportedInputTokens               int
	ReportedCacheReadInputTokens      int
	ReportedCacheWriteInputTokens     int
	ReportedOutputTokens              int
	ReportedReasoningTokens           int
	ReportedTotalTokens               int
	EstimatedCacheSavingsCost         float64
	CachePricingApplied               bool
	CachePricingMissing               bool
}

func LatestAgentProviderAttempt

func LatestAgentProviderAttempt(turn *TurnState) *TurnProviderAttemptState

type TurnProviderReportedUsageState

type TurnProviderReportedUsageState struct {
	Model                     string
	RequestID                 string
	Steps                     int
	Attempts                  int
	InputTokens               int
	CacheReadInputTokens      int
	CacheWriteInputTokens     int
	OutputTokens              int
	ReasoningTokens           int
	TotalTokens               int
	EstimatedCacheSavingsCost float64
	CachePricingApplied       bool
	CachePricingMissing       bool
}

type TurnProviderRouteAttemptPayload

type TurnProviderRouteAttemptPayload struct {
	Model    string
	Selected bool
	Error    string
}

type TurnProviderRouteAttemptState

type TurnProviderRouteAttemptState struct {
	Model    string
	Selected bool
	Error    string
}

type TurnProviderUsageKind

type TurnProviderUsageKind string
const (
	TurnProviderUsageKindAgent             TurnProviderUsageKind = "agent"
	TurnProviderUsageKindUtilityCompaction TurnProviderUsageKind = "utility_compaction"
)

type TurnProviderUsageRecordedPayload

type TurnProviderUsageRecordedPayload struct {
	Model                                      string
	Kind                                       string
	RequestedModel                             string
	Step                                       int
	Attempt                                    int
	DurationMillis                             int
	RequestStarted                             bool
	RequestAPIMode                             string
	RequestParallelToolCalls                   bool
	RouteAttempts                              []TurnProviderRouteAttemptPayload
	EstimatedRequestTokens                     int
	EstimatedPromptTokens                      int
	EstimatedConversationTokens                int
	EstimatedToolNameTokens                    int
	EstimatedToolDescriptionTokens             int
	EstimatedToolSchemaTokens                  int
	EstimatedPromptCompactionTokensSaved       int
	EstimatedHistoryCompactionTokensSaved      int
	EstimatedCurrentTurnProjectionTokensSaved  int
	EstimatedToolDescriptionTokensSaved        int
	EstimatedToolSchemaTokensSaved             int
	EstimatedDeterministicContextTokens        int
	EstimatedDeterministicContextOmittedTokens int
	EstimatedInputSavingsCost                  float64
	ToolCount                                  int
	RequestTokenSource                         string
	InputLimitTokens                           int
	EstimatedCompletionTokens                  int
	EstimatedInputCost                         float64
	EstimatedOutputCost                        float64
	Error                                      string
	Retryable                                  bool
	RetrySkippedReason                         string
	FinishReason                               string
	DurableProgress                            bool
	ExecutedTools                              int
	ReusedTools                                int
}

type TurnProviderUsageReportedPayload

type TurnProviderUsageReportedPayload struct {
	Model                     string
	Kind                      string
	RequestID                 string
	Step                      int
	Attempt                   int
	InputTokens               int
	CacheReadInputTokens      int
	CacheWriteInputTokens     int
	OutputTokens              int
	ReasoningTokens           int
	TotalTokens               int
	EstimatedInputCost        float64
	EstimatedOutputCost       float64
	EstimatedCacheSavingsCost float64
	CachePricingApplied       bool
	CachePricingMissing       bool
}

type TurnProviderUsageState

type TurnProviderUsageState struct {
	Model               string
	Steps               int
	Attempts            int
	RequestTokens       int
	CompletionTokens    int
	EstimatedInputCost  float64
	EstimatedOutputCost float64
}

type TurnRetryScheduledPayload

type TurnRetryScheduledPayload struct {
	Message     string
	Attempt     int
	MaxAttempts int
	RetryAt     time.Time
}

type TurnRetryState

type TurnRetryState struct {
	Message     string
	Attempt     int
	MaxAttempts int
	RetryAt     time.Time
}

type TurnState

type TurnState struct {
	TurnID                string
	Status                TurnStatus
	UserText              string
	UserAttachments       []UserAttachmentPayload
	Config                *TurnConfigState
	ContinuationStart     *TurnContinuationState
	Prompt                *PromptState
	Pruning               *PruningState
	CompactionAttempt     *CompactionAttemptState
	CompactionFailure     *CompactionFailureState
	HistoryCompactionUI   *HistoryCompactionUIState
	Continuation          *HistoryContinuationState
	ContextUsage          *TurnContextUsageState
	Handoffs              map[string]*AgentHandoffState
	HandoffOrder          []string
	AssistantText         string
	StreamingText         string
	ReasoningText         string
	Retry                 *TurnRetryState
	ProviderUsage         *TurnProviderUsageState
	ProviderReportedUsage *TurnProviderReportedUsageState
	ProviderAttempts      []TurnProviderAttemptState
	Review                *ReviewState
	WorkState             *TurnWorkState
	Error                 string
	ErrorCode             TurnFailureCode
	ErrorRetryable        bool
	Transcript            []TranscriptEntryState
	ToolCallBatches       []ToolCallBatchState
	ToolCallOrder         []string
	ToolCalls             map[string]*ToolCallState
	CompletedAtSeq        int64
	LastUpdatedAtSeq      int64
}

type TurnStatus

type TurnStatus string
const (
	TurnStatusRunning   TurnStatus = "running"
	TurnStatusCompleted TurnStatus = "completed"
	TurnStatusCanceled  TurnStatus = "canceled"
	TurnStatusFailed    TurnStatus = "failed"
)

type TurnWorkState

type TurnWorkState struct {
	Summary            TurnWorkStateSummaryState
	NativeContinuation *TurnNativeContinuationState
}

type TurnWorkStateSummaryPayload

type TurnWorkStateSummaryPayload struct {
	Objective     string
	Decisions     []string
	TouchedPaths  []string
	CompletedWork []string
	Verification  []string
	Failures      []string
	OpenItems     []string
}

type TurnWorkStateSummaryState

type TurnWorkStateSummaryState struct {
	Objective     string
	Decisions     []string
	TouchedPaths  []string
	CompletedWork []string
	Verification  []string
	Failures      []string
	OpenItems     []string
}

type TurnWorkStateUpdatedPayload

type TurnWorkStateUpdatedPayload struct {
	Summary            TurnWorkStateSummaryPayload
	NativeContinuation *TurnNativeContinuationPayload
}

type Type

type Type string
const (
	TypeUserMessage   Type = "user_message"
	TypeContextPruned Type = "context_pruned"
)
const (
	TypeSessionConfigured            Type = "session_configured"
	TypeSessionModelRouteUpdated     Type = "session_model_route_updated"
	TypeSessionWorkspaceRootsAdded   Type = "session_workspace_roots_added"
	TypeSessionPermissionModeUpdated Type = "session_permission_mode_updated"
	TypeSessionMCPCatalogUpdated     Type = "session_mcp_catalog_updated"
	TypeSessionProviderLimitUpdated  Type = "session_provider_limit_updated"
	TypeSessionStateSnapshot         Type = "session_state_snapshot"
	TypeAssistantPreviewDelta        Type = "assistant_preview_delta"
	TypeAssistantPreviewReset        Type = "assistant_preview_reset"
	TypeAssistantWorklogCommit       Type = "assistant_worklog_commit"
	TypeAssistantCommit              Type = "assistant_commit"
	TypeReasoningDelta               Type = "reasoning_delta"
	TypeAnthropicThinkingCommitted   Type = "anthropic_thinking_committed"
	TypeOpenAIReasoningCommitted     Type = "openai_reasoning_committed"
	TypeToolCallDelta                Type = "tool_call_delta"
	TypeToolCallDeclared             Type = "tool_call_declared"
	TypeToolCallBatch                Type = "tool_call_batch"
	TypeToolExecStart                Type = "tool_exec_start"
	TypeToolExecOutput               Type = "tool_exec_output"
	TypeToolExecEnd                  Type = "tool_exec_end"
	TypeExecutionDeclared            Type = "execution_declared"
	TypeExecutionApprovalRequested   Type = "execution_approval_requested"
	TypeExecutionApprovalResolved    Type = "execution_approval_resolved"
	TypeExecutionStarted             Type = "execution_started"
	TypeExecutionOutput              Type = "execution_output"
	TypeExecutionBackgroundStarted   Type = "execution_background_started"
	TypeExecutionBackgroundObserved  Type = "execution_background_observed"
	TypeExecutionBackgroundReady     Type = "execution_background_ready"
	TypeExecutionBackgroundExited    Type = "execution_background_exited"
	TypeExecutionBackgroundLost      Type = "execution_background_lost"
	TypePermissionRequested          Type = "permission_requested"
	TypePermissionResolved           Type = "permission_resolved"
	TypeQuestionRequested            Type = "question_requested"
	TypeQuestionAnswered             Type = "question_answered"
	TypeTurnConfigured               Type = "turn_configured"
	TypeTurnContinuationStarted      Type = "turn_continuation_started"
	TypeTurnWorkStateUpdated         Type = "turn_work_state_updated"
	TypeSessionHistoryCheckpoint     Type = "session_history_checkpoint"
	TypeContextCompactionStarted     Type = "context_compaction_started"
	TypeContextCompactionFailed      Type = "context_compaction_failed"
	TypeTurnProviderUsageRecorded    Type = "turn_provider_usage_recorded"
	TypeTurnProviderUsageReported    Type = "turn_provider_usage_reported"
	TypeTurnRetryScheduled           Type = "turn_retry_scheduled"
	TypeReviewRecorded               Type = "review_recorded"
	TypePlanRecorded                 Type = "plan_recorded"
	TypeTurnDone                     Type = "turn_done"
	TypeTurnCanceled                 Type = "turn_canceled"
	TypeTurnError                    Type = "turn_error"
)
const (
	TypeTaskCreated         Type = "task_created"
	TypeTaskProgressUpdated Type = "task_progress_updated"
	TypeTaskBlocked         Type = "task_blocked"
	TypeTaskCompleted       Type = "task_completed"
	TypeTaskReviewed        Type = "task_reviewed"
)
const TypeAgentHandoff Type = "agent_handoff"
const TypeAgentHandoffPreview Type = "agent_handoff_preview"
const TypeAgentResult Type = "agent_result"
const TypeAgentResultReused Type = "agent_result_reused"
const TypePromptCompiled Type = "prompt_compiled"
const TypeSessionHistoryContinuationUpdated Type = "session_history_continuation_updated"
const TypeSessionTitleUpdated Type = "session_title_updated"
const TypeWorkspaceWriteRestored Type = "workspace_write_restored"

type UserAttachmentPayload

type UserAttachmentPayload struct {
	Name     string `json:"name"`
	MIMEType string `json:"mime_type"`
	DataURL  string `json:"data_url"`
}

type UserMessagePayload

type UserMessagePayload struct {
	Content     string
	Attachments []UserAttachmentPayload `json:"attachments,omitempty"`
}

type WatchStore

type WatchStore interface {
	Watch(context.Context, Query) (<-chan Event, error)
}

type WorkspaceGrantState

type WorkspaceGrantState struct {
	Path      string
	Recursive bool
}

type WorkspaceWriteRestoreItem

type WorkspaceWriteRestoreItem struct {
	CallID        string `json:"call_id,omitempty"`
	Path          string `json:"path,omitempty"`
	ExistedBefore bool   `json:"existed_before,omitempty"`
}

type WorkspaceWriteRestoredPayload

type WorkspaceWriteRestoredPayload struct {
	SourceTurnID string                      `json:"source_turn_id,omitempty"`
	Restores     []WorkspaceWriteRestoreItem `json:"restores,omitempty"`
}

type WriteMutation

type WriteMutation struct {
	Path            string             `json:"path,omitempty"`
	Existed         bool               `json:"existed,omitempty"`
	Before          string             `json:"before,omitempty"`
	BeforeBlob      *ToolResultBlobRef `json:"before_blob,omitempty"`
	BeforeTruncated bool               `json:"before_truncated,omitempty"`
	DiffPreview     *textdiff.Preview  `json:"diff_preview,omitempty"`
	Mode            uint32             `json:"mode,omitempty"`
}

Jump to

Keyboard shortcuts

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