chat

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ArmyGreen  = lipgloss.Color("58")  // #5f5f00 - darker army green
	LightGreen = lipgloss.Color("64")  // #5f8700 - lighter army green
	Brown      = lipgloss.Color("94")  // #875f00 - brown
	Yellow     = lipgloss.Color("226") // #ffff00 - bright yellow
	GoldYellow = lipgloss.Color("220") // #ffd700 - gold yellow
	Red        = lipgloss.Color("196") // #ff0000 - red
	Tan        = lipgloss.Color("180") // #d7af87 - tan
)

Color theme constants for consistent styling

Functions

func CheckVoiceSystem

func CheckVoiceSystem() string

CheckVoiceSystem checks if all voice dependencies are available (stub)

func GetUIProgram

func GetUIProgram() *tea.Program

GetUIProgram returns the global UI program reference

func NewChatCommand

func NewChatCommand() *cobra.Command

NewChatCommand creates the chat command that integrates with the Cobra CLI

Types

type AiResponseMsg

type AiResponseMsg struct {
	Content string
}

AiResponseMsg represents complete AI response (exported for turn.go)

type AiStreamMsg

type AiStreamMsg struct {
	Content string
}

AiStreamMsg represents streaming AI content (exported for turn.go)

type ApprovalMode

type ApprovalMode int

ApprovalMode defines the level of autonomous behavior

const (
	DEFAULT ApprovalMode = iota
	AUTO_EDIT
	YOLO
)

func (ApprovalMode) Description

func (am ApprovalMode) Description() string

Description returns a description of what the mode does

func (ApprovalMode) GetModeIndicatorNoEmoji

func (am ApprovalMode) GetModeIndicatorNoEmoji() string

GetModeIndicatorNoEmoji returns the mode indicator without emojis for UI display

func (ApprovalMode) ShouldConfirm

func (am ApprovalMode) ShouldConfirm(functionName string) bool

ShouldConfirm returns whether a function should be confirmed based on the approval mode

func (ApprovalMode) String

func (am ApprovalMode) String() string

String returns the string representation of the approval mode

type BashCommandArgs

type BashCommandArgs struct {
	Command          string `json:"command"`
	WorkingDirectory string `json:"working_directory,omitempty"`
	Timeout          int    `json:"timeout,omitempty"` // in seconds
	Description      string `json:"description,omitempty"`
}

BashCommandArgs represents the arguments for bash command execution

type BashCommandResult

type BashCommandResult struct {
	Command     string `json:"command"`
	ExitCode    int    `json:"exit_code"`
	Stdout      string `json:"stdout"`
	Stderr      string `json:"stderr"`
	Duration    string `json:"duration"`
	WorkingDir  string `json:"working_dir"`
	Description string `json:"description,omitempty"`
}

BashCommandResult represents the result of bash command execution

type ChatUI

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

ChatUI represents the terminal UI model for the chat interface

func NewChatUI

func NewChatUI(tc *TermChat) *ChatUI

NewChatUI creates a new chat UI instance

func (*ChatUI) Init

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

Init initializes the chat UI

func (*ChatUI) Run

func (ui *ChatUI) Run() error

Run starts the chat UI

func (*ChatUI) Update

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

Update handles messages and updates the model

func (*ChatUI) View

func (m *ChatUI) View() string

View renders the chat UI

type ComprehensiveServerInfo

type ComprehensiveServerInfo struct {
	Name             string     `json:"name"`
	Version          string     `json:"version"`
	Description      string     `json:"description"`
	URL              string     `json:"url"`
	Protocol         string     `json:"protocol"`
	ConnectionStatus string     `json:"connection_status"`
	Capabilities     []string   `json:"capabilities"`
	Tools            []mcp.Tool `json:"tools"`
	LastSeen         time.Time  `json:"last_seen"`
}

ComprehensiveServerInfo represents detailed information about an MCP server

type ConversationTurn

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

ConversationTurn represents a single turn in the conversation

func NewConversationTurn

func NewConversationTurn(chat *TermChat, userRequest string) *ConversationTurn

NewConversationTurn creates a new conversation turn

func NewConversationTurnSilent

func NewConversationTurnSilent(chat *TermChat, userRequest string) *ConversationTurn

NewConversationTurnSilent creates a new conversation turn in silent mode

func (*ConversationTurn) Execute

