transcript

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 20 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 conversation files coding agents write — a JSONL format per harness — and normalizes them to wire.Message. Files are only ever read: backwards from the end for paging, forwards from a remembered offset for tailing, never whole unless a cache entry is new.

Index

Constants

View Source
const (
	RoleUser      = "user"
	RoleAssistant = "assistant"
	RoleTool      = "tool"
	RoleSystem    = "system"
)

Roles of wire.Message.

View Source
const (
	// DefaultLimit is the page size when the caller gives none.
	DefaultLimit = 50
)

Variables

This section is empty.

Functions

func AntigravityCwd added in v0.23.0

func AntigravityCwd(path string) string

AntigravityCwd is the working directory of the Antigravity CLI conversation whose transcript is path, "" while history.jsonl does not tell it.

func EndOffset

func EndOffset(path string) (int64, error)

EndOffset is where a tail of path should start to see only new records.

func OpenCodeProcPath added in v0.22.0

func OpenCodeProcPath(path string) string

OpenCodeProcPath is the process sidecar of the session recorded at path: {"pid", "started" (unix ms)}, the OpenCode process (its terminal UI) that last reported the session.

func ReadFrom

func ReadFrom(path, harness string, offset int64) ([]wire.Message, int64, error)

ReadFrom parses the complete records from offset on and returns their messages with the offset to continue from. A trailing partial record is left for the next call. If the file shrank (rewritten), reading restarts at its current end without replaying it.

func Summarize

func Summarize(input json.RawMessage) string

Summarize renders tool arguments (a JSON object, or a JSON string holding one) as a single short line: the command, file path, pattern, … whichever comes first in summaryKeys.

func SyncOpenCode added in v0.22.0

func SyncOpenCode(path string, export []byte) error

SyncOpenCode brings stagent's record of an OpenCode session at path (<root>/<session id>.jsonl) up to export, the output of `opencode session export <id>` ({info, messages}): it appends the session record when the title or directory changed and the messages the file lacks, in the export's order up to the first reply still being written (an assistant message without its completion time), which a later export brings complete. What the file holds is never rewritten. The file is replaced whole (a reader sees it before or after, never a part); two syncs at once write what one of them read, which the next sync completes.

Types

type Index

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

Index lists conversations of every harness, caching per-file metadata in a JSON file keyed by (path, mtime, size) so only changed files are read. Deleting the file only costs a rescan.

func OpenIndex

func OpenIndex(path string, roots Roots) *Index

OpenIndex loads the cache at path (missing or corrupt → empty).

func (*Index) Conversation

func (x *Index) Conversation(harness, path string) (c wire.Conversation, ok bool)

Conversation returns the metadata of one transcript file, re-reading it only when it changed since the last call. ok is false when the file is unreadable or is one List would skip (automation or sub-agent run, no id yet).

func (*Index) Find

func (x *Index) Find(harness, id string) (string, bool)

Find returns the transcript path of a harness's conversation id.

func (*Index) List

func (x *Index) List(harnesses []string, limit int) ([]wire.Conversation, error)

List returns the newest conversations of the given harnesses (all when empty), at most limit per harness, newest first.

func (*Index) Roots

func (x *Index) Roots() Roots

Roots returns the roots the index scans.

type Page

type Page struct {
	Messages []wire.Message // oldest first
	// Cursor is the byte offset to pass as before for older messages;
	// 0 means the beginning was reached.
	Cursor int64
	// End is the offset just after the newest complete record: tail from
	// here to receive only what comes after this page.
	End int64
}

Page is one page of a transcript.

func ReadPage

func ReadPage(path, harness string, before int64, limit int) (Page, error)

ReadPage returns up to limit messages that end before byte offset before (0 = end of file), reading the file backwards so large transcripts cost only what the page needs. A record's messages are never split across pages, so a page may exceed limit by the few messages of its first record.

type Roots

type Roots map[string]string

Roots are the directories each harness keeps its conversations in, by harness id (harness.Harness.TranscriptRoot).

func DefaultRoots

func DefaultRoots(home string, getenv func(string) string) Roots

DefaultRoots resolves the roots for a home directory as the harnesses do (CLAUDE_CONFIG_DIR, CODEX_HOME). getenv is the environment the harness runs with (os.Getenv for stagent's own).

func (Roots) HarnessOf

func (r Roots) HarnessOf(path string) (string, bool)

HarnessOf reports which harness's transcript directory holds path. Only .jsonl files under a known root qualify, so transcript requests cannot be pointed at arbitrary files.

Jump to

Keyboard shortcuts

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