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 DisplayToolName ¶ added in v0.1.1
DisplayToolName shows the sandbox's own browser tools by the product's name (DEC-141): `rafiiq-browser_http_request` reads `waniis-browser_http_request`.
func FormatElapsed ¶ added in v0.1.1
FormatElapsed writes a duration the way the chat shows it: "6s", "1m 05s".
func FormatMarkdown ¶
FormatMarkdown renders a whole answer at once.
func FromPerson ¶ added in v0.1.1
FromPerson is the name to show for one entry of the people route: the display name, else the GitHub login, never an id.
func LooksLikeID ¶ added in v0.1.1
LooksLikeID reports whether s is one of the API's ids. The people route answers with the id as the name when it knows nothing better, and that must never be shown.
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. With colors on, the rest is styled too: headings, **bold**, *italic*, `code`, links, lists, quotes and rules, and code blocks are syntax highlighted; without colors it passes through as written. Text can arrive in any chunking; ordinary lines are written as soon as their first word is known, so a streamed answer reads live.
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
// People names the people in the session: the signed-in person reads "you", others by their
// name, anyone unknown "someone"; "rafiiq" and agents read "Waniis". Ids are never shown.
People *People
// Names is a plain id-to-name map, used when People is nil.
Names map[string]string
// Chat is the interactive chat's transcript: a run's end is one quiet line ("✓ done · 6s")
// and the start of a run is not announced (the live status line shows it).
Chat bool
// Own recognizes the echoes of messages this chat sent, which are not shown again.
Own *Own
}
Options say how events are shown.
type Own ¶ added in v0.1.1
type Own struct {
// contains filtered or unexported fields
}
Own recognizes the events that echo what this chat just sent, so a message you typed is shown once, as you typed it, and not again when the server repeats it. A prompt is matched by its id (from the command's reply) or by its text, its author and how recently it was sent.
func NewOwn ¶ added in v0.1.1
NewOwn returns an empty tracker; now is the injected clock (nil: nothing expires).
type People ¶ added in v0.1.1
type People struct {
// contains filtered or unexported fields
}
People says who is who in a session, so events read "Sara" and never "usr_01…". The signed-in person reads "you". Someone it doesn't know reads "someone". It is safe for concurrent use.
func NewPeople ¶ added in v0.1.1
NewPeople returns a resolver for the signed-in person's id (may be empty) and known names.
func (*People) Known ¶ added in v0.1.1
Known reports whether id can be named: "you", Waniis or someone with a name.
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.