Documentation
¶
Index ¶
- Constants
- func ApprovalPrompt(tool, scopeDescription string, allowAlways bool) string
- func ApprovalPromptWithTranslator(t i18n.Translator, tool, scopeDescription string, allowAlways bool) string
- func BuildChatContext(tr i18n.Translator, rep ContextReport, tools ToolsInfo, ...) string
- func BuildChatContextFiles(tr i18n.Translator, rep ContextReport, files []personal.LoadedFile) string
- func BuildChatHelp(tr i18n.Translator) string
- func BuildChatModel(tr i18n.Translator, current ModelOption, options []ModelOption) string
- func BuildChatSkills(tr i18n.Translator, items []SkillInfo, namesOnly bool, limit int) string
- func BuildChatTasks(tr i18n.Translator, items []tasks.Info, now time.Time, showAll bool) string
- func BuildChatUsage(tr i18n.Translator, stats chatStats) string
- func BuildCheckpoints(tr i18n.Translator, rows []personal.Checkpoint) string
- func BuildUndoPlan(tr i18n.Translator, rows []personal.Checkpoint, command undoCommand) string
- func BuildUndoResult(tr i18n.Translator, result personal.UndoResult, rows []personal.Checkpoint) string
- func FormatElapsed(d time.Duration) string
- func ModelLabel(provider, model string) string
- func PersistPrompt(action string) string
- func PersistPromptWithTranslator(t i18n.Translator, action string) string
- func Run(ctx context.Context, runner *personal.Runner, opts Options, stdin io.Reader, ...) error
- type ApprovalReply
- type BannerInfo
- type ContextFile
- type ContextPart
- type ContextReport
- type ExitSummary
- type LastReplyInfo
- type LayoutLine
- type ModelOption
- type ModelSwitch
- type Options
- type PersistReply
- type Renderer
- func (r *Renderer) AgentTaskSummaries(infos []tasks.Info)
- func (r *Renderer) Answer(text string)
- func (r *Renderer) ApprovalDetails(q tools.Question) string
- func (r *Renderer) ApprovalDiff(qTool string) string
- func (r *Renderer) ApprovalPrompt(q tools.Question) string
- func (r *Renderer) Banner()
- func (r *Renderer) BeginTurn()
- func (r *Renderer) EndTurnAgents()
- func (r *Renderer) Error(err error)
- func (r *Renderer) External(text string)
- func (r *Renderer) Finish() bool
- func (r *Renderer) FollowUpQueued(text string)
- func (r *Renderer) FollowUpSent(text string)
- func (r *Renderer) Handle(event personal.Event)
- func (r *Renderer) Hint(text string)
- func (r *Renderer) Interrupt()
- func (r *Renderer) LastReply(text, sessionID string, incomplete bool)
- func (r *Renderer) Notice(text string)
- func (r *Renderer) Prompt(waiting bool) string
- func (r *Renderer) SetModel(provider, model, thinking string, contextWindow int)
- func (r *Renderer) SetSessionName(name string)
- func (r *Renderer) ShowCode(arg string)
- func (r *Renderer) ShowDiff(arg string)
- func (r *Renderer) Status(result personal.RunResult, elapsed time.Duration, steers int)
- func (r *Renderer) SteerDelivered(text string)
- func (r *Renderer) SteerLate(text string)
- func (r *Renderer) SteerWaiting(text string)
- func (r *Renderer) SteerWithdrawn(text string)
- type SessionDirs
- type SkillInfo
- type ToolsInfo
- type TurnMetrics
- type TurnStatus
Constants ¶
const ( ReplyDeny = chatui.ReplyDeny ReplyAllow = chatui.ReplyAllow ReplyAllowAlways = chatui.ReplyAllowAlways ReplyDenyAlways = chatui.ReplyDenyAlways )
const ( PersistSession = chatui.PersistSession PersistUser = chatui.PersistUser PersistProject = chatui.PersistProject )
Variables ¶
This section is empty.
Functions ¶
func ApprovalPrompt ¶
func ApprovalPromptWithTranslator ¶
func ApprovalPromptWithTranslator(t i18n.Translator, tool, scopeDescription string, allowAlways bool) string
func BuildChatContext ¶
func BuildChatContext(tr i18n.Translator, rep ContextReport, tools ToolsInfo, usage personal.ContextUsage) string
BuildChatContext renders :context: one line per part with its size and estimated tokens, the tool table, the handoff package and the history, then the estimate of the whole request and the last turn's traced estimate.
func BuildChatContextFiles ¶
func BuildChatContextFiles(tr i18n.Translator, rep ContextReport, files []personal.LoadedFile) string
BuildChatContextFiles renders :context --files: the files the context carries TOGETHER with where each came from. Tool-read files come first, most recent use first; the rule sources follow, since they are resident from the start.
func BuildChatHelp ¶
func BuildChatHelp(tr i18n.Translator) string
BuildChatHelp returns the complete local-command and keyboard help text.
func BuildChatModel ¶
func BuildChatModel(tr i18n.Translator, current ModelOption, options []ModelOption) string
BuildChatModel renders the current effective model and the configured choices.
func BuildChatSkills ¶
BuildChatSkills renders :skills: one line per skill with its description and source, or only the names (--only-names). limit 0 lists every skill; a smaller limit keeps the first ones by name and says how many are left.
func BuildChatTasks ¶
BuildChatTasks renders the task manager's snapshot for :tasks: by default the running tasks plus the 10 most recently active finished ones and how many are left; showAll lists every task in start order.
func BuildChatUsage ¶
func BuildChatUsage(tr i18n.Translator, stats chatStats) string
BuildChatUsage renders process and session usage using the same counters as the exit summary.
func BuildCheckpoints ¶
func BuildCheckpoints(tr i18n.Translator, rows []personal.Checkpoint) string
BuildCheckpoints renders the read-only checkpoint list. Every value originating from a path, event, or model call is cleaned before it can reach the terminal.
func BuildUndoPlan ¶
func BuildUndoPlan(tr i18n.Translator, rows []personal.Checkpoint, command undoCommand) string
func BuildUndoResult ¶
func BuildUndoResult(tr i18n.Translator, result personal.UndoResult, rows []personal.Checkpoint) string
func FormatElapsed ¶
FormatElapsed renders a duration for status lines (ms, s, then 1m2s).
func ModelLabel ¶
ModelLabel is "provider/model" (or whichever part is known).
func PersistPrompt ¶
func PersistPromptWithTranslator ¶
func PersistPromptWithTranslator(t i18n.Translator, action string) string
Types ¶
type ApprovalReply ¶
type ApprovalReply = chatui.ApprovalReply
ApprovalReply and PersistReply remain chat aliases for compatibility; the reusable parsing and prompt component lives in pkg/chatui.
func ParseApprovalReply ¶
func ParseApprovalReply(answer string) ApprovalReply
type BannerInfo ¶
type BannerInfo struct {
// Provider and Model label the head line; either may be empty.
Provider, Model string
// Thinking is the effective thinking level ("" = the provider's default)
// and ContextWindow the model's token window (0 = unknown).
Thinking string
ContextWindow int
// SessionName is the session's short name ("<workspace directory>-k7", the
// address `suga send --session <name>` accepts); empty while it is unknown,
// which keeps it off the head line.
SessionName string
// WriteTools selects the tool line: write and shell available, or read only.
// Translator is the host UI catalog; nil preserves legacy Chinese output.
Translator i18n.Translator
WriteTools bool
}
BannerInfo is everything the startup banner shows.
type ContextFile ¶
ContextFile is one file of a part: the rule sources the session read.
type ContextPart ¶
type ContextPart struct {
Name string
Bytes int
Tokens int
Note string
Files []ContextFile
}
ContextPart is one measured part of the current context, filled from the runtime's resident report (the same strings the provider receives, measured by the same estimator the context trace event uses).
type ContextReport ¶
type ContextReport struct {
Parts []ContextPart
Deferred int
Loaded int
}
ContextReport is what the runtime measures of the resident context plus the deferred native tools: how many are deferred and how many were loaded.
type ExitSummary ¶
type ExitSummary struct {
// SessionID is the session `suga chat --resume <id>` continues; an empty one
// means the summary is not printed at all.
SessionID string
// ShortName is the session's short name (the address `suga send --session
// <name>` accepts), shown before the resume command; empty keeps it out.
ShortName string
// Turns and Usage are what this chat process ran; SessionUsage is the
// session's cumulative usage after the last turn (its token counts 0:
// unknown, keeps that part out).
Turns int
Usage agentcore.Usage
SessionUsage agentcore.Usage
// Elapsed is how long this chat process ran.
Elapsed time.Duration
// Translator is the host UI catalog; nil preserves legacy Chinese output.
Translator i18n.Translator
}
ExitSummary is everything the exit summary shows.
type LastReplyInfo ¶
type LastReplyInfo struct {
// Incomplete notes that the previous turn did not end normally.
Incomplete bool
// Omitted is how many leading lines of a long reply are not shown (0: the
// whole reply is); a positive count adds the hint naming the trace command.
Omitted int
// SessionID only names the trace command of that hint.
SessionID string
// Translator is the host UI catalog; nil preserves legacy Chinese output.
Translator i18n.Translator
}
LastReplyInfo is what the preview of a continued session's last reply shows besides the reply itself: the label above it and the two notes about it.
type LayoutLine ¶
LayoutLine is one line of chat's layout: its text and the color it is painted in (colorNone: plain text).
func BuildBanner ¶
func BuildBanner(info BannerInfo) []LayoutLine
BuildBanner builds the chat header: the model in use, the commands, and whether the tools can write.
func BuildExitSummary ¶
func BuildExitSummary(s ExitSummary) []LayoutLine
BuildExitSummary builds the lines chat leaves behind when it ends: the resume command (behind the session's short name), this process's turns and tokens (plus the session total when known) and its running time. A chat without a session builds no lines.
func BuildLastReplyNotices ¶
func BuildLastReplyNotices(info LastReplyInfo) []LayoutLine
BuildLastReplyNotices builds the lines chat prints above the last reply of a session it continues: a dim label first, so the reply is not taken for a fresh answer, then the notes about that reply. The reply body is not part of them: the caller streams it like an answer (marker, markdown).
func BuildTurnMetrics ¶ added in v0.53.0
func BuildTurnMetrics(m TurnMetrics) []LayoutLine
BuildTurnMetrics builds the compact metrics line, "cache 82% · ctx 41% · 折叠余量 37% · 后台 2": gray, one line. An item without data is left out, and nil comes back when no item has any, so a turn without usage prints nothing.
func BuildTurnStatus ¶
func BuildTurnStatus(s TurnStatus) []LayoutLine
BuildTurnStatus builds the end of a turn: one green line per memory write of the turn, then the grey status line (model, token usage, how full the context is, elapsed time, the local time the turn ended at, inserted messages).
func (LayoutLine) Paint ¶
func (l LayoutLine) Paint(colorOn bool) string
Paint returns the line as it is written: the text as it is, or wrapped in the line's color when the output takes colors (a pipe, a redirected output or NO_COLOR prints the plain text).
type ModelOption ¶
type ModelOption struct {
Provider string
Model string
Thinking string
ContextWindow int
MaxOutputTokens int
}
Options selects which session a chat opens: a new one, an existing one, or a handoff child of another session. ModelOption is one configured model shown by :model and offered to completion.
func (ModelOption) Ref ¶
func (m ModelOption) Ref() string
type ModelSwitch ¶
type ModelSwitch func(ctx context.Context, sessionID, ref string) (ModelOption, error)
ModelSwitch activates a model for the next turn and returns its effective settings.
type Options ¶
type Options struct {
SessionID string
ResumeID string
// FromID starts a NEW session that inherits state from this session.
FromID string
// Asker is where the chat approver asks before running a tool. Run binds
// the terminal input to it only when stdin is a terminal; left unbound,
// every tool that needs a confirmation is refused. May be nil.
Asker *tools.BindableAsker
// WriteTools tells the banner whether file_write/shell_exec are available.
WriteTools bool
// Markdown renders the model's text as terminal markdown (config
// chat.markdown, on by default). Only a colored terminal uses it: a pipe,
// a redirected output or NO_COLOR keeps the raw text.
Markdown bool
// Spinner shows the "思考中…" waiting line while the model is asked for its
// next message (config chat.spinner, on by default). Like Markdown it needs
// a colored terminal: a pipe, a redirected output or NO_COLOR keeps it off.
Spinner bool
// AgentProgress controls sub-agent tool-call display: summary (default), full or off.
AgentProgress string
// HighlightInput paints the line the person submitted at the prompt, and the
// messages delivered from elsewhere, on a background of their own (config
// chat.highlight_input, on by default). Like Markdown it needs a colored
// terminal: a pipe, a redirected output or NO_COLOR keeps the plain text.
HighlightInput bool
// Steering keeps the input line available while a turn runs (config
// chat.steering, on by default): Enter inserts a message into the running
// turn, Esc or a single Ctrl-C ends this turn only, a second Ctrl-C within
// three seconds leaves chat. It needs a terminal: with a pipe or a redirected
// input a turn keeps the plain behaviour (nothing is read while it runs).
Steering bool
// Win32InputMode is chat.win32_input_mode (auto|on|off): whether the input
// read asks the terminal for win32-input-mode records (DECSET 9001), which is
// what makes Ctrl+Enter insert a newline instead of submitting the line. auto
// (the empty string) asks for it in Windows Terminal only.
Win32InputMode string
// TerminalTitle sets the terminal's window/tab title to the session, "suga ·
// <short name> · <session title>" (config chat.terminal_title, on by
// default). Like Markdown it needs a colored terminal: a pipe, a redirected
// output or NO_COLOR leaves the title alone.
TerminalTitle bool
// StatusMetrics adds the compact metrics line (cache hit rate, context share,
// folding headroom, running background tasks) under the end-of-turn status line
// (config chat.status_metrics, on by default). Like Markdown it needs a colored
// terminal: a pipe, a redirected output or NO_COLOR keeps the old output.
StatusMetrics bool
// Diff shows what a file tool call changed (config chat.diff, on by default):
// the unified diff under the tool result, the pending one before an approval
// question, and the :diff command. DiffLines caps how many lines one preview
// shows (chat.diff_lines, default 20); :diff shows the whole change. The change
// itself arrives on the runner's tool_call events, which the CLI turns on for
// chat (personal.Config.DiffPreview).
Diff bool
DiffLines int
// CodeHighlight colors a fenced code block by the language of its fence
// (config chat.code_highlight, on by default) and CodeMaxLines folds a block
// after that many lines (chat.code_max_lines, default 40; 0 folds nothing), the
// rest being shown by the :code command. Like Markdown they need a colored
// terminal.
CodeHighlight bool
CodeMaxLines int
// Theme is the palette the markdown rendering paints with (chat.theme,
// resolved to "dark" or "light"; empty keeps the dark default). Like the code
// options it only applies to a colored terminal.
Theme string
// Colors is chat.colors: the styles of chat's own lines - the tool families, the
// ok/error labels and the dim arguments. Its theme-dependent defaults come from
// Theme, and an unknown key, style, mode or color stops chat (see newPalette).
Colors map[string]string
// Thinking (the effective thinking level, "" = provider default) and
// ContextWindow (tokens, 0 = unknown) are shown in the banner.
Thinking string
ContextWindow int
// IdleAfter and IdleMinRatio configure the idle consolidation
// (context.idle_after, context.idle_min_ratio); IdleAfter 0 turns it off.
IdleAfter time.Duration
IdleMinRatio float64
// Tasks are the background tasks of this chat (nil: none); TaskWake
// signals a task end that should start a turn when chat is idle
// (tasks.wake_on_exit; nil: never).
Tasks *tasks.Manager
TaskWake <-chan struct{}
// Notify controls terminal completion/question notifications.
Notify string
NotifyAfter time.Duration
// StopBackground runs each Stop hook as a background task of Tasks
// (hooks.stop_background): typing does not interrupt it and a block
// reply arrives as a task notice. Needs Tasks.
StopBackground bool
// SetupSession, when set, runs once the session is open and before the first
// turn (the CLI publishes the session's added directories there); a failure
// stops the chat.
SetupSession func(ctx context.Context, sessionID string) error
// Dirs is the session's added-directory handle (--add-dir): the :add-dir,
// :dirs and :rm-dir commands work through it and nil leaves them out. The
// session it belongs to is opened by SetupSession, so it is only used from
// the loop on.
Dirs SessionDirs
// ReadImage loads a picture for the :image command and the Alt+V paste with
// the view_image rules (design 0.3); the CLI builds it over the session's
// workspace. ReadImage nil leaves both unavailable.
ReadImage func(path string) (agentcore.ImagePart, string, error)
// PasteImage reads one picture from the system clipboard for Alt+V (the
// same queue as :image); the CLI builds it per-platform with the view_image
// pipeline. PasteImage nil leaves the binding out.
PasteImage func() (agentcore.ImagePart, string, error)
// Vision is the live "the current model can see images" gate (nil = can
// see), the same one the runtime moves on a :model switch.
Vision *tools.VisionGate
// ModelOptions and ModelSwitch back the local :model command. Keeping the
// callback here avoids making chat depend on runtime wiring.
ModelOptions []ModelOption
ModelSwitch ModelSwitch
// Local runs a line the person typed at the prompt with a leading "!"
// ("!cmd": run it in the local shell; "!!cmd": run it and hand its result to
// the model with the next message). The CLI builds it with the same shell,
// workspace and output limits shell_exec uses; nil leaves the prefix an
// ordinary message (run, ACP, a chat without one).
Local *native.LocalCommand
// SetCallRewriter installs the pre-decision rewriter of the runtime's approval
// layer. Run hands it the PreToolUse hook (hooks.pre_tool_use.tools) once the
// hook client is recorded, so a rewritten call is approved on its new
// arguments and a failing hook refuses the call. nil leaves tool calls alone.
SetCallRewriter func(tools.CallRewriter)
// ContextNotices are the resident context warnings of this chat (rules
// truncated, a soft threshold crossed, skipped or shadowed skills). Run
// prints each once, on stderr, when the session is open; they never change
// what the model receives. A nil slice prints nothing.
ContextNotices []string
// Translator is the host UI catalog; nil callers use the Chinese compatibility fallback.
Translator i18n.Translator
// Skills lists the loaded skills for :skills; nil marks the command as
// unavailable in this process (a chat without the skill registry).
Skills func() []SkillInfo
// ContextParts reports the resident context composition for :context; nil
// leaves the command with the tool table, history and handoff only.
ContextParts func(context.Context) ContextReport
// contains filtered or unexported fields
}
type PersistReply ¶
type PersistReply = chatui.PersistReply
func ParsePersistReply ¶
func ParsePersistReply(answer string) PersistReply
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer owns all terminal output of one chat: prompt, streamed model text, tool lines, diff previews, plans, errors and the per-turn status line.
func (*Renderer) AgentTaskSummaries ¶
AgentTaskSummaries prints completions of background agents before their task notice. The task manager owns their counters because they outlive the turn.
func (*Renderer) Answer ¶
Answer prints a final answer that was not streamed: the streamed text's own renderer does it, so the message prefix, markdown and whole-line handling stay exactly the ones used by the streamed case.
func (*Renderer) ApprovalDetails ¶
ApprovalDetails formats the full key arguments of an approval question, one indented item per detail (continuation lines indented further). Nothing is truncated: the person must see exactly what will run.
func (*Renderer) ApprovalDiff ¶
ApprovalDiff returns the pending file change before the approval question.
func (*Renderer) ApprovalPrompt ¶
ApprovalPrompt is the line the approval answer is typed on.
func (*Renderer) Banner ¶
func (r *Renderer) Banner()
Banner prints the chat header: the model in use and the commands. The text and its styles are built by BuildBanner (layout.go).
func (*Renderer) BeginTurn ¶
func (r *Renderer) BeginTurn()
BeginTurn resets the per-turn text streaming state and starts the waiting line: the model was just asked for a new message.
func (*Renderer) EndTurnAgents ¶
func (r *Renderer) EndTurnAgents()
EndTurnAgents forgets the entries no background task backs: a foreground sub-agent ends with its turn (a cancelled turn leaves no tool result, a failed one no summary), so the status line of the next turn starts clean.
func (*Renderer) External ¶
External prints input that did not come from this keyboard (a reply sent from elsewhere through `suga send` or a Stop hook) in its own color, so it stands out from the model's answer. With chat.highlight_input on and a colored terminal each line is painted on a background of its own instead (the magenta family, so it is not taken for the person's own line), reaching the end of the terminal row.
func (*Renderer) FollowUpQueued ¶
FollowUpQueued prints the line a Tab press queued during a turn (followup.go): it does not go into the running turn, it waits for the next one.
func (*Renderer) FollowUpSent ¶
FollowUpSent prints that line again when the turn it was queued for starts.
func (*Renderer) Handle ¶
Handle renders one runner event: text deltas, tool calls/results, plans and budget observations. Events the chat does not render (run_started, usage, ...) leave the waiting line alone; budget observations update the final line and may emit one threshold reminder per turn.
func (*Renderer) Interrupt ¶
func (r *Renderer) Interrupt()
Interrupt reports a turn that was interrupted while it ran (Ctrl-C) on the chat output, in place of the runner's cancellation error: the catalog's notice, never the runner's raw "context canceled". cmd/suga still reports the process-wide 已中断 with exit 130, and run, ACP and stream-json keep the raw error text.
func (*Renderer) LastReply ¶
LastReply prints the last reply of a session chat continues, above the first prompt: the dim label and notes of BuildLastReplyNotices (layout.go) first, so it is not taken for a fresh answer, then the reply itself, rendered like an answer.
func (*Renderer) SetModel ¶
SetModel updates the model label used by the banner and every later status line.
func (*Renderer) SetSessionName ¶
SetSessionName records the session's short name for the banner; chat calls it once the local session socket is registered (before Banner).
func (*Renderer) ShowCode ¶
ShowCode prints a code block of the last answer in full: without an argument the most recent folded one, with N the Nth block of that answer in order. The block goes through the markdown renderer again, so it is highlighted like it streamed (with no fold limit).
func (*Renderer) ShowDiff ¶
ShowDiff prints a remembered change in full; :diff N selects the Nth change.
func (*Renderer) Status ¶
Status prints the end of a turn on the chat output: the memory lines of the turn and the status line (model, token usage, context share, elapsed time, local end time, inserted messages). The text and their styles are built by BuildTurnStatus (layout.go); this only collects the data.
func (*Renderer) SteerDelivered ¶
SteerDelivered prints the message again once a model request of the turn carried it (its "steer_delivered" event), on the background of the person's own input line (chat.highlight_input) - the same style the line submitted at the prompt gets, so a delivered message reads as the person's own.
func (*Renderer) SteerLate ¶
SteerLate prints that line when the turn did not take the message (it was already ending, or its inbox was full): it becomes the person's next input.
func (*Renderer) SteerWaiting ¶
SteerWaiting prints the line of a message a person inserted into the running turn that no model request has picked up yet: dim, like a tool line, so it is not taken for the model's answer.
func (*Renderer) SteerWithdrawn ¶
SteerWithdrawn prints the message once the person took it back out of the running turn's inbox with Up on an empty input line: the waiting line becomes the withdrawn one, the same in-place update a delivered message gets (SteerDelivered), and the text is on the input line for editing again.
type SessionDirs ¶
type SessionDirs interface {
// Workspace is the workspace root the file tools are confined to; List
// returns it as its first entry.
Workspace() string
// List returns the directories the session may reach: the workspace first,
// then the added ones in order, each with the mode in effect and where it
// came from (an adddir.Source* value; "" when unknown).
List(ctx context.Context) ([]adddir.Dir, error)
// Add authorizes one value ("<absolute directory>[:ro|:rw]", default :ro)
// for this session and reports the entry that took effect; source says who
// asked (adddir.SourceSession for a typed command).
Add(ctx context.Context, value, source string) (adddir.Dir, error)
// Remove revokes a directory (a trailing :ro/:rw, as :dirs prints it, is
// accepted and ignored) and reports whether it was in the set.
Remove(ctx context.Context, value string) (bool, error)
}
SessionDirs is the session's added-directory handle (--add-dir): chat's :add-dir, :dirs and :rm-dir commands and the outside-directory authorization both go through it, so the session metadata (add_dirs) and the set the tools read stay in step. The CLI owns the implementation (wiring.SessionAddDirs); nil (run, ACP, a test without one) leaves the commands out.
type SkillInfo ¶
SkillInfo is one loaded skill as :skills lists it: the name, the one-line description, where it came from (项目/内置/用户) and the SKILL.md path. The CLI fills it from the runtime's skill registry.
type ToolsInfo ¶
ToolsInfo is what :context says of the tool table: the schema size, how many tools it holds, how many are MCP ones and the deferred native ones.
type TurnMetrics ¶ added in v0.53.0
type TurnMetrics struct {
// Usage is this turn's model usage: CacheReadTokens over InputTokens (the
// input count already includes the cache) is the turn's cache hit rate.
Usage agentcore.Usage
// LastInputTokens and ContextWindow give the context share, the same
// "ctx 55%" figure as the status line (either unknown keeps it out).
LastInputTokens, ContextWindow int
// FoldThreshold is the input size (tokens) at which the runner folds the
// context into a new segment (personal.Runner.ContextThreshold); with
// LastInputTokens it gives the headroom left before that (0 = unknown).
FoldThreshold int
// Background is how many background tasks are running now.
Background int
// Translator is the host UI catalog; nil preserves legacy Chinese output.
Translator i18n.Translator
}
TurnMetrics is what the compact metrics line under the status line shows (chat.status_metrics). Every field is "unknown" at its zero value, and an unknown item stays out of the line.
type TurnStatus ¶
type TurnStatus struct {
// Memory lists this turn's successful memory writes, one line each, shown
// above the status line.
Memory []string
// Provider and Model label the line; either may be empty.
Provider, Model string
// Usage is what this turn's model calls used.
Usage agentcore.Usage
// Budget is the latest budget observation of this turn. It is nil when no
// budget is configured, preserving the historical status line byte-for-byte.
Budget *personal.BudgetSnapshot
// LastInputTokens is the input token count (cache included) of the turn's
// last model request and ContextWindow is the model's window: together they
// give the "ctx 55%" part (either unknown keeps it out).
LastInputTokens, ContextWindow int
// Elapsed is how long the turn took.
Elapsed time.Duration
// EndTime is the local time the turn ended at, shown as HH:MM.
EndTime time.Time
// Steers is how many inserted messages a model request of the turn carried
// (the delivered ones; a message taken back with Up, or one the turn never
// took, is not counted); 0 keeps that part out of the line.
Steers int
// Truncated marks an answer the model cut off at the output token limit
// (personal.RunResult.Truncated); OutputLimit is that limit in tokens
// (0 = neither the configuration nor the provider named one).
Truncated bool
// Translator is the host UI catalog; nil preserves legacy Chinese output.
Translator i18n.Translator
OutputLimit int
}
TurnStatus is everything the end-of-turn status shows.
Source Files
¶
- approval_reply.go
- ask.go
- autocomplete.go
- chat.go
- chat_commands.go
- chat_context.go
- chat_delivery.go
- chat_dirs.go
- chat_idle.go
- chat_input.go
- chat_input_delivery.go
- chat_nudge.go
- chat_skills.go
- chat_turn.go
- chat_undo.go
- chat_usage.go
- code.go
- colors.go
- delivery_images.go
- diff.go
- followup.go
- highlight.go
- history.go
- hooks_gate.go
- hooks_record.go
- i18n.go
- input_pump.go
- layout.go
- local_cmd.go
- notify.go
- render.go
- render_agents.go
- render_memory.go
- session_message.go
- session_name.go
- spinner.go
- steer_send.go
- steering.go
- stop_background.go
- terminal_title.go
- title_other.go
- tool_summary.go