agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TodoPending    = "pending"
	TodoInProgress = "in_progress"
	TodoCompleted  = "completed"
)

Task statuses shown in the TUI task panel.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentApp

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

AgentApp represents the Agent application structure

func NewAgentApp

func NewAgentApp(agentName string) (*AgentApp, error)

NewAgentApp creates a new Agent application

func (*AgentApp) ApproveTool

func (app *AgentApp) ApproveTool(ctx context.Context, req approval.Request) (bool, error)

ApproveTool implements tools.Host for agent sessions.

func (*AgentApp) AskUser

func (app *AgentApp) AskUser(ctx context.Context, question string, options []string) (string, error)

AskUser implements tools.Host for agent sessions.

func (*AgentApp) Interrupt

func (app *AgentApp) Interrupt()

Interrupt stops the reply that is currently streaming, if any.

func (*AgentApp) Run

func (app *AgentApp) Run() error

Run runs the Agent application

func (*AgentApp) Stop

func (app *AgentApp) Stop()

Stop stops the Agent application

func (*AgentApp) UpdateTodos

func (app *AgentApp) UpdateTodos(ctx context.Context, items []tools.TodoItem) error

UpdateTodos implements tools.Host for agent sessions.

type AskQuestionMsg

type AskQuestionMsg struct {
	Question string
	Options  []string
	Reply    chan string
	Approval bool   // tool-approval prompt: options only, no free text
	Detail   string // extra context shown dim below the question
}

AskQuestionMsg asks the user a question from a running tool. The answer is sent back on Reply ("" means the user cancelled). Approval prompts reuse the question panel but only accept one of the offered options.

type CancelQuestionMsg

type CancelQuestionMsg struct{}

CancelQuestionMsg dismisses a pending question when the turn was cancelled before the user answered.

type CommandResult

type CommandResult struct {
	Message  string  // transcript message (empty = nothing to show)
	Error    bool    // render the message as an error
	Subtitle string  // new header subtitle (empty = unchanged)
	Cmd      tea.Cmd // asynchronous work started by the command
}

CommandResult is returned by a command handler.

type ErrorMsg

type ErrorMsg string

type Message

type Message struct {
	Type       MessageType
	Content    string
	Name       string     // Tool name (only used for tool messages)
	CallID     string     // Tool call id, pairs a call with its result
	ToolStatus ToolStatus // Status of tool execution (only used for tool messages)
	Arguments  string     // Tool arguments (only used for tool messages)
	Result     string     // Tool result (only used for tool messages)
	StartTime  int64      // Tool start time (Unix timestamp, only used for tool messages)
	EndTime    int64      // Tool end time (Unix timestamp, only used for tool messages)
	// contains filtered or unexported fields
}

Message represents a chat message

type MessageType

type MessageType int

MessageType represents the type of a message

const (
	UserMessage MessageType = iota
	AssistantMessage
	ToolStartMessage
	ToolEndMessage
	ErrorMessage
	ReasoningMessage
	InfoMessage
)

type NoticeMsg

type NoticeMsg string

NoticeMsg appends an informational line to the transcript.

type ReasoningChunkMsg

type ReasoningChunkMsg string

type ResponseMsg

type ResponseMsg string

Message type definitions

type SlashCommand

type SlashCommand struct {
	Name        string   // command name without the leading slash
	Args        string   // argument hint, e.g. "<name>" (optional)
	Description string   // short description shown in the palette
	Values      []string // optional argument suggestions
}

SlashCommand describes a command available in the TUI command palette.

type SlashHandler

type SlashHandler func(input string) CommandResult

SlashHandler executes a command line without the leading slash.

type StreamChunkMsg

type StreamChunkMsg string

type StreamEndMsg

type StreamEndMsg struct{}

type Theme

type Theme struct {
	Name        string
	Description string
	Light       ThemeVariant
	Dark        ThemeVariant
}

Theme is a named color scheme with light and dark variants.

type ThemeVariant

type ThemeVariant = plugins.ThemeVariant

ThemeVariant is a set of interface colors tuned for one background mode.

type TodoItem

type TodoItem struct {
	Content string
	Status  string
}

TodoItem is one entry of the displayed task list.

type TodoUpdateMsg

type TodoUpdateMsg struct {
	Items []TodoItem
}

TodoUpdateMsg replaces the task panel contents.

type ToolEndMsg

type ToolEndMsg struct {
	Name   string
	CallID string
	Result string
	Failed bool
}

type ToolStartMsg

type ToolStartMsg struct {
	Name      string
	CallID    string
	Arguments string
}

type ToolStatus

type ToolStatus int

ToolStatus represents the status of a tool call

const (
	ToolWaiting ToolStatus = iota // Tool is being called (orange)
	ToolSuccess                   // Tool completed successfully (green)
	ToolError                     // Tool failed (red)
)

type ViewModel

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

ViewModel is the model for the Agent interface

func NewViewModel

func NewViewModel(onSendMsg func(string) error) *ViewModel

NewViewModel creates a new ViewModel

func (*ViewModel) ApplyTheme

func (m *ViewModel) ApplyTheme(name, mode string) error

ApplyTheme switches the color theme. mode may be "", "auto", "light" or "dark"; empty/auto follows the terminal background.

func (*ViewModel) DarkMode

func (m *ViewModel) DarkMode() bool

DarkMode reports whether the dark variant is active.

func (*ViewModel) Init

func (m *ViewModel) Init() tea.Cmd

Init initializes the model

func (*ViewModel) SetMouseToggle

func (m *ViewModel) SetMouseToggle(fn func() bool)

SetMouseToggle registers the callback used by Ctrl+Y to toggle mouse capture. It returns the new state (true = mouse captured).

func (*ViewModel) SetOnClear

func (m *ViewModel) SetOnClear(fn func())

SetOnClear registers a callback invoked whenever the transcript is cleared.

func (*ViewModel) SetOnInterrupt

func (m *ViewModel) SetOnInterrupt(fn func())

SetOnInterrupt registers the callback invoked when the user stops a running reply with Esc twice.

func (*ViewModel) SetSlashCommands

func (m *ViewModel) SetSlashCommands(cmds []SlashCommand, handler SlashHandler)

SetSlashCommands registers host-provided commands and their handler. Commands are shown in the palette while typing "/" and executed on enter.

func (*ViewModel) SetSubtitle

func (m *ViewModel) SetSubtitle(subtitle string)

SetSubtitle sets the header subtitle (agent or model name).

func (*ViewModel) SetTodos

func (m *ViewModel) SetTodos(items []TodoItem)

SetTodos replaces the task panel contents (used when resuming a session).

func (*ViewModel) SetTranscript

func (m *ViewModel) SetTranscript(msgs []Message)

SetTranscript replaces the conversation with the given messages (used when resuming a saved session).

func (*ViewModel) ThemeName

func (m *ViewModel) ThemeName() string

ThemeName returns the active theme name.

func (*ViewModel) Update

func (m *ViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*ViewModel) View

func (m *ViewModel) View() string

View renders the interface

Jump to

Keyboard shortcuts

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