render

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 10 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 render turns session events into readable terminal lines: one event becomes one or a few lines, streamed agent text is joined, and charts and tables in answers are drawn.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMarkdown

func FormatMarkdown(text string, o MDOptions) string

FormatMarkdown renders a whole answer at once.

Types

type MD

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

MD turns streamed Markdown into terminal text: charts become a plot and a table, Markdown tables become aligned tables, everything else passes through. Text can arrive in any chunking; ordinary lines are written as soon as they start, so a streamed answer reads live.

func NewMD

func NewMD(w io.Writer, o MDOptions) *MD

NewMD writes to w.

func (*MD) Flush

func (m *MD) Flush()

Flush finishes the text: an unfinished block is printed as written, and an open line ends.

func (*MD) Open

func (m *MD) Open() bool

Open reports whether a line is half written.

func (*MD) Write

func (m *MD) Write(s string)

Write adds a chunk of text.

type MDOptions

type MDOptions struct {
	Style style.Style
	Width int  // terminal columns, for plots
	Draw  bool // draw charts above their tables
}

MDOptions say how an answer's Markdown is shown in a terminal.

type Options

type Options struct {
	Style      style.Style
	Width      int  // terminal columns (0: 80)
	Charts     bool // draw plots above chart tables
	Live       bool // stream agent text as it arrives and show tool calls when they start
	Timestamps bool
	// Names maps user ids to what people read ("maya"); "rafiiq" and agents read "Waniis".
	Names map[string]string
}

Options say how events are shown.

type Renderer

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

Renderer writes events to w. It is stateful (it pairs tool calls with results and joins streamed deltas), so use one per stream and call Flush at the end.

func New

func New(w io.Writer, o Options) *Renderer

New builds a renderer.

func (*Renderer) Event

func (r *Renderer) Event(ev api.Event)

Event renders one event.

func (*Renderer) Flush

func (r *Renderer) Flush()

Flush finishes the output: an open agent line ends, buffered text and unfinished tool calls are written.

Jump to

Keyboard shortcuts

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