Documentation
¶
Overview ¶
Package transcripts collects, redacts, indexes and searches session transcripts across harnesses (claude, agy, codex, omp) and execution hosts.
Index ¶
- Constants
- func Allowed(caller Caller, meta Meta, grants []state.TranscriptGrant, now time.Time) bool
- func Covers(g state.TranscriptGrant, meta Meta) bool
- func ExtractRefs(text string) []string
- func GrantAppliesTo(g state.TranscriptGrant, caller Caller) bool
- func NormalizeRef(s string) string
- func RepoOfRef(ref string) string
- func SafeKey(harness, host, id string) string
- type Caller
- type Loss
- type Meta
- type Parsed
- type ReadOptions
- type SearchHit
- type SearchOptions
- type Store
- func (s Store) AppendRemoteLog(meta Meta, chunk []byte, nextCursor string, prompts []Turn) (Meta, error)
- func (s Store) IngestFile(meta Meta, path string) (Meta, bool, error)
- func (s Store) List() ([]Meta, error)
- func (s Store) ReadMeta(key string) (Meta, bool, error)
- func (s Store) ReadTurns(key string, opts ReadOptions) ([]Turn, error)
- func (s Store) Save(meta Meta, turns []Turn) (Meta, error)
- func (s Store) Search(metas []Meta, query string, opts SearchOptions) ([]SearchHit, error)
- func (s Store) UpdateMeta(meta Meta) (Meta, error)
- type Turn
Constants ¶
const ( RoleUser = "user" RoleAssistant = "assistant" RoleTool = "tool" )
Roles of stored transcript turns.
Variables ¶
This section is empty.
Functions ¶
func Covers ¶
func Covers(g state.TranscriptGrant, meta Meta) bool
Covers reports whether the scope of g reaches meta.
func ExtractRefs ¶
ExtractRefs extracts canonical "owner/repo#n" references from text.
func GrantAppliesTo ¶
func GrantAppliesTo(g state.TranscriptGrant, caller Caller) bool
GrantAppliesTo reports whether grant g was issued to caller.
func NormalizeRef ¶
NormalizeRef converts a GitHub issue/PR URL or owner/repo#n string into canonical "owner/repo#n" form; returns "" when s is neither.
Types ¶
type Caller ¶
type Caller struct {
Party state.Party
RosterName string
Execution string
Role string // "guide", "worker", or ""
Repo string // worker's repository (owner/repo)
IsGuide bool // true when caller holds the guide role or is an unmanaged operator CLI call
}
Caller describes the session or operator requesting transcript access.
type Loss ¶
type Loss struct {
HarnessBytes int64 `json:"harnessBytes,omitempty"`
HarnessCuts int `json:"harnessCuts,omitempty"`
ClippedBytes int64 `json:"clippedBytes,omitempty"`
Clipped int `json:"clipped,omitempty"`
NoResult int `json:"noResult,omitempty"`
Pending int `json:"pending,omitempty"`
// SourceGone says the source file the index was read from no longer
// exists, so what the index misses is gone too.
SourceGone bool `json:"sourceGone,omitempty"`
}
Loss is what a transcript's turns do not hold. Text its harness cut before the store read it is gone for good. The rest is only missing from the index, and its source may still hold it: tool results the store clipped, and tool calls of an ended session stored with no result. A running session's Pending calls may simply not have finished. A call answered with empty output is none of these.
type Meta ¶
type Meta struct {
Key string `json:"key"`
ID string `json:"id,omitempty"`
HostSession string `json:"hostSession,omitempty"`
Execution string `json:"execution,omitempty"`
Name string `json:"name,omitempty"`
RosterName string `json:"rosterName,omitempty"`
Role string `json:"role,omitempty"`
Repo string `json:"repo,omitempty"`
Ref string `json:"ref,omitempty"`
Refs []string `json:"refs,omitempty"`
Harness string `json:"harness"`
Host string `json:"host"`
Cwd string `json:"cwd,omitempty"`
Model string `json:"model,omitempty"`
Running bool `json:"running,omitempty"`
StartedAt time.Time `json:"startedAt,omitzero"`
LastActive time.Time `json:"lastActive,omitzero"`
EndedAt time.Time `json:"endedAt,omitzero"`
Turns int `json:"turns"`
Bytes int64 `json:"bytes"`
SourcePath string `json:"sourcePath,omitempty"`
SourceMod time.Time `json:"sourceMod,omitzero"`
SourceSize int64 `json:"sourceSize,omitempty"`
RemoteCursor string `json:"remoteCursor,omitempty"`
// Parser is the parser version that indexed the turns (parserVersions).
Parser int `json:"parser,omitempty"`
}
Meta is the persisted metadata of one session's transcript in the store. It survives the session ending or leaving the roster.
func Resolve ¶
Resolve finds the transcript matching query among metas (which should already be filtered for caller access and sorted most-recent first).
func (Meta) DisplayName ¶
DisplayName is the most descriptive human-readable name for the session.
func (Meta) ExactMatch ¶
ExactMatch reports whether q equals one of m's identifiers or names.
type Parsed ¶
type Parsed struct {
SessionID string
Title string
Cwd string
Model string
Repo string
Refs []string
StartedAt time.Time
LastActive time.Time
Turns []Turn
}
Parsed holds the turns and metadata extracted from a harness transcript file or remote execution stream.
type ReadOptions ¶
ReadOptions controls which turns ReadTurns returns.
type SearchHit ¶
type SearchHit struct {
Meta Meta `json:"meta"`
TurnIndex int `json:"turnIndex"`
Turn Turn `json:"turn"`
Snippet string `json:"snippet"`
}
SearchHit is one matching turn from Search.
type SearchOptions ¶
type SearchOptions struct {
Repo string
Harness string
Host string
Ref string
Session string
Since time.Time
Tools bool
Results bool
Limit int
}
SearchOptions filters and bounds a transcript search.
type Store ¶
Store manages the coordinator's transcript directory (<stateDir>/transcripts).
func (Store) AppendRemoteLog ¶
func (s Store) AppendRemoteLog(meta Meta, chunk []byte, nextCursor string, prompts []Turn) (Meta, error)
AppendRemoteLog appends a page of an SSH execution's stream log (after redacting secret values), reparses the accumulated stream with any prompt turns from the execution record, and updates the stored transcript. The chunk ends at a record boundary: redaction matches whole records only, so a secret split across two chunks would reach the raw stream unmasked.
func (Store) IngestFile ¶
IngestFile parses a local harness transcript at path and saves it into the store. If path's size and modification time match what is already stored for meta.Key, only changed metadata fields are updated.
func (Store) List ¶
List returns all stored transcript metadata entries, most recently active first.
func (Store) ReadTurns ¶
func (s Store) ReadTurns(key string, opts ReadOptions) ([]Turn, error)
ReadTurns reads the stored turns of key according to opts.
func (Store) Save ¶
Save redacts turns, merges metadata with any prior record for meta.Key, and atomically writes both <key>.jsonl and <key>.json.
type Turn ¶
type Turn struct {
At time.Time `json:"at,omitzero"`
Role string `json:"role"`
Tool string `json:"tool,omitempty"`
Text string `json:"text"`
Result string `json:"result,omitempty"`
// Answered says a result arrived, however empty.
Answered bool `json:"answered,omitempty"`
// Phase is a Codex assistant message's phase ("commentary",
// "final_answer"), empty where the harness names none.
Phase string `json:"phase,omitempty"`
}
Turn is one conversational or tool turn in a stored transcript.