Documentation
¶
Overview ¶
Package transcript reads the coding agents' conversation files (Claude Code and Codex jsonl) into timeline entries, the shape the conversation view draws, exactly as the previous runtime's parsers built them: the same entries, keys in the same order, the same byte offsets.
Index ¶
- Variables
- func CodexTimelineStats(path string) *jsvalue.Object
- func NewCodexImageURL(uploadsDir, prefix string) func(string) string
- func ParseCodexContent(content string, opts CodexOptions) (out []*jsvalue.Object)
- func ParseCodexContentChecked(content string, opts CodexOptions) (entries []*jsvalue.Object, threw bool)
- func ParseContent(content string) []*jsvalue.Object
- func ParseContentChecked(content string) (entries []*jsvalue.Object, threw bool)
- func ParseFile(path string) []*jsvalue.Object
- type 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 NewID = func() string { var b [21]byte _, _ = rand.Read(b[:]) for i := range b { b[i] = idAlphabet[b[i]&63] } return string(b[:]) }
NewID is an entry id (nanoid's 21 characters); tests replace it with a counter.
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) (out []*jsvalue.Object)
ParseCodexContent is the entries of Codex transcript text (parseCodexContent); nil where the previous runtime threw.
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.
func ParseContentChecked ¶
ParseContentChecked is ParseContent that tells a throw of the previous runtime's parser from an empty result.
Types ¶
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
}
Chunk is a read of a stretch of a transcript.
func ReadBefore ¶
ReadBefore is up to max entries that end before beforeByte (readEntriesBefore).
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.
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
}
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).