transcript

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package transcript turns a conversation into cells that render at any width. Cells built from live events and from a saved history must look the same, so a conversation renders identically live, restored and in a sub-agent's view.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ago

func Ago(d time.Duration) string

Ago returns "just now", "5m ago", "3h ago", "yesterday" or "4d ago".

func Duration

func Duration(d time.Duration) string

Duration formats d as "8s", "1m 20s" or "2h 5m".

func HomePath

func HomePath(p string) string

HomePath abbreviates the home directory as ~. Use it for the workspace itself, where ShortPath would show ".".

func ShortPath

func ShortPath(p string) string

ShortPath makes p relative to the working directory when inside it, else abbreviates the home directory as ~.

func Spinner

func Spinner(now time.Time) string

Spinner advances a frame every 80ms.

func Title

func Title(name string) string

func Tokens

func Tokens(n int) string

Tokens formats a count as "950", "12.3k" or "1.2M".

Types

type Agent

type Agent struct {
	ID         string // "explore#2"
	Name       string // "explore"
	Transcript *Transcript
	Turns      int
	Tools      int
	In, Out    int
	Done       bool
}

type Assistant

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

func (Assistant) Live

func (Assistant) Live() bool

func (*Assistant) Render

func (c *Assistant) Render(p Params) []string

func (*Assistant) Toggle

func (c *Assistant) Toggle()

func (*Assistant) Version

func (r *Assistant) Version() uint64

type Attached

type Attached interface {
	Attached() bool
}

An Attached cell renders with no gap below the cell above it.

type Cell

type Cell interface {
	// Render returns lines no wider than p.Width.
	Render(p Params) []string
	// Version changes whenever Render may return something else for the
	// same Params.
	Version() uint64
	// Live cells animate with p.Now, so their rendering must not be cached.
	Live() bool
}

A Cell keeps its content, not its rendering, so it can render at any width.

type Level

type Level int
const (
	// Info is something the harness did, such as compacting.
	Info Level = iota
	Error
	// Output is what a command printed.
	Output
	Summary
)

type Notice

type Notice struct {
	Level Level
	Text  string
	// contains filtered or unexported fields
}

Notice is a message from the harness or a command, not the agent.

func Fail

func Fail(text string) *Notice

func Note

func Note(text string) *Notice

func Print

func Print(text string) *Notice

func (*Notice) Attached

func (c *Notice) Attached() bool

func (Notice) Live

func (Notice) Live() bool

func (*Notice) Render

func (c *Notice) Render(p Params) []string

func (*Notice) Version

func (r *Notice) Version() uint64

type Params

type Params struct {
	Width int
	// Expanded shows thinking and tool output in full.
	Expanded bool
	// Live cells render as a function of Now, however often they render.
	Now time.Time
}

type Prompt

type Prompt struct {
	Text   string
	Images int
	Kind   PromptKind
	// contains filtered or unexported fields
}

func (Prompt) Live

func (Prompt) Live() bool

func (*Prompt) Render

func (c *Prompt) Render(p Params) []string

func (*Prompt) Toggle

func (c *Prompt) Toggle()

func (*Prompt) Version

func (r *Prompt) Version() uint64

type PromptKind

type PromptKind int
const (
	ToAgent PromptKind = iota
	ToCommand
	ToShell
)

type Toggler

type Toggler interface {
	Toggle()
}

type Tool

type Tool struct {
	ID      string
	Name    string
	Args    json.RawMessage
	Preview string // what the tool's Check previewed, such as an edit's diff
	State   ToolState
	Result  string
	Started time.Time
	// contains filtered or unexported fields
}

func (*Tool) Agents

func (t *Tool) Agents() []*Agent

func (*Tool) Live

func (t *Tool) Live() bool

func (*Tool) Render

func (t *Tool) Render(p Params) []string

func (*Tool) Toggle

func (t *Tool) Toggle()

func (*Tool) Version

func (r *Tool) Version() uint64

type ToolState

type ToolState int
const (
	Running ToolState = iota
	Succeeded
	Failed
	// Interrupted means the run ended before the call did.
	Interrupted
)

type Transcript

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

func Load

func Load(history []agentcore.Message) *Transcript

func New

func New() *Transcript

func (*Transcript) Append

func (t *Transcript) Append(c Cell)

func (*Transcript) Apply

func (t *Transcript) Apply(ev agentcore.Event)

func (*Transcript) Cells

func (t *Transcript) Cells() []Cell

Jump to

Keyboard shortcuts

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