Documentation
¶
Overview ¶
Package render provides emoji-driven terminal rendering for the odek agent loop.
It produces structured output for each phase of the ReAct cycle: thinking, tool calls, tool results, and the final answer. When a Renderer is nil or disabled, no output is produced — this keeps the programmatic API silent and the CLI colorful.
Design ¶
- Zero dependencies. Uses ANSI escape codes directly.
- Emoji icons as visual anchors (🧠 🔧 ✅ ❌).
- Color detection: respects NO_COLOR env var and tty detection.
- Truncation: tool output is collapsed to one line to keep the terminal scannable during multi-step tool chains.
- Maintainable: each rendering method is self-contained; adding a new event type requires one constant + one method.
Index ¶
- func ColorEnabled() bool
- type Event
- type Renderer
- func (r *Renderer) Error(err error)
- func (r *Renderer) FinalAnswer(text string)
- func (r *Renderer) Iteration(n, maxN int, latency time.Duration, inTokens, outTokens int, turn int)
- func (r *Renderer) Start(task string)
- func (r *Renderer) Thinking(text string)
- func (r *Renderer) ToolCall(name, args string)
- func (r *Renderer) ToolResult(output string)
- func (r *Renderer) WithModel(name string) *Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶
func ColorEnabled() bool
ColorEnabled returns true when the terminal supports ANSI colors and the user hasn't set NO_COLOR.
Types ¶
type Event ¶
type Event int
Event identifies a point in the agent loop lifecycle. Programmatic consumers can type-switch on Event values.
const ( // IterStart marks the beginning of an iteration cycle. IterStart Event = iota // Thinking is the model's reasoning text before tool calls. Thinking // ToolCall is a tool invocation requested by the model. ToolCall // ToolResult is the output from a completed tool call. ToolResult // FinalAnswer is the model's final response (no tool calls). FinalAnswer // Error is a non-fatal error during the loop. Error )
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer writes formatted agent loop output to an io.Writer. The zero value is usable but won't produce any output — call New() to create a properly initialized Renderer.
func New ¶
New creates a Renderer that writes to w. If color is false, ANSI escape codes are stripped from the output.
func (*Renderer) FinalAnswer ¶
FinalAnswer prints the model's concluding response with a checkmark emoji.
func (*Renderer) Iteration ¶
Iteration prints the cycle header with optional turn statistics and turn number. When turn > 0, shows "Turn N" in the header. When latency > 0 or tokens are reported, a compact stats suffix appears on the same line: [1,247 in · 342 out · 4.1s]
func (*Renderer) ToolCall ¶
ToolCall prints a tool invocation with wrench emoji, name, and compact args.
func (*Renderer) ToolResult ¶
ToolResult prints a one-line summary of the tool output in gray. Long output is collapsed to the first line + ellipsis to keep the terminal readable during multi-step tool chains.