domain

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleUser      = sdk.User
	RoleAssistant = sdk.Assistant
	RoleTool      = sdk.Tool
	RoleSystem    = sdk.System
)

Common role constants

Variables

This section is empty.

Functions

func CreateTitleFromMessage added in v0.46.0

func CreateTitleFromMessage(content string) string

CreateTitleFromMessage creates a short title from message content (fallback title)

func GetBashDetachChannel added in v0.97.0

func GetBashDetachChannel(ctx context.Context) <-chan struct{}

GetBashDetachChannel retrieves the bash detach channel from context Returns nil if the key is not set or if the value is not a channel

func GetSessionID added in v0.97.0

func GetSessionID(ctx context.Context) string

GetSessionID retrieves the session ID from context Returns empty string if the key is not set or if the value is not a string

func HasBashDetachChannel added in v0.97.0

func HasBashDetachChannel(ctx context.Context) bool

HasBashDetachChannel checks if a bash detach channel is set in the context

func HasBashOutputCallback added in v0.97.0

func HasBashOutputCallback(ctx context.Context) bool

HasBashOutputCallback checks if a bash output callback is set in the context

func HasChatHandler added in v0.97.0

func HasChatHandler(ctx context.Context) bool

HasChatHandler checks if a ChatHandler is set in the context

func HasSessionID added in v0.97.0

func HasSessionID(ctx context.Context) bool

HasSessionID checks if a session ID is set in the context

func IsDirectExecution added in v0.97.0

func IsDirectExecution(ctx context.Context) bool

IsDirectExecution checks if the tool was invoked directly by the user Returns false if the key is not set or if the value is not a bool

func IsFallbackTitle added in v0.46.0

func IsFallbackTitle(title string) bool

IsFallbackTitle checks if a title appears to be a fallback title that needs AI generation

func IsSimpleUserMessage added in v0.46.0

func IsSimpleUserMessage(title string) bool

IsSimpleUserMessage checks if the title looks like a simple user message (hello, hi, help, etc.)

func IsToolApproved added in v0.97.0

func IsToolApproved(ctx context.Context) bool

IsToolApproved checks if the tool was explicitly approved by the user Returns false if the key is not set or if the value is not a bool

func WithBashDetachChannel added in v0.97.0

func WithBashDetachChannel(ctx context.Context, ch <-chan struct{}) context.Context

WithBashDetachChannel returns a new context with a bash detach signal channel

func WithBashOutputCallback added in v0.97.0

func WithBashOutputCallback(ctx context.Context, callback BashOutputCallback) context.Context

WithBashOutputCallback returns a new context with a bash output streaming callback

func WithChatHandler added in v0.97.0

func WithChatHandler(ctx context.Context, handler BashDetachChannelHolder) context.Context

WithChatHandler returns a new context with a ChatHandler reference

func WithDirectExecution added in v0.97.0

func WithDirectExecution(ctx context.Context) context.Context

WithDirectExecution returns a new context with DirectExecutionKey set to true

func WithSessionID added in v0.97.0

func WithSessionID(ctx context.Context, sessionID string) context.Context

WithSessionID returns a new context with a session ID

func WithToolApproved added in v0.97.0

func WithToolApproved(ctx context.Context) context.Context

WithToolApproved returns a new context with ToolApprovedKey set to true

Types

type A2AAgentService added in v0.49.0

type A2AAgentService interface {
	GetAgentCards(ctx context.Context) ([]*CachedAgentCard, error)
	GetConfiguredAgents() []string
}

A2AAgentService manages A2A agent operations

type A2ATaskCompletedEvent added in v0.49.0

type A2ATaskCompletedEvent struct {
	RequestID string
	Timestamp time.Time
	TaskID    string
	Result    ToolExecutionResult
}

A2ATaskCompletedEvent indicates an A2A task was completed successfully

func (A2ATaskCompletedEvent) GetRequestID added in v0.49.0

func (e A2ATaskCompletedEvent) GetRequestID() string

func (A2ATaskCompletedEvent) GetTimestamp added in v0.49.0

func (e A2ATaskCompletedEvent) GetTimestamp() time.Time

type A2ATaskFailedEvent added in v0.53.0

type A2ATaskFailedEvent struct {
	RequestID string
	Timestamp time.Time
	TaskID    string
	Result    ToolExecutionResult
	Error     string
}

A2ATaskFailedEvent indicates an A2A task failed

func (A2ATaskFailedEvent) GetRequestID added in v0.53.0

func (e A2ATaskFailedEvent) GetRequestID() string

func (A2ATaskFailedEvent) GetTimestamp added in v0.53.0

func (e A2ATaskFailedEvent) GetTimestamp() time.Time

type A2ATaskInputRequiredEvent added in v0.49.0

type A2ATaskInputRequiredEvent struct {
	RequestID string
	Timestamp time.Time
	TaskID    string
	Message   string
	Required  bool
}

A2ATaskInputRequiredEvent indicates an A2A task requires user input

func (A2ATaskInputRequiredEvent) GetRequestID added in v0.49.0

func (e A2ATaskInputRequiredEvent) GetRequestID() string

func (A2ATaskInputRequiredEvent) GetTimestamp added in v0.49.0

func (e A2ATaskInputRequiredEvent) GetTimestamp() time.Time

type A2ATaskStatusUpdate added in v0.53.0

type A2ATaskStatusUpdate struct {
	TaskID    string
	AgentURL  string
	State     string
	Message   string
	Timestamp time.Time
}

A2ATaskStatusUpdate represents a status update for an ongoing A2A task

type A2ATaskStatusUpdateEvent added in v0.49.0

type A2ATaskStatusUpdateEvent struct {
	RequestID string
	Timestamp time.Time
	TaskID    string
	Status    string
	Progress  float64
	Message   string
}

A2ATaskStatusUpdateEvent indicates an A2A task status update

func (A2ATaskStatusUpdateEvent) GetRequestID added in v0.49.0

func (e A2ATaskStatusUpdateEvent) GetRequestID() string

func (A2ATaskStatusUpdateEvent) GetTimestamp added in v0.49.0

func (e A2ATaskStatusUpdateEvent) GetTimestamp() time.Time

type A2ATaskSubmittedEvent added in v0.49.0

type A2ATaskSubmittedEvent struct {
	RequestID string
	Timestamp time.Time
	TaskID    string
	AgentName string
	TaskType  string
}

A2ATaskSubmittedEvent indicates an A2A task was submitted

func (A2ATaskSubmittedEvent) GetRequestID added in v0.49.0

func (e A2ATaskSubmittedEvent) GetRequestID() string

func (A2ATaskSubmittedEvent) GetTimestamp added in v0.49.0

func (e A2ATaskSubmittedEvent) GetTimestamp() time.Time

type A2AToolCallExecutedEvent added in v0.48.0

type A2AToolCallExecutedEvent struct {
	RequestID         string
	Timestamp         time.Time
	ToolCallID        string
	ToolName          string
	Arguments         string
	ExecutedOnGateway bool
	TaskID            string
}

A2AToolCallExecutedEvent indicates an A2A tool call was executed on the gateway

func (A2AToolCallExecutedEvent) GetRequestID added in v0.48.0

func (e A2AToolCallExecutedEvent) GetRequestID() string

func (A2AToolCallExecutedEvent) GetTimestamp added in v0.48.0

func (e A2AToolCallExecutedEvent) GetTimestamp() time.Time

type AgentErrorEvent added in v0.67.0

type AgentErrorEvent struct {
	AgentName string
	Error     error
}

AgentErrorEvent indicates an agent has encountered an error

type AgentManager added in v0.54.0

type AgentManager interface {
	// StartAgents starts all agents configured with run: true
	StartAgents(ctx context.Context) error

	// StopAgents stops all running agent containers
	StopAgents(ctx context.Context) error

	// StopAgent stops a specific agent container by name
	StopAgent(ctx context.Context, agentName string) error

	// IsRunning returns whether any agents are running
	IsRunning() bool

	// SetStatusCallback sets the callback function for agent status updates
	SetStatusCallback(callback func(agentName string, state AgentState, message string, url string, image string))
}

AgentManager manages the lifecycle of A2A agent containers

type AgentMode added in v0.56.0

type AgentMode int

AgentMode represents the operational mode of the agent

const (
	// AgentModeStandard is the default mode with all configured tools and approval checks
	AgentModeStandard AgentMode = iota
	// AgentModePlan is a read-only mode for planning without execution
	AgentModePlan
	// AgentModeAutoAccept bypasses all approval checks (YOLO mode)
	AgentModeAutoAccept
)

func (AgentMode) DisplayName added in v0.56.0

func (m AgentMode) DisplayName() string

DisplayName returns a user-friendly display name for the mode

func (AgentMode) String added in v0.56.0

func (m AgentMode) String() string

type AgentReadinessState added in v0.67.0

type AgentReadinessState struct {
	TotalAgents int                     `json:"total_agents"`
	ReadyAgents int                     `json:"ready_agents"`
	Agents      map[string]*AgentStatus `json:"agents"`
	StartTime   time.Time               `json:"start_time"`
}

AgentReadinessState represents the current state of A2A agents during startup

type AgentReadyEvent added in v0.67.0

type AgentReadyEvent struct {
	AgentName   string
	ReadyAgents int
	TotalAgents int
}

AgentReadyEvent indicates an agent has become ready

type AgentRequest added in v0.36.0

type AgentRequest struct {
	RequestID  string        `json:"request_id"`
	Model      string        `json:"model"`
	Messages   []sdk.Message `json:"messages"`
	IsChatMode bool          `json:"is_chat_mode"`
}

AgentRequest represents a request to the agent service

type AgentService added in v0.36.0

type AgentService interface {
	// Run executes an agent task synchronously (for background/batch processing)
	Run(ctx context.Context, req *AgentRequest) (*ChatSyncResponse, error)

	// RunWithStream executes an agent task with streaming (for interactive chat)
	RunWithStream(ctx context.Context, req *AgentRequest) (<-chan ChatEvent, error)

	// CancelRequest cancels an active request
	CancelRequest(requestID string) error

	// GetMetrics returns metrics for a completed request
	GetMetrics(requestID string) *ChatMetrics
}

AgentService handles agent operations with both sync and streaming modes

type AgentState added in v0.67.0

type AgentState int

AgentState represents the current state of an agent

const (
	AgentStateUnknown AgentState = iota
	AgentStatePullingImage
	AgentStateStarting
	AgentStateWaitingReady
	AgentStateReady
	AgentStateFailed
)

func (AgentState) DisplayName added in v0.67.0

func (a AgentState) DisplayName() string

DisplayName returns a user-friendly display name for the agent state

func (AgentState) String added in v0.67.0

func (a AgentState) String() string

type AgentStatus added in v0.67.0

type AgentStatus struct {
	Name      string     `json:"name"`
	URL       string     `json:"url"`
	Image     string     `json:"image"`
	State     AgentState `json:"state"`
	Message   string     `json:"message,omitempty"`
	StartTime time.Time  `json:"start_time"`
	ReadyTime *time.Time `json:"ready_time,omitempty"`
	Error     string     `json:"error,omitempty"`
}

AgentStatus represents the status of an individual A2A agent

type AgentStatusUpdateEvent added in v0.67.0

type AgentStatusUpdateEvent struct {
	AgentName string
	State     AgentState
	Message   string
	URL       string
	Image     string
}

AgentStatusUpdateEvent indicates an agent's status has changed

type ApplicationState added in v0.27.0

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

ApplicationState represents the overall application state with proper typing

func NewApplicationState added in v0.27.0

func NewApplicationState() *ApplicationState

NewApplicationState creates a new application state

func (*ApplicationState) AddQueuedMessage added in v0.53.0

func (s *ApplicationState) AddQueuedMessage(message sdk.Message, requestID string)

AddQueuedMessage adds a message to the input queue

func (*ApplicationState) AreAllAgentsReady added in v0.67.0

func (s *ApplicationState) AreAllAgentsReady() bool

AreAllAgentsReady returns true if all agents are ready

func (*ApplicationState) ClearAgentReadiness added in v0.67.0

func (s *ApplicationState) ClearAgentReadiness()

ClearAgentReadiness clears the agent readiness state

func (*ApplicationState) ClearApprovalUIState added in v0.27.0

func (s *ApplicationState) ClearApprovalUIState()

ClearApprovalUIState clears the approval UI state

func (*ApplicationState) ClearComputerUsePauseState added in v0.96.0

func (s *ApplicationState) ClearComputerUsePauseState()

ClearComputerUsePauseState clears the pause state

func (*ApplicationState) ClearFileSelectionState added in v0.27.0

func (s *ApplicationState) ClearFileSelectionState()

ClearFileSelectionState clears the file selection state

func (*ApplicationState) ClearLastClickCoordinates added in v0.96.0

func (s *ApplicationState) ClearLastClickCoordinates()

ClearLastClickCoordinates clears the stored click coordinates

func (*ApplicationState) ClearLastFocusedApp added in v0.96.0

func (s *ApplicationState) ClearLastFocusedApp()

ClearLastFocusedApp clears the stored focused app

func (*ApplicationState) ClearMessageEditState added in v0.92.0

func (s *ApplicationState) ClearMessageEditState()

ClearMessageEditState clears the message edit state

func (*ApplicationState) ClearPlanApprovalUIState added in v0.68.0

func (s *ApplicationState) ClearPlanApprovalUIState()

ClearPlanApprovalUIState clears the plan approval UI state

func (*ApplicationState) ClearQueuedMessages added in v0.53.0

func (s *ApplicationState) ClearQueuedMessages()

ClearQueuedMessages clears all queued messages

func (*ApplicationState) CompleteCurrentTool added in v0.27.0

func (s *ApplicationState) CompleteCurrentTool(result *ToolExecutionResult) error

CompleteCurrentTool marks the current tool as completed and moves to next

func (*ApplicationState) CycleAgentMode added in v0.56.0

func (s *ApplicationState) CycleAgentMode() AgentMode

CycleAgentMode cycles to the next agent mode

func (*ApplicationState) EndChatSession added in v0.27.0

func (s *ApplicationState) EndChatSession()

EndChatSession cleans up the chat session

func (*ApplicationState) EndToolExecution added in v0.27.0

func (s *ApplicationState) EndToolExecution()

EndToolExecution cleans up the tool execution session

func (*ApplicationState) FailCurrentTool added in v0.27.0

func (s *ApplicationState) FailCurrentTool(result *ToolExecutionResult) error

FailCurrentTool marks the current tool as failed and moves to next

func (*ApplicationState) GetAgentMode added in v0.56.0

func (s *ApplicationState) GetAgentMode() AgentMode

GetAgentMode returns the current agent mode

func (*ApplicationState) GetAgentReadiness added in v0.67.0

func (s *ApplicationState) GetAgentReadiness() *AgentReadinessState

GetAgentReadiness returns the current agent readiness state

func (*ApplicationState) GetApprovalUIState added in v0.27.0

