tui

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentConsoleArgsForLine

func AgentConsoleArgsForLine(line string) ([]string, error)

func AgentStreamingEnabled

func AgentStreamingEnabled(_ *cfg.Option) bool

func RunAgentConsoleWithTerminal

func RunAgentConsoleWithTerminal(ctx context.Context, option *cfg.Option, appInfo AppInfo, session *agent.Agent, terminal *rlterm.Terminal, bus ...*eventbus.Bus[agent.Event]) error

func RunIOAContext

func RunIOAContext(ctx context.Context, client *ioaclient.Client, option *cfg.Option, args cfg.IOAClientArgs, stdout, stderr io.Writer) error

func RunIOAMessages

func RunIOAMessages(ctx context.Context, client *ioaclient.Client, option *cfg.Option, args cfg.IOAClientArgs, stdout, stderr io.Writer) error

func RunIOANodes

func RunIOANodes(ctx context.Context, client *ioaclient.Client, option *cfg.Option, args cfg.IOAClientArgs, stdout, stderr io.Writer) error

func RunIOASpaces

func RunIOASpaces(ctx context.Context, client *ioaclient.Client, option *cfg.Option, stdout, stderr io.Writer) error

func RunPrompt

func RunPrompt(s *Session, label, input string) error

RunPrompt expands skills and submits a prompt to the controller.

func RunRemoteAgentConsole

func RunRemoteAgentConsole(ctx context.Context, option *cfg.Option, appInfo AppInfo, session *agent.Agent, input io.Reader, output io.Writer, bus ...*eventbus.Bus[agent.Event]) error

RunRemoteAgentConsole runs the agent console over a byte-stream transport. The transport provides raw terminal input and receives terminal output.

func RunRemoteAgentConsoleWithControl

func RunRemoteAgentConsoleWithControl(ctx context.Context, option *cfg.Option, appInfo AppInfo, session *agent.Agent, input io.Reader, output io.Writer, control *rlterm.StreamControl, bus ...*eventbus.Bus[agent.Event]) error

Types

type AgentConsole

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

func NewAgentConsole

func NewAgentConsole(ctx context.Context, option *cfg.Option, appInfo AppInfo, session *agent.Agent, output *AgentOutput, bus ...*eventbus.Bus[agent.Event]) *AgentConsole

func NewAgentConsoleWithTerminal

func NewAgentConsoleWithTerminal(ctx context.Context, option *cfg.Option, appInfo AppInfo, session *agent.Agent, output *AgentOutput, t *rlterm.Terminal, bus ...*eventbus.Bus[agent.Event]) *AgentConsole

func (*AgentConsole) InterruptCurrentRun

func (r *AgentConsole) InterruptCurrentRun() bool

InterruptCurrentRun stops the current agent run or direct command.

func (*AgentConsole) Start

func (r *AgentConsole) Start() error

type AgentOutput

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

func NewAgentOutput

func NewAgentOutput(option *cfg.Option) *AgentOutput

func NewAgentOutputWithWriters

func NewAgentOutputWithWriters(option *cfg.Option, stdout, stderr io.Writer, terminal bool) *AgentOutput

func NewStaticAgentOutput added in v0.2.7

func NewStaticAgentOutput(option *cfg.Option) *AgentOutput

func NewStaticAgentOutputWithWriters added in v0.2.7

func NewStaticAgentOutputWithWriters(option *cfg.Option, stdout, stderr io.Writer, terminal bool) *AgentOutput

func (*AgentOutput) AbortCurrentRun

func (o *AgentOutput) AbortCurrentRun()

func (*AgentOutput) Empty

func (o *AgentOutput) Empty()

func (*AgentOutput) EnsureStreamNewline

func (o *AgentOutput) EnsureStreamNewline()

func (*AgentOutput) Error

func (o *AgentOutput) Error(err error)

func (*AgentOutput) Final

func (o *AgentOutput) Final(content string)

func (*AgentOutput) HandleEvent

func (o *AgentOutput) HandleEvent(event agent.Event)

func (*AgentOutput) Markdown added in v0.2.7

func (o *AgentOutput) Markdown() bool

Markdown returns whether markdown rendering is enabled.

func (*AgentOutput) Queued

func (o *AgentOutput) Queued(text string)

func (*AgentOutput) QueuedFollowUp