func (t *ConversationTurn) Execute(ctx context.Context) error

Execute runs the conversation turn with automatic continuation

type DiscoveryResponse

type DiscoveryResponse struct {
	DiscoveredServers []struct {
		Name         string   `json:"name"`
		URL          string   `json:"url"`
		Protocol     string   `json:"protocol"`
		Capabilities []string `json:"capabilities"`
	} `json:"discovered_servers"`
	ConnectionStatus map[string]struct {
		Connected bool   `json:"connected"`
		LastSeen  string `json:"last_seen"`
	} `json:"connection_status"`
}

DiscoveryResponse represents the response from the discovery endpoint

type FunctionConfirmation

type FunctionConfirmation struct {
	FunctionName string
	Arguments    string
	Callback     func(bool) // Callback to execute when confirmation is received
}

FunctionConfirmation represents a pending function call confirmation

type MCPServerInfo

type MCPServerInfo struct {
	Name        string   `json:"name"`
	Status      string   `json:"status"`
	Tools       []string `json:"tools"`
	Description string   `json:"description"`
}

MCPServerInfo represents information about an MCP server

type MCPServerListResult

type MCPServerListResult struct {
	Servers []MCPServerInfo `json:"servers"`
	Total   int             `json:"total"`
	Status  string          `json:"status"`
}

MCPServerListResult represents the result of listing MCP servers

type TermChat

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

TermChat represents a split-screen terminal chat interface

func NewTermChat

func NewTermChat() *TermChat

NewTermChat creates a new terminal chat instance

func (*TermChat) AddMessage

func (tc *TermChat) AddMessage(role, content string)

AddMessage adds a message to chat history (public wrapper)

func (*TermChat) ExecuteNativeToolCall

func (tc *TermChat) ExecuteNativeToolCall(toolCall interface{}, index int) (interface{}, error)

ExecuteNativeToolCall executes a native tool call

func (*TermChat) FindServerForTool

func (tc *TermChat) FindServerForTool(toolName string) string

FindServerForTool finds the appropriate server for a tool

func (*TermChat) FormatToolResultWithArgs

func (tc *TermChat) FormatToolResultWithArgs(toolName, serverName string, result interface{}, duration time.Duration, args map[string]interface{}) string

FormatToolResultWithArgs formats tool execution results with access to original arguments (exported for testing)

func (*TermChat) GetAIManager

func (tc *TermChat) GetAIManager() *ai.Manager

GetAIManager returns the AI manager

func (*TermChat) GetApprovalMode

func (tc *TermChat) GetApprovalMode() ApprovalMode

GetApprovalMode returns the current approval mode

func (*TermChat) GetChatHistory

func (tc *TermChat) GetChatHistory() []TermChatMessage

GetChatHistory returns the chat history

func (*TermChat) GetCurrentModel

func (tc *TermChat) GetCurrentModel() string

GetCurrentModel returns the current model

func (*TermChat) GetMCPClient

func (tc *TermChat) GetMCPClient() *mcp.MCPClient

GetMCPClient returns the MCP client

func (*TermChat) GetMCPFunctions

func (tc *TermChat) GetMCPFunctions() []ai.Function

GetMCPFunctions returns MCP functions (public wrapper)

func (*TermChat) GetOptimizedSystemPrompt

func (tc *TermChat) GetOptimizedSystemPrompt() string

GetOptimizedSystemPrompt returns a comprehensive system prompt optimized for all AI providers

func (*TermChat) GetSystemContext

func (tc *TermChat) GetSystemContext() string

GetSystemContext returns the system context (wrapper for GetOptimizedSystemPrompt)

func (*TermChat) GetVerboseMode

func (tc *TermChat) GetVerboseMode() bool

GetVerboseMode returns the verbose mode setting

func (*TermChat) RequestFunctionConfirmation

func (tc *TermChat) RequestFunctionConfirmation(functionName, arguments string) bool

RequestFunctionConfirmation requests confirmation for function execution

func (*TermChat) Run

func (tc *TermChat) Run() error

Run starts the terminal chat interface

type TermChatMessage

type TermChatMessage struct {
	Role      string
	Content   string // Markdown content (for AI context)
	Timestamp time.Time
}

TermChatMessage represents a chat message

type TodoItem

