render

package
v0.175.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package render formats domain.ChatEvent streams for the headless CLI.

Each format function consumes the event channel from AgentService.RunWithStream and writes formatted output to an io.Writer. All renderers drain the channel until it closes (the engine closes it when the run ends), so the producer is never left blocked mid-run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitPreRunError

func EmitPreRunError(w io.Writer, format string, err error)

EmitPreRunError writes a machine-readable failure line for errors that occur before the event stream starts (gateway down, unknown model, ...), so stdout consumers - the channel manager and agentrunner - see the failure instead of silence. The text format stays quiet; the CLI's stderr prose covers it.

func RenderAGUI

func RenderAGUI(events <-chan domain.ChatEvent, w io.Writer, approvals <-chan domain.ApprovalResponse, sessionID, model string) error

RenderAGUI renders events as newline-delimited AG-UI protocol events. The run gets exactly one RUN_STARTED and one terminal event (RUN_FINISHED or RUN_ERROR); per-turn events in between carry deltas, tool calls, and results. When approvals is non-nil it acts as the IPC approval broker, same as RenderJSON. A ComputerUseResumedEvent clears any error carried over from the paused (cancelled) run, same as RenderJSON.

func RenderJSON

func RenderJSON(events <-chan domain.ChatEvent, w io.Writer, approvals <-chan domain.ApprovalResponse, sessionID, model string, cfg *config.Config, repo domain.ConversationRepository) error

RenderJSON renders events as JSON lines, streaming each message as its turn completes: assistant messages on ChatCompleteEvent, tool results on ToolExecutionCompletedEvent, approval requests and errors in real time. After the channel closes only the session stats are read from the repo. When approvals is non-nil it acts as the IPC approval broker: each approval_request line is answered by the next matching ApprovalResponse. A ComputerUseResumedEvent clears any error carried over from the paused (cancelled) run, so a resumed run that completes cleanly exits zero.

func RenderJSONPretty

func RenderJSONPretty(events <-chan domain.ChatEvent, w io.Writer, approvals <-chan domain.ApprovalResponse, sessionID, model string, cfg *config.Config, repo domain.ConversationRepository) error

RenderJSONPretty is RenderJSON with each object indented across multiple lines for human reading. Objects are separated by newlines but are no longer one-per-line, so machine consumers should use RenderJSON.

func RenderText

func RenderText(events <-chan domain.ChatEvent, w io.Writer) error

RenderText streams content deltas as plain text to w, matching the non-interactive chat output style. The engine emits one ChatCompleteEvent per turn, so rendering continues until the channel closes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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