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 ¶
- func EmitPreRunError(w io.Writer, format string, err error)
- func RenderAGUI(events <-chan domain.ChatEvent, w io.Writer, ...) error
- func RenderJSON(events <-chan domain.ChatEvent, w io.Writer, ...) error
- func RenderJSONPretty(events <-chan domain.ChatEvent, w io.Writer, ...) error
- func RenderText(events <-chan domain.ChatEvent, w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitPreRunError ¶
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.
Types ¶
This section is empty.