func (s *ApplicationState) GetApprovalUIState() *ApprovalUIState

GetApprovalUIState returns the current approval UI state

func (*ApplicationState) GetChatSession added in v0.27.0

func (s *ApplicationState) GetChatSession() *ChatSession

GetChatSession returns the current chat session

func (*ApplicationState) GetCurrentView added in v0.27.0

func (s *ApplicationState) GetCurrentView() ViewState

GetCurrentView returns the current view state

func (*ApplicationState) GetDimensions added in v0.27.0

func (s *ApplicationState) GetDimensions() (int, int)

GetDimensions returns the current UI dimensions

func (*ApplicationState) GetFileSelectionState added in v0.27.0

func (s *ApplicationState) GetFileSelectionState() *FileSelectionState

GetFileSelectionState returns the current file selection state

func (*ApplicationState) GetLastClickCoordinates added in v0.96.0

func (s *ApplicationState) GetLastClickCoordinates() (x, y int)

GetLastClickCoordinates returns the coordinates of the last click

func (*ApplicationState) GetLastFocusedApp added in v0.96.0

func (s *ApplicationState) GetLastFocusedApp() string

GetLastFocusedApp returns the bundle ID of the last focused application

func (*ApplicationState) GetMessageEditState added in v0.92.0

func (s *ApplicationState) GetMessageEditState() *MessageEditState

GetMessageEditState returns the current message edit state

func (*ApplicationState) GetPausedRequestID added in v0.96.0

func (s *ApplicationState) GetPausedRequestID() string

GetPausedRequestID returns the request ID of the paused execution

func (*ApplicationState) GetPlanApprovalUIState added in v0.68.0

func (s *ApplicationState) GetPlanApprovalUIState() *PlanApprovalUIState

GetPlanApprovalUIState returns the current plan approval UI state

func (*ApplicationState) GetPreviousView added in v0.86.0

func (s *ApplicationState) GetPreviousView() ViewState

GetPreviousView returns the previous view state

func (*ApplicationState) GetQueuedMessages added in v0.53.0

func (s *ApplicationState) GetQueuedMessages() []QueuedMessage

GetQueuedMessages returns the current queued messages

func (*ApplicationState) GetStateSnapshot added in v0.27.0

func (s *ApplicationState) GetStateSnapshot() StateSnapshot

GetStateSnapshot returns a complete snapshot of the current state

func (*ApplicationState) GetTodos added in v0.63.1

func (s *ApplicationState) GetTodos() []TodoItem

GetTodos returns the current todo list

func (*ApplicationState) GetToolExecution added in v0.27.0

func (s *ApplicationState) GetToolExecution() *ToolExecutionSession

GetToolExecution returns the current tool execution session

func (*ApplicationState) InitializeAgentReadiness added in v0.67.0

func (s *ApplicationState) InitializeAgentReadiness(totalAgents int)

InitializeAgentReadiness initializes the agent readiness tracking

func (*ApplicationState) IsComputerUsePaused added in v0.96.0

func (s *ApplicationState) IsComputerUsePaused() bool

IsComputerUsePaused returns whether computer use is currently paused

func (*ApplicationState) IsDebugMode added in v0.27.0

func (s *ApplicationState) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

func (*ApplicationState) IsEditingMessage added in v0.92.0

func (s *ApplicationState) IsEditingMessage() bool

IsEditingMessage returns true if currently editing a message

func (*ApplicationState) PopQueuedMessage added in v0.53.0

func (s *ApplicationState) PopQueuedMessage() *QueuedMessage

PopQueuedMessage removes and returns the first message from the queue (FIFO)

func (*ApplicationState) RemoveAgent added in v0.67.0

func (s *ApplicationState) RemoveAgent(name string)

RemoveAgent removes an agent from the readiness tracking

func (*ApplicationState) SetAgentError added in v0.67.0

func (s *ApplicationState) SetAgentError(name string, err error)

SetAgentError sets an error for a specific agent

func (*ApplicationState) SetAgentMode added in v0.56.0

func (s *ApplicationState) SetAgentMode(mode AgentMode)

SetAgentMode sets the agent mode

func (*ApplicationState) SetApprovalSelectedIndex added in v0.27.0

func (s *ApplicationState) SetApprovalSelectedIndex(index int)

SetApprovalSelectedIndex sets the approval selection index

func (*ApplicationState) SetChatPending added in v0.63.1

func (s *ApplicationState) SetChatPending()

SetChatPending creates a minimal chat session to mark the agent as busy before the actual chat starts. This prevents race conditions.

func (*ApplicationState) SetComputerUsePaused added in v0.96.0

func (s *ApplicationState) SetComputerUsePaused(paused bool, requestID string)

SetComputerUsePaused sets the paused state for computer use

func (*ApplicationState) SetDebugMode added in v0.27.0

func (s *ApplicationState) SetDebugMode(enabled bool)

SetDebugMode enables or disables debug mode

func (*ApplicationState) SetDimensions added in v0.27.0

func (s *ApplicationState) SetDimensions(width, height int)

SetDimensions updates the UI dimensions

func (*ApplicationState) SetFileSelectedIndex added in v0.27.0

func (s *ApplicationState) SetFileSelectedIndex(index int)

SetFileSelectedIndex sets the selected file index

func (*ApplicationState) SetLastClickCoordinates added in v0.96.0

func (s *ApplicationState) SetLastClickCoordinates(x, y int)

SetLastClickCoordinates stores the coordinates of the last click

func (*ApplicationState) SetLastFocusedApp added in v0.96.0

func (s *ApplicationState) SetLastFocusedApp(appID string)

SetLastFocusedApp stores the bundle ID of the last focused application This is used to restore focus before keyboard operations

func (*ApplicationState) SetMessageEditState added in v0.92.0

func (s *ApplicationState) SetMessageEditState(state *MessageEditState)

SetMessageEditState sets the message edit state

func (*ApplicationState) SetPlanApprovalSelectedIndex added in v0.68.0

func (s *ApplicationState) SetPlanApprovalSelectedIndex(index int)

SetPlanApprovalSelectedIndex sets the plan approval selection index

func (*ApplicationState) SetTodos added in v0.63.1

func (s *ApplicationState) SetTodos(todos []TodoItem)

SetTodos sets the todo list

func (*ApplicationState) SetupApprovalUIState added in v0.56.0

func (s *ApplicationState) SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan ApprovalAction)

SetupApprovalUIState initializes approval UI state with the pending tool call

func (*ApplicationState) SetupFileSelection added in v0.27.0

func (s *ApplicationState) SetupFileSelection(files []string)

SetupFileSelection initializes file selection state

func (*ApplicationState) SetupPlanApprovalUIState added in v0.68.0

func (s *ApplicationState) SetupPlanApprovalUIState(planContent string, responseChan chan PlanApprovalAction)

SetupPlanApprovalUIState initializes plan approval UI state

func (*ApplicationState) StartChatSession added in v0.27.0

func (s *ApplicationState) StartChatSession(requestID, model string, eventChan <-chan ChatEvent)

StartChatSession initializes a new chat session

func (*ApplicationState) StartToolExecution added in v0.27.0

func (s *ApplicationState) StartToolExecution(tools []ToolCall)

StartToolExecution initializes a new tool execution session

func (*ApplicationState) TransitionToView added in v0.27.0

func (s *ApplicationState) TransitionToView(newView ViewState) error

TransitionToView changes the current view with validation

func (*ApplicationState) UpdateAgentStatus added in v0.67.0

func (s *ApplicationState) UpdateAgentStatus(name string, state AgentState, message string, url string, image string)

UpdateAgentStatus updates the status of a specific agent

func (*ApplicationState) UpdateChatStatus added in v0.27.0

func (s *ApplicationState) UpdateChatStatus(status ChatStatus) error

UpdateChatStatus updates the chat session status

func (*ApplicationState) UpdateFileSearchQuery added in v0.27.0

func (s *ApplicationState) UpdateFileSearchQuery(query string)

UpdateFileSearchQuery updates the file search query

type ApprovalAction

type ApprovalAction int

ApprovalAction represents the user's choice for tool approval

const (
	ApprovalApprove ApprovalAction = iota
	ApprovalReject
	ApprovalAutoAccept
)

func (ApprovalAction) String added in v0.27.0

func (a ApprovalAction) String() string

type ApprovalPolicy added in v0.97.0

type ApprovalPolicy interface {
	// ShouldRequireApproval returns true if the tool execution requires user approval
	// ctx: context for the approval decision
	// toolCall: the tool being invoked with its arguments
	// isChatMode: whether execution is in interactive chat mode
	ShouldRequireApproval(ctx context.Context, toolCall *sdk.ChatCompletionMessageToolCall, isChatMode bool) bool
}

ApprovalPolicy determines whether a tool execution requires user approval This interface allows for different approval strategies (standard, permissive, strict, etc.) Implementations define the business rules for when user approval is required before executing potentially dangerous or state-changing operations.

type ApprovalUIState added in v0.27.0

type ApprovalUIState struct {
	SelectedIndex   int                                `json:"selected_index"`
	PendingToolCall *sdk.ChatCompletionMessageToolCall `json:"pending_tool_call"`
	ResponseChan    chan ApprovalAction                `json:"-"`
}

ApprovalUIState represents the state of approval UI

type AutocompleteCompleteEvent added in v0.76.5

type AutocompleteCompleteEvent struct {
	Completion         string
	ExecuteImmediately bool
}

AutocompleteCompleteEvent is fired when a completion is selected

type AutocompleteHideEvent added in v0.76.5

type AutocompleteHideEvent struct{}

AutocompleteHideEvent is fired when autocomplete should be hidden

type AutocompleteUpdateEvent added in v0.76.5

type AutocompleteUpdateEvent struct {
	Text      string
	CursorPos int
}

AutocompleteUpdateEvent is fired when input text changes and autocomplete should update

type AutocompleteVisibilityCheckEvent added in v0.76.5

type AutocompleteVisibilityCheckEvent struct {
	ResponseChan chan bool
}

AutocompleteVisibilityCheckEvent requests autocomplete visibility state

type BackgroundShell added in v0.81.0

type BackgroundShell struct {
	ShellID      string
	Command      string
	Cmd          *exec.Cmd
	StartedAt    time.Time
	CompletedAt  *time.Time
	State        ShellState
	ExitCode     *int
	OutputBuffer OutputRingBuffer
	CancelFunc   context.CancelFunc
	ReadOffset   int64
}

BackgroundShell represents a command running in the background.

type BackgroundShellRequestEvent added in v0.81.0

type BackgroundShellRequestEvent struct{}

BackgroundShellRequestEvent requests that the current running Bash command be moved to background

type BackgroundShellService added in v0.81.0

type BackgroundShellService interface {
	// DetachToBackground moves a running command to background
	DetachToBackground(ctx context.Context, cmd *exec.Cmd, command string, outputBuffer OutputRingBuffer) (string, error)

	// GetShellOutput retrieves output from a shell
	GetShellOutput(shellID string, fromOffset int64) (string, int64, ShellState, error)

	// GetShellOutputWithFilter retrieves filtered output from a shell
	GetShellOutputWithFilter(shellID string, fromOffset int64, filterPattern string) (string, int64, ShellState, error)

	// GetShell returns a specific shell by ID
	GetShell(shellID string) *BackgroundShell

	// GetAllShells returns all tracked shells
	GetAllShells() []*BackgroundShell

	// CancelShell cancels a running background shell
	CancelShell(shellID string) error

	// RemoveShell removes a shell from tracking
	RemoveShell(shellID string) error
}

BackgroundShellService defines the interface for managing background shells

type BackgroundTaskService added in v0.53.3

type BackgroundTaskService interface {
	// GetBackgroundTasks returns all current background polling tasks
	GetBackgroundTasks() []TaskPollingState

	// CancelBackgroundTask cancels a background task by task ID
	CancelBackgroundTask(taskID string) error
}

BackgroundTaskService handles background A2A task operations Only enabled when A2A is enabled - provides task cancellation and retrieval

type BaseChatEvent added in v0.49.0

type BaseChatEvent struct {
	RequestID string
	Timestamp time.Time
}

BaseChatEvent provides common implementation for ChatEvent interface

func (BaseChatEvent) GetRequestID added in v0.49.0

func (e BaseChatEvent) GetRequestID() string

func (BaseChatEvent) GetTimestamp added in v0.49.0

func (e BaseChatEvent) GetTimestamp() time.Time

type BaseFormatter added in v0.33.4

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

BaseFormatter provides common formatting functionality that tools can embed

func NewBaseFormatter added in v0.33.4

func NewBaseFormatter(toolName string) BaseFormatter

NewBaseFormatter creates a new base formatter for a tool

func (BaseFormatter) FormatAsJSON added in v0.33.4

func (f BaseFormatter) FormatAsJSON(data any) string

FormatAsJSON formats data as JSON if possible, falls back to string representation

func (BaseFormatter) FormatDataSection added in v0.33.4

func (f BaseFormatter) FormatDataSection(dataContent string, hasMetadata bool) string

FormatDataSection formats the data section with proper indentation

func (BaseFormatter) FormatDuration added in v0.33.4

func (f BaseFormatter) FormatDuration(result *ToolExecutionResult) string

FormatDuration formats a duration for display in a human-friendly way

func (BaseFormatter) FormatExpandedFooter added in v0.33.4

func (f BaseFormatter) FormatExpandedFooter(result *ToolExecutionResult, hasDataSection bool) string

FormatExpandedFooter formats the expanded view footer with metadata

func (BaseFormatter) FormatExpandedHeader added in v0.33.4

func (f BaseFormatter) FormatExpandedHeader(result *ToolExecutionResult) string

FormatExpandedHeader formats the expanded view header with tool call and metadata

func (BaseFormatter) FormatStatus added in v0.33.4

func (f BaseFormatter) FormatStatus(success bool) string

FormatStatus returns a formatted status with icon

func (BaseFormatter) FormatStatusIcon added in v0.33.4

func (f BaseFormatter) FormatStatusIcon(success bool) string

FormatStatusIcon returns just the status icon

func (BaseFormatter) FormatToolCall added in v0.33.4

func (f BaseFormatter) FormatToolCall(args map[string]any, expanded bool) string

FormatToolCall formats a tool call for consistent display

func (BaseFormatter) GetDomainFromURL added in v0.33.4

func (f BaseFormatter) GetDomainFromURL(url string) string

GetDomainFromURL extracts domain from URL

func (BaseFormatter) GetFileName added in v0.33.4

func (f BaseFormatter) GetFileName(path string) string

GetFileName extracts filename from a path

func (BaseFormatter) ShouldCollapseArg added in v0.33.4

func (f BaseFormatter) ShouldCollapseArg(key string) bool

ShouldCollapseArg provides default collapse behavior (can be overridden by tools)

func (BaseFormatter) TruncateText added in v0.33.4

func (f BaseFormatter) TruncateText(text string, maxLength int) string