type TodoItem struct {
	ID          string       `json:"id"`
	Content     string       `json:"content"`
	Status      TodoStatus   `json:"status"`
	Priority    TodoPriority `json:"priority"`
	CreatedAt   time.Time    `json:"createdAt"`
	UpdatedAt   time.Time    `json:"updatedAt"`
	CompletedAt *time.Time   `json:"completedAt,omitempty"`
}

TodoItem represents a single TODO item in the AI's task list

type TodoList

type TodoList struct {
	Items []TodoItem `json:"items"`
}

TodoList manages a collection of TODO items for the AI agent

func (*TodoList) AddItem

func (tl *TodoList) AddItem(content string, priority TodoPriority) string

AddItem adds a new TODO item to the list

func (*TodoList) RemoveItem

func (tl *TodoList) RemoveItem(id string) bool

RemoveItem removes a TODO item from the list

func (*TodoList) UpdateItemStatus

func (tl *TodoList) UpdateItemStatus(id string, status TodoStatus) bool

UpdateItemStatus updates the status of a TODO item

type TodoPriority

type TodoPriority string

TodoPriority represents the priority level of a TODO item

const (
	TodoPriorityLow    TodoPriority = "low"
	TodoPriorityMedium TodoPriority = "medium"
	TodoPriorityHigh   TodoPriority = "high"
	TodoPriorityUrgent TodoPriority = "urgent"
)

type TodoStatus

type TodoStatus string

TodoStatus represents the status of a TODO item

const (
	TodoStatusPending    TodoStatus = "pending"
	TodoStatusInProgress TodoStatus = "in_progress"
	TodoStatusCompleted  TodoStatus = "completed"
	TodoStatusCancelled  TodoStatus = "cancelled"
)

type ToolExecutionResult

type ToolExecutionResult struct {
	ToolCall ai.ToolCall
	Result   interface{}
	Error    error
	Index    int // Preserve original order
}

ToolExecutionResult holds the result of a single tool execution

type VoiceConfig

type VoiceConfig struct {
	WakeWord              string
	TTSEndpoint           string
	TTSVoice              string
	TTSModel              string
	WhisperModel          string
	SampleRate            int
	FrameLength           int
	EnergyThreshold       int
	SpeechTimeoutSeconds  float64
	MaxRecordingSeconds   int
	WakeWordExclusionTime float64
	PostWakewordDelay     float64
	Enabled               bool
}

VoiceConfig holds voice-related configuration (stub version)

func NewVoiceConfig

func NewVoiceConfig() *VoiceConfig

NewVoiceConfig creates voice configuration from environment variables (stub)

type VoiceManager

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

VoiceManager handles voice interaction (stub version)

func NewVoiceManager

func NewVoiceManager(config *VoiceConfig) (*VoiceManager, error)

NewVoiceManager creates a new voice manager (stub)

func (*VoiceManager) GetTTSQueueStatus

func (vm *VoiceManager) GetTTSQueueStatus() (queueLength int, isPlaying bool)

GetTTSQueueStatus returns info about the current TTS queue (stub)

func (*VoiceManager) InterruptTTS

func (vm *VoiceManager) InterruptTTS()

InterruptTTS stops current TTS playback and clears the queue (stub)

func (*VoiceManager) PlayAudio

func (vm *VoiceManager) PlayAudio(audioData []byte) error

PlayAudio plays audio data (stub)

func (*VoiceManager) SetCallbacks

func (vm *VoiceManager) SetCallbacks(onWakeWord func(), onTranscript func(string), onTTSReady func([]byte))

SetCallbacks sets the callback functions (stub)

func (*VoiceManager) SkipToNextTTS

func (vm *VoiceManager) SkipToNextTTS()

SkipToNextTTS skips to the next TTS response in queue (stub)

func (*VoiceManager) Start

func (vm *VoiceManager) Start() error

Start begins voice processing (stub)

func (*VoiceManager) Stop

func (vm *VoiceManager) Stop()

Stop stops voice processing (stub)

func (*VoiceManager) TextToSpeech

func (vm *VoiceManager) TextToSpeech(text string) error

TextToSpeech converts text to speech (stub)

func (*VoiceManager) TriggerManualRecording

func (vm *VoiceManager) TriggerManualRecording() error

TriggerManualRecording manually starts a recording session (stub)

Jump to

Keyboard shortcuts

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