render

package
v0.266.3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ErrorMessageLimit = 3500

ErrorMessageLimit caps error messages embedded in machine-format output lines so a runaway provider error cannot flood them.

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, until the engine stops waiting. Responses carrying a different tool_call_id are skipped, so a late answer does 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 AnswerPlan added in v0.239.0

AnswerPlan waits for the decision on the plan e asks to execute. Stale plan ids are skipped, and a nil or closed channel keeps planning.

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: it stops once the engine stops waiting, stale tool_call_ids are skipped, and a cancelled response, a nil or closed channel or an unparseable answers payload closes ResponseChan (the tool's "dismissed" path).

func ApprovalAction added in v0.219.0

func ApprovalAction(resp ipc.ApprovalResponse) agentdomain.ApprovalAction

ApprovalAction maps an IPC approval response to the engine's decision: an approved response with scope "always" auto-accepts, a plain approved response approves the call once, anything else rejects.

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), ErrMaxDurationReached for a time-budget completion (exit code 3), 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 agentheadless - 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 headless presentation.

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 PlanAction added in v0.239.0

func PlanAction(action string) agentdomain.PlanApprovalAction

PlanAction maps a plan decision's wire name to the agent's action. An unknown name keeps planning.

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 QuoteBlock added in v0.239.0

func QuoteBlock(s string) string

QuoteBlock prefixes every line with "> " so tool traffic arrives as a markdown blockquote - channels render quotes as collapsed or secondary content (Telegram: an expandable blockquote).

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 streams events as JSON lines as each turn completes, then reads only the session stats from the repo once the channel closes. A non-nil approvals channel makes it the IPC approval broker, answering each approval_request with the next matching ApprovalResponse.

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 runes, never splitting a UTF-8 rune, marking the cut with an ellipsis. It caps non-display text, so the width-aware formatting.TruncateText does not fit.

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