TruncateText truncates text to specified length with ellipsis

type BashCommandCompletedEvent added in v0.65.0

type BashCommandCompletedEvent struct {
	History []ConversationEntry
}

BashCommandCompletedEvent indicates a direct bash command (! prefix) has completed

type BashDetachChannelHolder added in v0.81.0

type BashDetachChannelHolder interface {
	SetBashDetachChan(chan<- struct{})
	GetBashDetachChan() chan<- struct{}
	ClearBashDetachChan()
}

BashDetachChannelHolder manages the bash detach channel for background shell operations

func GetChatHandler added in v0.97.0

func GetChatHandler(ctx context.Context) BashDetachChannelHolder

GetChatHandler retrieves the ChatHandler from context Returns nil if the key is not set or if the value is not a BashDetachChannelHolder

type BashOutputCallback added in v0.65.0

type BashOutputCallback func(line string)

BashOutputCallback is a function type for receiving streaming bash output

func GetBashOutputCallback added in v0.97.0

func GetBashOutputCallback(ctx context.Context) BashOutputCallback

GetBashOutputCallback retrieves the bash output callback from context Returns nil if the key is not set or if the value is not a BashOutputCallback

type BashOutputChunkEvent added in v0.65.0

type BashOutputChunkEvent struct {
	BaseChatEvent
	ToolCallID string
	Output     string
	IsComplete bool
}

BashOutputChunkEvent indicates a new chunk of bash output is available

type BashToolResult added in v0.13.1

type BashToolResult struct {
	Command  string `json:"command"`
	Output   string `json:"output"`
	Error    string `json:"error,omitempty"`
	ExitCode int    `json:"exit_code"`
	Duration string `json:"duration"`
}

BashToolResult represents the result of a bash command execution

type BorderOverlayEvent added in v0.96.0

type BorderOverlayEvent struct {
	BaseChatEvent
	BorderAction string
}

BorderOverlayEvent indicates the screen border overlay should be shown or hidden

type CachedAgentCard added in v0.49.0

type CachedAgentCard struct {
	Card      *adk.AgentCard `json:"card"`
	URL       string         `json:"url"`
	FetchedAt time.Time      `json:"fetched_at"`
}

CachedAgentCard represents a cached agent card with metadata

type CancelledEvent

type CancelledEvent struct {
	RequestID string
	Timestamp time.Time
	Reason    string
}

CancelledEvent indicates a request was cancelled

func (CancelledEvent) GetRequestID

func (e CancelledEvent) GetRequestID() string

func (CancelledEvent) GetTimestamp

func (e CancelledEvent) GetTimestamp() time.Time

type ChatChunkEvent

type ChatChunkEvent struct {
	RequestID        string
	Timestamp        time.Time
	Content          string
	ReasoningContent string
	ToolCalls        []sdk.ChatCompletionMessageToolCallChunk
	Delta            bool
	Usage            *sdk.CompletionUsage
}

ChatChunkEvent represents a streaming chunk of chat response

func (ChatChunkEvent) GetRequestID

func (e ChatChunkEvent) GetRequestID() string

func (ChatChunkEvent) GetTimestamp

func (e ChatChunkEvent) GetTimestamp() time.Time

type ChatCompleteEvent

type ChatCompleteEvent struct {
	RequestID        string
	Timestamp        time.Time
	Message          string
	ReasoningContent string
	ToolCalls        []sdk.ChatCompletionMessageToolCall
	Metrics          *ChatMetrics
}

ChatCompleteEvent indicates chat completion

func (ChatCompleteEvent) GetRequestID

func (e ChatCompleteEvent) GetRequestID() string

func (ChatCompleteEvent) GetTimestamp

func (e ChatCompleteEvent) GetTimestamp() time.Time

type ChatErrorEvent

type ChatErrorEvent struct {
	RequestID string
	Timestamp time.Time
	Error     error
}

ChatErrorEvent represents an error during chat

func (ChatErrorEvent) GetRequestID

func (e ChatErrorEvent) GetRequestID() string

func (ChatErrorEvent) GetTimestamp

func (e ChatErrorEvent) GetTimestamp() time.Time

type ChatEvent

type ChatEvent interface {
	GetRequestID() string
	GetTimestamp() time.Time
}

ChatEvent represents events during chat operations

type ChatHandler added in v0.97.0

type ChatHandler interface {
	// Core event handling (to be deprecated as we move to component-based handling)
	Handle(msg tea.Msg) tea.Cmd

	// Specific event handlers
	HandleUserInputEvent(msg UserInputEvent) tea.Cmd
	HandleFileSelectionRequestEvent(msg FileSelectionRequestEvent) tea.Cmd
	HandleConversationSelectedEvent(msg ConversationSelectedEvent) tea.Cmd
	HandleToolApprovalRequestedEvent(msg ToolApprovalRequestedEvent) tea.Cmd
	HandleToolApprovalResponseEvent(msg ToolApprovalResponseEvent) tea.Cmd
	HandlePlanApprovalRequestedEvent(msg PlanApprovalRequestedEvent) tea.Cmd
	HandlePlanApprovalResponseEvent(msg PlanApprovalResponseEvent) tea.Cmd

	// Command handlers
	HandleCommand(commandText string) tea.Cmd
	HandleBashCommand(commandText string) tea.Cmd
	HandleToolCommand(commandText string) tea.Cmd
	HandleBackgroundShellRequest() tea.Cmd

	// Event channel listeners
	ListenForEvents(eventChan <-chan tea.Msg) tea.Cmd
	ListenForChatEvents(eventChan <-chan ChatEvent) tea.Cmd

	// State management
	GetActiveToolCallID() string
	SetActiveToolCallID(id string)

	// Utility methods
	ParseToolCall(input string) (string, map[string]any, error)
	ParseArguments(argsStr string) (map[string]any, error)
	SetBashDetachChan(chan<- struct{})
	GetBashDetachChan() chan<- struct{}
	ClearBashDetachChan()
}

ChatHandler defines the interface for the chat handler This interface enables testing handlers in isolation and provides a clear contract

type ChatMetrics

type ChatMetrics struct {
	Duration time.Duration
	Usage    *sdk.CompletionUsage
}

ChatMetrics holds performance and usage metrics

type ChatService

type ChatService interface {
	CancelRequest(requestID string) error
	GetMetrics(requestID string) *ChatMetrics
}

ChatService handles chat completion operations

type ChatSession added in v0.27.0

type ChatSession struct {
	RequestID    string
	Status       ChatStatus
	StartTime    time.Time
	Model        string
	EventChannel <-chan ChatEvent
	IsFirstChunk bool
	HasToolCalls bool
	LastActivity time.Time
}

ChatSession represents an active chat session state

type ChatSessionSnapshot added in v0.27.0

type ChatSessionSnapshot struct {
	RequestID    string    `json:"request_id"`
	Status       string    `json:"status"`
	Model        string    `json:"model"`
	StartTime    time.Time `json:"start_time"`
	IsFirstChunk bool      `json:"is_first_chunk"`
	HasToolCalls bool      `json:"has_tool_calls"`
	LastActivity time.Time `json:"last_activity"`
}

ChatSessionSnapshot represents a snapshot of chat session state

type ChatStartEvent

type ChatStartEvent struct {
	RequestID string
	Timestamp time.Time
	Model     string
}

ChatStartEvent indicates a chat request has started

func (ChatStartEvent) GetRequestID

func (e ChatStartEvent) GetRequestID() string

func (ChatStartEvent) GetTimestamp

func (e ChatStartEvent) GetTimestamp() time.Time

type ChatStatus added in v0.27.0

type ChatStatus int

ChatStatus represents the current chat operation status

const (
	ChatStatusIdle ChatStatus = iota
	ChatStatusStarting
	ChatStatusThinking
	ChatStatusGenerating
	ChatStatusReceivingTools
	ChatStatusWaitingTools
	ChatStatusCompleted
	ChatStatusError
	ChatStatusCancelled
)

func (ChatStatus) String added in v0.27.0

func (c ChatStatus) String() string

type ChatSyncResponse added in v0.36.0

type ChatSyncResponse struct {
	RequestID string                              `json:"request_id"`
	Content   string                              `json:"content"`
	ToolCalls []sdk.ChatCompletionMessageToolCall `json:"tool_calls,omitempty"`
	Usage     *sdk.CompletionUsage                `json:"usage,omitempty"`
	Duration  time.Duration                       `json:"duration"`
}

ChatSyncResponse represents a synchronous chat completion response

type ClearErrorEvent added in v0.45.0

type ClearErrorEvent struct{}

ClearErrorEvent clears any displayed error

type ClearInputEvent added in v0.45.0

type ClearInputEvent struct{}

ClearInputEvent clears the input field

type ClickIndicatorEvent added in v0.96.0

type ClickIndicatorEvent struct {
	BaseChatEvent
	X              int  `json:"X"`
	Y              int  `json:"Y"`
	ClickIndicator bool `json:"ClickIndicator"`
}

ClickIndicatorEvent indicates a visual click indicator should be shown at coordinates

type ComputerUsePauseRequestedEvent added in v0.96.0

type ComputerUsePauseRequestedEvent struct {
	RequestID string
	Timestamp time.Time
}

ComputerUsePauseRequestedEvent indicates user requested to pause computer-use execution

func (ComputerUsePauseRequestedEvent) GetRequestID added in v0.96.0

func (e ComputerUsePauseRequestedEvent) GetRequestID() string

func (ComputerUsePauseRequestedEvent) GetTimestamp added in v0.96.0

func (e ComputerUsePauseRequestedEvent) GetTimestamp() time.Time

type ComputerUsePausedEvent added in v0.96.0

type ComputerUsePausedEvent struct {
	RequestID string
	Timestamp time.Time
}

ComputerUsePausedEvent indicates computer-use execution has been paused

func (ComputerUsePausedEvent) GetRequestID added in v0.96.0

func (e ComputerUsePausedEvent) GetRequestID() string

func (ComputerUsePausedEvent) GetTimestamp added in v0.96.0

func (e ComputerUsePausedEvent) GetTimestamp() time.Time

type ComputerUseResumeRequestedEvent added in v0.96.0

type ComputerUseResumeRequestedEvent struct {
	RequestID string
	Timestamp time.Time
}

ComputerUseResumeRequestedEvent indicates user requested to resume computer-use execution

func (ComputerUseResumeRequestedEvent) GetRequestID added in v0.96.0

func (e ComputerUseResumeRequestedEvent) GetRequestID() string

func (ComputerUseResumeRequestedEvent) GetTimestamp added in v0.96.0

func (e ComputerUseResumeRequestedEvent) GetTimestamp() time.Time

type ComputerUseResumedEvent added in v0.96.0

type ComputerUseResumedEvent struct {
	RequestID string
	Timestamp time.Time
}

ComputerUseResumedEvent indicates computer-use execution has resumed

func (ComputerUseResumedEvent) GetRequestID added in v0.96.0

func (e ComputerUseResumedEvent) GetRequestID() string

func (ComputerUseResumedEvent) GetTimestamp added in v0.96.0

func (e ComputerUseResumedEvent) GetTimestamp() time.Time

type ComputerUseScreenshotEvent added in v0.96.0

type ComputerUseScreenshotEvent struct {
	RequestID string
	Timestamp time.Time
	Width     int
	Height    int
	Region    *ScreenRegion
	ImageData string
}

ComputerUseScreenshotEvent is emitted when a screenshot is captured

func (ComputerUseScreenshotEvent) GetRequestID added in v0.96.0

func (e ComputerUseScreenshotEvent) GetRequestID() string

func (ComputerUseScreenshotEvent) GetTimestamp added in v0.96.0

func (e ComputerUseScreenshotEvent) GetTimestamp() time.Time

type ConfigService added in v0.27.0

type ConfigService interface {
	// Tool approval configuration
	IsApprovalRequired(toolName string) bool
	IsBashCommandWhitelisted(command string) bool

	// Debug and output configuration
	GetOutputDirectory() string

	// Gateway configuration
	GetGatewayURL() string
	GetAPIKey() string
	GetTimeout() int

	// Chat configuration
	GetAgentConfig() *config.AgentConfig

	// Sandbox configuration
	GetSandboxDirectories() []string
	GetProtectedPaths() []string

	// Full configuration access
	GetConfig() *config.Config
}

ConfigService provides configuration-related functionality

type ContainerInfo added in v0.82.0

type ContainerInfo struct {
	ID   string
	Name string
}

ContainerInfo represents basic container information

type ContainerRuntime added in v0.82.0

type ContainerRuntime interface {
	// Network operations
	GetNetworkName() string
	EnsureNetwork(ctx context.Context) error
	CleanupNetwork(ctx context.Context) error

	// Container lifecycle operations
	ContainerExists(containerIDOrName string) bool
	RunContainer(ctx context.Context, opts RunContainerOptions) (containerID string, err error)
	StopContainer(ctx context.Context, containerIDOrName string) error

	// Image operations
	PullImage(ctx context.Context, image string) error

	// Container inspection
	GetContainerHealth(ctx context.Context, containerIDOrName string) (HealthStatus, error)
	ListRunningContainers(ctx context.Context, nameFilter string) ([]ContainerInfo, error)
}

ContainerRuntime defines the interface for container runtime operations This abstraction allows support for Docker, Podman, or any other container runtime

type ContextKey added in v0.56.0

type ContextKey string

ContextKey is the type used for context keys in the application

const BashDetachChannelKey ContextKey = "bash_detach_channel"

BashDetachChannelKey is the context key for the bash detach signal channel When this key is set in the context, the bash tool can signal when a command should be detached to the background (e.g., via keyboard shortcut)

const BashOutputCallbackKey ContextKey = "bash_output_callback"

BashOutputCallbackKey is the context key for bash output streaming callback When this key is set in the context, the bash tool will stream output line by line through the callback function instead of waiting for the command to complete

const ChatHandlerKey ContextKey = "chat_handler"

ChatHandlerKey is the context key for passing the ChatHandler reference This allows the agent service to access ChatHandler for setting up the detach channel

const DirectExecutionKey ContextKey = "direct_execution"

DirectExecutionKey is the context key for direct tool execution When this key is set to true in the context, it indicates that the tool was invoked directly by the user (e.g., via !! command) rather than by the LLM This allows tools to adjust behavior (e.g., skip coordinate scaling for mouse operations)

const SessionIDKey ContextKey = "session_id"

SessionIDKey is the context key for the current conversation session ID This allows shortcuts to access the session ID when they need it (e.g., /export)

const ToolApprovedKey ContextKey = "tool_approved"

ToolApprovedKey is the context key for user-approved tool executions When this key is set to true in the context, it indicates that the tool execution was explicitly approved by the user and should bypass whitelist validation

type ConversationEntry

