render

package
v0.216.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentStartupEmitter added in v0.198.0

func AgentStartupEmitter(w io.Writer, format string) func(name, state, message string, done, total int)

AgentStartupEmitter reports local A2A agent startup (image pull, container start, health check) that happens before the event stream begins as JSON agent_status lines, so a client can show progress instead of silence while a multi-GB image pulls. The ag-ui format has its own emitter in the agui context. Returns nil for formats that carry no machine-readable output.

func AnswerApproval added in v0.216.0

func AnswerApproval(e agentdomain.ToolApprovalRequestedEvent, approvals <-chan ipc.ApprovalResponse)

AnswerApproval answers the engine's pending approval on the event's response channel from the broker's approvals channel. Responses carrying a different tool_call_id are skipped (a late answer to a request the engine already timed out must not decide the next one). A nil or closed channel rejects the tool so the engine never waits out its timeout on a dead broker.

func AnswerQuestions added in v0.216.0

func AnswerQuestions(e agentdomain.UserQuestionRequestedEvent, questions <-chan ipc.UserQuestionResponse)

AnswerQuestions answers the AskUserQuestion tool's pending form on the event's response channel from the broker's questions channel, mirroring AnswerApproval: stale tool_call_ids are skipped, a cancelled response or a nil/closed channel closes ResponseChan (the tool's "dismissed" path), and an unparseable answers payload counts as a dismissal too.

func CompletionErr added in v0.216.0

func CompletionErr(e agentdomain.ChatCompleteEvent) error

CompletionErr maps a terminal event to the error the command should return: ErrMaxTurnsReached for a turn-limit completion (exit code 2), nil otherwise.

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. The ag-ui format has its own RUN_ERROR writer in the agui context.

func JudgeStderr added in v0.216.0

func JudgeStderr(e agentdomain.JudgeVerdictChatEvent)

JudgeStderr echoes a judge rejection to stderr in every headless format: the TUI flash equivalent for unattended runs. CI consumers watching stdout keep the machine-readable judge_verdict line.

func QueuedNote added in v0.216.0

func QueuedNote(e agentdomain.MessageQueuedEvent) (string, bool)

QueuedNote returns the text of a drained queue message worth rendering: a background-job note, not the echo of a user message sent over IPC.

func RenderJSON

func RenderJSON(events <-chan agentdomain.ChatEvent, w io.Writer, approvals <-chan ipc.ApprovalResponse, questions <-chan ipc.UserQuestionResponse, sessionID, model string, cfg *config.Config, repo convdomain.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 agentdomain.ChatEvent, w io.Writer, approvals <-chan ipc.ApprovalResponse, questions <-chan ipc.UserQuestionResponse, sessionID, model string, cfg *config.Config, repo convdomain.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 agentdomain.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.

func Truncate added in v0.216.0

func Truncate(s string, maxLen int) string

Truncate caps s at maxLen characters, marking the cut with an ellipsis.

func UserQuestionRequest added in v0.216.0

UserQuestionRequest builds the IPC payload for one question form.

Types

This section is empty.

Jump to

Keyboard shortcuts

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