types

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 0 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SkillEventTypePromptInvocation = "prompt_invocation"
	SkillEventTypeToolInvocation   = "tool_invocation"
)

Skill event types recorded in checkpoint metadata.

View Source
const (
	SkillSignalPiInputSlashCommand = "input_slash_command"
	SkillSignalPromptSlashCommand  = "prompt_slash_command"
	SkillSignalClaudeSkillToolUse  = "skill_tool_use"
)

Skill event source signals.

View Source
const (
	SkillCollapseTargetUserMessage = "user_message"
	SkillCollapseTargetToolPair    = "tool_pair"
)

Skill event collapse targets.

View Source
const MaxSubagentDepth = 16

MaxSubagentDepth caps how deep a SubagentTokens chain is walked. Real chains are depth 1 — an agent reports one aggregate for all its subagents — so this is insurance against a malformed or hostile chain, not a real limit.

It matters because token usage is read back from per-session metadata.json blobs on the shared checkpoint branch, which anyone with push access can author. The depth is not a stack-overflow risk (encoding/json caps nesting at 10000), but an unbounded chain reaching the root CheckpointSummary is a write amplification vector: the summary is re-marshalled with indentation, which is O(depth²) in output size, so a ~10k-deep chain in a 200KB session blob expands to a ~700MB root blob that then gets written and pushed.

View Source
const (
	SkillConfidenceExplicit = "explicit"
)

Skill event confidence values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentName

type AgentName string

AgentName is the registry key type for agents (e.g., "claude-code", "gemini").

type AgentType

type AgentType string

AgentType is the display name type stored in metadata/trailers (e.g., "Claude Code", "Gemini CLI").

type SkillEvent added in v0.7.8

type SkillEvent struct {
	ID        string           `json:"id,omitempty"`
	EventType string           `json:"event_type"`
	Skill     SkillEventSkill  `json:"skill"`
	Source    SkillEventSource `json:"source"`

	TurnID    string `json:"turn_id,omitempty"`
	Timestamp string `json:"timestamp,omitempty"`

	TranscriptAnchor *SkillEventTranscriptAnchor `json:"transcript_anchor,omitempty"`
	Native           map[string]string           `json:"native,omitempty"`
	Collapse         SkillEventCollapse          `json:"collapse"`
}

SkillEvent records a native agent skill signal without rewriting the raw transcript. Consumers use TranscriptAnchor/Native to locate the underlying raw event and Collapse to decide whether/how to hide verbose skill material by default.

type SkillEventCollapse added in v0.7.8

type SkillEventCollapse struct {
	Target           string `json:"target"`
	Label            string `json:"label,omitempty"`
	DefaultCollapsed bool   `json:"default_collapsed"`
}

type SkillEventSkill added in v0.7.8

type SkillEventSkill struct {
	Name string `json:"name"`
}

type SkillEventSource added in v0.7.8

type SkillEventSource struct {
	Agent      string `json:"agent"`
	Signal     string `json:"signal"`
	Confidence string `json:"confidence"`
}

type SkillEventTranscriptAnchor added in v0.7.8

type SkillEventTranscriptAnchor struct {
	Unit      string   `json:"unit,omitempty"`
	Start     int      `json:"start,omitempty"`
	End       int      `json:"end,omitempty"`
	EntryIDs  []string `json:"entry_ids,omitempty"`
	ToolUseID string   `json:"tool_use_id,omitempty"`
}

type TokenUsage added in v0.7.8

type TokenUsage struct {
	// InputTokens is the number of input tokens (fresh, not from cache)
	InputTokens int `json:"input_tokens"`
	// CacheCreationTokens is tokens written to cache (billable at cache write rate)
	CacheCreationTokens int `json:"cache_creation_tokens"`
	// CacheReadTokens is tokens read from cache (discounted rate)
	CacheReadTokens int `json:"cache_read_tokens"`
	// OutputTokens is the number of output tokens generated
	OutputTokens int `json:"output_tokens"`
	// APICallCount is the number of API calls made
	APICallCount int `json:"api_call_count"`
	// SubagentTokens contains token usage from spawned subagents (if any)
	SubagentTokens *TokenUsage `json:"subagent_tokens,omitempty"`
}

TokenUsage represents aggregated token usage for a checkpoint. This is agent-agnostic and can be populated by any agent that tracks token usage.

func AddTokenUsage added in v0.9.0

func AddTokenUsage(a, b *TokenUsage) *TokenUsage

AddTokenUsage returns the sum of a and b, recursing into subagent usage. Either operand may be nil (treated as zero); the result is nil only when both are. Neither input is mutated. Subagent chains deeper than MaxSubagentDepth are truncated.

func SubtractTokenUsage added in v0.9.0

func SubtractTokenUsage(a, b *TokenUsage) *TokenUsage

SubtractTokenUsage returns a-b, recursing into subagent usage and clamping every field at zero (a nil operand is treated as zero). Neither input is mutated. Used to rescope a cumulative-since-session-start snapshot (e.g. subagent token usage, which is always re-read from the start of each subagent transcript) down to a delta since a previously captured baseline.

Jump to

Keyboard shortcuts

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