type ConversationEntry struct {
	// Core message fields
	Message          Message           `json:"message"`
	Model            string            `json:"model,omitempty"`
	Time             time.Time         `json:"time"`
	Hidden           bool              `json:"hidden,omitempty"`
	Images           []ImageAttachment `json:"images,omitempty"`
	ReasoningContent string            `json:"reasoning_content,omitempty"`

	// Tool-related fields
	ToolExecution      *ToolExecutionResult               `json:"tool_execution,omitempty"`
	PendingToolCall    *sdk.ChatCompletionMessageToolCall `json:"pending_tool_call,omitempty"`
	ToolApprovalStatus ToolApprovalStatus                 `json:"tool_approval_status,omitempty"`

	// Plan mode fields
	Rejected           bool               `json:"rejected,omitempty"`
	IsPlan             bool               `json:"is_plan,omitempty"`
	PlanApprovalStatus PlanApprovalStatus `json:"plan_approval_status,omitempty"`
}

ConversationEntry represents a message in the conversation with metadata

type ConversationOptimizer added in v0.99.0

type ConversationOptimizer interface {
	OptimizeMessages(messages []sdk.Message, model string, force bool) []sdk.Message
}

ConversationOptimizer optimizes conversation history to reduce token usage

type ConversationRepository

type ConversationRepository interface {
	AddMessage(msg ConversationEntry) error
	GetMessages() []ConversationEntry
	Clear() error
	ClearExceptFirstUserMessage() error
	Export(format ExportFormat) ([]byte, error)
	GetMessageCount() int
	UpdateLastMessage(content string) error
	UpdateLastMessageToolCalls(toolCalls *[]sdk.ChatCompletionMessageToolCall) error
	AddTokenUsage(model string, inputTokens, outputTokens, totalTokens int) error
	GetSessionTokens() SessionTokenStats
	GetSessionCostStats() SessionCostStats
	FormatToolResultForLLM(result *ToolExecutionResult) string
	FormatToolResultForUI(result *ToolExecutionResult, terminalWidth int) string
	FormatToolResultExpanded(result *ToolExecutionResult, terminalWidth int) string
	RemovePendingToolCallByID(toolCallID string)
	StartNewConversation(title string) error
	DeleteMessagesAfterIndex(index int) error
	GetCurrentConversationTitle() string
}

ConversationRepository handles conversation storage and retrieval

type ConversationSelectedEvent added in v0.45.0

type ConversationSelectedEvent struct {
	ConversationID string
}

ConversationSelectedEvent indicates conversation selection

type ConversationsLoadedEvent added in v0.45.0

type ConversationsLoadedEvent struct {
	Conversations []any
	Error         error
}

ConversationsLoadedEvent indicates conversations have been loaded

type CustomFormatter added in v0.33.4

type CustomFormatter struct {
	BaseFormatter
	// contains filtered or unexported fields
}

CustomFormatter extends BaseFormatter with customizable collapse behavior

func NewCustomFormatter added in v0.33.4

func NewCustomFormatter(toolName string, collapseFunc func(string) bool) CustomFormatter

NewCustomFormatter creates a formatter with custom collapse logic

func (CustomFormatter) FormatExpandedHeader added in v0.33.4

func (f CustomFormatter) FormatExpandedHeader(result *ToolExecutionResult) string

FormatExpandedHeader overrides BaseFormatter to use custom collapse logic

func (CustomFormatter) FormatToolCall added in v0.33.4

func (f CustomFormatter) FormatToolCall(args map[string]any, expanded bool) string

FormatToolCall overrides BaseFormatter to use custom collapse logic

func (CustomFormatter) ShouldCollapseArg added in v0.33.4

func (f CustomFormatter) ShouldCollapseArg(key string) bool

ShouldCollapseArg uses the custom collapse function if provided

type DebugKeyEvent added in v0.45.0

type DebugKeyEvent struct {
	Key     string
	Handler string
}

DebugKeyEvent provides debug information about key presses

type DeleteToolResult added in v0.18.0

type DeleteToolResult struct {
	Path              string   `json:"path"`
	DeletedFiles      []string `json:"deleted_files"`
	DeletedDirs       []string `json:"deleted_dirs"`
	TotalFilesDeleted int      `json:"total_files_deleted"`
	TotalDirsDeleted  int      `json:"total_dirs_deleted"`
	WildcardExpanded  bool     `json:"wildcard_expanded"`
	Errors            []string `json:"errors,omitempty"`
}

DeleteToolResult represents the result of a delete operation

type DraculaTheme added in v0.47.0

type DraculaTheme struct{}

DraculaTheme provides the popular Dracula color scheme

func NewDraculaTheme added in v0.47.0

func NewDraculaTheme() *DraculaTheme

func (*DraculaTheme) GetAccentColor added in v0.47.0

func (t *DraculaTheme) GetAccentColor() string

func (*DraculaTheme) GetAssistantColor added in v0.47.0

func (t *DraculaTheme) GetAssistantColor() string

func (*DraculaTheme) GetBorderColor added in v0.47.0

func (t *DraculaTheme) GetBorderColor() string

func (*DraculaTheme) GetDiffAddColor added in v0.47.0

func (t *DraculaTheme) GetDiffAddColor() string

func (*DraculaTheme) GetDiffRemoveColor added in v0.47.0

func (t *DraculaTheme) GetDiffRemoveColor() string

func (*DraculaTheme) GetDimColor added in v0.47.0

func (t *DraculaTheme) GetDimColor() string

func (*DraculaTheme) GetErrorColor added in v0.47.0

func (t *DraculaTheme) GetErrorColor() string

func (*DraculaTheme) GetStatusColor added in v0.47.0

func (t *DraculaTheme) GetStatusColor() string

func (*DraculaTheme) GetSuccessColor added in v0.56.0

func (t *DraculaTheme) GetSuccessColor() string

func (*DraculaTheme) GetUserColor added in v0.47.0

func (t *DraculaTheme) GetUserColor() string

type EditOperationResult added in v0.22.0

type EditOperationResult struct {
	OldString     string `json:"old_string"`
	NewString     string `json:"new_string"`
	ReplaceAll    bool   `json:"replace_all"`
	ReplacedCount int    `json:"replaced_count"`
	Success       bool   `json:"success"`
	Error         string `json:"error,omitempty"`
}

EditOperationResult represents the result of a single edit operation within MultiEdit

type EditToolResult added in v0.21.0

type EditToolResult struct {
	FilePath        string `json:"file_path"`
	OldString       string `json:"old_string"`
	NewString       string `json:"new_string"`
	ReplacedCount   int    `json:"replaced_count"`
	ReplaceAll      bool   `json:"replace_all"`
	FileModified    bool   `json:"file_modified"`
	OriginalSize    int64  `json:"original_size"`
	NewSize         int64  `json:"new_size"`
	BytesDifference int64  `json:"bytes_difference"`
	OriginalLines   int    `json:"original_lines"`
	NewLines        int    `json:"new_lines"`
	LinesDifference int    `json:"lines_difference"`
	Diff            string `json:"diff,omitempty"`
}

EditToolResult represents the result of an edit operation

type EventBridge added in v0.96.0

type EventBridge interface {
	// Tap intercepts an event stream and multicasts it to all subscribers
	// Returns a new channel that mirrors the input channel
	Tap(input <-chan ChatEvent) <-chan ChatEvent

	// Publish broadcasts an event to all subscribers
	Publish(event ChatEvent)

	// Subscribe creates a new event channel and returns it
	Subscribe() chan ChatEvent

	// Unsubscribe removes a subscriber and closes its channel
	Unsubscribe(ch chan ChatEvent)
}

EventBridge multicasts chat events to multiple subscribers (e.g., terminal UI and floating window)

type ExportFormat

type ExportFormat string

ExportFormat defines the format for exporting conversations

const (
	ExportMarkdown ExportFormat = "markdown"
	ExportJSON     ExportFormat = "json"
	ExportText     ExportFormat = "text"
)

type FetchResult added in v0.11.0

type FetchResult struct {
	Content     string            `json:"content"`
	URL         string            `json:"url"`
	Status      int               `json:"status"`
	Size        int64             `json:"size"`
	ContentType string            `json:"content_type"`
	Cached      bool              `json:"cached"`
	SavedPath   string            `json:"saved_path,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Warning     string            `json:"warning,omitempty"`
}

FetchResult represents the result of a fetch operation

type FileInfo

type FileInfo struct {
	Path  string
	Size  int64
	IsDir bool
}

FileInfo contains file metadata

type FileReadToolResult added in v0.13.1

type FileReadToolResult struct {
	FilePath  string `json:"file_path"`
	Content   string `json:"content"`
	Size      int64  `json:"size"`
	StartLine int    `json:"start_line,omitempty"`
	EndLine   int    `json:"end_line,omitempty"`
	Error     string `json:"error,omitempty"`
}

FileReadToolResult represents the result of a file read operation

type FileSelectedEvent added in v0.45.0

type FileSelectedEvent struct {
	FilePath string
}

FileSelectedEvent indicates file selection

type FileSelectionRequestEvent added in v0.45.0

type FileSelectionRequestEvent struct{}

FileSelectionRequestEvent requests file selection UI

type FileSelectionState added in v0.27.0

type FileSelectionState struct {
	Files         []string `json:"files"`
	SearchQuery   string   `json:"search_query"`
	SelectedIndex int      `json:"selected_index"`
}

FileSelectionState represents the state of file selection UI

type FileService

type FileService interface {
	ListProjectFiles() ([]string, error)
	ReadFile(path string) (string, error)
	ReadFileLines(path string, startLine, endLine int) (string, error)
	ValidateFile(path string) error
	GetFileInfo(path string) (FileInfo, error)
}

FileService handles file operations

type FileWriteToolResult added in v0.17.0

type FileWriteToolResult struct {
	FilePath     string `json:"file_path"`
	BytesWritten int64  `json:"bytes_written"`
	LinesWritten int    `json:"lines_written"`
	Created      bool   `json:"created"`
	Overwritten  bool   `json:"overwritten"`
	DirsCreated  bool   `json:"dirs_created"`
	Appended     bool   `json:"appended"`
	ChunkIndex   int    `json:"chunk_index,omitempty"`
	TotalChunks  int    `json:"total_chunks,omitempty"`
	IsComplete   bool   `json:"is_complete"`
	Error        string `json:"error,omitempty"`
}

FileWriteToolResult represents the result of a file write operation

type FocusRequestEvent added in v0.45.0

type FocusRequestEvent struct {
	ComponentID string
}

FocusRequestEvent requests focus change

type FormatterType added in v0.33.4

type FormatterType string

FormatterType defines the context for formatting tool results

const (
	FormatterUI    FormatterType = "ui"    // Compact display for UI
	FormatterLLM   FormatterType = "llm"   // Formatted for LLM consumption
	FormatterShort FormatterType = "short" // Brief summary format
)

type GatewayManager added in v0.54.0

type GatewayManager interface {
	// Start starts the gateway container or binary if configured to run locally
	Start(ctx context.Context) error

	// Stop stops the gateway container or binary
	Stop(ctx context.Context) error

	// IsRunning returns whether the gateway is running
	IsRunning() bool

	// GetGatewayURL returns the actual gateway URL with the assigned port
	GetGatewayURL() string

	// EnsureStarted starts the gateway if configured and not already running
	// This is a convenience method that checks config and running state before starting
	EnsureStarted() error
}

GatewayManager manages the lifecycle of the gateway (container or binary)

type GitHubBranch added in v0.31.0

type GitHubBranch struct {
	Label string           `json:"label"`
	Ref   string           `json:"ref"`
	SHA   string           `json:"sha"`
	User  GitHubUser       `json:"user"`
	Repo  GitHubRepository `json:"repo"`
}

GitHubBranch represents a branch reference in a pull request

type GitHubComment added in v0.31.0

type GitHubComment struct {
	ID        int        `json:"id"`
	Body      string     `json:"body"`
	User      GitHubUser `json:"user"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	HTMLURL   string     `json:"html_url"`
}

GitHubComment represents a GitHub comment

type GitHubError added in v0.31.0

type GitHubError struct {
	Message          string `json:"message"`
	DocumentationURL string `json:"documentation_url,omitempty"`
}

GitHubError represents a GitHub API error response

type GitHubIssue added in v0.31.0

type GitHubIssue struct {
	ID          int              `json:"id"`
	Number      int              `json:"number"`
	Title       string           `json:"title"`
	Body        string           `json:"body"`
	State       string           `json:"state"`
	User        GitHubUser       `json:"user"`
	Assignees   []GitHubUser     `json:"assignees,omitempty"`
	Labels      []GitHubLabel    `json:"labels,omitempty"`
	Milestone   *GitHubMilestone `json:"milestone,omitempty"`
	Comments    int              `json:"comments"`
	CreatedAt   time.Time        `json:"created_at"`
	UpdatedAt   time.Time        `json:"updated_at"`
	ClosedAt    *time.Time       `json:"closed_at,omitempty"`
	HTMLURL     string           `json:"html_url"`
	PullRequest *struct {
		URL      string `json:"url"`
		HTMLURL  string `json:"html_url"`
		DiffURL  string `json:"diff_url"`
		PatchURL string `json:"patch_url"`
	} `json:"pull_request,omitempty"`
}

GitHubIssue represents a GitHub issue

type GitHubLabel added in v0.31.0

type GitHubLabel struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description,omitempty"`
}

GitHubLabel represents a GitHub label

type GitHubMilestone added in v0.31.0

type GitHubMilestone struct {
	ID          int        `json:"id"`
	Number      int        `json:"number"`
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	State       string     `json:"state"`
	DueOn       *time.Time `json:"due_on,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

GitHubMilestone represents a GitHub milestone

type GitHubPullRequest added in v0.31.0

type GitHubPullRequest struct {
	ID           int              `json:"id"`
	Number       int              `json:"number"`
	Title        string           `json:"title"`
	Body         string           `json:"body"`
	State        string           `json:"state"`
	User         GitHubUser       `json:"user"`
	Assignees    []GitHubUser     `json:"assignees,omitempty"`
	Labels       []GitHubLabel    `json:"labels,omitempty"`
	Milestone    *GitHubMilestone `json:"milestone,omitempty"`
	Comments     int              `json:"comments"`
	Commits      int              `json:"commits"`
	Additions    int              `json:"additions"`
	Deletions    int              `json:"deletions"`
	ChangedFiles int              `json:"changed_files"`
	CreatedAt    time.Time        `json:"created_at"`
	UpdatedAt    time.Time        `json:"updated_at"`
	ClosedAt     *time.Time       `json:"closed_at,omitempty"`
	MergedAt     *time.Time       `json:"merged_at,omitempty"`
	Merged       bool             `json:"merged"`
	Mergeable    *bool            `json:"mergeable,omitempty"`
	Head         GitHubBranch     `json:"head"`
	Base         GitHubBranch     `json:"base"`
	HTMLURL      string           `json:"html_url"`
	DiffURL      string           `json:"diff_url"`
	PatchURL     string           `json:"patch_url"`
}

GitHubPullRequest represents a GitHub pull request

type GitHubRepository added in v0.31.0

type GitHubRepository struct {
	ID       int        `json:"id"`
	Name     string     `json:"name"`
	FullName string     `json:"full_name"`
	Owner    GitHubUser `json:"owner"`
	Private  bool       `json:"private"`
	HTMLURL  string     `json:"html_url"`
	CloneURL string     `json:"clone_url"`
}

GitHubRepository represents a GitHub repository

type GitHubUser added in v0.31.0

type GitHubUser struct {
	ID        int    `json:"id"`
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url"`
	HTMLURL   string `json:"html_url"`
	Type      string `json:"type"`
}

