domain

package
v0.48.13 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 10 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.1

func CreateTitleFromMessage(content string) string

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

func IsFallbackTitle added in v0.46.1

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.1

func IsSimpleUserMessage(title string) bool

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

Types

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

func (A2AToolCallExecutedEvent) GetType added in v0.48.0

type AgentRequest added in v0.36.0

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

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 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) ClearFileSelectionState added in v0.27.0

func (s *ApplicationState) ClearFileSelectionState()

ClearFileSelectionState clears the file selection state

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) 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) 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) GetStateSnapshot added in v0.27.0

func (s *ApplicationState) GetStateSnapshot() StateSnapshot

GetStateSnapshot returns a complete snapshot of the current state

func (*ApplicationState) GetToolExecution added in v0.27.0

func (s *ApplicationState) GetToolExecution() *ToolExecutionSession

GetToolExecution returns the current tool execution session

func (*ApplicationState) IsDebugMode added in v0.27.0

func (s *ApplicationState) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

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) SetupFileSelection added in v0.27.0

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

SetupFileSelection initializes file selection 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) 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 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

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 BashToolResult added in v0.14.0

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 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

func (CancelledEvent) GetType

func (e CancelledEvent) GetType() ChatEventType

type ChatChunkEvent

type ChatChunkEvent struct {
	RequestID        string
	Timestamp        time.Time
	Content          string
	ReasoningContent string
	ToolCalls        []sdk.ChatCompletionMessageToolCallChunk
	Delta            bool
	Usage            *sdk.CompletionUsage // Live token usage during streaming
}

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

func (ChatChunkEvent) GetType

func (e ChatChunkEvent) GetType() ChatEventType

type ChatCompleteEvent

