trace

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package trace defines shared types for conversation trace parsing. These types are produced by each provider's ParseTrace method and consumed by the TUI views for rendering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTurnCost

func EstimateTurnCost(model string, tokIn, tokOut int64) float64

EstimateTurnCost calculates the estimated cost for a turn based on model name and token counts, delegating to the cost package.

func EstimateTurnCostLegacy

func EstimateTurnCostLegacy(model string, tokIn, tokOut int64) float64

EstimateTurnCostLegacy uses the original heuristic-based cost estimation from the view layer. It applies rough per-million-token rates based on model name substrings. Use EstimateTurnCost for more accurate pricing.

Types

type Tailer added in v0.9.0

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

Tailer watches a JSONL file and calls onLine for each new complete line appended after the tailer starts. Uses fsnotify for immediate detection with a 1s poll fallback.

func NewTailer added in v0.9.0

func NewTailer(path string, onLine func(string)) (*Tailer, error)

NewTailer starts watching from the current end of file. Existing content is skipped. Only new appended lines trigger onLine.

func (*Tailer) Stop added in v0.9.0

func (t *Tailer) Stop()

Stop shuts down the tailer and waits for the goroutine to exit.

type ToolSpan

type ToolSpan struct {
	Name      string
	Snippet   string // short description of the input
	Success   bool   // true if tool succeeded
	ErrorMsg  string // error message if failed
	FilePath  string // for Edit/Write/Read: the file path
	OldString string // for Edit: the old text
	NewString string // for Edit: the new text
	Content   string // for Write: the file content
	ToolUseID string // for matching tool_result entries
}

ToolSpan represents a single tool call within a turn.

type Turn

type Turn struct {
	Number      int
	Timestamp   time.Time
	EndTime     time.Time // timestamp of last entry in this turn (for duration)
	UserLines   []string  // full user input text
	Actions     []ToolSpan
	OutputLines []string
	TokensIn    int64
	TokensOut   int64
	CostUSD     float64       // calculated from tokens + model
	Model       string        // model used for this turn
	Subagent    subagent.Info // subagent identity (empty for main thread)
}

Turn groups a user prompt with the assistant response into one logical unit -- the fundamental trace element for evaluation (input -> actions -> output).

func (Turn) Duration

func (t Turn) Duration() time.Duration

Duration returns the wall-clock duration of this turn.

func (Turn) ErrorCount

func (t Turn) ErrorCount() int

ErrorCount returns the number of failed tool calls in this turn.

Jump to

Keyboard shortcuts

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