GitHubUser represents a GitHub user

type GithubLightTheme added in v0.47.0

type GithubLightTheme struct{}

GithubLightTheme provides a light theme similar to GitHub's interface

func NewGithubLightTheme added in v0.47.0

func NewGithubLightTheme() *GithubLightTheme

func (*GithubLightTheme) GetAccentColor added in v0.47.0

func (t *GithubLightTheme) GetAccentColor() string

func (*GithubLightTheme) GetAssistantColor added in v0.47.0

func (t *GithubLightTheme) GetAssistantColor() string

func (*GithubLightTheme) GetBorderColor added in v0.47.0

func (t *GithubLightTheme) GetBorderColor() string

func (*GithubLightTheme) GetDiffAddColor added in v0.47.0

func (t *GithubLightTheme) GetDiffAddColor() string

func (*GithubLightTheme) GetDiffRemoveColor added in v0.47.0

func (t *GithubLightTheme) GetDiffRemoveColor() string

func (*GithubLightTheme) GetDimColor added in v0.47.0

func (t *GithubLightTheme) GetDimColor() string

func (*GithubLightTheme) GetErrorColor added in v0.47.0

func (t *GithubLightTheme) GetErrorColor() string

func (*GithubLightTheme) GetStatusColor added in v0.47.0

func (t *GithubLightTheme) GetStatusColor() string

func (*GithubLightTheme) GetSuccessColor added in v0.56.0

func (t *GithubLightTheme) GetSuccessColor() string

func (*GithubLightTheme) GetUserColor added in v0.47.0

func (t *GithubLightTheme) GetUserColor() string

type HealthCheckConfig added in v0.82.0

type HealthCheckConfig struct {
	Interval    string // e.g., "10s"
	Timeout     string // e.g., "5s"
	Retries     int
	StartPeriod string // e.g., "10s"
}

HealthCheckConfig defines container health check configuration

type HealthStatus added in v0.82.0

type HealthStatus string

HealthStatus represents the health status of a container

const (
	HealthStatusHealthy   HealthStatus = "healthy"
	HealthStatusUnhealthy HealthStatus = "unhealthy"
	HealthStatusStarting  HealthStatus = "starting"
	HealthStatusNone      HealthStatus = "none"
)

type HideHelpBarEvent added in v0.45.0

type HideHelpBarEvent struct{}

HideHelpBarEvent hides the help bar when typing other characters

type ImageAttachment added in v0.57.0

type ImageAttachment struct {
	Data        string `json:"data"`
	MimeType    string `json:"mime_type"`
	Filename    string `json:"filename,omitempty"`
	DisplayName string `json:"display_name"`
	SourcePath  string `json:"-"`
}

ImageAttachment represents an image attachment in a message

type ImageService added in v0.57.0

type ImageService interface {
	// ReadImageFromFile reads an image from a file path and returns it as a base64 attachment
	ReadImageFromFile(filePath string) (*ImageAttachment, error)
	// ReadImageFromBinary reads an image from binary data and returns it as a base64 attachment
	ReadImageFromBinary(imageData []byte, filename string) (*ImageAttachment, error)
	// ReadImageFromURL fetches an image from a URL and returns it as a base64 attachment
	ReadImageFromURL(imageURL string) (*ImageAttachment, error)
	// CreateDataURL creates a data URL from an image attachment
	CreateDataURL(attachment *ImageAttachment) string
	// IsImageFile checks if a file is a supported image format
	IsImageFile(filePath string) bool
	// IsImageURL checks if a string is a valid image URL
	IsImageURL(urlStr string) bool
}

ImageService handles image operations including loading and encoding

type InitializeA2ATaskManagementEvent added in v0.53.3

type InitializeA2ATaskManagementEvent struct{}

InitializeA2ATaskManagementEvent indicates A2A task management view should be initialized

type InitializeConversationSelectionEvent added in v0.45.0

type InitializeConversationSelectionEvent struct{}

InitializeConversationSelectionEvent indicates conversation selection view should be initialized

type KeyboardTypeToolResult added in v0.96.0

type KeyboardTypeToolResult struct {
	Text     string `json:"text,omitempty"`
	KeyCombo string `json:"key_combo,omitempty"`
	Display  string `json:"display"`
	Method   string `json:"method"`
}

KeyboardTypeToolResult represents the result of a keyboard input operation

type MCPClient added in v0.79.0

type MCPClient interface {
	// DiscoverTools discovers all tools from enabled MCP servers
	DiscoverTools(ctx context.Context) (map[string][]MCPDiscoveredTool, error)

	// CallTool executes a tool on an MCP server
	CallTool(ctx context.Context, serverName, toolName string, args map[string]any) (any, error)

	// PingServer sends a ping request to check if a specific server is alive
	PingServer(ctx context.Context, serverName string) error

	// Close cleans up MCP client resources
	Close() error
}

MCPClient handles communication with MCP servers

type MCPDiscoveredTool added in v0.79.0

type MCPDiscoveredTool struct {
	ServerName  string
	Name        string
	Description string
	InputSchema any
}

MCPDiscoveredTool represents a tool discovered from an MCP server

type MCPManager added in v0.79.0

type MCPManager interface {
	// Returns a list of clients
	GetClients() []MCPClient

	// GetTotalServers returns the total number of configured MCP servers
	GetTotalServers() int

	// StartMonitoring begins background health monitoring and returns a channel for status updates
	StartMonitoring(ctx context.Context) <-chan MCPServerStatusUpdateEvent

	// UpdateToolCount updates the tool count for a specific server
	UpdateToolCount(serverName string, count int)

	// ClearToolCount removes the tool count for a specific server
	ClearToolCount(serverName string)

	// Container lifecycle management
	// StartServers starts all MCP servers that have run=true (non-fatal)
	StartServers(ctx context.Context) error

	// StopServers stops all running MCP server containers
	StopServers(ctx context.Context) error

	// Close stops monitoring, stops containers, and cleans up resources
	Close() error
}

MCPManager manages the lifecycle, health monitoring, and container orchestration of MCP servers

type MCPServerEntry added in v0.79.0

type MCPServerEntry struct {
	Name         string
	URL          string
	Enabled      bool
	Timeout      int
	Description  string
	IncludeTools []string
	ExcludeTools []string
}

MCPServerEntry represents an MCP server configuration entry

type MCPServerStatus added in v0.79.0

type MCPServerStatus struct {
	TotalServers     int `json:"total_servers"`
	ConnectedServers int `json:"connected_servers"`
	TotalTools       int `json:"total_tools"`
}

MCPServerStatus represents the status of MCP server connections

type MCPServerStatusUpdateEvent added in v0.79.0

type MCPServerStatusUpdateEvent struct {
	ServerName       string
	Connected        bool
	TotalServers     int
	ConnectedServers int
	TotalTools       int
	Tools            []MCPDiscoveredTool
}

MCPServerStatusUpdateEvent indicates MCP server status has changed

type MCPToolResult added in v0.79.0

type MCPToolResult struct {
	ServerName string `json:"server_name"`
	ToolName   string `json:"tool_name"`
	Content    string `json:"content"`
	Error      string `json:"error,omitempty"`
}

MCPToolResult represents the result of an MCP tool execution

type MarkdownRenderer added in v0.61.0

type MarkdownRenderer interface {
	// Render converts markdown text to styled terminal output
	Render(content string) string
	// SetWidth updates the renderer width for responsive rendering
	SetWidth(width int)
}

MarkdownRenderer handles conversion of markdown text to styled terminal output

type Message added in v0.45.4

type Message = sdk.Message

Assistant message

type MessageEditState added in v0.92.0

type MessageEditState struct {
	OriginalMessageIndex int       `json:"original_message_index"`
	OriginalContent      string    `json:"original_content"`
	EditTimestamp        time.Time `json:"edit_timestamp"`
}

MessageEditState represents the state when editing a message

type MessageEditSubmitEvent added in v0.92.0

type MessageEditSubmitEvent struct {
	RequestID     string
	Timestamp     time.Time
	OriginalIndex int
	EditedContent string
	Images        []ImageAttachment
}

MessageEditSubmitEvent is emitted when edited message is submitted

func (MessageEditSubmitEvent) GetRequestID added in v0.92.0

func (e MessageEditSubmitEvent) GetRequestID() string

func (MessageEditSubmitEvent) GetTimestamp added in v0.92.0

func (e MessageEditSubmitEvent) GetTimestamp() time.Time

type MessageHistoryEditEvent added in v0.92.0

type MessageHistoryEditEvent struct {
	RequestID       string
	Timestamp       time.Time
	MessageIndex    int
	MessageContent  string
	MessageSnapshot MessageSnapshot
}

MessageHistoryEditEvent is emitted when user wants to edit a selected message

func (MessageHistoryEditEvent) GetRequestID added in v0.92.0

func (e MessageHistoryEditEvent) GetRequestID() string

func (MessageHistoryEditEvent) GetTimestamp added in v0.92.0

func (e MessageHistoryEditEvent) GetTimestamp() time.Time

type MessageHistoryEditReadyEvent added in v0.92.0

type MessageHistoryEditReadyEvent struct {
	MessageIndex int
	Content      string
	Snapshot     MessageSnapshot
}

MessageHistoryEditReadyEvent indicates editing is ready to begin

type MessageHistoryReadyEvent added in v0.91.0

type MessageHistoryReadyEvent struct {
	Messages []MessageSnapshot
}

MessageHistoryReadyEvent indicates message history has been loaded and is ready to display

type MessageHistoryRestoreEvent added in v0.91.0

type MessageHistoryRestoreEvent struct {
	RequestID      string
	Timestamp      time.Time
	RestoreToIndex int
}

MessageHistoryRestoreEvent is emitted when user selects a restore point in message history

func (MessageHistoryRestoreEvent) GetRequestID added in v0.91.0

func (e MessageHistoryRestoreEvent) GetRequestID() string

func (MessageHistoryRestoreEvent) GetTimestamp added in v0.91.0

func (e MessageHistoryRestoreEvent) GetTimestamp() time.Time

type MessageQueue added in v0.53.0

type MessageQueue interface {
	// Enqueue adds a message to the queue
	Enqueue(message Message, requestID string)

	// Dequeue removes and returns the next message from the queue
	// Returns nil if the queue is empty
	Dequeue() *QueuedMessage

	// Peek returns the next message without removing it
	// Returns nil if the queue is empty
	Peek() *QueuedMessage

	// Size returns the number of messages in the queue
	Size() int

	// IsEmpty returns true if the queue has no messages
	IsEmpty() bool

	// Clear removes all messages from the queue
	Clear()

	// GetAll returns all messages in the queue without removing them
	GetAll() []QueuedMessage
}

MessageQueue handles centralized message queuing for all components

type MessageQueuedEvent added in v0.53.0

type MessageQueuedEvent struct {
	RequestID string
	Timestamp time.Time
	Message   sdk.Message
}

MessageQueuedEvent indicates a message was received from the queue and stored

func (MessageQueuedEvent) GetRequestID added in v0.53.0

func (e MessageQueuedEvent) GetRequestID() string

func (MessageQueuedEvent) GetTimestamp added in v0.53.0

func (e MessageQueuedEvent) GetTimestamp() time.Time

type MessageSnapshot added in v0.91.0

type MessageSnapshot struct {
	Index        int             `json:"index"`
	Role         sdk.MessageRole `json:"role"`
	Content      string          `json:"content"`
	Timestamp    time.Time       `json:"timestamp"`
	TruncatedMsg string          `json:"truncated_msg"`
}

MessageSnapshot represents a snapshot of a message for the history view

type ModelCostStats added in v0.86.0

type ModelCostStats struct {
	Model        string
	InputTokens  int
	OutputTokens int
	InputCost    float64
	OutputCost   float64
	TotalCost    float64
	RequestCount int
}

ModelCostStats tracks cost statistics for a specific model within a session. This allows detailed breakdown when multiple models are used in the same conversation.

type ModelSelectedEvent added in v0.45.0

type ModelSelectedEvent struct {
	Model string
}

ModelSelectedEvent indicates model selection

type ModelService

type ModelService interface {
	ListModels(ctx context.Context) ([]string, error)
	SelectModel(modelID string) error
	GetCurrentModel() string
	IsModelAvailable(modelID string) bool
	ValidateModel(modelID string) error
	IsVisionModel(modelID string) bool
}

ModelService handles model selection and information

type MouseClickToolResult added in v0.96.0

type MouseClickToolResult struct {
	Button  string `json:"button"`
	Clicks  int    `json:"clicks"`
	X       int    `json:"x"`
	Y       int    `json:"y"`
	Display string `json:"display"`
	Method  string `json:"method"`
}

MouseClickToolResult represents the result of a mouse click operation

type MouseMoveToolResult added in v0.96.0

type MouseMoveToolResult struct {
	FromX   int    `json:"from_x"`
	FromY   int    `json:"from_y"`
	ToX     int    `json:"to_x"`
	ToY     int    `json:"to_y"`
	Display string `json:"display"`
	Method  string `json:"method"`
}

MouseMoveToolResult represents the result of a mouse move operation

type MoveIndicatorEvent added in v0.96.0

type MoveIndicatorEvent struct {
	BaseChatEvent
	FromX         int  `json:"FromX"`
	FromY         int  `json:"FromY"`
	ToX           int  `json:"ToX"`
	ToY           int  `json:"ToY"`
	MoveIndicator bool `json:"MoveIndicator"`
}

MoveIndicatorEvent indicates a visual move indicator should be shown at coordinates

type MultiEditToolResult added in v0.22.0

type MultiEditToolResult struct {
	FilePath        string                `json:"file_path"`
	Edits           []EditOperationResult `json:"edits"`
	TotalEdits      int                   `json:"total_edits"`
	SuccessfulEdits int                   `json:"successful_edits"`
	FileModified    bool                  `json:"file_modified"`
	OriginalSize    int64                 `json:"original_size"`
	NewSize         int64                 `json:"new_size"`
	BytesDifference int64                 `json:"bytes_difference"`
}

MultiEditToolResult represents the result of a MultiEdit operation

type NavigateBackInTimeEvent struct {
	RequestID string
	Timestamp time.Time
}

NavigateBackInTimeEvent triggers the message history selector view

func (e NavigateBackInTimeEvent) GetRequestID() string
func (e NavigateBackInTimeEvent) GetTimestamp() time.Time

