transcript

package
v0.143.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 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 turns an agent CLI's own session file into a short list of conversation turns for the work-item summarizer (W2a, design §14.2). It reads only the tail of a file the session registered, parses the three jsonl dialects gofer knows (claude, codex rollout, omp), and never touches the network or any tool.

Parsing is deliberately forgiving: an unknown line, a missing field or a truncated first line is skipped, because a transcript is a moving target written by someone else's program.

Index

Constants

View Source
const (
	RoleUser      = "user"
	RoleAssistant = "assistant"
	RoleTool      = "tool" // a one-line note that the agent ran a tool
)

Turn roles.

View Source
const (
	DialectClaude = "claude"
	DialectCodex  = "codex"
	DialectOmp    = "omp"
	// DialectGeneric is the agent-neutral format a self-built agent can write: one JSON
	// object per line, {"v":1,"type":"user|assistant|tool","ts":RFC3339,"text":…,
	// "injected":bool,"name":…,"summary":…}.
	DialectGeneric = "generic"
)

Dialects.

View Source
const DefaultTailBytes = 256 * 1024

DefaultTailBytes is how much of a transcript's end is read by default.

View Source
const EnvRoots = "GOFER_TRANSCRIPT_ROOTS"

EnvRoots adds directories (an OS path list) a transcript may live under, besides the user's home directory. Operators who keep agent session stores elsewhere (a relocated CLAUDE_CONFIG_DIR / CODEX_HOME is picked up automatically) set it.

View Source
const MaxTailBytes = 512 * 1024

MaxTailBytes is the hard cap of one safe tail read (the wire cap of a worker answer).

Variables

This section is empty.

Functions

func CheckPath

func CheckPath(path string) (string, error)

CheckPath is the boundary for reading a session-registered transcript: an absolute .jsonl path that, with symlinks resolved, is a regular file under an allowed root. The server only ever passes the path a session registered, but the reader must not trust that — it would otherwise be a remote file reader. It returns the resolved path.

func DialectFor

func DialectFor(agent string) string

DialectFor maps a gofer agent name (or an acp variant of it) to the transcript dialect, "" when unknown (Parse then sniffs the content).

func Format

func Format(turns []Turn, o FormatOpts) string

Format renders the newest turns as plain text, oldest first, within the bounds.

func ReadTail

func ReadTail(path string, maxBytes int64) ([]byte, error)

ReadTail reads at most maxBytes from the end of the file. When it had to cut, the first (partial) line is dropped so the result starts on a line boundary.

func ReadTailSafe

func ReadTailSafe(path string, maxBytes int64) (data []byte, size int64, truncated bool, err error)

ReadTailSafe vets the path (CheckPath) and reads at most maxBytes from its end (capped at MaxTailBytes; <=0 = DefaultTailBytes). size is the file's full size and truncated says the file was longer than what came back.

func Resolve

func Resolve(configured, agent string) string

Resolve picks the dialect for a session: the agent's configured transcript_dialect first, then the agent key's name, "" when neither says (Parse then sniffs).

func Roots

func Roots() []string

Roots lists where a transcript file may live.

Types

type FormatOpts

type FormatOpts struct {
	// MaxTurns keeps at most this many of the newest turns (default 40).
	MaxTurns int
	// MaxBytes bounds the whole rendering (default 32KB); older turns are dropped first.
	MaxBytes int
	// MaxTurnRunes caps one turn's text (default 2000); an over-long turn keeps its head
	// and its tail (the conclusion is usually at the end).
	MaxTurnRunes int
}

FormatOpts bounds the rendered tail.

type Turn

type Turn struct {
	Role string `json:"role"`
	Text string `json:"text"`
}

Turn is one utterance (or tool note) of the conversation.

func Parse

func Parse(dialect string, raw []byte) []Turn

Parse extracts the conversation from raw jsonl. dialect "" sniffs it from the lines.

Jump to

Keyboard shortcuts

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