type ChatCompleteEvent struct {
	RequestID string
	Timestamp time.Time
	Message   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

func (ChatCompleteEvent) GetType

func (e ChatCompleteEvent) GetType() ChatEventType

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

func (ChatErrorEvent) GetType

func (e ChatErrorEvent) GetType() ChatEventType

type ChatEvent

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

ChatEvent represents events during chat operations

type ChatEventType

type ChatEventType int

ChatEventType defines types of chat events

const (
	EventChatStart ChatEventType = iota
	EventChatChunk
	EventChatComplete
	EventChatError
	EventToolCallStart
	EventToolCallPreview
	EventToolCallUpdate
	EventToolCallReady
	EventToolCallComplete
	EventToolCallError
	EventCancelled
	EventOptimizationStatus
	EventA2AToolCallExecuted
)

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
	PendingMessages []sdk.Message
	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

func (ChatStartEvent) GetType

func (e ChatStartEvent) GetType() ChatEventType

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

func (ClearErrorEvent) GetType added in v0.45.0

func (e ClearErrorEvent) GetType() UIEventType

type ClearInputEvent added in v0.45.0

type ClearInputEvent struct{}

ClearInputEvent clears the input field

func (ClearInputEvent) GetType added in v0.45.0

func (e ClearInputEvent) GetType() UIEventType

type ConfigService added in v0.27.0

type ConfigService interface {
	// Tool approval configuration
	IsApprovalRequired(toolName 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

	// Gateway middleware configuration
	ShouldSkipA2AToolOnClient() bool
	ShouldSkipMCPToolOnClient() bool
}

ConfigService provides configuration-related functionality

type ConversationEntry

type ConversationEntry struct {
	Message       Message              `json:"message"`
	Model         string               `json:"model,omitempty"`
	Time          time.Time            `json:"time"`
	ToolExecution *ToolExecutionResult `json:"tool_execution,omitempty"`
	Hidden        bool                 `json:"hidden,omitempty"`
}

ConversationEntry represents a message in the conversation with metadata

type ConversationRepository

type ConversationRepository interface {
	AddMessage(msg ConversationEntry) error
	GetMessages() []ConversationEntry
	Clear() error
	Export(format ExportFormat) ([]byte, error)
	GetMessageCount() int
	UpdateLastMessage(content string) error
	UpdateLastMessageToolCalls(toolCalls *[]sdk.ChatCompletionMessageToolCall) error
	AddTokenUsage(inputTokens, outputTokens, totalTokens int) error
	GetSessionTokens() SessionTokenStats
	FormatToolResultForLLM(result *ToolExecutionResult) string
	FormatToolResultForUI(result *ToolExecutionResult, terminalWidth int) string
	FormatToolResultExpanded(result *ToolExecutionResult, terminalWidth int) string
}

ConversationRepository handles conversation storage and retrieval

type ConversationSelectedEvent added in v0.45.0

type ConversationSelectedEvent struct {
	ConversationID string
}

ConversationSelectedEvent indicates conversation selection

func (ConversationSelectedEvent) GetType added in v0.45.0

type ConversationsLoadedEvent added in v0.45.0

type ConversationsLoadedEvent struct {
	Conversations []interface{}
	Error         error
}

ConversationsLoadedEvent indicates conversations have been loaded

func (ConversationsLoadedEvent) GetType added in v0.45.0

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

func (DebugKeyEvent) GetType added in v0.45.0

func (e DebugKeyEvent) GetType() UIEventType

type DeleteToolResult added in v0.18.2

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.48.0

type DraculaTheme struct{}

DraculaTheme provides the popular Dracula color scheme

func NewDraculaTheme added in v0.48.0

func NewDraculaTheme() *DraculaTheme

func (*DraculaTheme) GetAccentColor added in v0.48.0

func (t *DraculaTheme) GetAccentColor() string

func (*DraculaTheme) GetAssistantColor added in v0.48.0

func (t *DraculaTheme) GetAssistantColor() string

func (*DraculaTheme) GetBorderColor added in v0.48.0

func (t *DraculaTheme) GetBorderColor() string

func (*DraculaTheme) GetDiffAddColor added in v0.48.0

func (t *DraculaTheme) GetDiffAddColor() string

func (*DraculaTheme) GetDiffRemoveColor added in v0.48.0

func (t *DraculaTheme) GetDiffRemoveColor() string

func (*DraculaTheme) GetDimColor added in v0.48.0

func (t *DraculaTheme) GetDimColor() string

func (*DraculaTheme) GetErrorColor added in v0.48.0

func (t *DraculaTheme) GetErrorColor() string

func (*DraculaTheme) GetStatusColor added in v0.48.0

func (t *DraculaTheme) GetStatusColor() string

func (*DraculaTheme) GetUserColor added in v0.48.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"`
	Diff            string `json:"diff,omitempty"`
}

EditToolResult represents the result of an edit operation

type ExitSelectionModeEvent added in v0.45.0

type ExitSelectionModeEvent struct{}

ExitSelectionModeEvent exits text selection mode

func (ExitSelectionModeEvent) GetType added in v0.45.0

func (e ExitSelectionModeEvent) GetType() UIEventType

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.1

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"`
	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.14.0

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

func (FileSelectedEvent) GetType added in v0.45.0

func (e FileSelectedEvent) GetType() UIEventType

type FileSelectionRequestEvent added in v0.45.0

type FileSelectionRequestEvent struct{}

FileSelectionRequestEvent requests file selection UI

func (FileSelectionRequestEvent) GetType added in v0.45.0

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

func (FocusRequestEvent) GetType added in v0.45.0

func (e FocusRequestEvent) GetType() UIEventType

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 GitHubBranch added in v0.32.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.32.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.32.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.32.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.32.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.32.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.32.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.32.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.32.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.48.0

type GithubLightTheme struct{}

GithubLightTheme provides a light theme similar to GitHub's interface

func NewGithubLightTheme added in v0.48.0

func NewGithubLightTheme() *GithubLightTheme

func (*GithubLightTheme) GetAccentColor added in v0.48.0

func (t *GithubLightTheme) GetAccentColor() string

func (*GithubLightTheme) GetAssistantColor added in v0.48.0

func (t *GithubLightTheme) GetAssistantColor() string

func (*GithubLightTheme) GetBorderColor added in v0.48.0

func (t *GithubLightTheme) GetBorderColor() string

func (*GithubLightTheme) GetDiffAddColor added in v0.48.0

func (t *GithubLightTheme) GetDiffAddColor() string

func (*GithubLightTheme) GetDiffRemoveColor added in v0.48.0

func (t *GithubLightTheme) GetDiffRemoveColor() string

func (*GithubLightTheme) GetDimColor added in v0.48.0

func (t *GithubLightTheme) GetDimColor() string

func (*GithubLightTheme) GetErrorColor added in v0.48.0

func (t *GithubLightTheme) GetErrorColor() string

func (*GithubLightTheme) GetStatusColor added in v0.48.0

func (t *GithubLightTheme) GetStatusColor() string

func (*GithubLightTheme) GetUserColor added in v0.48.0

func (t *GithubLightTheme) GetUserColor() string

type HideHelpBarEvent added in v0.45.0

type HideHelpBarEvent struct{}

HideHelpBarEvent hides the help bar when typing other characters

func (HideHelpBarEvent) GetType added in v0.45.0

func (e HideHelpBarEvent) GetType() UIEventType

type InitializeConversationSelectionEvent added in v0.45.0

type InitializeConversationSelectionEvent struct{}

InitializeConversationSelectionEvent indicates conversation selection view should be initialized

func (InitializeConversationSelectionEvent) GetType added in v0.45.0

type InitializeTextSelectionEvent added in v0.45.0

type InitializeTextSelectionEvent struct{}

InitializeTextSelectionEvent initializes text selection mode with current conversation

func (InitializeTextSelectionEvent) GetType added in v0.45.0

type Message added in v0.45.4

type Message = sdk.Message

Assistant message

type ModelSelectedEvent added in v0.45.0

type ModelSelectedEvent struct {
	Model string
}

ModelSelectedEvent indicates model selection

func (ModelSelectedEvent) GetType added in v0.45.0

func (e ModelSelectedEvent) GetType() UIEventType

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
}