type OptimizationStatusEvent added in v0.48.0

type OptimizationStatusEvent struct {
	RequestID      string
	Timestamp      time.Time
	Message        string
	IsActive       bool
	OriginalCount  int
	OptimizedCount int
}

OptimizationStatusEvent indicates conversation optimization status

func (OptimizationStatusEvent) GetRequestID added in v0.48.0

func (e OptimizationStatusEvent) GetRequestID() string

func (OptimizationStatusEvent) GetTimestamp added in v0.48.0

func (e OptimizationStatusEvent) GetTimestamp() time.Time

type OutputRingBuffer added in v0.81.0

type OutputRingBuffer interface {
	Write(p []byte) (n int, err error)
	ReadFrom(offset int64) (string, int64)
	Recent(maxBytes int) string
	TotalWritten() int64
	Size() int
	String() string
	Clear()
}

OutputRingBuffer defines the interface for the circular output buffer.

type PlanApprovalAction added in v0.68.0

type PlanApprovalAction int

PlanApprovalAction represents the user's choice for plan approval

const (
	PlanApprovalAccept PlanApprovalAction = iota
	PlanApprovalReject
	PlanApprovalAcceptAndAutoApprove
)

func (PlanApprovalAction) String added in v0.68.0

func (a PlanApprovalAction) String() string

type PlanApprovalRequestedEvent added in v0.68.0

type PlanApprovalRequestedEvent struct {
	RequestID    string
	Timestamp    time.Time
	PlanContent  string
	ResponseChan chan PlanApprovalAction `json:"-"`
}

PlanApprovalRequestedEvent indicates plan mode completion requires user approval

func (PlanApprovalRequestedEvent) GetRequestID added in v0.68.0

func (e PlanApprovalRequestedEvent) GetRequestID() string

func (PlanApprovalRequestedEvent) GetTimestamp added in v0.68.0

func (e PlanApprovalRequestedEvent) GetTimestamp() time.Time

type PlanApprovalResponseEvent added in v0.68.0

type PlanApprovalResponseEvent struct {
	Action PlanApprovalAction
}

PlanApprovalResponseEvent captures the user's plan approval decision

type PlanApprovalStatus added in v0.68.0

type PlanApprovalStatus int

PlanApprovalStatus represents the approval status of a plan

const (
	PlanApprovalPending PlanApprovalStatus = iota
	PlanApprovalAccepted
	PlanApprovalRejected
)

type PlanApprovalUIState added in v0.68.0

type PlanApprovalUIState struct {
	SelectedIndex int                     `json:"selected_index"`
	PlanContent   string                  `json:"plan_content"`
	ResponseChan  chan PlanApprovalAction `json:"-"`
}

PlanApprovalUIState represents the state of plan approval UI

type PlanApprovedAndAutoAcceptEvent added in v0.68.0

type PlanApprovedAndAutoAcceptEvent struct {
	RequestID string
	Timestamp time.Time
}

PlanApprovedAndAutoAcceptEvent indicates the user approved the plan and wants to enable auto-accept

func (PlanApprovedAndAutoAcceptEvent) GetRequestID added in v0.68.0

func (e PlanApprovedAndAutoAcceptEvent) GetRequestID() string

func (PlanApprovedAndAutoAcceptEvent) GetTimestamp added in v0.68.0

func (e PlanApprovedAndAutoAcceptEvent) GetTimestamp() time.Time

type PlanApprovedEvent added in v0.68.0

type PlanApprovedEvent struct {
	RequestID string
	Timestamp time.Time
}

PlanApprovedEvent indicates the user approved the plan

func (PlanApprovedEvent) GetRequestID added in v0.68.0

func (e PlanApprovedEvent) GetRequestID() string

func (PlanApprovedEvent) GetTimestamp added in v0.68.0

func (e PlanApprovedEvent) GetTimestamp() time.Time

type PlanRejectedEvent added in v0.68.0

type PlanRejectedEvent struct {
	RequestID string
	Timestamp time.Time
}

PlanRejectedEvent indicates the user rejected the plan

func (PlanRejectedEvent) GetRequestID added in v0.68.0

func (e PlanRejectedEvent) GetRequestID() string

func (PlanRejectedEvent) GetTimestamp added in v0.68.0

func (e PlanRejectedEvent) GetTimestamp() time.Time

type PricingService added in v0.86.0

type PricingService interface {
	// IsEnabled returns whether pricing is enabled in the configuration.
	IsEnabled() bool

	// GetInputPrice retrieves the input price per million tokens for a specific model.
	// Returns 0.0 for unknown models (e.g., Ollama, custom models).
	GetInputPrice(model string) float64

	// GetOutputPrice retrieves the output price per million tokens for a specific model.
	// Returns 0.0 for unknown models (e.g., Ollama, custom models).
	GetOutputPrice(model string) float64

	// CalculateCost computes the total cost for a given number of input and output tokens.
	CalculateCost(model string, inputTokens, outputTokens int) (inputCost, outputCost, totalCost float64)

	// FormatModelPricing returns a formatted string describing the model's pricing.
	// Returns empty string if pricing is disabled.
	// Returns "free" if both input and output prices are 0.0.
	// Returns "$X.XX/$Y.YY per MTok" for paid models.
	FormatModelPricing(model string) string
}

PricingService provides pricing information and cost calculation for different models. Note: This interface returns float64 for pricing to avoid import cycles. The actual ModelPricing struct is defined in the config package.

type QueuedMessage added in v0.53.0

type QueuedMessage struct {
	Message   sdk.Message
	QueuedAt  time.Time
	RequestID string
}

QueuedMessage represents a message in the input queue

type RateLimiter added in v0.96.0

type RateLimiter interface {
	// CheckAndRecord checks if the action is within rate limits and records it
	CheckAndRecord(toolName string) error
	// GetCurrentCount returns the number of actions in the current window
	GetCurrentCount() int
	// Reset clears all recorded actions
	Reset()
}

RateLimiter defines the interface for rate limiting computer use actions

type RefreshAutocompleteEvent added in v0.76.2

type RefreshAutocompleteEvent struct{}

RefreshAutocompleteEvent is sent when autocomplete needs to refresh (e.g., after mode change)

type ResizeEvent added in v0.45.0

type ResizeEvent struct {
	Width  int
	Height int
}

ResizeEvent handles terminal resize

type RunContainerOptions added in v0.82.0

type RunContainerOptions struct {
	Name         string
	Image        string
	Network      string
	Ports        []string // Format: "host:container" or "host:container/protocol"
	Environment  map[string]string
	Volumes      []string // Format: "host:container" or "host:container:mode"
	Entrypoint   []string
	Command      []string
	Args         []string
	HealthCmd    string
	HealthConfig *HealthCheckConfig
	RemoveOnExit bool
	Detached     bool
	EnvFile      string // Optional .env file path
}

RunContainerOptions contains all options for running a container

type SDKClient added in v0.46.0

