Documentation
¶
Overview ¶
Package claudetranscript reads Claude Code transcripts as typed, classified lines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentMeta ¶
type AgentMeta struct {
AgentType string `json:"agentType"`
Description string `json:"description"`
ToolUseID string `json:"toolUseId"`
SpawnDepth int `json:"spawnDepth"`
ParentAgentID string `json:"parentAgentId"`
Model string `json:"model"`
}
AgentMeta is `subagents/agent-<A>.meta.json`, the primary spawn link. ToolUseID names the spawning call directly.
type Attachment ¶
type Attachment struct {
Type string
Prompt string
CommandMode string
Origin json.RawMessage
Timestamp *time.Time
}
Attachment is the typed envelope payload used by queued_command.
type Block ¶
type Block struct {
Type string
Text string
// tool_use
ID string
Name string
Input json.RawMessage
// tool_result
ToolUseID string
IsError *bool
Content json.RawMessage
Raw json.RawMessage
}
Block is one element of a message's content array.
func (Block) ResultText ¶
ResultText is a tool result block's text.
type Control ¶
type Control struct {
Mode string
PermissionMode string
AITitle string
AgentName string
LeafUUID string
LastPrompt string
BridgeSessionID string
LastSequenceNum *int64
Operation string
Content string
Value json.RawMessage
}
Control is the union of the control-line payloads.
type File ¶
type File struct {
Path string
SessionID string
AgentID string
Meta *AgentMeta
Lines []Line
// TornFinalLine is true when the last line was a partial write, which happens
// while a session is still running.
TornFinalLine bool
}
File is one transcript: the main thread, or one subagent.
func DecodeSubagent ¶
DecodeSubagent reads one subagent transcript that arrived outside a session directory, under the same checks as one listed beside its parent. The caller supplies the spawn link with Meta and adds the file with AddSubagent.
type FileSources ¶
type FileSources = traceprocessing.FileSources
type Line ¶
type Line struct {
Ordinal int
Class Class
Type string
UserKind UserKind
Raw json.RawMessage
UUID string
ParentUUID string
SessionID string
AgentID string
PromptID string
RequestID string
Timestamp *time.Time
IsSidechain bool
IsMeta bool
CWD string
GitBranch string
Version string
// Subtype is the `system` line's subtype.
Subtype string
// PromptSource, Origin and ToolDenialKind appear on `user` lines. The first
// two say whether a person typed the text or the harness injected it; the
// third says why a tool was refused.
PromptSource string
Origin json.RawMessage
ToolDenialKind string
// ToolUseResult is the structured payload beside a tool result.
ToolUseResult json.RawMessage
// Message is the model message on `user` and `assistant` lines.
Message *Message
// Control carries the payload of a control line.
Control Control
// Attachment carries the small typed subset of attachment payloads.
Attachment Attachment
}
Line is one JSONL record, classified and decoded as far as the model defines.
type Message ¶
type Message struct {
ID string
Role string
Model string
StopReason *string
Usage *Usage
Content json.RawMessage
}
Message is one model message.
type ResultEvidence ¶
type ResultEvidence struct {
Present bool
Text string
Stdout string
Stderr string
Interrupted bool
ExitCode *int
FilePath string
StructuredPatch []PatchHunk
StartLine *int
NumLines *int
// AgentID names the subagent a spawn created. ResumedAgentID names the one a
// SendMessage call woke up again.
AgentID string
ResumedAgentID string
Status string
Raw json.RawMessage
}
ResultEvidence is what a tool-result line's `toolUseResult` says about the tool that ran.
func DecodeResultEvidence ¶
func DecodeResultEvidence(raw json.RawMessage) ResultEvidence
type Shape ¶
type Tree ¶
func DecodeFiles ¶
func DecodeFiles[T FileSources](fsys fs.FS, files T) (*Tree, error)
DecodeFiles decodes the explicitly listed session tree.
func DecodeLocalFiles ¶
func DecodeLocalFiles[T FileSources](files T) (*Tree, error)
DecodeLocalFiles decodes an explicitly listed set of local files.
func SingleFileTree ¶
SingleFileTree constructs the tree represented by one already-decoded main transcript.
func (*Tree) AddSubagent ¶
AddSubagent records a decoded subagent on the tree, checking it against its parent exactly as a listed one is.
func (*Tree) SubagentForToolUse ¶
SubagentForToolUse returns the transcript a tool call spawned, or nil.
type Usage ¶
type Usage struct {
InputTokens int64
OutputTokens int64
CacheCreationInputTokens int64
CacheReadInputTokens int64
// CacheWrite1h is usage.cache_creation.ephemeral_1h_input_tokens. Nil means
// the transcript did not report it (no cache_creation object, or a value
// that is not an integer).
CacheWrite1h *int64
// Speed is usage.speed verbatim ("standard", "fast"); empty when absent.
Speed string
}
Usage is the token accounting of one reply: four disjoint buckets, plus the cache-write TTL split and the service speed when the transcript reports them.