Documentation
¶
Index ¶
- func NewFileService() domain.FileService
- type ApprovalArgumentFormatter
- type ConversationOptimizer
- func (co *ConversationOptimizer) CompactToolCalls(message sdk.Message) sdk.Message
- func (co *ConversationOptimizer) EstimateTokens(content string) int
- func (co *ConversationOptimizer) GetOptimizationStats(messages []sdk.Message) map[string]int
- func (co *ConversationOptimizer) OptimizeForExport(entries []domain.ConversationEntry) []domain.ConversationEntry
- func (co *ConversationOptimizer) OptimizeMessages(messages []sdk.Message) []sdk.Message
- func (co *ConversationOptimizer) SummarizeOldMessages(messages []domain.ConversationEntry) string
- type DebugEvent
- type DebugEventType
- type DebugService
- func (ds *DebugService) Cleanup()
- func (ds *DebugService) Disable()
- func (ds *DebugService) Enable()
- func (ds *DebugService) ExportEvents(filename string) error
- func (ds *DebugService) ExportMetrics(filename string) error
- func (ds *DebugService) GetEventsByType(eventType DebugEventType) []DebugEvent
- func (ds *DebugService) GetEventsSince(since time.Time) []DebugEvent
- func (ds *DebugService) GetPerformanceSummary() map[string]any
- func (ds *DebugService) IsEnabled() bool
- func (ds *DebugService) LogCommand(command string, args []string, result any, duration time.Duration)
- func (ds *DebugService) LogError(err error, source string, context map[string]any)
- func (ds *DebugService) LogEvent(eventType DebugEventType, source, message string, data map[string]any)
- func (ds *DebugService) LogKeyPress(key string, handler string, view string)
- func (ds *DebugService) LogMessage(msg tea.Msg, source string)
- func (ds *DebugService) LogSDKEvent(eventType string, requestID string, data any)
- func (ds *DebugService) LogToolExecution(toolName string, phase string, data map[string]any)
- func (ds *DebugService) OnStateChanged(oldState, newState domain.StateSnapshot)
- func (ds *DebugService) TrackMessageProcessing(msgType string, duration time.Duration)
- func (ds *DebugService) TrackSDKCall(operation string, duration time.Duration)
- func (ds *DebugService) TrackStateTransition(duration time.Duration)
- func (ds *DebugService) TrackUIRender(duration time.Duration)
- type FileServiceImpl
- func (s *FileServiceImpl) GetFileInfo(path string) (domain.FileInfo, error)
- func (s *FileServiceImpl) ListProjectFiles() ([]string, error)
- func (s *FileServiceImpl) ReadFile(path string) (string, error)
- func (s *FileServiceImpl) ReadFileLines(path string, startLine, endLine int) (string, error)
- func (s *FileServiceImpl) ValidateFile(path string) error
- type HTTPModelService
- func (s *HTTPModelService) GetCurrentModel() string
- func (s *HTTPModelService) IsModelAvailable(modelID string) bool
- func (s *HTTPModelService) ListModels(ctx context.Context) ([]string, error)
- func (s *HTTPModelService) SelectModel(modelID string) error
- func (s *HTTPModelService) ValidateModel(modelID string) error
- type HealthStatus
- type InMemoryConversationRepository
- func (r *InMemoryConversationRepository) AddMessage(msg domain.ConversationEntry) error
- func (r *InMemoryConversationRepository) AddTokenUsage(inputTokens, outputTokens, totalTokens int) error
- func (r *InMemoryConversationRepository) Clear() error
- func (r *InMemoryConversationRepository) Export(format domain.ExportFormat) ([]byte, error)
- func (r *InMemoryConversationRepository) GetMessageCount() int
- func (r *InMemoryConversationRepository) GetMessages() []domain.ConversationEntry
- func (r *InMemoryConversationRepository) GetSessionTokens() domain.SessionTokenStats
- func (r *InMemoryConversationRepository) UpdateLastMessage(content string) error
- func (r *InMemoryConversationRepository) UpdateLastMessageToolCalls(toolCalls *[]sdk.ChatCompletionMessageToolCall) error
- type LLMToolService
- func (s *LLMToolService) ExecuteTool(ctx context.Context, name string, args map[string]any) (*domain.ToolExecutionResult, error)
- func (s *LLMToolService) IsToolEnabled(name string) bool
- func (s *LLMToolService) ListAvailableTools() []string
- func (s *LLMToolService) ListTools() []domain.ToolDefinition
- func (s *LLMToolService) ValidateTool(name string, args map[string]any) error
- type ModelsResponse
- type NoOpToolService
- func (s *NoOpToolService) ExecuteTool(ctx context.Context, name string, args map[string]any) (*domain.ToolExecutionResult, error)
- func (s *NoOpToolService) IsToolEnabled(name string) bool
- func (s *NoOpToolService) ListAvailableTools() []string
- func (s *NoOpToolService) ListTools() []domain.ToolDefinition
- func (s *NoOpToolService) ValidateTool(name string, args map[string]any) error
- type OptimizerConfig
- type PerformanceMetrics
- type StateChangeEvent
- type StateChangeListener
- type StateChangeType
- type StateManager
- func (sm *StateManager) AddListener(listener StateChangeListener)
- func (sm *StateManager) ApproveCurrentTool() error
- func (sm *StateManager) ClearApprovalUIState()
- func (sm *StateManager) ClearFileSelectionState()
- func (sm *StateManager) CompleteCurrentTool(result *domain.ToolExecutionResult) error
- func (sm *StateManager) DenyCurrentTool() error
- func (sm *StateManager) EndChatSession()
- func (sm *StateManager) EndToolExecution()
- func (sm *StateManager) ExportStateHistory() ([]byte, error)
- func (sm *StateManager) FailCurrentTool(result *domain.ToolExecutionResult) error
- func (sm *StateManager) GetApprovalUIState() *domain.ApprovalUIState
- func (sm *StateManager) GetChatSession() *domain.ChatSession
- func (sm *StateManager) GetCurrentView() domain.ViewState
- func (sm *StateManager) GetDimensions() (int, int)
- func (sm *StateManager) GetFileSelectionState() *domain.FileSelectionState
- func (sm *StateManager) GetHealthStatus() HealthStatus
- func (sm *StateManager) GetStateHistory() []domain.StateSnapshot
- func (sm *StateManager) GetStateSnapshot() domain.StateSnapshot
- func (sm *StateManager) GetToolExecution() *domain.ToolExecutionSession
- func (sm *StateManager) IsDebugMode() bool
- func (sm *StateManager) RecoverFromInconsistentState() error
- func (sm *StateManager) RemoveListener(listener StateChangeListener)
- func (sm *StateManager) SetApprovalSelectedIndex(index int)
- func (sm *StateManager) SetDebugMode(enabled bool)
- func (sm *StateManager) SetDimensions(width, height int)
- func (sm *StateManager) SetFileSelectedIndex(index int)
- func (sm *StateManager) SetToolApprovalRequired(required bool) error
- func (sm *StateManager) SetupApprovalUI()
- func (sm *StateManager) SetupFileSelection(files []string)
- func (sm *StateManager) StartChatSession(requestID, model string, eventChan <-chan domain.ChatEvent) error
- func (sm *StateManager) StartToolExecution(toolCalls []sdk.ChatCompletionMessageToolCall) error
- func (sm *StateManager) TransitionToView(newView domain.ViewState) error
- func (sm *StateManager) UpdateChatStatus(status domain.ChatStatus) error
- func (sm *StateManager) UpdateFileSearchQuery(query string)
- func (sm *StateManager) ValidateState() []error
- type StreamingChatService
- func (s *StreamingChatService) CancelRequest(requestID string) error
- func (s *StreamingChatService) GetMetrics(requestID string) *domain.ChatMetrics
- func (s *StreamingChatService) SendMessage(ctx context.Context, requestID string, model string, messages []sdk.Message) (<-chan domain.ChatEvent, error)
- type ToolApprovalRequestMsg
- type ToolApprovalResponseMsg
- type ToolExecutionCompletedMsg
- type ToolExecutionContext
- type ToolExecutionOrchestrator
- func (teo *ToolExecutionOrchestrator) CancelExecution(reason string) tea.Cmd
- func (teo *ToolExecutionOrchestrator) GetExecutionStatus() (bool, *ToolExecutionContext)
- func (teo *ToolExecutionOrchestrator) GetHealthStatus() map[string]any
- func (teo *ToolExecutionOrchestrator) HandleApprovalResponse(approved bool, toolIndex int) tea.Cmd
- func (teo *ToolExecutionOrchestrator) RecoverFromStuckState() tea.Cmd
- func (teo *ToolExecutionOrchestrator) StartToolExecution(requestID string, toolCalls []sdk.ChatCompletionMessageToolCall) (string, tea.Cmd)
- type ToolExecutionProgressMsg
- type ToolExecutionStartedMsg
- type ToolExecutionStatus
- type ToolFormatterService
- func (s *ToolFormatterService) FormatToolArgumentsForApproval(toolName string, args map[string]any) string
- func (s *ToolFormatterService) FormatToolCall(toolName string, args map[string]any) string
- func (s *ToolFormatterService) FormatToolResultExpanded(result *domain.ToolExecutionResult, terminalWidth int) string
- func (s *ToolFormatterService) FormatToolResultForLLM(result *domain.ToolExecutionResult) string
- func (s *ToolFormatterService) FormatToolResultForUI(result *domain.ToolExecutionResult, terminalWidth int) string
- type ToolRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileService ¶ added in v0.15.0
func NewFileService() domain.FileService
NewFileService creates a new file service
Types ¶
type ApprovalArgumentFormatter ¶ added in v0.33.5
ApprovalArgumentFormatter interface for tools that need custom approval argument formatting
type ConversationOptimizer ¶ added in v0.30.0
type ConversationOptimizer struct {
// contains filtered or unexported fields
}
ConversationOptimizer provides methods to optimize conversation history for token efficiency
func NewConversationOptimizer ¶ added in v0.30.0
func NewConversationOptimizer(config OptimizerConfig) *ConversationOptimizer
NewConversationOptimizer creates a new conversation optimizer with configuration
func (*ConversationOptimizer) CompactToolCalls ¶ added in v0.30.0
func (co *ConversationOptimizer) CompactToolCalls(message sdk.Message) sdk.Message
CompactToolCalls reduces the verbosity of tool call results
func (*ConversationOptimizer) EstimateTokens ¶ added in v0.30.0
func (co *ConversationOptimizer) EstimateTokens(content string) int
EstimateTokens provides rough token estimation (4 chars ≈ 1 token)
func (*ConversationOptimizer) GetOptimizationStats ¶ added in v0.30.0
func (co *ConversationOptimizer) GetOptimizationStats(messages []sdk.Message) map[string]int
GetOptimizationStats returns statistics about potential token savings
func (*ConversationOptimizer) OptimizeForExport ¶ added in v0.30.0
func (co *ConversationOptimizer) OptimizeForExport(entries []domain.ConversationEntry) []domain.ConversationEntry
OptimizeForExport prepares messages for export with token optimization
func (*ConversationOptimizer) OptimizeMessages ¶ added in v0.30.0
func (co *ConversationOptimizer) OptimizeMessages(messages []sdk.Message) []sdk.Message
OptimizeMessages reduces token usage by intelligently managing conversation history
func (*ConversationOptimizer) SummarizeOldMessages ¶ added in v0.30.0
func (co *ConversationOptimizer) SummarizeOldMessages(messages []domain.ConversationEntry) string
SummarizeOldMessages creates a summary of older messages to reduce tokens
type DebugEvent ¶ added in v0.27.0
type DebugEvent struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Type DebugEventType `json:"type"`
Source string `json:"source"`
Message string `json:"message"`
Data map[string]any `json:"data"`
StateAfter *domain.StateSnapshot `json:"state_after,omitempty"`
Duration *time.Duration `json:"duration,omitempty"`
}
DebugEvent represents a debug event in the TUI flow
type DebugEventType ¶ added in v0.27.0
type DebugEventType int
DebugEventType represents the type of debug event
const ( DebugEventTypeKeyPress DebugEventType = iota DebugEventTypeMessage DebugEventTypeStateChange DebugEventTypeUIUpdate DebugEventTypeCommand DebugEventTypeError DebugEventTypePerformance DebugEventTypeSDKEvent DebugEventTypeToolExecution )
func (DebugEventType) String ¶ added in v0.27.0
func (d DebugEventType) String() string
type DebugService ¶ added in v0.27.0
type DebugService struct {
// contains filtered or unexported fields
}
DebugService provides comprehensive debugging capabilities for TUI flow understanding
func NewDebugService ¶ added in v0.27.0
func NewDebugService(enabled bool, stateManager *StateManager, outputDir string) *DebugService
NewDebugService creates a new debug service
func (*DebugService) Cleanup ¶ added in v0.27.0
func (ds *DebugService) Cleanup()
Cleanup closes resources and saves final debug data
func (*DebugService) Disable ¶ added in v0.27.0
func (ds *DebugService) Disable()
Disable disables debug mode
func (*DebugService) Enable ¶ added in v0.27.0
func (ds *DebugService) Enable()
Enable enables debug mode
func (*DebugService) ExportEvents ¶ added in v0.27.0
func (ds *DebugService) ExportEvents(filename string) error
ExportEvents exports debug events to a file
func (*DebugService) ExportMetrics ¶ added in v0.27.0
func (ds *DebugService) ExportMetrics(filename string) error
ExportMetrics exports performance metrics to a file
func (*DebugService) GetEventsByType ¶ added in v0.27.0
func (ds *DebugService) GetEventsByType(eventType DebugEventType) []DebugEvent
GetEventsByType returns events of a specific type
func (*DebugService) GetEventsSince ¶ added in v0.27.0
func (ds *DebugService) GetEventsSince(since time.Time) []DebugEvent
GetEventsSince returns events since a specific timestamp
func (*DebugService) GetPerformanceSummary ¶ added in v0.27.0
func (ds *DebugService) GetPerformanceSummary() map[string]any
GetPerformanceSummary returns a performance summary
func (*DebugService) IsEnabled ¶ added in v0.27.0
func (ds *DebugService) IsEnabled() bool
IsEnabled returns whether debug mode is enabled
func (*DebugService) LogCommand ¶ added in v0.27.0
func (ds *DebugService) LogCommand(command string, args []string, result any, duration time.Duration)
LogCommand logs a command execution
func (*DebugService) LogError ¶ added in v0.27.0
func (ds *DebugService) LogError(err error, source string, context map[string]any)
LogError logs an error event
func (*DebugService) LogEvent ¶ added in v0.27.0
func (ds *DebugService) LogEvent(eventType DebugEventType, source, message string, data map[string]any)
LogEvent logs a debug event
func (*DebugService) LogKeyPress ¶ added in v0.27.0
func (ds *DebugService) LogKeyPress(key string, handler string, view string)
LogKeyPress logs a key press event
func (*DebugService) LogMessage ¶ added in v0.27.0
func (ds *DebugService) LogMessage(msg tea.Msg, source string)
LogMessage logs a Bubble Tea message
func (*DebugService) LogSDKEvent ¶ added in v0.27.0
func (ds *DebugService) LogSDKEvent(eventType string, requestID string, data any)
LogSDKEvent logs an SDK event
func (*DebugService) LogToolExecution ¶ added in v0.27.0
func (ds *DebugService) LogToolExecution(toolName string, phase string, data map[string]any)
LogToolExecution logs tool execution events
func (*DebugService) OnStateChanged ¶ added in v0.27.0
func (ds *DebugService) OnStateChanged(oldState, newState domain.StateSnapshot)
OnStateChanged implements StateChangeListener
func (*DebugService) TrackMessageProcessing ¶ added in v0.27.0
func (ds *DebugService) TrackMessageProcessing(msgType string, duration time.Duration)
TrackMessageProcessing tracks message processing time
func (*DebugService) TrackSDKCall ¶ added in v0.27.0
func (ds *DebugService) TrackSDKCall(operation string, duration time.Duration)
TrackSDKCall tracks SDK call time
func (*DebugService) TrackStateTransition ¶ added in v0.27.0
func (ds *DebugService) TrackStateTransition(duration time.Duration)
TrackStateTransition tracks state transition time
func (*DebugService) TrackUIRender ¶ added in v0.27.0
func (ds *DebugService) TrackUIRender(duration time.Duration)
TrackUIRender tracks UI render time
type FileServiceImpl ¶ added in v0.15.0
type FileServiceImpl struct{}
FileServiceImpl implements domain.FileService
func (*FileServiceImpl) GetFileInfo ¶ added in v0.15.0
func (s *FileServiceImpl) GetFileInfo(path string) (domain.FileInfo, error)
GetFileInfo returns information about a file
func (*FileServiceImpl) ListProjectFiles ¶ added in v0.15.0
func (s *FileServiceImpl) ListProjectFiles() ([]string, error)
ListProjectFiles returns a list of all files in the current directory and subdirectories
func (*FileServiceImpl) ReadFile ¶ added in v0.15.0
func (s *FileServiceImpl) ReadFile(path string) (string, error)
ReadFile reads the content of a file
func (*FileServiceImpl) ReadFileLines ¶ added in v0.15.0
func (s *FileServiceImpl) ReadFileLines(path string, startLine, endLine int) (string, error)
ReadFileLines reads specific lines from a file
func (*FileServiceImpl) ValidateFile ¶ added in v0.15.0
func (s *FileServiceImpl) ValidateFile(path string) error
ValidateFile checks if a file path is valid and accessible
type HTTPModelService ¶
type HTTPModelService struct {
// contains filtered or unexported fields
}
HTTPModelService implements ModelService using HTTP API calls
func NewHTTPModelService ¶
func NewHTTPModelService(baseURL, apiKey string) *HTTPModelService
NewHTTPModelService creates a new HTTP-based model service
func (*HTTPModelService) GetCurrentModel ¶
func (s *HTTPModelService) GetCurrentModel() string
func (*HTTPModelService) IsModelAvailable ¶
func (s *HTTPModelService) IsModelAvailable(modelID string) bool
func (*HTTPModelService) ListModels ¶
func (s *HTTPModelService) ListModels(ctx context.Context) ([]string, error)
func (*HTTPModelService) SelectModel ¶
func (s *HTTPModelService) SelectModel(modelID string) error
func (*HTTPModelService) ValidateModel ¶
func (s *HTTPModelService) ValidateModel(modelID string) error
type HealthStatus ¶ added in v0.27.0
type HealthStatus struct {
Healthy bool `json:"healthy"`
ValidationErrors []error `json:"validation_errors"`
StateHistorySize int `json:"state_history_size"`
LastStateChange time.Time `json:"last_state_change"`
MemoryUsageKB int `json:"memory_usage_kb"`
}
HealthStatus represents the health status of the state manager
type InMemoryConversationRepository ¶
type InMemoryConversationRepository struct {
// contains filtered or unexported fields
}
InMemoryConversationRepository implements ConversationRepository using in-memory storage
func NewInMemoryConversationRepository ¶
func NewInMemoryConversationRepository(formatterService *ToolFormatterService) *InMemoryConversationRepository
NewInMemoryConversationRepository creates a new in-memory conversation repository
func (*InMemoryConversationRepository) AddMessage ¶
func (r *InMemoryConversationRepository) AddMessage(msg domain.ConversationEntry) error
func (*InMemoryConversationRepository) AddTokenUsage ¶ added in v0.28.0
func (r *InMemoryConversationRepository) AddTokenUsage(inputTokens, outputTokens, totalTokens int) error
AddTokenUsage adds token usage from a single API call to session totals
func (*InMemoryConversationRepository) Clear ¶
func (r *InMemoryConversationRepository) Clear() error
func (*InMemoryConversationRepository) Export ¶
func (r *InMemoryConversationRepository) Export(format domain.ExportFormat) ([]byte, error)
func (*InMemoryConversationRepository) GetMessageCount ¶
func (r *InMemoryConversationRepository) GetMessageCount() int
func (*InMemoryConversationRepository) GetMessages ¶
func (r *InMemoryConversationRepository) GetMessages() []domain.ConversationEntry
func (*InMemoryConversationRepository) GetSessionTokens ¶ added in v0.28.0
func (r *InMemoryConversationRepository) GetSessionTokens() domain.SessionTokenStats
GetSessionTokens returns the accumulated token statistics for the session
func (*InMemoryConversationRepository) UpdateLastMessage ¶
func (r *InMemoryConversationRepository) UpdateLastMessage(content string) error
func (*InMemoryConversationRepository) UpdateLastMessageToolCalls ¶
func (r *InMemoryConversationRepository) UpdateLastMessageToolCalls(toolCalls *[]sdk.ChatCompletionMessageToolCall) error
type LLMToolService ¶
type LLMToolService struct {
// contains filtered or unexported fields
}
LLMToolService implements ToolService with the new tools package architecture
func NewLLMToolService ¶
func NewLLMToolService(cfg *config.Config) *LLMToolService
NewLLMToolService creates a new LLM tool service with a new registry
func NewLLMToolServiceWithRegistry ¶ added in v0.14.1
func NewLLMToolServiceWithRegistry(cfg *config.Config, registry *tools.Registry) *LLMToolService
NewLLMToolServiceWithRegistry creates a new LLM tool service with an existing registry
func (*LLMToolService) ExecuteTool ¶
func (s *LLMToolService) ExecuteTool(ctx context.Context, name string, args map[string]any) (*domain.ToolExecutionResult, error)
ExecuteTool executes a tool with the given arguments
func (*LLMToolService) IsToolEnabled ¶
func (s *LLMToolService) IsToolEnabled(name string) bool
IsToolEnabled checks if a tool is enabled
func (*LLMToolService) ListAvailableTools ¶ added in v0.32.0
func (s *LLMToolService) ListAvailableTools() []string
ListAvailableTools returns names of all enabled tools
func (*LLMToolService) ListTools ¶
func (s *LLMToolService) ListTools() []domain.ToolDefinition
ListTools returns definitions for all enabled tools
func (*LLMToolService) ValidateTool ¶
func (s *LLMToolService) ValidateTool(name string, args map[string]any) error
ValidateTool validates tool arguments
type ModelsResponse ¶
type ModelsResponse struct {
Data []struct {
ID string `json:"id"`
Object string `json:"object"`
} `json:"data"`
}
ModelsResponse represents the API response for listing models
type NoOpToolService ¶
type NoOpToolService struct{}
NoOpToolService implements ToolService as a no-op (when tools are disabled)
func NewNoOpToolService ¶
func NewNoOpToolService() *NoOpToolService
NewNoOpToolService creates a new no-op tool service
func (*NoOpToolService) ExecuteTool ¶
func (s *NoOpToolService) ExecuteTool(ctx context.Context, name string, args map[string]any) (*domain.ToolExecutionResult, error)
func (*NoOpToolService) IsToolEnabled ¶
func (s *NoOpToolService) IsToolEnabled(name string) bool
func (*NoOpToolService) ListAvailableTools ¶ added in v0.32.0
func (s *NoOpToolService) ListAvailableTools() []string
func (*NoOpToolService) ListTools ¶
func (s *NoOpToolService) ListTools() []domain.ToolDefinition
func (*NoOpToolService) ValidateTool ¶
func (s *NoOpToolService) ValidateTool(name string, args map[string]any) error
type OptimizerConfig ¶ added in v0.30.0
type OptimizerConfig struct {
Enabled bool
MaxHistory int
CompactThreshold int
TruncateLargeOutputs bool
SkipRedundantConfirmations bool
}
OptimizerConfig represents configuration for the conversation optimizer
type PerformanceMetrics ¶ added in v0.27.0
type PerformanceMetrics struct {
MessageProcessingTimes map[string][]time.Duration
UIRenderTimes []time.Duration
StateTransitionTimes []time.Duration
SDKCallTimes map[string][]time.Duration
// contains filtered or unexported fields
}
PerformanceMetrics tracks performance metrics for debugging
func NewPerformanceMetrics ¶ added in v0.27.0
func NewPerformanceMetrics() *PerformanceMetrics
NewPerformanceMetrics creates a new performance metrics tracker
type StateChangeEvent ¶ added in v0.27.0
type StateChangeEvent struct {
Type StateChangeType
OldState domain.StateSnapshot
NewState domain.StateSnapshot
Timestamp time.Time
}
StateChangeEvent represents a state change event
type StateChangeListener ¶ added in v0.27.0
type StateChangeListener interface {
OnStateChanged(oldState, newState domain.StateSnapshot)
}
StateChangeListener interface for components that need to react to state changes
type StateChangeType ¶ added in v0.27.0
type StateChangeType int
StateChangeType represents the type of state change
const ( StateChangeTypeViewTransition StateChangeType = iota StateChangeTypeChatStatus StateChangeTypeToolExecution StateChangeTypeDimensions )
func (StateChangeType) String ¶ added in v0.27.0
func (s StateChangeType) String() string
type StateManager ¶ added in v0.27.0
type StateManager struct {
// contains filtered or unexported fields
}
StateManager provides centralized state management with proper synchronization
func NewStateManager ¶ added in v0.27.0
func NewStateManager(debugMode bool) *StateManager
NewStateManager creates a new state manager
func (*StateManager) AddListener ¶ added in v0.27.0
func (sm *StateManager) AddListener(listener StateChangeListener)
AddListener adds a state change listener
func (*StateManager) ApproveCurrentTool ¶ added in v0.27.0
func (sm *StateManager) ApproveCurrentTool() error
ApproveCurrentTool approves the current tool for execution
func (*StateManager) ClearApprovalUIState ¶ added in v0.27.0
func (sm *StateManager) ClearApprovalUIState()
ClearApprovalUIState clears the approval UI state
func (*StateManager) ClearFileSelectionState ¶ added in v0.27.0
func (sm *StateManager) ClearFileSelectionState()
ClearFileSelectionState clears the file selection state
func (*StateManager) CompleteCurrentTool ¶ added in v0.27.0
func (sm *StateManager) CompleteCurrentTool(result *domain.ToolExecutionResult) error
CompleteCurrentTool marks the current tool as completed
func (*StateManager) DenyCurrentTool ¶ added in v0.27.0
func (sm *StateManager) DenyCurrentTool() error
DenyCurrentTool denies the current tool execution
func (*StateManager) EndChatSession ¶ added in v0.27.0
func (sm *StateManager) EndChatSession()
EndChatSession ends the current chat session
func (*StateManager) EndToolExecution ¶ added in v0.27.0
func (sm *StateManager) EndToolExecution()
EndToolExecution ends the current tool execution session
func (*StateManager) ExportStateHistory ¶ added in v0.27.0
func (sm *StateManager) ExportStateHistory() ([]byte, error)
ExportStateHistory exports the state history as JSON for debugging
func (*StateManager) FailCurrentTool ¶ added in v0.27.0
func (sm *StateManager) FailCurrentTool(result *domain.ToolExecutionResult) error
FailCurrentTool marks the current tool as failed
func (*StateManager) GetApprovalUIState ¶ added in v0.27.0
func (sm *StateManager) GetApprovalUIState() *domain.ApprovalUIState
GetApprovalUIState returns the current approval UI state
func (*StateManager) GetChatSession ¶ added in v0.27.0
func (sm *StateManager) GetChatSession() *domain.ChatSession
GetChatSession returns the current chat session (read-only)
func (*StateManager) GetCurrentView ¶ added in v0.27.0
func (sm *StateManager) GetCurrentView() domain.ViewState
GetCurrentView returns the current view state
func (*StateManager) GetDimensions ¶ added in v0.27.0
func (sm *StateManager) GetDimensions() (int, int)
GetDimensions returns the current UI dimensions
func (*StateManager) GetFileSelectionState ¶ added in v0.27.0
func (sm *StateManager) GetFileSelectionState() *domain.FileSelectionState
GetFileSelectionState returns the current file selection state
func (*StateManager) GetHealthStatus ¶ added in v0.27.0
func (sm *StateManager) GetHealthStatus() HealthStatus
GetHealthStatus returns the health status of the state manager
func (*StateManager) GetStateHistory ¶ added in v0.27.0
func (sm *StateManager) GetStateHistory() []domain.StateSnapshot
GetStateHistory returns the state change history
func (*StateManager) GetStateSnapshot ¶ added in v0.27.0
func (sm *StateManager) GetStateSnapshot() domain.StateSnapshot
GetStateSnapshot returns the current state snapshot
func (*StateManager) GetToolExecution ¶ added in v0.27.0
func (sm *StateManager) GetToolExecution() *domain.ToolExecutionSession
GetToolExecution returns the current tool execution session (read-only)
func (*StateManager) IsDebugMode ¶ added in v0.27.0
func (sm *StateManager) IsDebugMode() bool
IsDebugMode returns whether debug mode is enabled
func (*StateManager) RecoverFromInconsistentState ¶ added in v0.27.0
func (sm *StateManager) RecoverFromInconsistentState() error
RecoverFromInconsistentState attempts to recover from an inconsistent state
func (*StateManager) RemoveListener ¶ added in v0.27.0
func (sm *StateManager) RemoveListener(listener StateChangeListener)
RemoveListener removes a state change listener
func (*StateManager) SetApprovalSelectedIndex ¶ added in v0.27.0
func (sm *StateManager) SetApprovalSelectedIndex(index int)
SetApprovalSelectedIndex sets the approval selection index
func (*StateManager) SetDebugMode ¶ added in v0.27.0
func (sm *StateManager) SetDebugMode(enabled bool)
SetDebugMode enables or disables debug mode
func (*StateManager) SetDimensions ¶ added in v0.27.0
func (sm *StateManager) SetDimensions(width, height int)
SetDimensions updates the UI dimensions
func (*StateManager) SetFileSelectedIndex ¶ added in v0.27.0
func (sm *StateManager) SetFileSelectedIndex(index int)
SetFileSelectedIndex sets the selected file index
func (*StateManager) SetToolApprovalRequired ¶ added in v0.27.0
func (sm *StateManager) SetToolApprovalRequired(required bool) error
SetToolApprovalRequired marks the current tool as requiring approval
func (*StateManager) SetupApprovalUI ¶ added in v0.27.0
func (sm *StateManager) SetupApprovalUI()
SetupApprovalUI initializes approval UI state
func (*StateManager) SetupFileSelection ¶ added in v0.27.0
func (sm *StateManager) SetupFileSelection(files []string)
SetupFileSelection initializes file selection state
func (*StateManager) StartChatSession ¶ added in v0.27.0
func (sm *StateManager) StartChatSession(requestID, model string, eventChan <-chan domain.ChatEvent) error
StartChatSession starts a new chat session
func (*StateManager) StartToolExecution ¶ added in v0.27.0
func (sm *StateManager) StartToolExecution(toolCalls []sdk.ChatCompletionMessageToolCall) error
StartToolExecution starts a new tool execution session
func (*StateManager) TransitionToView ¶ added in v0.27.0
func (sm *StateManager) TransitionToView(newView domain.ViewState) error
TransitionToView transitions to a new view with validation and logging
func (*StateManager) UpdateChatStatus ¶ added in v0.27.0
func (sm *StateManager) UpdateChatStatus(status domain.ChatStatus) error
UpdateChatStatus updates the chat session status with validation
func (*StateManager) UpdateFileSearchQuery ¶ added in v0.27.0
func (sm *StateManager) UpdateFileSearchQuery(query string)
UpdateFileSearchQuery updates the file search query
func (*StateManager) ValidateState ¶ added in v0.27.0
func (sm *StateManager) ValidateState() []error
ValidateState performs comprehensive state validation
type StreamingChatService ¶
type StreamingChatService struct {
// contains filtered or unexported fields
}
StreamingChatService implements ChatService using streaming SDK client
func NewStreamingChatService ¶
func NewStreamingChatService(baseURL, apiKey string, timeoutSeconds int, toolService domain.ToolService, systemPrompt string) *StreamingChatService
NewStreamingChatService creates a new streaming chat service
func (*StreamingChatService) CancelRequest ¶
func (s *StreamingChatService) CancelRequest(requestID string) error
func (*StreamingChatService) GetMetrics ¶
func (s *StreamingChatService) GetMetrics(requestID string) *domain.ChatMetrics
type ToolApprovalRequestMsg ¶ added in v0.27.0
type ToolApprovalRequestMsg struct {
SessionID string
ToolCall sdk.ChatCompletionMessageToolCall
ToolIndex int
TotalTools int
}
ToolApprovalRequestMsg requests approval for a specific tool
type ToolApprovalResponseMsg ¶ added in v0.27.0
ToolApprovalResponseMsg provides the approval response
type ToolExecutionCompletedMsg ¶ added in v0.27.0
type ToolExecutionCompletedMsg struct {
SessionID string
TotalExecuted int
SuccessCount int
FailureCount int
Results []*domain.ToolExecutionResult
}
ToolExecutionCompletedMsg indicates tool execution is complete
type ToolExecutionContext ¶ added in v0.27.0
type ToolExecutionContext struct {
SessionID string
RequestID string
ToolCalls []sdk.ChatCompletionMessageToolCall
CurrentIndex int
StartTime time.Time
Status ToolExecutionStatus
Results []*domain.ToolExecutionResult
EventChannel chan tea.Msg
}
ToolExecutionContext tracks the context of a tool execution session
type ToolExecutionOrchestrator ¶ added in v0.27.0
type ToolExecutionOrchestrator struct {
// contains filtered or unexported fields
}
ToolExecutionOrchestrator manages the complete tool execution flow
func NewToolExecutionOrchestrator ¶ added in v0.27.0
func NewToolExecutionOrchestrator( stateManager *StateManager, debugService *DebugService, toolService domain.ToolService, conversationRepo domain.ConversationRepository, configService domain.ConfigService, ) *ToolExecutionOrchestrator
NewToolExecutionOrchestrator creates a new tool execution orchestrator
func (*ToolExecutionOrchestrator) CancelExecution ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) CancelExecution(reason string) tea.Cmd
CancelExecution cancels the current tool execution
func (*ToolExecutionOrchestrator) GetExecutionStatus ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) GetExecutionStatus() (bool, *ToolExecutionContext)
GetExecutionStatus returns the current execution status
func (*ToolExecutionOrchestrator) GetHealthStatus ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) GetHealthStatus() map[string]any
GetHealthStatus returns the health status of the tool execution orchestrator
func (*ToolExecutionOrchestrator) HandleApprovalResponse ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) HandleApprovalResponse(approved bool, toolIndex int) tea.Cmd
HandleApprovalResponse handles the response to a tool approval request
func (*ToolExecutionOrchestrator) RecoverFromStuckState ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) RecoverFromStuckState() tea.Cmd
RecoverFromStuckState attempts to recover from a stuck tool execution state
func (*ToolExecutionOrchestrator) StartToolExecution ¶ added in v0.27.0
func (teo *ToolExecutionOrchestrator) StartToolExecution( requestID string, toolCalls []sdk.ChatCompletionMessageToolCall, ) (string, tea.Cmd)
StartToolExecution initiates a new tool execution session
type ToolExecutionProgressMsg ¶ added in v0.27.0
type ToolExecutionProgressMsg struct {
SessionID string
CurrentTool int
TotalTools int
ToolName string
Status string
RequiresApproval bool
}
ToolExecutionProgressMsg indicates progress in tool execution
type ToolExecutionStartedMsg ¶ added in v0.27.0
ToolExecutionStartedMsg indicates tool execution has started
type ToolExecutionStatus ¶ added in v0.27.0
type ToolExecutionStatus int
ToolExecutionStatus represents the current execution status
const ( ToolExecutionStatusReady ToolExecutionStatus = iota ToolExecutionStatusProcessing ToolExecutionStatusWaitingApproval ToolExecutionStatusExecuting ToolExecutionStatusCompleting ToolExecutionStatusCompleted ToolExecutionStatusFailed ToolExecutionStatusCancelled )
func (ToolExecutionStatus) String ¶ added in v0.27.0
func (t ToolExecutionStatus) String() string
type ToolFormatterService ¶ added in v0.33.4
type ToolFormatterService struct {
// contains filtered or unexported fields
}
ToolFormatterService provides formatting for tool results by delegating to individual tools
func NewToolFormatterService ¶ added in v0.33.4
func NewToolFormatterService(registry ToolRegistry) *ToolFormatterService
NewToolFormatterService creates a new tool formatter service
func (*ToolFormatterService) FormatToolArgumentsForApproval ¶ added in v0.33.5
func (s *ToolFormatterService) FormatToolArgumentsForApproval(toolName string, args map[string]any) string
FormatToolArgumentsForApproval formats tool arguments for approval display This delegates to individual tools if they have special formatting needs
func (*ToolFormatterService) FormatToolCall ¶ added in v0.33.4
func (s *ToolFormatterService) FormatToolCall(toolName string, args map[string]any) string
FormatToolCall formats a tool call for consistent display
func (*ToolFormatterService) FormatToolResultExpanded ¶ added in v0.33.4
func (s *ToolFormatterService) FormatToolResultExpanded(result *domain.ToolExecutionResult, terminalWidth int) string
FormatToolResultExpanded formats expanded tool execution results
func (*ToolFormatterService) FormatToolResultForLLM ¶ added in v0.33.4
func (s *ToolFormatterService) FormatToolResultForLLM(result *domain.ToolExecutionResult) string
FormatToolResultForLLM formats tool execution results for LLM consumption
func (*ToolFormatterService) FormatToolResultForUI ¶ added in v0.33.4
func (s *ToolFormatterService) FormatToolResultForUI(result *domain.ToolExecutionResult, terminalWidth int) string
FormatToolResultForUI formats tool execution results for UI display