type SDKClient interface {
	WithOptions(opts *sdk.CreateChatCompletionRequest) SDKClient
	WithMiddlewareOptions(opts *sdk.MiddlewareOptions) SDKClient
	WithTools(tools *[]sdk.ChatCompletionTool) SDKClient
	GenerateContent(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (*sdk.CreateChatCompletionResponse, error)
	GenerateContentStream(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (<-chan sdk.SSEvent, error)
}

SDKClient is our interface wrapper for the SDK client to make it testable

type ScreenRegion added in v0.96.0

type ScreenRegion struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

ScreenRegion represents a rectangular region of the screen

type Screenshot added in v0.96.0

type Screenshot struct {
	ID             string    `json:"id"`
	Timestamp      time.Time `json:"timestamp"`
	Data           string    `json:"data"`            // base64 encoded image
	Width          int       `json:"width"`           // Final image width (after scaling)
	Height         int       `json:"height"`          // Final image height (after scaling)
	Format         string    `json:"format"`          // "png" or "jpeg"
	Method         string    `json:"method"`          // "x11" or "wayland"
	OriginalWidth  int       `json:"original_width"`  // Screen width before scaling
	OriginalHeight int       `json:"original_height"` // Screen height before scaling
}

Screenshot represents a captured screenshot with metadata

type ScreenshotProvider added in v0.96.0

type ScreenshotProvider interface {
	GetLatestScreenshot() (*Screenshot, error)
}

ScreenshotProvider defines the interface for getting screenshots from a buffer

type ScreenshotToolResult added in v0.96.0

type ScreenshotToolResult struct {
	Display string        `json:"display"`
	Region  *ScreenRegion `json:"region,omitempty"`
	Width   int           `json:"width"`
	Height  int           `json:"height"`
	Format  string        `json:"format"`
	Method  string        `json:"method"`
}

ScreenshotToolResult represents the result of a screenshot capture

type ScrollDirection added in v0.45.0

type ScrollDirection int

ScrollDirection defines scroll direction

const (
	ScrollUp ScrollDirection = iota
	ScrollDown
	ScrollLeft
	ScrollRight
	ScrollToTop
	ScrollToBottom
)

type ScrollRequestEvent added in v0.45.0

type ScrollRequestEvent struct {
	ComponentID string
	Direction   ScrollDirection
	Amount      int
}

ScrollRequestEvent requests scrolling in a component

type SessionCostStats added in v0.86.0

type SessionCostStats struct {
	TotalCost       float64
	TotalInputCost  float64
	TotalOutputCost float64
	PerModelStats   map[string]*ModelCostStats // keyed by model name
	Currency        string
}

SessionCostStats aggregates cost information for an entire session. It provides both total costs and per-model breakdowns.

type SessionID added in v0.82.0

type SessionID string

SessionID represents a unique identifier for a chat session. Format: {unix-timestamp}-{8-char-random-hex} Example: 1733678400-a3f2bc8d

func GenerateSessionID added in v0.82.0

func GenerateSessionID() SessionID

GenerateSessionID creates a new unique session identifier. The ID combines a Unix timestamp (for temporal uniqueness) with random hex characters (for collision resistance).

func (SessionID) Age added in v0.82.0

func (s SessionID) Age() time.Duration

Age returns the duration since the session was created. Returns 0 if the session ID format is invalid.

func (SessionID) String added in v0.82.0

func (s SessionID) String() string

String returns the string representation of the SessionID.

func (SessionID) Timestamp added in v0.82.0

func (s SessionID) Timestamp() int64

Timestamp extracts the Unix timestamp from the session ID. Returns 0 if the session ID format is invalid.

type SessionTokenStats added in v0.28.0

type SessionTokenStats struct {
	TotalInputTokens  int `json:"total_input_tokens"`
	TotalOutputTokens int `json:"total_output_tokens"`
	TotalTokens       int `json:"total_tokens"`
	RequestCount      int `json:"request_count"`
	LastInputTokens   int `json:"last_input_tokens"`
}

SessionTokenStats tracks accumulated token usage across a session

type SetInputEvent added in v0.45.0

type SetInputEvent struct {
	Text string
}

SetInputEvent sets text in the input field

type SetStatusEvent added in v0.45.0

type SetStatusEvent struct {
	Message    string
	Spinner    bool
	StatusType StatusType
	Progress   *StatusProgress
	ToolName   string
}

SetStatusEvent sets a status message

type SetupFileSelectionEvent added in v0.45.0

type SetupFileSelectionEvent struct {
	Files []string
}

SetupFileSelectionEvent sets up file selection state with files

type ShellCancelledEvent added in v0.81.0

type ShellCancelledEvent struct {
	RequestID string
	Timestamp time.Time
	ShellID   string
}

ShellCancelledEvent indicates a background shell was killed

func (ShellCancelledEvent) GetRequestID added in v0.81.0

func (e ShellCancelledEvent) GetRequestID() string

func (ShellCancelledEvent) GetTimestamp added in v0.81.0

func (e ShellCancelledEvent) GetTimestamp() time.Time

type ShellCompletedEvent added in v0.81.0

type ShellCompletedEvent struct {
	RequestID string
	Timestamp time.Time
	ShellID   string
	ExitCode  int
	Duration  time.Duration
}

ShellCompletedEvent indicates a background shell finished successfully

func (ShellCompletedEvent) GetRequestID added in v0.81.0

func (e ShellCompletedEvent) GetRequestID() string

func (ShellCompletedEvent) GetTimestamp added in v0.81.0

func (e ShellCompletedEvent) GetTimestamp() time.Time

type ShellDetachedEvent added in v0.81.0

type ShellDetachedEvent struct {
	RequestID string
	Timestamp time.Time
	ShellID   string
	Command   string
}

ShellDetachedEvent indicates a Bash command has been moved to background

func (ShellDetachedEvent) GetRequestID added in v0.81.0

func (e ShellDetachedEvent) GetRequestID() string

func (ShellDetachedEvent) GetTimestamp added in v0.81.0

func (e ShellDetachedEvent) GetTimestamp() time.Time

type ShellFailedEvent added in v0.81.0

type ShellFailedEvent struct {
	RequestID string
	Timestamp time.Time
	ShellID   string
	Error     string
	ExitCode  int
}

ShellFailedEvent indicates a background shell failed

func (ShellFailedEvent) GetRequestID added in v0.81.0

func (e ShellFailedEvent) GetRequestID() string

func (ShellFailedEvent) GetTimestamp added in v0.81.0

func (e ShellFailedEvent) GetTimestamp() time.Time

type ShellInfo added in v0.81.0

type ShellInfo struct {
	ShellID     string
	Command     string
	State       ShellState
	StartedAt   time.Time
	CompletedAt *time.Time
	ExitCode    *int
	OutputSize  int64
	Elapsed     time.Duration
}

ShellInfo provides summary information about a shell for UI display.

func NewShellInfo added in v0.81.0

func NewShellInfo(shell *BackgroundShell) *ShellInfo

NewShellInfo creates a ShellInfo from a BackgroundShell.

type ShellOutputUpdateEvent added in v0.81.0

type ShellOutputUpdateEvent struct {
	RequestID  string
	Timestamp  time.Time
	ShellID    string
	NewOutput  string
	TotalBytes int64
}

ShellOutputUpdateEvent contains new output from a background shell

func (ShellOutputUpdateEvent) GetRequestID added in v0.81.0

func (e ShellOutputUpdateEvent) GetRequestID() string

func (ShellOutputUpdateEvent) GetTimestamp added in v0.81.0

func (e ShellOutputUpdateEvent) GetTimestamp() time.Time

type ShellState added in v0.81.0

type ShellState string

ShellState represents the state of a background shell.

const (
	ShellStateRunning   ShellState = "running"
	ShellStateCompleted ShellState = "completed"
	ShellStateFailed    ShellState = "failed"
	ShellStateCancelled ShellState = "cancelled"
)

func (ShellState) IsTerminal added in v0.81.0

func (s ShellState) IsTerminal() bool

IsTerminal returns true if the state is a terminal state (completed, failed, or cancelled).

func (ShellState) String added in v0.81.0

func (s ShellState) String() string

String returns the string representation of the shell state.

type ShellTracker added in v0.81.0

type ShellTracker interface {
	// Add adds a new shell to the tracker.
	// Returns an error if max concurrent limit is reached.
	Add(shell *BackgroundShell) error

	// Get retrieves a shell by ID.
	// Returns nil if not found.
	Get(shellID string) *BackgroundShell

	// GetAll returns all tracked shells.
	GetAll() []*BackgroundShell

	// Remove removes a shell from the tracker.
	Remove(shellID string) error

	// Cleanup removes shells in terminal states older than the specified duration.
	Cleanup(olderThan time.Duration) int

	// Count returns the number of tracked shells.
	Count() int

	// CountRunning returns the number of shells in running state.
	CountRunning() int
}

ShellTracker defines the interface for managing background shells.

type ShowErrorEvent added in v0.45.0

type ShowErrorEvent struct {
	Error  string
	Sticky bool // Whether error persists until dismissed
}

ShowErrorEvent displays an error message

type ShowPlanApprovalEvent added in v0.68.0

type ShowPlanApprovalEvent struct {
	PlanContent  string
	ResponseChan chan PlanApprovalAction
}

ShowPlanApprovalEvent displays the plan approval modal

type StateManager added in v0.53.0

type StateManager interface {
	// View state management
	GetCurrentView() ViewState
	GetPreviousView() ViewState
	TransitionToView(newView ViewState) error

	// Agent mode management
	GetAgentMode() AgentMode
	SetAgentMode(mode AgentMode)
	CycleAgentMode() AgentMode

	// Chat session management
	SetChatPending()
	StartChatSession(requestID, model string, eventChan <-chan ChatEvent) error
	UpdateChatStatus(status ChatStatus) error
	EndChatSession()
	GetChatSession() *ChatSession
	IsAgentBusy() bool

	// Event multicast for floating window
	SetEventBridge(bridge EventBridge)
	GetEventBridge() EventBridge
	BroadcastEvent(event ChatEvent)

	// Tool execution management
	StartToolExecution(toolCalls []sdk.ChatCompletionMessageToolCall) error
	CompleteCurrentTool(result *ToolExecutionResult) error
	FailCurrentTool(result *ToolExecutionResult) error
	EndToolExecution()
	GetToolExecution() *ToolExecutionSession

	// Dimensions management
	SetDimensions(width, height int)
	GetDimensions() (int, int)

	// File selection management
	SetupFileSelection(files []string)
	GetFileSelectionState() *FileSelectionState
	UpdateFileSearchQuery(query string)
	SetFileSelectedIndex(index int)
	ClearFileSelectionState()

	// Approval management
	SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan ApprovalAction)
	GetApprovalUIState() *ApprovalUIState
	SetApprovalSelectedIndex(index int)
	ClearApprovalUIState()

	// Plan approval management
	SetupPlanApprovalUIState(planContent string, responseChan chan PlanApprovalAction)
	GetPlanApprovalUIState() *PlanApprovalUIState
	SetPlanApprovalSelectedIndex(index int)
	ClearPlanApprovalUIState()

	// Todo management
	SetTodos(todos []TodoItem)
	GetTodos() []TodoItem

	// Agent readiness management
	InitializeAgentReadiness(totalAgents int)
	UpdateAgentStatus(name string, state AgentState, message string, url string, image string)
	SetAgentError(name string, err error)
	GetAgentReadiness() *AgentReadinessState
	AreAllAgentsReady() bool
	ClearAgentReadiness()
	RemoveAgent(name string)

	// Message edit state management
	SetMessageEditState(state *MessageEditState)
	GetMessageEditState() *MessageEditState
	ClearMessageEditState()
	IsEditingMessage() bool

	// Focus management (macOS computer-use tools)
	SetLastFocusedApp(appID string)
	GetLastFocusedApp() string
	ClearLastFocusedApp()
	SetLastClickCoordinates(x, y int)
	GetLastClickCoordinates() (x, y int)
	ClearLastClickCoordinates()

	// Computer Use Pause State
	SetComputerUsePaused(paused bool, requestID string)
	IsComputerUsePaused() bool
	GetPausedRequestID() string
	ClearComputerUsePauseState()
}

StateManager interface defines state management operations

type StateSnapshot added in v0.27.0

type StateSnapshot struct {
	CurrentView   string                 `json:"current_view"`
	PreviousView  string                 `json:"previous_view"`
	Width         int                    `json:"width"`
	Height        int                    `json:"height"`
	DebugMode     bool                   `json:"debug_mode"`
	Timestamp     time.Time              `json:"timestamp"`
	ChatSession   *ChatSessionSnapshot   `json:"chat_session,omitempty"`
	ToolExecution *ToolExecutionSnapshot `json:"tool_execution,omitempty"`
}

StateSnapshot represents a point-in-time snapshot of application state

type StatusProgress added in v0.45.0

type StatusProgress struct {
	Current int
	Total   int
}

StatusProgress represents progress information for status messages

type StatusType added in v0.45.0

type StatusType int

StatusType represents different types of status messages

const (
	StatusDefault StatusType = iota
	StatusThinking
	StatusGenerating
	StatusWorking
	StatusProcessing
	StatusPreparing
	StatusError
)

type StreamingContentEvent added in v0.48.0

type StreamingContentEvent struct {
	RequestID        string
	Content          string
	ReasoningContent string
	Delta            bool
	Model            string
}

StreamingContentEvent delivers live streaming content for immediate UI display

type TaskCancelledEvent added in v0.53.3

type TaskCancelledEvent struct {
	TaskID string
	Error  error
}

TaskCancelledEvent indicates a task has been cancelled

type TaskInfo added in v0.53.3

type TaskInfo struct {
	// ADK Task contains: ID, ContextID, Status (with State), History, Artifacts, Metadata
	Task adk.Task

	// UI-specific fields
	AgentURL    string
	StartedAt   time.Time
	CompletedAt time.Time
}

TaskInfo wraps ADK Task with UI-specific metadata for completed/terminal tasks Used for A2A task retention and display

type TaskPollingState added in v0.53.0

type TaskPollingState struct {
	TaskID          string
	ContextID       string
	AgentURL        string
	TaskDescription string
	IsPolling       bool
	StartedAt       time.Time
	LastPollAt      time.Time
	NextPollTime    time.Time
	CurrentInterval time.Duration
	LastKnownState  string
	CancelFunc      context.CancelFunc
	ResultChan      chan *ToolExecutionResult
	ErrorChan       chan error
	StatusChan      chan *A2ATaskStatusUpdate
}

TaskPollingState represents the state of background polling for a task

type TaskRetentionService added in v0.53.3

type TaskRetentionService interface {
	// AddTask adds a terminal task (completed, failed, canceled, etc.) to retention
	AddTask(task TaskInfo)

	// GetTasks returns all retained tasks
	GetTasks() []TaskInfo

	// Clear removes all retained tasks
	Clear()

	// SetMaxRetention updates the maximum retention count
	SetMaxRetention(maxRetention int)

	// GetMaxRetention returns the current maximum retention count
	GetMaxRetention() int
}

TaskRetentionService manages in-memory retention of completed/terminal A2A tasks Only enabled when A2A is enabled - decouples task retention from StateManager

type TaskTracker added in v0.49.0

type TaskTracker interface {
	// Context management (contexts are server-generated and tracked here)
	// Multiple contexts per agent enable multi-tenant/multi-session support
	RegisterContext(agentURL, contextID string)
	GetContextsForAgent(agentURL string) []string
	GetAgentForContext(contextID string) string
	GetLatestContextForAgent(agentURL string) string
	HasContext(contextID string) bool
	RemoveContext(contextID string)

	// Task management (tasks are server-generated and scoped to contexts per A2A spec)
	AddTask(contextID, taskID string)
	GetTasksForContext(contextID string) []string
	GetLatestTaskForContext(contextID string) string
	GetContextForTask(taskID string) string
	RemoveTask(taskID string)
	HasTask(taskID string) bool

	// Agent management
	GetAllAgents() []string
	GetAllContexts() []string
	ClearAllAgents()

	// Polling state management (one polling state per task)
	StartPolling(taskID string, state *TaskPollingState)
	StopPolling(taskID string)
	GetPollingState(taskID string) *TaskPollingState
	IsPolling(taskID string) bool
	GetPollingTasksForContext(contextID string) []string
	GetAllPollingTasks() []string
}

TaskTracker handles task ID and context ID tracking within chat sessions Following A2A spec: supports multi-tenant with multiple contexts per agent

type TasksLoadedEvent added in v0.53.3

type TasksLoadedEvent struct {
	ActiveTasks    []any
	CompletedTasks []any
	Error          error
}

TasksLoadedEvent indicates tasks have been loaded

type Theme added in v0.47.0

type Theme interface {
	GetUserColor() string
	GetAssistantColor() string
	GetErrorColor() string
	GetSuccessColor() string
	GetStatusColor() string
	GetAccentColor() string
	GetDimColor() string
	GetBorderColor() string
	GetDiffAddColor() string
	GetDiffRemoveColor() string
}

Theme interface for theming support

type ThemeProvider added in v0.47.0

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

ThemeProvider implements ThemeService and manages available themes

func NewThemeProvider added in v0.47.0

func NewThemeProvider() *ThemeProvider

NewThemeProvider creates a new theme provider with default themes

func (*ThemeProvider) GetCurrentTheme added in v0.47.0

func (tp *ThemeProvider) GetCurrentTheme() Theme

GetCurrentTheme returns the currently active theme (implements ThemeService interface)

func (*ThemeProvider) GetCurrentThemeName added in v0.47.0

func (tp *ThemeProvider) GetCurrentThemeName() string

GetCurrentThemeName returns the name of the currently active theme (implements ThemeService interface)

func (*ThemeProvider) GetTheme added in v0.47.0

func (tp *ThemeProvider) GetTheme(name string) (Theme, error)

GetTheme returns the theme by name, or the current theme if name is empty

func (*ThemeProvider) ListThemes added in v0.47.0

func (tp *ThemeProvider) ListThemes() []string

ListThemes returns all available theme names (implements ThemeService interface)

func (*ThemeProvider) SetCurrentTheme added in v0.47.0

func (tp *ThemeProvider) SetCurrentTheme(name string) error

SetCurrentTheme is an alias for SetTheme for backward compatibility

func (*ThemeProvider) SetTheme added in v0.47.0

func (tp *ThemeProvider) SetTheme(name string) error

SetTheme sets the current theme by name (implements ThemeService interface)

type ThemeSelectedEvent added in v0.47.0

type ThemeSelectedEvent struct {
	Theme string
}

ThemeSelectedEvent indicates theme selection

type ThemeService added in v0.47.0

type ThemeService interface {
	ListThemes() []string
	GetCurrentTheme() Theme
	GetCurrentThemeName() string
	SetTheme(themeName string) error
}

ThemeService handles theme management

type TodoItem added in v0.20.0

type TodoItem struct {
	ID      string `json:"id"`
	Content string `json:"content"`
	Status  string `json:"status"`
}

TodoItem represents a single todo item

type TodoUpdateChatEvent added in v0.63.1

type TodoUpdateChatEvent struct {
	BaseChatEvent
	Todos []TodoItem
}

TodoUpdateChatEvent indicates the todo list has been updated (flows through chat event channel)

type TodoUpdateEvent added in v0.63.1

type TodoUpdateEvent struct {
	Todos []TodoItem
}

TodoUpdateEvent indicates the todo list has been updated

type TodoWriteToolResult added in v0.20.0

type TodoWriteToolResult struct {
	Todos          []TodoItem `json:"todos"`
	TotalTasks     int        `json:"total_tasks"`
	CompletedTasks int        `json:"completed_tasks"`
	InProgressTask string     `json:"in_progress_task,omitempty"`
	ValidationOK   bool       `json:"validation_ok"`
}

TodoWriteToolResult represents the result of a TodoWrite operation

type ToggleHelpBarEvent added in v0.45.0

type ToggleHelpBarEvent struct{}

ToggleHelpBarEvent toggles the help bar visibility

type ToggleTodoBoxEvent added in v0.63.1

type ToggleTodoBoxEvent struct{}

ToggleTodoBoxEvent toggles the todo box expanded/collapsed state

type TokenEstimator added in v0.81.0

type TokenEstimator interface {
	// GetToolStats returns token count and tool count for a given agent mode
	GetToolStats(toolService ToolService, agentMode AgentMode) (tokens int, count int)

	// EstimateMessagesTokens estimates the total tokens for a slice of messages
	EstimateMessagesTokens(messages []sdk.Message) int
}

TokenEstimator provides token count estimation for LLM content

type TokyoNightTheme added in v0.47.0

type TokyoNightTheme struct{}

TokyoNightTheme is the default theme (same as DefaultTheme)

func NewTokyoNightTheme added in v0.47.0

func NewTokyoNightTheme() *TokyoNightTheme

func (*TokyoNightTheme) GetAccentColor added in v0.47.0

func (t *TokyoNightTheme) GetAccentColor() string

func (*TokyoNightTheme) GetAssistantColor added in v0.47.0

func (t *TokyoNightTheme) GetAssistantColor() string

func (*TokyoNightTheme) GetBorderColor added in v0.47.0

func (t *TokyoNightTheme) GetBorderColor() string

func (*TokyoNightTheme) GetDiffAddColor added in v0.47.0

func (t *TokyoNightTheme) GetDiffAddColor() string

func (*TokyoNightTheme) GetDiffRemoveColor added in v0.47.0

func (t *TokyoNightTheme) GetDiffRemoveColor() string

func (*TokyoNightTheme) GetDimColor added in v0.47.0

func (t *TokyoNightTheme) GetDimColor() string

func (*TokyoNightTheme) GetErrorColor added in v0.47.0

func (t *TokyoNightTheme) GetErrorColor() string

func (*TokyoNightTheme) GetStatusColor added in v0.47.0

func (t *TokyoNightTheme) GetStatusColor() string

func (*TokyoNightTheme) GetSuccessColor added in v0.56.0

func (t *TokyoNightTheme) GetSuccessColor() string

func (*TokyoNightTheme) GetUserColor added in v0.47.0

func (t *TokyoNightTheme) GetUserColor() string

type Tool added in v0.14.1

type Tool interface {
	// Definition returns the tool definition for the LLM
	Definition() sdk.ChatCompletionTool

	// Execute runs the tool with given arguments
	Execute(ctx context.Context, args map[string]any) (*ToolExecutionResult, error)

	// Validate checks if the tool arguments are valid
	Validate(args map[string]any) error

	// IsEnabled returns whether this tool is enabled
	IsEnabled() bool

	// FormatResult formats tool execution results for different contexts
	FormatResult(result *ToolExecutionResult, formatType FormatterType) string

	// FormatPreview returns a short preview of the result for UI display
	FormatPreview(result *ToolExecutionResult) string

	// ShouldCollapseArg determines if an argument should be collapsed in display
	ShouldCollapseArg(key string) bool

	// ShouldAlwaysExpand determines if tool results should always be expanded in UI
	ShouldAlwaysExpand() bool
}

Tool represents a single tool with its definition, handler, and validator

type ToolApprovalClearedEvent added in v0.96.0

type ToolApprovalClearedEvent struct {
	RequestID string
	Timestamp time.Time
}

ToolApprovalClearedEvent is used for standard tool approval workflow. Computer-use tools use a separate pause/resume mechanism.

func (ToolApprovalClearedEvent) GetRequestID added in v0.96.0

func (e ToolApprovalClearedEvent) GetRequestID() string

func (ToolApprovalClearedEvent) GetTimestamp added in v0.96.0

func (e ToolApprovalClearedEvent) GetTimestamp() time.Time

type ToolApprovalNotificationEvent added in v0.96.0

type ToolApprovalNotificationEvent struct {
	RequestID string
	Timestamp time.Time
	ToolName  string
	Message   string
}

ToolApprovalNotificationEvent is sent to notify the Computer Use dialog when tool approval is required in TUI

func (ToolApprovalNotificationEvent) GetRequestID added in v0.96.0

func (e ToolApprovalNotificationEvent) GetRequestID() string

func (ToolApprovalNotificationEvent) GetTimestamp added in v0.96.0

func (e ToolApprovalNotificationEvent) GetTimestamp() time.Time

type ToolApprovalRequestedEvent added in v0.56.0

type ToolApprovalRequestedEvent struct {
	RequestID    string
	Timestamp    time.Time
	ToolCall     sdk.ChatCompletionMessageToolCall
	ResponseChan chan ApprovalAction `json:"-"`
}

ToolApprovalRequestedEvent is used for standard tool approval workflow. Computer-use tools use a separate pause/resume mechanism (ComputerUsePauseRequestedEvent).

func (ToolApprovalRequestedEvent) GetRequestID added in v0.56.0

func (e ToolApprovalRequestedEvent) GetRequestID() string

func (ToolApprovalRequestedEvent) GetTimestamp added in v0.56.0

func (e ToolApprovalRequestedEvent) GetTimestamp() time.Time

type ToolApprovalResponseEvent added in v0.45.0

type ToolApprovalResponseEvent struct {
	Action   ApprovalAction
	ToolCall sdk.ChatCompletionMessageToolCall
}

ToolApprovalResponseEvent captures the user's approval decision

type ToolApprovalStatus added in v0.68.0

type ToolApprovalStatus int

ToolApprovalStatus represents the approval status of a tool

const (
	ToolApprovalPending ToolApprovalStatus = iota
	ToolApprovalApproved
	ToolApprovalRejected
)

type ToolApprovedEvent added in v0.56.0

type ToolApprovedEvent struct {
	RequestID string
	Timestamp time.Time
	ToolCall  sdk.ChatCompletionMessageToolCall
}

ToolApprovedEvent is used for standard tool approval workflow. Computer-use tools use a separate pause/resume mechanism.

func (ToolApprovedEvent) GetRequestID added in v0.56.0

func (e ToolApprovedEvent) GetRequestID() string

func (ToolApprovedEvent) GetTimestamp added in v0.56.0

func (e ToolApprovedEvent) GetTimestamp() time.Time

type ToolCall added in v0.27.0

type ToolCall struct {
	ID        string               `json:"id"`
	Name      string               `json:"name"`
	Arguments map[string]any       `json:"arguments"`
	Status    ToolCallStatus       `json:"status"`
	Result    *ToolExecutionResult `json:"result,omitempty"`
	StartTime time.Time            `json:"start_time"`
	EndTime   *time.Time           `json:"end_time,omitempty"`
}

ToolCall represents a tool call with proper typing

type ToolCallPreviewEvent added in v0.48.0

type ToolCallPreviewEvent struct {
	RequestID  string
	Timestamp  time.Time
	ToolCallID string
	ToolName   string
	Arguments  string
	Status     ToolCallStreamStatus
	IsComplete bool
}

ToolCallPreviewEvent shows a tool call as it's being streamed (before execution)

func (ToolCallPreviewEvent) GetRequestID added in v0.48.0

func (e ToolCallPreviewEvent) GetRequestID() string

func (ToolCallPreviewEvent) GetTimestamp added in v0.48.0

func (e ToolCallPreviewEvent) GetTimestamp() time.Time

type ToolCallReadyEvent added in v0.48.0

type ToolCallReadyEvent struct {
	RequestID string
	Timestamp time.Time
	ToolCalls []sdk.ChatCompletionMessageToolCall
}

ToolCallReadyEvent indicates all tool calls are ready for approval/execution

func (ToolCallReadyEvent) GetRequestID added in v0.48.0

func (e ToolCallReadyEvent) GetRequestID() string

func (ToolCallReadyEvent) GetTimestamp added in v0.48.0

func (e ToolCallReadyEvent) GetTimestamp() time.Time

type ToolCallSnapshot added in v0.27.0

type ToolCallSnapshot struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Status    string    `json:"status"`
	StartTime time.Time `json:"start_time"`
}

