transcript

package
v0.16.397 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 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

Overview

Package transcript reads the coding agents' conversation files (Claude Code and Codex jsonl) into timeline entries, the shape the conversation view draws, as the previous runtime's parsers built them: the same entries, keys in the same order, the same byte offsets; only the ids differ.

An entry id is made of the transcript's own bytes, never at random, so any read of the same bytes (the whole file, a tail, a page back, an incremental read) names an entry alike. A line's entries are numbered k = 0, 1, ... in the order they were made, and named wire.ClaudeEntryID(uuid, k) for a Claude line with a uuid, else wire.OffsetEntryID(offset, k) by the byte offset of the line in the file (every Codex line). Entries of a flush (CodexParser.FlushStale) belong to no line: they are named by the line that began their call, with k from 1000, and a re-read does not make them.

Index

Constants

This section is empty.

Variables

View Source
var MaxLineBytes = 64 << 20

parseClaude reads content, which lies in the file as at says. MaxLineBytes is the longest transcript line that is parsed. A line is decoded into a tree several times its size, so one written without bound (a tool's output gone wrong) is counted as an error and left out, as a line that is not JSON is; the largest lines agents write, pictures in a tool's result, are a few megabytes.

View Source
var Now = func() float64 { return float64(time.Now().UnixMilli()) }

Now is Date.now() for the parsers; tests pin it.

Functions

func CodexTimelineStats

func CodexTimelineStats(path string) *jsvalue.Object

CodexTimelineStats is the session statistics of a Codex transcript (readCodexTimelineSessionStats); nil for null.

func NewCodexImageURL

func NewCodexImageURL(uploadsDir, prefix string) func(string) string

NewCodexImageURL is the ImageURL of a runtime that serves the images under uploadsDir at <prefix>/api/uploads/<path below uploadsDir> (uploadPathToImageUrl): "" for a path outside it or not an image.

func OutputShape

func OutputShape(text string) (lines int, tail string)

OutputShape is how many lines an output has and its last few non-empty lines, each cut to tailLineMax runes. The tail is a copy: a slice of the text would keep the whole read alive.

func ParseCodexContent

func ParseCodexContent(content string, opts CodexOptions) []*jsvalue.Object

ParseCodexContent is the entries of Codex transcript text (parseCodexContent); nil where the previous runtime threw. The text is taken to be a whole file: a line is named by its offset in the text.

func ParseCodexContentAt added in v0.15.40

func ParseCodexContentAt(content string, start int64, opts CodexOptions) (out []*jsvalue.Object)

ParseCodexContentAt is ParseCodexContent of text that starts at byte start of its file, whole lines from a line's start.

func ParseCodexContentChecked

func ParseCodexContentChecked(content string, opts CodexOptions) (entries []*jsvalue.Object, threw bool)

ParseCodexContentChecked is ParseCodexContent that tells a throw of the previous runtime's parser from an empty result.

func ParseContent

func ParseContent(content string) []*jsvalue.Object

ParseContent is the entries of transcript text (parseJsonlContent); nil where the previous runtime threw. The text is taken to be a whole file, so a line without a uuid is named by its offset in the text.

func ParseContentAt added in v0.15.40

func ParseContentAt(content string, start int64) []*jsvalue.Object

ParseContentAt is ParseContent of text that starts at byte start of its file, whole lines from a line's start.

func ParseContentChecked

func ParseContentChecked(content string) (entries []*jsvalue.Object, threw bool)

ParseContentChecked is ParseContent that tells a throw of the previous runtime's parser from an empty result.

func ParseFile

func ParseFile(path string) []*jsvalue.Object

ParseFile is the entries of a whole file, its last 512 000 bytes when it is over 1 MiB (parseJsonlFile). Where the previous runtime threw (a malformed line its parser trips on) this is empty.

Types

type Carry added in v0.15.40

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

Carry is the state Claude lines leave for the lines after them: a command still running, whose expanded prompt may be the next line. A read that goes on from where another ended takes its carry, so it reads the lines as a whole read does.

func (Carry) Open

func (c Carry) Open() bool

Open says the read ended inside something the next lines belong to: a read that starts after it from nothing would read those lines differently.

type Chunk

type Chunk struct {
	Entries []*jsvalue.Object
	// StartByteOffset is where the line of the first entry starts.
	StartByteOffset int64
	// FileSize is where the read ends: for a tail, the end of the last whole line, so a live feed goes on from there.
	FileSize   int64
	HasMore    bool
	ErrorCount int
	// Summary and CustomTitle are nil when the transcript names none (undefined in the old runtime).
	Summary     *string
	CustomTitle *string
	// Carry is what the read leaves for an incremental read that goes on from FileSize (Claude).
	Carry Carry
}

Chunk is a read of a stretch of a transcript.

func ReadBefore

func ReadBefore(path string, beforeByte int64, max int) Chunk

ReadBefore is up to max entries that end before beforeByte (readEntriesBefore).

func ReadBeforeBytes added in v0.15.40

func ReadBeforeBytes(path string, beforeByte, window int64, max int) Chunk

ReadBeforeBytes is ReadTailBytes of what precedes beforeByte: the entries whose lines start in the window bytes before it.

func ReadCodexBefore

func ReadCodexBefore(path string, beforeByte int64, maxEntries int, until int64, opts CodexOptions) (out Chunk)

ReadCodexBefore is readCodexEntriesBefore: the page of up to max entries before beforeByte, read on to until (< 0 for the end of the file) so the calls of the page meet their ends.

func ReadCodexTail

func ReadCodexTail(path string, maxEntries int, opts CodexOptions) Chunk

ReadCodexTail is readTailCodexEntries.

func ReadTail

func ReadTail(path string, max int) Chunk

ReadTail is the last max entries of a transcript (readTailEntries).

func ReadTailBytes added in v0.15.40

func ReadTailBytes(path string, window int64, max int) Chunk

ReadTailBytes is the entries of the last window bytes of a transcript, whole lines from the first line that starts in it, the last max of them: one read from the end, where ReadTail reads ever larger tails until it has max entries. A transcript whose lines are large (tool outputs, pictures) is read only as far back as asked.

type CodexOptions

type CodexOptions struct {
	// ImageURL is the page's address of an image the person attached (an upload path), "" when it is none.
	ImageURL func(path string) string
}

CodexOptions are what a Codex parse needs from the deployment.

type CodexParser

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

CodexParser follows one Codex transcript; it keeps the state of calls still waiting for their output.

func NewCodexParser

func NewCodexParser(path string, opts CodexOptions) *CodexParser

func (*CodexParser) AtRest

func (p *CodexParser) AtRest() bool

AtRest says the parser holds nothing the lines after its offset depend on: no line half written, no call still running.

func (*CodexParser) Dispose

func (p *CodexParser) Dispose()

func (*CodexParser) FlushStale

func (p *CodexParser) FlushStale(ts float64) []*jsvalue.Object

FlushStale ends the calls still in flight as failed at ts (milliseconds), each once.

func (*CodexParser) Holding

func (p *CodexParser) Holding() bool

Holding says the parser holds the start of a line the next read must finish: it has no place at a line's start.

func (*CodexParser) Offset

func (p *CodexParser) Offset() int64

Offset is where the next incremental read starts.

func (*CodexParser) ParseAll

func (p *CodexParser) ParseAll() (entries []*jsvalue.Object, offset int64)

ParseAll reads the whole file afresh (parseAll); the entries and the offset the next incremental read starts at.

func (*CodexParser) ParseAppended

func (p *CodexParser) ParseAppended(buf []byte, from int64) (out Incremental, ok bool)

ParseAppended is ParseIncremental of whole lines read by the caller (a transcript index): buf starts at byte from of the file and ends with a newline. false leaves the read to ParseIncremental: the parser holds the start of a line, or buf does not start where the parser stands.

func (*CodexParser) ParseIncremental

func (p *CodexParser) ParseIncremental() (out Incremental)

ParseIncremental is what the file gained since the last read (parseIncremental). A last line still being written waits in the pending buffer, unless it already parses as JSON.

func (*CodexParser) ParseTail

func (p *CodexParser) ParseTail(maxEntries int) (out Chunk)

ParseTail resets the parser to the tail of the file (parseTail): the last max entries, read in chunks that double until they hold enough.

func (*CodexParser) Path

func (p *CodexParser) Path() string

func (*CodexParser) Reset

func (p *CodexParser) Reset()

func (*CodexParser) Seat

func (p *CodexParser) Seat(offset int64)

Seat makes the next incremental read start at offset with nothing held, as a parser that was at rest there.

type Incremental

type Incremental struct {
	NewEntries []*jsvalue.Object
	NewOffset  int64
	// PendingBuffer is the start of a line still being written, read again whole next time.
	PendingBuffer string
	// Carry is what the read leaves for the next one (Claude).
	Carry Carry
}

Incremental is what a transcript gained since an offset.

func ParseAppended

func ParseAppended(buf []byte, offset int64, carry Carry) Incremental

ParseAppended is ParseIncrementalCarry of bytes already read off the transcript: buf is the whole lines, each with its newline, that start at byte offset of the file. What a read of the same bytes off the file gives, without the file being opened.

func ParseIncremental

func ParseIncremental(path string, offset int64, pending string) Incremental

ParseIncremental is what the file gained after offset (parseIncremental).

func ParseIncrementalCarry added in v0.15.40

func ParseIncrementalCarry(path string, offset int64, pending string, carry Carry) Incremental

ParseIncrementalCarry is ParseIncremental going on from a read that left carry.

Jump to

Keyboard shortcuts

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