Documentation
¶
Overview ¶
Go Multi-Agent - Metrics Display
ChatCLI - CLI metrics
Copyright (c) 2024 Edilson Freitas
License: Apache-2.0
ChatCLI - CLI metrics
Copyright (c) 2024 Edilson Freitas
License: Apache-2.0
ChatCLI - Metrics Timer
Copyright (c) 2024 Edilson Freitas
License: Apache-2.0
Index ¶
- Constants
- func ClearLine() string
- func ClearLines(n int) string
- func FormatDispatchProgress(state *AgentProgressState, model string) string
- func FormatDuration(d time.Duration) string
- func FormatDurationShort(d time.Duration) string
- func FormatTimerComplete(d time.Duration) string
- func FormatTimerStatus(d time.Duration, model, msg string) string
- func FormatTurnInfo(t, m int, d time.Duration, stats *TurnStats) string
- func GetDotsAnimation() string
- func GetSpinnerFrame() string
- type AgentProgressState
- func (p *AgentProgressState) CompletedCount() int
- func (p *AgentProgressState) LineCount() int
- func (p *AgentProgressState) MarkCompleted(callID string, d time.Duration)
- func (p *AgentProgressState) MarkFailed(callID string, d time.Duration, errMsg string)
- func (p *AgentProgressState) MarkStarted(callID string)
- func (p *AgentProgressState) SetLive(callID string, turn, maxTurns int, action string, subLines []string)
- type AgentSlot
- type AgentSlotStatus
- type Spinner
- type Timer
- type TurnStats
Constants ¶
const ( ColorReset = "\033[0m" ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorRed = "\033[31m" ColorCyan = "\033[36m" ColorGray = "\033[90m" ColorBold = "\033[1m" )
Variables ¶
This section is empty.
Functions ¶
func ClearLines ¶ added in v1.68.2
ClearLines moves cursor up N lines and clears each one.
func FormatDispatchProgress ¶ added in v1.68.2
func FormatDispatchProgress(state *AgentProgressState, model string) string
FormatDispatchProgress renders a multi-line live progress display.
func FormatDuration ¶
func FormatDurationShort ¶
func FormatTimerComplete ¶
func GetDotsAnimation ¶ added in v1.49.0
func GetDotsAnimation() string
func GetSpinnerFrame ¶ added in v1.49.0
func GetSpinnerFrame() string
Types ¶
type AgentProgressState ¶ added in v1.68.2
type AgentProgressState struct {
Total int
Agents []AgentSlot
StartTime time.Time
// contains filtered or unexported fields
}
AgentProgressState tracks the live status of each agent in a dispatch batch. It is safe for concurrent use.
func NewAgentProgressState ¶ added in v1.68.2
func NewAgentProgressState(total int, agents []struct{ CallID, Agent, Task string }) *AgentProgressState
NewAgentProgressState creates a progress tracker for N agents.
func (*AgentProgressState) CompletedCount ¶ added in v1.68.2
func (p *AgentProgressState) CompletedCount() int
CompletedCount returns how many agents have finished (completed + failed).
func (*AgentProgressState) LineCount ¶ added in v1.68.2
func (p *AgentProgressState) LineCount() int
LineCount returns the number of display lines FormatDispatchProgress produces.
func (*AgentProgressState) MarkCompleted ¶ added in v1.68.2
func (p *AgentProgressState) MarkCompleted(callID string, d time.Duration)
MarkCompleted marks an agent as completed.
func (*AgentProgressState) MarkFailed ¶ added in v1.68.2
func (p *AgentProgressState) MarkFailed(callID string, d time.Duration, errMsg string)
MarkFailed marks an agent as failed.
func (*AgentProgressState) MarkStarted ¶ added in v1.68.2
func (p *AgentProgressState) MarkStarted(callID string)
MarkStarted marks an agent as running.
func (*AgentProgressState) SetLive ¶ added in v1.176.0
func (p *AgentProgressState) SetLive(callID string, turn, maxTurns int, action string, subLines []string)
SetLive refreshes a slot's live progress fields (current turn, action and subagent sub-lines). Fed from the agent run registry on each redraw tick; zero/empty values clear the corresponding field.
type AgentSlot ¶ added in v1.68.2
type AgentSlot struct {
CallID string
Agent string
Task string
Status AgentSlotStatus
Duration time.Duration
Error string
// Live progress (fed from the agent run registry between redraw ticks).
Turn int // current ReAct turn (0 = unknown)
MaxTurns int // turn budget (0 = unknown)
Action string // current action label, e.g. "read cli/foo.go"
// SubLines holds pre-formatted, newline-separated lines rendered
// indented under this agent (e.g. live subagents spawned by it). Kept
// as a single string so AgentSlot stays comparable.
SubLines string
}
AgentSlot represents the current status of a single agent.
type AgentSlotStatus ¶ added in v1.68.2
type AgentSlotStatus int
AgentSlotStatus represents the lifecycle state of an agent slot.
const ( SlotPending AgentSlotStatus = iota SlotRunning SlotCompleted SlotFailed )
type Spinner ¶ added in v1.49.0
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶ added in v1.49.0
func NewSpinner() *Spinner
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer representa um cronometro de execução com display em tempo real
func (*Timer) Pause ¶ added in v1.64.0
func (t *Timer) Pause()
Pause temporarily suppresses the display output without stopping the timer. The elapsed time continues accumulating. Call Resume to restore display. If an onPause callback was registered, it runs under the mutex before pausing, allowing multi-line displays to be properly cleared.
Pause/Resume pairs nest: each Pause increments a depth counter and the display only restarts when the counter drains back to zero, so concurrent pausers (security prompt, mid-run side command) never resume each other's display prematurely.
func (*Timer) Resume ¶ added in v1.64.0
func (t *Timer) Resume()
Resume restores the display output after a Pause once every outstanding pauser has resumed.
func (*Timer) SetOnPause ¶ added in v1.68.3
func (t *Timer) SetOnPause(f func())
SetOnPause registers a callback that runs (under mu) when Pause is called. Use this to clear multi-line displays before a security prompt takes over. The callback runs under the same mutex as displayFunc, so sharing closure variables (like a line counter) between them is safe without extra locking.
type TurnStats ¶ added in v1.62.0
type TurnStats struct {
// Per-turn counters (reset each turn)
TurnAgents int
TurnToolCalls int
// Session totals (accumulated across all turns)
SessionAgents int
SessionToolCalls int
// Telemetry is a pre-formatted, locale-aware, " · "-joined telemetry
// string (token in/out, context %, cost, compression savings) appended to
// the end of the turn line. A plain string (not a slice) keeps TurnStats
// comparable and the metrics package free of any cli/i18n/catalog import.
Telemetry string
}
TurnStats holds per-turn and accumulated session counters.