ToolCallSnapshot represents a snapshot of tool call state

type ToolCallStatus added in v0.27.0

type ToolCallStatus int

ToolCallStatus represents the status of an individual tool call

const (
	ToolCallStatusPending ToolCallStatus = iota
	ToolCallStatusWaitingApproval
	ToolCallStatusExecuting
	ToolCallStatusCompleted
	ToolCallStatusFailed
	ToolCallStatusCancelled
	ToolCallStatusDenied
)

func (ToolCallStatus) String added in v0.27.0

func (t ToolCallStatus) String() string

type ToolCallStreamStatus added in v0.48.0

type ToolCallStreamStatus string

ToolCallStreamStatus represents the status of a tool call during streaming

const (
	ToolCallStreamStatusStreaming ToolCallStreamStatus = "streaming"
	ToolCallStreamStatusComplete  ToolCallStreamStatus = "completed"
	ToolCallStreamStatusReady     ToolCallStreamStatus = "ready"
)

type ToolCallUpdateEvent added in v0.48.0

type ToolCallUpdateEvent struct {
	RequestID  string
	Timestamp  time.Time
	ToolCallID string
	ToolName   string
	Arguments  string
	Status     ToolCallStreamStatus
}

ToolCallUpdateEvent updates a streaming tool call with new content

func (ToolCallUpdateEvent) GetRequestID added in v0.48.0

func (e ToolCallUpdateEvent) GetRequestID() string

func (ToolCallUpdateEvent) GetTimestamp added in v0.48.0

func (e ToolCallUpdateEvent) GetTimestamp() time.Time

type ToolExecutionCompletedEvent added in v0.45.0

type ToolExecutionCompletedEvent struct {
	SessionID     string
	RequestID     string
	Timestamp     time.Time
	TotalExecuted int
	SuccessCount  int
	FailureCount  int
	Results       []*ToolExecutionResult
}

ToolExecutionCompletedEvent indicates tool execution is complete

func (ToolExecutionCompletedEvent) GetRequestID added in v0.99.1

func (e ToolExecutionCompletedEvent) GetRequestID() string

func (ToolExecutionCompletedEvent) GetTimestamp added in v0.99.1

func (e ToolExecutionCompletedEvent) GetTimestamp() time.Time

type ToolExecutionProgressEvent added in v0.45.0

type ToolExecutionProgressEvent struct {
	BaseChatEvent
	ToolCallID string
	ToolName   string
	Arguments  string
	Status     string
	Message    string
	Images     []ImageAttachment
}

ToolExecutionProgressEvent indicates progress in tool execution

type ToolExecutionResult added in v0.13.1

type ToolExecutionResult struct {
	ToolName  string            `json:"tool_name"`
	Arguments map[string]any    `json:"arguments"`
	Success   bool              `json:"success"`
	Duration  time.Duration     `json:"duration"`
	Error     string            `json:"error,omitempty"`
	Data      any               `json:"data,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Diff      string            `json:"diff,omitempty"`
	Rejected  bool              `json:"rejected,omitempty"`
	Images    []ImageAttachment `json:"images,omitempty"`
}

ToolExecutionResult represents the complete result of a tool execution

type ToolExecutionSession added in v0.27.0

type ToolExecutionSession struct {
	CurrentTool    *ToolCall
	RemainingTools []ToolCall
	TotalTools     int
	CompletedTools int
	Status         ToolExecutionStatus
	StartTime      time.Time
}

ToolExecutionSession represents an active tool execution session

type ToolExecutionSnapshot added in v0.27.0

type ToolExecutionSnapshot struct {
	Status         string            `json:"status"`
	TotalTools     int               `json:"total_tools"`
	CompletedTools int               `json:"completed_tools"`
	StartTime      time.Time         `json:"start_time"`
	CurrentTool    *ToolCallSnapshot `json:"current_tool,omitempty"`
}

ToolExecutionSnapshot represents a snapshot of tool execution state

type ToolExecutionStartedEvent added in v0.45.0

type ToolExecutionStartedEvent struct {
	SessionID  string
	TotalTools int
}

ToolExecutionStartedEvent indicates tool execution has started

type ToolExecutionStatus added in v0.27.0

type ToolExecutionStatus int

ToolExecutionStatus represents the overall tool execution session status

const (
	ToolExecutionStatusIdle ToolExecutionStatus = iota
	ToolExecutionStatusProcessing
	ToolExecutionStatusExecuting
	ToolExecutionStatusCompleted
	ToolExecutionStatusFailed
)

func (ToolExecutionStatus) String added in v0.27.0

func (t ToolExecutionStatus) String() string

type ToolFactory added in v0.14.1

type ToolFactory interface {
	// CreateTool creates a tool instance by name
	CreateTool(name string) (Tool, error)

	// ListAvailableTools returns names of all available tools
	ListAvailableTools() []string
}

ToolFactory creates tool instances

type ToolFormatter added in v0.33.4

type ToolFormatter interface {
	// FormatToolCall formats a tool call for consistent display
	FormatToolCall(toolName string, args map[string]any) string

	// FormatToolResultForUI formats tool execution results for UI display
	FormatToolResultForUI(result *ToolExecutionResult, terminalWidth int) string

	// FormatToolResultExpanded formats expanded tool execution results
	FormatToolResultExpanded(result *ToolExecutionResult, terminalWidth int) string

	// FormatToolResultForLLM formats tool execution results for LLM consumption
	FormatToolResultForLLM(result *ToolExecutionResult) string

	// ShouldAlwaysExpandTool checks if a tool result should always be expanded
	ShouldAlwaysExpandTool(toolName string) bool
}

ToolFormatter provides formatting capabilities for tool results

type ToolRejectedEvent added in v0.56.0

type ToolRejectedEvent struct {
	RequestID string
	Timestamp time.Time
	ToolCall  sdk.ChatCompletionMessageToolCall
}

ToolRejectedEvent is used for standard tool approval workflow. Computer-use tools use a separate pause/resume mechanism.

func (ToolRejectedEvent) GetRequestID added in v0.56.0

func (e ToolRejectedEvent) GetRequestID() string

func (ToolRejectedEvent) GetTimestamp added in v0.56.0

func (e ToolRejectedEvent) GetTimestamp() time.Time

type ToolService

type ToolService interface {
	ListTools() []sdk.ChatCompletionTool
	ListToolsForMode(mode AgentMode) []sdk.ChatCompletionTool
	ListAvailableTools() []string
	ExecuteTool(ctx context.Context, tool sdk.ChatCompletionMessageToolCallFunction) (*ToolExecutionResult, error)
	ExecuteToolDirect(ctx context.Context, tool sdk.ChatCompletionMessageToolCallFunction) (*ToolExecutionResult, error)
	IsToolEnabled(name string) bool
	ValidateTool(name string, args map[string]any) error
	GetTaskTracker() TaskTracker
	GetTool(name string) (Tool, error)
}

ToolService handles tool execution

type TreeToolResult added in v0.16.0

type TreeToolResult struct {
	Path            string `json:"path"`
	Output          string `json:"output"`
	TotalFiles      int    `json:"total_files"`
	TotalDirs       int    `json:"total_dirs"`
	MaxDepth        int    `json:"max_depth"`
	MaxFiles        int    `json:"max_files"`
	ShowHidden      bool   `json:"show_hidden"`
	Format          string `json:"format"`
	UsingNativeTree bool   `json:"using_native_tree"`
	Truncated       bool   `json:"truncated"`
}

TreeToolResult represents the result of a tree operation

type TriggerGithubActionSetupEvent added in v0.87.0

type TriggerGithubActionSetupEvent struct{}

TriggerGithubActionSetupEvent triggers the GitHub App setup flow

type UpdateHistoryEvent added in v0.45.0

type UpdateHistoryEvent struct {
	History []ConversationEntry
}

UpdateHistoryEvent updates the conversation history display

type UpdateStatusEvent added in v0.45.0

type UpdateStatusEvent struct {
	Message    string
	StatusType StatusType
	ToolName   string
}

UpdateStatusEvent updates an existing status message without resetting timer

type UserInputEvent added in v0.45.0

type UserInputEvent struct {
	Content string
	Images  []ImageAttachment
}

UserInputEvent represents user input submission

type VersionInfo added in v0.85.0

type VersionInfo struct {
	Version string
	Commit  string
	Date    string
}

VersionInfo contains build-time version information

type ViewState added in v0.27.0

type ViewState int

ViewState represents the current view with proper state management

const (
	ViewStateModelSelection ViewState = iota
	ViewStateChat
	ViewStateFileSelection
	ViewStateConversationSelection
	ViewStateThemeSelection
	ViewStateA2ATaskManagement
	ViewStatePlanApproval
	ViewStateGithubActionSetup
)

func (ViewState) String added in v0.27.0

func (v ViewState) String() string

type WebFetchService added in v0.29.2

type WebFetchService interface {
	ValidateURL(url string) error
	FetchContent(ctx context.Context, target string) (*FetchResult, error)
	ClearCache()
	GetCacheStats() map[string]any
}

WebFetchService handles content fetching operations

type WebSearchResponse added in v0.13.0

type WebSearchResponse struct {
	Query   string            `json:"query"`
	Engine  string            `json:"engine"`
	Results []WebSearchResult `json:"results"`
	Total   int               `json:"total"`
	Time    time.Duration     `json:"time"`
	Error   string            `json:"error,omitempty"`
}

WebSearchResponse represents the complete search response

type WebSearchResult added in v0.13.0

type WebSearchResult struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet"`
}

WebSearchResult represents a single search result

type WebSearchService added in v0.13.0

type WebSearchService interface {
	SearchGoogle(ctx context.Context, query string, maxResults int) (*WebSearchResponse, error)
	SearchDuckDuckGo(ctx context.Context, query string, maxResults int) (*WebSearchResponse, error)
	IsEnabled() bool
	SetEnabled(enabled bool)
}

WebSearchService handles web search operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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