Documentation
¶
Overview ¶
Package compact converts full.jsonl transcripts into a normalized, compact transcript.jsonl format. Only shared formatting is contained here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compact ¶
func Compact(redacted redact.RedactedBytes, opts MetadataFields) ([]byte, error)
Compact converts a full.jsonl transcript into the condensed transcript.jsonl format. The input must be pre-redacted (via redact.JSONLBytes or redact.AlreadyRedacted for trusted sources).
The output format puts version, agent, and cli_version on every line, merges streaming assistant fragments with the same message ID, and inlines tool results into the preceding assistant's tool_use blocks:
{"v":1,"agent":"claude-code","cli_version":"0.42.0","type":"user","ts":"...","content":"..."}
{"v":1,"agent":"claude-code","cli_version":"0.42.0","type":"assistant","ts":"...","id":"msg_xxx","content":[{"type":"text","text":"..."},{"type":"tool_use","id":"...","name":"...","input":{...},"result":{"output":"...","status":"..."}}]}
Types ¶
type CondensedEntry ¶
func BuildCondensedEntries ¶
func BuildCondensedEntries(content []byte) ([]CondensedEntry, error)
type MetadataFields ¶
type MetadataFields struct {
Agent string // e.g. "claude-code"
CLIVersion string // e.g. "0.42.0"
StartLine int // checkpoint_transcript_start (0 = no truncation)
}
MetadataFields provides metadata fields written to every output line.
type OTelSpan ¶
type OTelSpan struct {
Name string // gen_ai.completion (assistant) or gen_ai.user (user)
Attributes map[string]interface{} // OTel span attributes keyed by gen_ai.* names
}
OTelSpan represents an OpenTelemetry span derived from a compact transcript line. The attributes use gen_ai.* semantic convention names as defined by the OpenTelemetry Gen AI semantic conventions.
func TranscriptToOTelSpan ¶
func TranscriptToOTelSpan(line transcriptLine) OTelSpan
TranscriptToOTelSpan converts a parsed transcript line into an OTel span representation with gen_ai.* semantic convention attributes.
Attribute mapping:
- gen_ai.usage.input_tokens <- InputTokens
- gen_ai.usage.output_tokens <- OutputTokens
- gen_ai.request.model <- Model
- gen_ai.system <- Provider
- gen_ai.operation.name <- Type ("user" or "assistant")
- gen_ai.agent.name <- Agent
- gen_ai.completion.id <- ID