ModelService handles model selection and information

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 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

func (OptimizationStatusEvent) GetType added in v0.48.0

type ResizeEvent added in v0.45.0

type ResizeEvent struct {
	Width  int
	Height int
}

ResizeEvent handles terminal resize

func (ResizeEvent) GetType added in v0.45.0

func (e ResizeEvent) GetType() UIEventType

type SDKClient added in v0.46.1

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 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

func (ScrollRequestEvent) GetType added in v0.45.0

func (e ScrollRequestEvent) GetType() UIEventType

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"`
}

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

func (SetInputEvent) GetType added in v0.45.0

func (e SetInputEvent) GetType() UIEventType

type SetStatusEvent added in v0.45.0

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

SetStatusEvent sets a status message

func (SetStatusEvent) GetType added in v0.45.0

func (e SetStatusEvent) GetType() UIEventType

type SetupFileSelectionEvent added in v0.45.0

type SetupFileSelectionEvent struct {
	Files []string
}

SetupFileSelectionEvent sets up file selection state with files

func (SetupFileSelectionEvent) GetType added in v0.45.0

type ShowErrorEvent added in v0.45.0

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

ShowErrorEvent displays an error message

func (ShowErrorEvent) GetType added in v0.45.0

func (e ShowErrorEvent) GetType() UIEventType

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
	Delta     bool
}

StreamingContentEvent delivers live streaming content for immediate UI display

func (StreamingContentEvent) GetType added in v0.48.0

func (e StreamingContentEvent) GetType() UIEventType

type Theme added in v0.48.0

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

Theme interface for theming support

type ThemeProvider added in v0.48.0

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

ThemeProvider implements ThemeService and manages available themes

func NewThemeProvider added in v0.48.0

func NewThemeProvider() *ThemeProvider

NewThemeProvider creates a new theme provider with default themes

func (*ThemeProvider) GetCurrentTheme added in v0.48.0

func (tp *ThemeProvider) GetCurrentTheme() Theme

GetCurrentTheme returns the currently active theme (implements ThemeService interface)

func (*ThemeProvider) GetCurrentThemeName added in v0.48.0

func (tp *ThemeProvider) GetCurrentThemeName() string

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