func (o *AgentOutput) QueuedFollowUp(text string)

func (*AgentOutput) SetVerbosity added in v0.2.7

func (o *AgentOutput) SetVerbosity(level int)

func (*AgentOutput) Start

func (o *AgentOutput) Start(label, text string)

func (*AgentOutput) Stderr added in v0.2.7

func (o *AgentOutput) Stderr() io.Writer

Stderr returns the stream writer's stderr for direct output.

func (*AgentOutput) Stdout added in v0.2.7

func (o *AgentOutput) Stdout() io.Writer

Stdout returns the stream writer's stdout.

func (*AgentOutput) Stopped

func (o *AgentOutput) Stopped()

func (*AgentOutput) Stopping

func (o *AgentOutput) Stopping()

func (*AgentOutput) VerbosityLabel added in v0.2.7

func (o *AgentOutput) VerbosityLabel() string

func (*AgentOutput) VerbosityLevel added in v0.2.7

func (o *AgentOutput) VerbosityLevel() int

type AppInfo

type AppInfo struct {
	Provider          agent.Provider
	ProviderConfig    agent.ProviderConfig
	ProviderFallbacks []agent.ProviderEntry
	Commands          *commands.CommandRegistry
	Skills            *skills.Store
	OnProviderChange  func(agent.Provider, agent.ProviderConfig)
}

AppInfo holds the subset of runtime state that tui commands need.

type ArgSpec

type ArgSpec int
const (
	ArgsNone ArgSpec = iota
	ArgsExact1
	ArgsOptional
)

type Command

type Command struct {
	Name        string
	Aliases     []string
	Description string
	Args        ArgSpec
	Hidden      bool
	Run         func(ctx context.Context, s *Session, args []string) error
}

Command describes a REPL command independent of any UI framework.

func SkillCommands

func SkillCommands(s *Session) []Command

SkillCommands generates commands for each non-internal skill.

type Controller

type Controller interface {
	SubmitPrompt(label, displayText, prompt string) error
	Continue() error
	Stop() bool
	Running() bool
}

Controller is the async execution interface that tui implements.

type EvalSettings

type EvalSettings struct {
	Criteria string
	Model    string
	Provider agent.Provider
	Bus      *eventbus.Bus[agent.Event]
	Logger   telemetry.Logger
}

type LiveStatus added in v0.2.7

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

func NewLiveStatus added in v0.2.7

func NewLiveStatus(view *LiveView, dim func(string) string, renderToolLine func(agent.Event) string) *LiveStatus

func (*LiveStatus) BeginTurn added in v0.2.7

func (l *LiveStatus) BeginTurn()

func (*LiveStatus) ContextUsage added in v0.2.7

func (l *LiveStatus) ContextUsage(tokens int) string

func (*LiveStatus) DrainTools added in v0.2.7

func (l *LiveStatus) DrainTools() []agent.Event

func (*LiveStatus) FinishAgent added in v0.2.7

func (l *LiveStatus) FinishAgent(event agent.Event)

func (*LiveStatus) FinishTurn added in v0.2.7

func (l *LiveStatus) FinishTurn(event agent.Event)

func (*LiveStatus) HasTools added in v0.2.7

func (l *LiveStatus) HasTools() bool

func (*LiveStatus) MessageUpdate added in v0.2.7

func (l *LiveStatus) MessageUpdate(event agent.Event, contentDelta bool)

func (*LiveStatus) Render added in v0.2.7

func (l *LiveStatus) Render()

func (*LiveStatus) Reset added in v0.2.7

func (l *LiveStatus) Reset()

func (*LiveStatus) Running added in v0.2.7

func (l *LiveStatus) Running() bool

func (*LiveStatus) SetContextWindow added in v0.2.7

func (l *LiveStatus) SetContextWindow(tokens int)

func (*LiveStatus) ShowEvalRound added in v0.2.7

func (l *LiveStatus) ShowEvalRound(round int)

func (*LiveStatus) StartTool added in v0.2.7

func (l *LiveStatus) StartTool(event agent.Event)

func (*LiveStatus) Status added in v0.2.7

func (l *LiveStatus) Status() string

func (*LiveStatus) Stop added in v0.2.7

func (l *LiveStatus) Stop()

func (*LiveStatus) StopAndDrainTools added in v0.2.7

func (l *LiveStatus) StopAndDrainTools() []agent.Event

