metrics

package
v1.68.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Go Multi-Agent - Metrics Display

  • ChatCLI - CLI metrics

  • Copyright (c) 2024 Edilson Freitas

  • License: MIT

  • ChatCLI - CLI metrics

  • Copyright (c) 2024 Edilson Freitas

  • License: MIT

  • ChatCLI - Metrics Timer

  • Copyright (c) 2024 Edilson Freitas

  • License: MIT

Index

Constants

View Source
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 ClearLine

func ClearLine() string

func ClearLines added in v1.68.2

func ClearLines(n int) string

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 FormatDuration(d time.Duration) string

func FormatDurationShort

func FormatDurationShort(d time.Duration) string

func FormatTimerComplete

func FormatTimerComplete(d time.Duration) string

func FormatTimerStatus

func FormatTimerStatus(d time.Duration, model, msg string) string

func FormatTurnInfo

func FormatTurnInfo(t, m int, d time.Duration, stats *TurnStats) string

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.

type AgentSlot added in v1.68.2

type AgentSlot struct {
	CallID   string
	Agent    string
	Task     string
	Status   AgentSlotStatus
	Duration time.Duration
	Error    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

func (*Spinner) Next added in v1.49.0

func (s *Spinner) Next() string

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer representa um cronometro de execução com display em tempo real

func NewTimer

func NewTimer() *Timer

NewTimer cria um novo timer

func (*Timer) Elapsed

func (t *Timer) Elapsed() time.Duration

Elapsed retorna o tempo decorrido (funciona mesmo com timer rúdando)

func (*Timer) IsRunning

func (t *Timer) IsRunning() bool

IsRunning retorna se o timer está em execução

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.

func (*Timer) Resume added in v1.64.0

func (t *Timer) Resume()

Resume restores the display output after a Pause.

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.

func (*Timer) Start

func (t *Timer) Start(ctx context.Context, displayFunc func(duration time.Duration))

Start inicia o timer e opcionalmente atualiza o display em tempo real

func (*Timer) Stop

func (t *Timer) Stop() time.Duration

Stop para o timer e retorna a duração total

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
}

TurnStats holds per-turn and accumulated session counters.

Jump to

Keyboard shortcuts

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