func (*ThemeProvider) GetTheme added in v0.48.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.48.0

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

ListThemes returns all available theme names (implements ThemeService interface)

func (*ThemeProvider) SetCurrentTheme added in v0.48.0

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

SetCurrentTheme is an alias for SetTheme for backward compatibility

func (*ThemeProvider) SetTheme added in v0.48.0

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

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

type ThemeSelectedEvent added in v0.48.0

type ThemeSelectedEvent struct {
	Theme string
}

ThemeSelectedEvent indicates theme selection

func (ThemeSelectedEvent) GetType added in v0.48.0

func (e ThemeSelectedEvent) GetType() UIEventType

type ThemeService added in v0.48.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 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

func (ToggleHelpBarEvent) GetType added in v0.45.0

func (e ToggleHelpBarEvent) GetType() UIEventType

type TokyoNightTheme added in v0.48.0

type TokyoNightTheme struct{}

TokyoNightTheme is the default theme (same as DefaultTheme)

func NewTokyoNightTheme added in v0.48.0

func NewTokyoNightTheme() *TokyoNightTheme

func (*TokyoNightTheme) GetAccentColor added in v0.48.0

func (t *TokyoNightTheme) GetAccentColor() string

func (*TokyoNightTheme) GetAssistantColor added in v0.48.0

func (t *TokyoNightTheme) GetAssistantColor() string

func (*TokyoNightTheme) GetBorderColor added in v0.48.0

func (t *TokyoNightTheme) GetBorderColor() string

func (*TokyoNightTheme) GetDiffAddColor added in v0.48.0

func (t *TokyoNightTheme) GetDiffAddColor() string

func (*TokyoNightTheme) GetDiffRemoveColor added in v0.48.0

func (t *TokyoNightTheme) GetDiffRemoveColor() string

func (*TokyoNightTheme) GetDimColor added in v0.48.0

func (t *TokyoNightTheme) GetDimColor() string

func (*TokyoNightTheme) GetErrorColor added in v0.48.0

func (t *TokyoNightTheme) GetErrorColor() string

func (*TokyoNightTheme) GetStatusColor added in v0.48.0

func (t *TokyoNightTheme) GetStatusColor() string

func (*TokyoNightTheme) GetUserColor added in v0.48.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 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 ToolCallCompleteEvent added in v0.48.0

type ToolCallCompleteEvent struct {
	RequestID  string
	Timestamp  time.Time
	ToolCallID string
	ToolName   string
	Result     any
	Success    bool
}

ToolCallCompleteEvent indicates a single tool call has completed execution

func (ToolCallCompleteEvent) GetRequestID added in v0.48.0

func (e ToolCallCompleteEvent) GetRequestID() string

func (ToolCallCompleteEvent) GetTimestamp added in v0.48.0

func (e ToolCallCompleteEvent) GetTimestamp() time.Time

func (ToolCallCompleteEvent) GetType added in v0.48.0

type ToolCallErrorEvent added in v0.48.0

type ToolCallErrorEvent struct {
	RequestID  string
	Timestamp  time.Time
	ToolCallID string
	ToolName   string
	Error      error
}

ToolCallErrorEvent indicates a tool call failed during execution

func (ToolCallErrorEvent) GetRequestID added in v0.48.0

func (e ToolCallErrorEvent) GetRequestID() string

func (ToolCallErrorEvent) GetTimestamp added in v0.48.0

func (e ToolCallErrorEvent) GetTimestamp() time.Time

func (ToolCallErrorEvent) GetType added in v0.48.0

func (e ToolCallErrorEvent) GetType() ChatEventType

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

func (ToolCallPreviewEvent) GetType added in v0.48.0

func (e ToolCallPreviewEvent) GetType() ChatEventType

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

func (ToolCallReadyEvent) GetType added in v0.48.0

func (e ToolCallReadyEvent) GetType() ChatEventType

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 ToolCallStartEvent added in v0.27.0

type ToolCallStartEvent struct {
	RequestID     string
	Timestamp     time.Time
	ToolName      string
	ToolArguments string
}

ToolCallStartEvent indicates tool calls have started being received