func (*LiveStatus) UpdateTool added in v0.2.7

func (l *LiveStatus) UpdateTool(event agent.Event) (tracked bool, done bool)

func (*LiveStatus) WithHidden added in v0.2.7

func (l *LiveStatus) WithHidden(fn func())

type LiveView added in v0.2.7

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

LiveView manages a transient, animated region on the terminal. Lines containing spinnerSentinel get the current animation frame injected on each tick. Stop erases the region cleanly.

func NewLiveView added in v0.2.7

func NewLiveView(w io.Writer, accent string) *LiveView

func (*LiveView) Start added in v0.2.7

func (v *LiveView) Start()

func (*LiveView) Stop added in v0.2.7

func (v *LiveView) Stop()

func (*LiveView) Update added in v0.2.7

func (v *LiveView) Update(lines []string)

func (*LiveView) WithHidden added in v0.2.7

func (v *LiveView) WithHidden(fn func())

type ProviderInfo

type ProviderInfo struct {
	Name   string
	Model  string
	Active bool
}

StatusInfo collects current session state for display.

type RenderMode

type RenderMode int
const (
	ModeInteractive RenderMode = iota
	ModeStatic
	ModeForwarded
)

type Session

type Session struct {
	Ctx          context.Context
	Option       *cfg.Option
	AppInfo      AppInfo
	Agent        *agent.Agent
	Controller   Controller
	EvalCriteria string
	OnEvalChange func(string)
}

Session holds the dependencies commands need to operate on.

type StatusInfo

type StatusInfo struct {
	Provider  string
	Model     string
	Providers []ProviderInfo
	Mode      string
	Task      string
	IOA       string
	History   string
	Skills    string
}

func CollectStatus

func CollectStatus(s *Session, mode, historyPath string) StatusInfo

type StreamWriter added in v0.2.7

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

StreamWriter manages token-by-token content streaming with paragraph-level markdown buffering and reasoning block tracking. It owns all cursor state for the stdout/stderr interleaving.

func NewStreamWriter added in v0.2.7

func NewStreamWriter(stdout, stderr io.Writer, enabled, markdown bool, color output.Color, verbosity int) *StreamWriter

func (*StreamWriter) ContentPrinted added in v0.2.7

func (w *StreamWriter) ContentPrinted() int

ContentPrinted returns the number of content bytes already flushed.

func (*StreamWriter) Delta added in v0.2.7

func (w *StreamWriter) Delta(content, reasoning *string)

Delta processes a new token delta (content and/or reasoning).

func (*StreamWriter) EnsureLiveBoundary added in v0.2.7

func (w *StreamWriter) EnsureLiveBoundary()

func (*StreamWriter) EnsureNewline added in v0.2.7

func (w *StreamWriter) EnsureNewline()

EnsureNewline closes any mid-line stdout cursor.

func (*StreamWriter) Flush added in v0.2.7

func (w *StreamWriter) Flush()

Flush writes any buffered content and closes open reasoning blocks.

func (*StreamWriter) MarkStreamed added in v0.2.7

func (w *StreamWriter) MarkStreamed()

MarkStreamed marks the current content as rendered directly.

func (*StreamWriter) NewTurn added in v0.2.7

func (w *StreamWriter) NewTurn()

NewTurn resets per-turn counters (called at EventTurnStart).

func (*StreamWriter) ReasoningPrinted added in v0.2.7

func (w *StreamWriter) ReasoningPrinted() int

ReasoningPrinted returns the number of reasoning bytes already flushed.

func (*StreamWriter) Reset added in v0.2.7

func (w *StreamWriter) Reset()

Reset clears all state (called at run start).

func (*StreamWriter) Streamed added in v0.2.7

func (w *StreamWriter) Streamed() bool

Streamed returns true if any content was streamed this run.

func (*StreamWriter) WouldPrintContentDelta added in v0.2.7

func (w *StreamWriter) WouldPrintContentDelta(content *string) bool

func (*StreamWriter) WouldPrintDelta added in v0.2.7

func (w *StreamWriter) WouldPrintDelta(content, reasoning *string) bool

WouldPrintDelta reports whether Delta would emit visible output for this update. Role-only updates, hidden reasoning, and partial markdown chunks keep the live "thinking" view on screen.

Jump to

Keyboard shortcuts

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