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 ¶
- Variables
- func CodexTimelineStats(path string) *jsvalue.Object
- func NewCodexImageURL(uploadsDir, prefix string) func(string) string
- func ParseCodexContent(content string, opts CodexOptions) []*jsvalue.Object
- func ParseCodexContentAt(content string, start int64, opts CodexOptions) (out []*jsvalue.Object)
- func ParseCodexContentChecked(content string, opts CodexOptions) (entries []*jsvalue.Object, threw bool)
- func ParseContent(content string) []*jsvalue.Object
- func ParseContentAt(content string, start int64) []*jsvalue.Object
- func ParseContentChecked(content string) (entries []*jsvalue.Object, threw bool)
- func ParseFile(path string) []*jsvalue.Object
- type Carry
- type Chunk
- func ReadBefore(path string, beforeByte int64, max int) Chunk
- func ReadBeforeBytes(path string, beforeByte, window int64, max int) Chunk
- func ReadCodexBefore(path string, beforeByte int64, maxEntries int, until int64, opts CodexOptions) (out Chunk)
- func ReadCodexTail(path string, maxEntries int, opts CodexOptions) Chunk
- func ReadTail(path string, max int) Chunk
- func ReadTailBytes(path string, window int64, max int) Chunk
- type CodexOptions
- type CodexParser
- func (p *CodexParser) Dispose()
- func (p *CodexParser) FlushStale(ts float64) []*jsvalue.Object
- func (p *CodexParser) Offset() int64
- func (p *CodexParser) ParseAll() (entries []*jsvalue.Object, offset int64)
- func (p *CodexParser) ParseIncremental() (out Incremental)
- func (p *CodexParser) ParseTail(maxEntries int) (out Chunk)
- func (p *CodexParser) Path() string
- func (p *CodexParser) Reset()
- type Incremental
Constants ¶
This section is empty.
Variables ¶
var Now = func() float64 { return float64(time.Now().UnixMilli()) }
Now is Date.now() for the parsers; tests pin it.
Functions ¶
func CodexTimelineStats ¶
CodexTimelineStats is the session statistics of a Codex transcript (readCodexTimelineSessionStats); nil for null.
func NewCodexImageURL ¶
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 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 ¶
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
ParseContentAt is ParseContent of text that starts at byte start of its file, whole lines from a line's start.
func ParseContentChecked ¶
ParseContentChecked is ParseContent that tells a throw of the previous runtime's parser from an empty result.
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.
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 ¶
ReadBefore is up to max entries that end before beforeByte (readEntriesBefore).
func ReadBeforeBytes ¶ added in v0.15.40
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 ReadTailBytes ¶ added in v0.15.40
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) 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) 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) 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()
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 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.