func (ToolCallStartEvent) GetRequestID added in v0.27.0

func (e ToolCallStartEvent) GetRequestID() string

func (ToolCallStartEvent) GetTimestamp added in v0.27.0

func (e ToolCallStartEvent) GetTimestamp() time.Time

func (ToolCallStartEvent) GetType added in v0.27.0

func (e ToolCallStartEvent) GetType() ChatEventType

type ToolCallStatus added in v0.27.0

type ToolCallStatus int

ToolCallStatus represents the status of an individual tool call

const (
	ToolCallStatusPending ToolCallStatus = iota
	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 = "complete"
	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

func (ToolCallUpdateEvent) GetType added in v0.48.0

func (e ToolCallUpdateEvent) GetType() ChatEventType

type ToolExecutionCompletedEvent added in v0.45.0

type ToolExecutionCompletedEvent struct {
	SessionID     string
	TotalExecuted int
	SuccessCount  int
	FailureCount  int
	Results       []*ToolExecutionResult
}

ToolExecutionCompletedEvent indicates tool execution is complete

func (ToolExecutionCompletedEvent) GetType added in v0.45.0

type ToolExecutionProgressEvent added in v0.45.0

type ToolExecutionProgressEvent struct {
	SessionID   string
	CurrentTool int
	TotalTools  int
	ToolName    string
	Status      string
}

ToolExecutionProgressEvent indicates progress in tool execution

func (ToolExecutionProgressEvent) GetType added in v0.45.0

type ToolExecutionResult added in v0.14.0

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"`
}

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

func (ToolExecutionStartedEvent) GetType added in v0.45.0

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 ToolService

type ToolService interface {
	ListTools() []sdk.ChatCompletionTool
	ListAvailableTools() []string
	ExecuteTool(ctx context.Context, tool sdk.ChatCompletionMessageToolCallFunction) (*ToolExecutionResult, error)
	IsToolEnabled(name string) bool
	ValidateTool(name string, args map[string]any) 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 UIEvent added in v0.45.0

type UIEvent interface {
	GetType() UIEventType
}

UIEvent interface for all UI-related events

type UIEventType added in v0.45.0

type UIEventType int

UIEventType defines types of UI events

const (
	UIEventUpdateHistory UIEventType = iota
	UIEventStreamingContent
	UIEventSetStatus
	UIEventUpdateStatus
	UIEventShowError
	UIEventClearError
	UIEventClearInput
	UIEventSetInput
	UIEventUserInput
	UIEventModelSelected
	UIEventThemeSelected
	UIEventConversationSelected
	UIEventInitializeConversationSelection
	UIEventFileSelected
	UIEventFileSelectionRequest
	UIEventSetupFileSelection
	UIEventScrollRequest
	UIEventFocusRequest
	UIEventResize
	UIEventDebugKey
	UIEventToggleHelpBar
	UIEventHideHelpBar
	UIEventExitSelectionMode
	UIEventInitializeTextSelection
	UIEventConversationsLoaded
	UIEventToolExecutionStarted
	UIEventToolExecutionProgress
	UIEventToolExecutionCompleted
)

type UpdateHistoryEvent added in v0.45.0

type UpdateHistoryEvent struct {
	History []ConversationEntry
}

UpdateHistoryEvent updates the conversation history display

func (UpdateHistoryEvent) GetType added in v0.45.0

func (e UpdateHistoryEvent) GetType() UIEventType

type UpdateStatusEvent added in v0.45.0

type UpdateStatusEvent struct {
	Message    string
	StatusType StatusType
}

UpdateStatusEvent updates an existing status message without resetting timer

func (UpdateStatusEvent) GetType added in v0.45.0

func (e UpdateStatusEvent) GetType() UIEventType

type UserInputEvent added in v0.45.0

type UserInputEvent struct {
	Content string
}

UserInputEvent represents user input submission

func (UserInputEvent) GetType added in v0.45.0

func (e UserInputEvent) GetType() UIEventType

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
	ViewStateTextSelection
	ViewStateConversationSelection
	ViewStateThemeSelection
	ViewStateA2AServers
)

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