services

package
v0.86.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentContainerPrefix is the naming prefix for agent containers
	AgentContainerPrefix = "inference-agent-"
)
View Source
const (
	// InferNetworkPrefix is the prefix for session-specific Docker networks
	InferNetworkPrefix = "infer-network"
)

Variables

This section is empty.

Functions

func Merge added in v0.79.0

func Merge(base *config.MCPConfig, optional *config.MCPConfig) *config.MCPConfig

Merge merges the optional mcp.yaml config with the base config The optional config takes precedence for global settings Servers from both configs are combined (optional servers can override base servers by name)

func NewContainerRuntime added in v0.82.0

func NewContainerRuntime(sessionID domain.SessionID, runtimeType RuntimeType) (domain.ContainerRuntime, error)

NewContainerRuntime creates a container runtime based on the configured type If runtimeType is empty, returns nil to allow binary mode fallback

func NewDockerRuntime added in v0.82.0

func NewDockerRuntime(sessionID domain.SessionID) domain.ContainerRuntime

NewDockerRuntime creates a new Docker runtime manager

func NewFileService added in v0.15.0

func NewFileService() domain.FileService

NewFileService creates a new file service

func NewPodmanRuntime added in v0.82.0

func NewPodmanRuntime(sessionID domain.SessionID) domain.ContainerRuntime

NewPodmanRuntime creates a new Podman runtime manager

func NewPricingService added in v0.86.0

func NewPricingService(cfg *config.PricingConfig) domain.PricingService

NewPricingService creates a new pricing service instance.

Types

type A2AAgentService added in v0.49.0

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

func NewA2AAgentService added in v0.49.0

func NewA2AAgentService(cfg *config.Config) *A2AAgentService

func (*A2AAgentService) GetAgentCard added in v0.49.0

func (s *A2AAgentService) GetAgentCard(ctx context.Context, agentURL string) (*adk.AgentCard, error)

func (*A2AAgentService) GetAgentCards added in v0.49.0

func (s *A2AAgentService) GetAgentCards(ctx context.Context) ([]*domain.CachedAgentCard, error)

func (*A2AAgentService) GetConfiguredAgents added in v0.49.0

func (s *A2AAgentService) GetConfiguredAgents() []string

type A2APollingMonitor added in v0.53.0

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

func NewA2APollingMonitor added in v0.53.0

func NewA2APollingMonitor(
	taskTracker domain.TaskTracker,
	eventChan chan<- domain.ChatEvent,
	messageQueue domain.MessageQueue,
	requestID string,
	conversationRepo domain.ConversationRepository,
) *A2APollingMonitor

func (*A2APollingMonitor) MonitorPollingState added in v0.53.0

func (m *A2APollingMonitor) MonitorPollingState(ctx context.Context, taskID string, state *domain.TaskPollingState)

func (*A2APollingMonitor) Start added in v0.53.0

func (m *A2APollingMonitor) Start(ctx context.Context)

func (*A2APollingMonitor) Stop added in v0.53.0

func (m *A2APollingMonitor) Stop()

type AgentManager added in v0.54.0

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

AgentManager manages the lifecycle of A2A agent containers

func NewAgentManager added in v0.54.0

func NewAgentManager(sessionID domain.SessionID, cfg *config.Config, agentsConfig *config.AgentsConfig, runtime domain.ContainerRuntime) *AgentManager

NewAgentManager creates a new agent manager

func (*AgentManager) IsRunning added in v0.54.0

func (am *AgentManager) IsRunning() bool

IsRunning returns whether any agents are running

func (*AgentManager) SetStatusCallback added in v0.67.0

func (am *AgentManager) SetStatusCallback(callback func(agentName string, state domain.AgentState, message string, url string, image string))

SetStatusCallback sets the callback function for agent status updates

func (*AgentManager) StartAgent added in v0.54.0

func (am *AgentManager) StartAgent(ctx context.Context, agent config.AgentEntry) error

StartAgent starts a single agent container with status updates

func (*AgentManager) StartAgents added in v0.54.0

func (am *AgentManager) StartAgents(ctx context.Context) error

StartAgents starts all agents configured with run: true asynchronously

func (*AgentManager) StopAgent added in v0.54.0

func (am *AgentManager) StopAgent(ctx context.Context, agentName string) error

StopAgent stops a single agent container

func (*AgentManager) StopAgents added in v0.54.0

func (am *AgentManager) StopAgents(ctx context.Context) error

StopAgents stops all running agent containers

type AgentServiceImpl added in v0.36.0

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

AgentServiceImpl implements the AgentService interface with direct chat functionality

func NewAgentService added in v0.36.0

func NewAgentService(
	client sdk.Client,
	toolService domain.ToolService,
	config domain.ConfigService,
	conversationRepo domain.ConversationRepository,
	a2aAgentService domain.A2AAgentService,
	messageQueue domain.MessageQueue,
	stateManager domain.StateManager,
	timeoutSeconds int,
	optimizer domain.ConversationOptimizerService,
) *AgentServiceImpl

NewAgentService creates a new agent service with pre-configured client

func (*AgentServiceImpl) CancelRequest added in v0.36.0

func (s *AgentServiceImpl) CancelRequest(requestID string) error

CancelRequest cancels an active request

func (*AgentServiceImpl) GetMetrics added in v0.36.0

func (s *AgentServiceImpl) GetMetrics(requestID string) *domain.ChatMetrics

GetMetrics returns metrics for a completed request

func (*AgentServiceImpl) Run added in v0.36.0

Run executes an agent task synchronously (for background/batch processing)

func (*AgentServiceImpl) RunWithStream added in v0.36.0

func (s *AgentServiceImpl) RunWithStream(ctx context.Context, req *domain.AgentRequest) (<-chan domain.ChatEvent, error)

RunWithStream executes an agent task with streaming (for interactive chat)

type AgentsConfigService added in v0.54.0

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

AgentsConfigService manages the agents.yaml configuration

func NewAgentsConfigService added in v0.54.0

func NewAgentsConfigService(configPath string) *AgentsConfigService

NewAgentsConfigService creates a new agents config service

func (*AgentsConfigService) AddAgent added in v0.54.0

func (s *AgentsConfigService) AddAgent(agent config.AgentEntry) error

AddAgent adds a new agent to the configuration

func (*AgentsConfigService) GetAgent added in v0.54.0

func (s *AgentsConfigService) GetAgent(name string) (*config.AgentEntry, error)

GetAgent returns a specific agent by name

func (*AgentsConfigService) GetAgentURLs added in v0.54.0

func (s *AgentsConfigService) GetAgentURLs() ([]string, error)

GetAgentURLs returns URLs of all configured agents

func (*AgentsConfigService) ListAgents added in v0.54.0

func (s *AgentsConfigService) ListAgents() ([]config.AgentEntry, error)

ListAgents returns all configured agents

func (*AgentsConfigService) Load added in v0.54.0

Load loads the agents configuration from the file

func (*AgentsConfigService) RemoveAgent added in v0.54.0

func (s *AgentsConfigService) RemoveAgent(name string) error

RemoveAgent removes an agent by name

func (*AgentsConfigService) Save added in v0.54.0

Save saves the agents configuration to the file

func (*AgentsConfigService) UpdateAgent added in v0.55.0

func (s *AgentsConfigService) UpdateAgent(agent config.AgentEntry) error

UpdateAgent updates an existing agent in the configuration

type ApprovalArgumentFormatter added in v0.33.5

type ApprovalArgumentFormatter interface {
	FormatArgumentsForApproval(args map[string]any) string
}

ApprovalArgumentFormatter interface for tools that need custom approval argument formatting

type BackgroundJobManager added in v0.46.0

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

BackgroundJobManager manages background tasks

func NewBackgroundJobManager added in v0.46.0

func NewBackgroundJobManager(titleGenerator TitleGenerator, config *config.Config) *BackgroundJobManager

NewBackgroundJobManager creates a new background job manager

func (*BackgroundJobManager) IsRunning added in v0.46.0

func (m *BackgroundJobManager) IsRunning() bool

IsRunning returns whether the job manager is currently running

func (*BackgroundJobManager) Start added in v0.46.0

func (m *BackgroundJobManager) Start(ctx context.Context)

Start begins running background jobs

func (*BackgroundJobManager) Stop added in v0.46.0

func (m *BackgroundJobManager) Stop()

Stop stops all background jobs gracefully

func (*BackgroundJobManager) TriggerTitleGeneration added in v0.46.0

func (m *BackgroundJobManager) TriggerTitleGeneration(ctx context.Context) error

TriggerTitleGeneration manually triggers title generation for pending conversations

type BackgroundShellService added in v0.81.0

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

BackgroundShellService manages background shell execution

func NewBackgroundShellService added in v0.81.0

func NewBackgroundShellService(
	tracker domain.ShellTracker,
	cfg *config.Config,
	eventChannel chan<- domain.ChatEvent,
) *BackgroundShellService

NewBackgroundShellService creates a new background shell service

func (*BackgroundShellService) CancelShell added in v0.81.0

func (s *BackgroundShellService) CancelShell(shellID string) error

CancelShell cancels a running background shell

func (*BackgroundShellService) DetachToBackground added in v0.81.0

func (s *BackgroundShellService) DetachToBackground(
	ctx context.Context,
	cmd *exec.Cmd,
	command string,
	outputBuffer domain.OutputRingBuffer,
) (string, error)

DetachToBackground moves a running command to background

func (*BackgroundShellService) GetAllShells added in v0.81.0

func (s *BackgroundShellService) GetAllShells() []*domain.BackgroundShell

GetAllShells returns all tracked shells

func (*BackgroundShellService) GetShell added in v0.81.0

func (s *BackgroundShellService) GetShell(shellID string) *domain.BackgroundShell

GetShell returns a specific shell by ID

func (*BackgroundShellService) GetShellOutput added in v0.81.0

func (s *BackgroundShellService) GetShellOutput(shellID string, fromOffset int64) (string, int64, domain.ShellState, error)

GetShellOutput retrieves incremental output from a shell

func (*BackgroundShellService) GetShellOutputWithFilter added in v0.81.0

func (s *BackgroundShellService) GetShellOutputWithFilter(shellID string, fromOffset int64, filterPattern string) (string, int64, domain.ShellState, error)

GetShellOutputWithFilter retrieves output with optional regex filtering

func (*BackgroundShellService) GetStats added in v0.81.0

func (s *BackgroundShellService) GetStats() map[string]int

GetStats returns statistics about background shells

func (*BackgroundShellService) RemoveShell added in v0.81.0

func (s *BackgroundShellService) RemoveShell(shellID string) error

RemoveShell removes a shell from tracking

func (*BackgroundShellService) Stop added in v0.81.0

func (s *BackgroundShellService) Stop()

Stop stops the background shell service and cleanup routine

type BackgroundTaskService added in v0.53.3

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

BackgroundTaskService handles background task operations (A2A-specific) Only instantiated when A2A tools are enabled

func NewBackgroundTaskService added in v0.53.3

func NewBackgroundTaskService(taskTracker domain.TaskTracker) *BackgroundTaskService

NewBackgroundTaskService creates a new background task service

func (*BackgroundTaskService) CancelBackgroundTask added in v0.53.3

func (s *BackgroundTaskService) CancelBackgroundTask(taskID string) error

CancelBackgroundTask cancels a background task by task ID

func (*BackgroundTaskService) GetBackgroundTasks added in v0.53.3

func (s *BackgroundTaskService) GetBackgroundTasks() []domain.TaskPollingState

GetBackgroundTasks returns all current background polling tasks

type ConfigService added in v0.41.0

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

ConfigService handles configuration management and reloading

func NewConfigService added in v0.41.0

func NewConfigService(v *viper.Viper, cfg *config.Config) *ConfigService

NewConfigService creates a new config service

func (*ConfigService) GetConfig added in v0.41.0

func (cs *ConfigService) GetConfig() *config.Config

GetConfig returns the current config

func (*ConfigService) Reload added in v0.41.0

func (cs *ConfigService) Reload() (*config.Config, error)

Reload reloads configuration from disk

func (*ConfigService) SetValue added in v0.41.0

func (cs *ConfigService) SetValue(key, value string) error

SetValue sets a configuration value using dot notation and saves it to disk

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) OptimizeMessages added in v0.30.0

func (co *ConversationOptimizer) OptimizeMessages(messages []sdk.Message, force bool) []sdk.Message

OptimizeMessages reduces token usage by intelligently managing conversation history

func (*ConversationOptimizer) OptimizeMessagesWithModel added in v0.48.0

func (co *ConversationOptimizer) OptimizeMessagesWithModel(messages []sdk.Message, currentModel string, force bool) []sdk.Message

OptimizeMessagesWithModel reduces token usage with optional current model for fallback

type ConversationTitleGenerator added in v0.46.0

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

ConversationTitleGenerator generates titles for conversations using AI

func NewConversationTitleGenerator added in v0.46.0

func NewConversationTitleGenerator(client sdk.Client, storage storage.ConversationStorage, config *config.Config) *ConversationTitleGenerator

NewConversationTitleGenerator creates a new conversation title generator

func NewConversationTitleGeneratorWithSDKClient added in v0.46.0

func NewConversationTitleGeneratorWithSDKClient(client domain.SDKClient, storage storage.ConversationStorage, config *config.Config) *ConversationTitleGenerator

NewConversationTitleGeneratorWithSDKClient creates a new conversation title generator with a custom SDKClient (for testing)

func (*ConversationTitleGenerator) GenerateTitleForConversation added in v0.46.0

func (g *ConversationTitleGenerator) GenerateTitleForConversation(ctx context.Context, conversationID string) error

GenerateTitleForConversation generates a title for a specific conversation

func (*ConversationTitleGenerator) InvalidateTitle added in v0.46.0

func (g *ConversationTitleGenerator) InvalidateTitle(ctx context.Context, conversationID string) error

InvalidateTitle marks a conversation title as needing regeneration

func (*ConversationTitleGenerator) ProcessPendingTitles added in v0.46.0

func (g *ConversationTitleGenerator) ProcessPendingTitles(ctx context.Context) error

ProcessPendingTitles processes a batch of conversations that need title generation

type DockerRuntime added in v0.82.0

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

DockerRuntime implements ContainerRuntime interface for Docker

func (*DockerRuntime) CleanupNetwork added in v0.82.0

func (dr *DockerRuntime) CleanupNetwork(ctx context.Context) error

CleanupNetwork removes the session-specific network

func (*DockerRuntime) ContainerExists added in v0.82.0

func (dr *DockerRuntime) ContainerExists(containerIDOrName string) bool

ContainerExists checks if a Docker container exists by ID or name (running or stopped)

func (*DockerRuntime) EnsureNetwork added in v0.82.0

func (dr *DockerRuntime) EnsureNetwork(ctx context.Context) error

EnsureNetwork creates the Docker network if it doesn't exist

func (*DockerRuntime) GetContainerHealth added in v0.82.0

func (dr *DockerRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (domain.HealthStatus, error)

GetContainerHealth returns the health status of a container

func (*DockerRuntime) GetNetworkName added in v0.82.0

func (dr *DockerRuntime) GetNetworkName() string

GetNetworkName returns the session-specific network name

func (*DockerRuntime) ListRunningContainers added in v0.82.0

func (dr *DockerRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]domain.ContainerInfo, error)

ListRunningContainers lists all running containers matching the name filter

func (*DockerRuntime) PullImage added in v0.82.0

func (dr *DockerRuntime) PullImage(ctx context.Context, image string) error

PullImage pulls a Docker image

func (*DockerRuntime) RunContainer added in v0.82.0

func (dr *DockerRuntime) RunContainer(ctx context.Context, opts domain.RunContainerOptions) (string, error)

RunContainer runs a Docker container with the given options

func (*DockerRuntime) StopContainer added in v0.82.0

func (dr *DockerRuntime) StopContainer(ctx context.Context, containerIDOrName string) error

StopContainer stops a Docker container

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 GatewayManager added in v0.54.0

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

GatewayManager manages the lifecycle of the gateway container or binary

func NewGatewayManager added in v0.54.0

func NewGatewayManager(sessionID domain.SessionID, cfg *config.Config, runtime domain.ContainerRuntime) *GatewayManager

NewGatewayManager creates a new gateway manager

func (*GatewayManager) GetGatewayURL added in v0.82.0

func (gm *GatewayManager) GetGatewayURL() string

GetGatewayURL returns the actual gateway URL with the assigned port

func (*GatewayManager) IsRunning added in v0.54.0

func (gm *GatewayManager) IsRunning() bool

IsRunning returns whether the gateway container is running

func (*GatewayManager) Start added in v0.54.0

func (gm *GatewayManager) Start(ctx context.Context) error

Start starts the gateway container or binary if configured to run locally

func (*GatewayManager) Stop added in v0.54.0

func (gm *GatewayManager) Stop(ctx context.Context) error

Stop stops the gateway container or binary

type HTTPModelService

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

HTTPModelService implements ModelService using SDK client

func NewHTTPModelService

func NewHTTPModelService(client sdk.Client) *HTTPModelService

NewHTTPModelService creates a new HTTP-based model service with pre-configured client

func (*HTTPModelService) GetCurrentModel

func (s *HTTPModelService) GetCurrentModel() string

func (*HTTPModelService) IsModelAvailable

func (s *HTTPModelService) IsModelAvailable(modelID string) bool

func (*HTTPModelService) IsVisionModel added in v0.61.0

func (s *HTTPModelService) IsVisionModel(modelID string) bool

IsVisionModel checks if a model supports vision/image input capabilities It uses a hardcoded list of known vision-capable model patterns

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 ImageService added in v0.57.0

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

ImageService handles image operations including file-based image loading and base64 encoding Note: Direct clipboard support requires platform-specific dependencies and is not yet implemented

func NewImageService added in v0.57.0

func NewImageService(cfg *config.Config) *ImageService

NewImageService creates a new image service

func (*ImageService) CreateDataURL added in v0.57.0

func (s *ImageService) CreateDataURL(attachment *domain.ImageAttachment) string

CreateDataURL creates a data URL from an image attachment

func (*ImageService) IsImageFile added in v0.57.0

func (s *ImageService) IsImageFile(filePath string) bool

IsImageFile checks if a file is a supported image format

func (*ImageService) IsImageURL added in v0.72.0

func (s *ImageService) IsImageURL(urlStr string) bool

IsImageURL checks if a string is a valid image URL

func (*ImageService) ReadImageFromBinary added in v0.57.0

func (s *ImageService) ReadImageFromBinary(imageData []byte, filename string) (*domain.ImageAttachment, error)

ReadImageFromBinary reads an image from binary data and returns it as a base64 attachment

func (*ImageService) ReadImageFromFile added in v0.57.0

func (s *ImageService) ReadImageFromFile(filePath string) (*domain.ImageAttachment, error)

ReadImageFromFile reads an image from a file path and returns it as a base64 attachment

func (*ImageService) ReadImageFromURL added in v0.72.0

func (s *ImageService) ReadImageFromURL(imageURL string) (*domain.ImageAttachment, error)

ReadImageFromURL fetches an image from a URL and returns it as a base64 attachment

type InMemoryConversationRepository

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

InMemoryConversationRepository implements ConversationRepository using in-memory storage

func NewInMemoryConversationRepository

func NewInMemoryConversationRepository(formatterService *ToolFormatterService, pricingService domain.PricingService) *InMemoryConversationRepository

NewInMemoryConversationRepository creates a new in-memory conversation repository

func (*InMemoryConversationRepository) AddMessage

func (*InMemoryConversationRepository) AddPendingToolCall added in v0.68.0

func (r *InMemoryConversationRepository) AddPendingToolCall(toolCall sdk.ChatCompletionMessageToolCall, responseChan chan domain.ApprovalAction) error

AddPendingToolCall adds a pending tool call entry that requires approval

func (*InMemoryConversationRepository) AddTokenUsage added in v0.28.0

func (r *InMemoryConversationRepository) AddTokenUsage(model string, inputTokens, outputTokens, totalTokens int) error

AddTokenUsage adds token usage from a single API call to session totals with model tracking. The model parameter is required for cost tracking. Use empty string for unknown models.

func (*InMemoryConversationRepository) Clear

func (*InMemoryConversationRepository) ClearExceptFirstUserMessage added in v0.49.0

func (r *InMemoryConversationRepository) ClearExceptFirstUserMessage() error

func (*InMemoryConversationRepository) Export

func (*InMemoryConversationRepository) FormatToolResultExpanded added in v0.48.0

func (r *InMemoryConversationRepository) FormatToolResultExpanded(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultExpanded formats expanded tool execution results

func (*InMemoryConversationRepository) FormatToolResultForLLM added in v0.48.0

func (r *InMemoryConversationRepository) FormatToolResultForLLM(result *domain.ToolExecutionResult) string

FormatToolResultForLLM formats tool execution results for LLM consumption

func (*InMemoryConversationRepository) FormatToolResultForUI added in v0.48.0

func (r *InMemoryConversationRepository) FormatToolResultForUI(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultForUI formats tool execution results for UI display

func (*InMemoryConversationRepository) GetMessageCount

func (r *InMemoryConversationRepository) GetMessageCount() int

func (*InMemoryConversationRepository) GetMessages

func (*InMemoryConversationRepository) GetSessionCostStats added in v0.86.0

func (r *InMemoryConversationRepository) GetSessionCostStats() domain.SessionCostStats

GetSessionCostStats returns the accumulated cost statistics for the session

func (*InMemoryConversationRepository) GetSessionTokens added in v0.28.0

GetSessionTokens returns the accumulated token statistics for the session

func (*InMemoryConversationRepository) MarkLastMessageAsPlan added in v0.68.0

func (r *InMemoryConversationRepository) MarkLastMessageAsPlan()

MarkLastMessageAsPlan marks the last assistant message as a plan with pending approval

func (*InMemoryConversationRepository) MarkMessageAsPlanByIndex added in v0.76.2

func (r *InMemoryConversationRepository) MarkMessageAsPlanByIndex(index int)

MarkMessageAsPlanByIndex marks a specific message by index as a plan with pending approval

func (*InMemoryConversationRepository) RemovePendingToolCallByID added in v0.68.0

func (r *InMemoryConversationRepository) RemovePendingToolCallByID(toolCallID string)

RemovePendingToolCallByID removes a specific pending tool call by its ID

func (*InMemoryConversationRepository) UpdateLastMessage

func (r *InMemoryConversationRepository) UpdateLastMessage(content string) error

func (*InMemoryConversationRepository) UpdateLastMessageToolCalls

func (r *InMemoryConversationRepository) UpdateLastMessageToolCalls(toolCalls *[]sdk.ChatCompletionMessageToolCall) error

func (*InMemoryConversationRepository) UpdatePlanStatus added in v0.68.0

func (r *InMemoryConversationRepository) UpdatePlanStatus(action domain.PlanApprovalAction)

UpdatePlanStatus updates the status of the most recent pending plan

func (*InMemoryConversationRepository) UpdateToolApprovalStatus added in v0.68.0

func (r *InMemoryConversationRepository) UpdateToolApprovalStatus(action domain.ApprovalAction)

UpdateToolApprovalStatus updates the approval status of the most recent pending tool

type IndexedToolResult added in v0.49.0

type IndexedToolResult struct {
	Index  int
	Result domain.ConversationEntry
}

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

ExecuteTool executes a tool with the given arguments

func (*LLMToolService) ExecuteToolDirect added in v0.68.0

ExecuteToolDirect executes a tool directly without checking if it's enabled Used for user-initiated commands where the user explicitly wants to run the tool

func (*LLMToolService) GetTaskTracker added in v0.53.0

func (s *LLMToolService) GetTaskTracker() domain.TaskTracker

func (*LLMToolService) GetTool added in v0.81.0

func (s *LLMToolService) GetTool(name string) (domain.Tool, error)

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() []sdk.ChatCompletionTool

ListTools returns definitions for all enabled tools

func (*LLMToolService) ListToolsForMode added in v0.56.0

func (s *LLMToolService) ListToolsForMode(mode domain.AgentMode) []sdk.ChatCompletionTool

ListToolsForMode returns definitions for enabled tools filtered by agent mode

func (*LLMToolService) ValidateTool

func (s *LLMToolService) ValidateTool(name string, args map[string]any) error

ValidateTool validates tool arguments

type MCPConfigService added in v0.79.0

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

MCPConfigService manages the mcp.yaml configuration

func NewMCPConfigService added in v0.79.0

func NewMCPConfigService(configPath string) *MCPConfigService

NewMCPConfigService creates a new MCP config service

func (*MCPConfigService) AddServer added in v0.79.0

func (s *MCPConfigService) AddServer(server config.MCPServerEntry) error

AddServer adds a new MCP server to the configuration

func (*MCPConfigService) GetServer added in v0.79.0

func (s *MCPConfigService) GetServer(name string) (*config.MCPServerEntry, error)

GetServer returns a specific MCP server by name

func (*MCPConfigService) ListServers added in v0.79.0

func (s *MCPConfigService) ListServers() ([]config.MCPServerEntry, error)

ListServers returns all configured MCP servers

func (*MCPConfigService) Load added in v0.79.0

func (s *MCPConfigService) Load() (*config.MCPConfig, error)

Load loads the MCP configuration from the file

func (*MCPConfigService) RemoveServer added in v0.79.0

func (s *MCPConfigService) RemoveServer(name string) error

RemoveServer removes an MCP server by name

func (*MCPConfigService) Save added in v0.79.0

func (s *MCPConfigService) Save(cfg *config.MCPConfig) error

Save saves the MCP configuration to the file

func (*MCPConfigService) UpdateServer added in v0.79.0

func (s *MCPConfigService) UpdateServer(server config.MCPServerEntry) error

UpdateServer updates an existing MCP server in the configuration

type MCPManager added in v0.79.0

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

MCPManager manages multiple MCP server connections and their container lifecycle

func NewMCPManager added in v0.79.0

func NewMCPManager(sessionID domain.SessionID, cfg *config.MCPConfig, runtime domain.ContainerRuntime) *MCPManager

NewMCPManager creates a new MCP manager

func (*MCPManager) ClearToolCount added in v0.79.0

func (m *MCPManager) ClearToolCount(serverName string)

ClearToolCount removes the tool count for a specific server

func (*MCPManager) Close added in v0.79.0

func (m *MCPManager) Close() error

Close stops monitoring, stops containers, and cleans up resources

func (*MCPManager) GetClients added in v0.79.0

func (m *MCPManager) GetClients() []domain.MCPClient

GetClients returns a list of MCP clients

func (*MCPManager) GetTotalServers added in v0.79.0

func (m *MCPManager) GetTotalServers() int

GetTotalServers returns the total number of configured MCP servers from config

func (*MCPManager) StartMonitoring added in v0.79.0

func (m *MCPManager) StartMonitoring(ctx context.Context) <-chan domain.MCPServerStatusUpdateEvent

StartMonitoring begins background health monitoring and returns a channel for status updates This method is idempotent - calling it multiple times returns the same channel

func (*MCPManager) StartServer added in v0.80.0

func (m *MCPManager) StartServer(ctx context.Context, server config.MCPServerEntry) error

StartServer starts a single MCP server container

func (*MCPManager) StartServers added in v0.80.0

func (m *MCPManager) StartServers(ctx context.Context) error

StartServers starts all MCP servers that have run=true This method is non-fatal and always returns nil

func (*MCPManager) StopServers added in v0.80.0

func (m *MCPManager) StopServers(ctx context.Context) error

StopServers stops all running MCP server containers

func (*MCPManager) UpdateToolCount added in v0.79.0

func (m *MCPManager) UpdateToolCount(serverName string, count int)

UpdateToolCount updates the tool count for a specific server

type MessageQueueService added in v0.53.0

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

MessageQueueService manages a centralized queue for messages waiting to be processed

func NewMessageQueueService added in v0.53.0

func NewMessageQueueService() *MessageQueueService

NewMessageQueueService creates a new message queue service

func (*MessageQueueService) Clear added in v0.53.0

func (mq *MessageQueueService) Clear()

Clear removes all messages from the queue

func (*MessageQueueService) Dequeue added in v0.53.0

func (mq *MessageQueueService) Dequeue() *domain.QueuedMessage

Dequeue removes and returns the next message from the queue Returns nil if the queue is empty

func (*MessageQueueService) Enqueue added in v0.53.0

func (mq *MessageQueueService) Enqueue(message sdk.Message, requestID string)

Enqueue adds a message to the queue

func (*MessageQueueService) GetAll added in v0.53.0

func (mq *MessageQueueService) GetAll() []domain.QueuedMessage

GetAll returns all messages in the queue without removing them

func (*MessageQueueService) IsEmpty added in v0.53.0

func (mq *MessageQueueService) IsEmpty() bool

IsEmpty returns true if the queue has no messages

func (*MessageQueueService) Peek added in v0.53.0

Peek returns the next message without removing it Returns nil if the queue is empty

func (*MessageQueueService) Size added in v0.53.0

func (mq *MessageQueueService) Size() int

Size returns the number of messages in the queue

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 (*NoOpToolService) ExecuteToolDirect added in v0.68.0

func (*NoOpToolService) GetTaskTracker added in v0.53.0

func (s *NoOpToolService) GetTaskTracker() domain.TaskTracker

func (*NoOpToolService) GetTool added in v0.81.0

func (s *NoOpToolService) GetTool(name string) (domain.Tool, 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() []sdk.ChatCompletionTool

func (*NoOpToolService) ListToolsForMode added in v0.56.0

func (s *NoOpToolService) ListToolsForMode(mode domain.AgentMode) []sdk.ChatCompletionTool

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
	AutoAt     int
	BufferSize int
	Client     sdk.Client
	Config     *config.Config
	Tokenizer  *TokenizerService
}

OptimizerConfig represents configuration for the conversation optimizer

type PersistentConversationRepository added in v0.45.0

type PersistentConversationRepository struct {
	*InMemoryConversationRepository
	// contains filtered or unexported fields
}

PersistentConversationRepository wraps the InMemoryConversationRepository and adds persistence capabilities using a storage backend

func NewPersistentConversationRepository added in v0.45.0

func NewPersistentConversationRepository(formatterService *ToolFormatterService, pricingService domain.PricingService, storageBackend storage.ConversationStorage) *PersistentConversationRepository

NewPersistentConversationRepository creates a new persistent conversation repository

func (*PersistentConversationRepository) AddMessage added in v0.45.0

Override AddMessage to trigger auto-save

func (*PersistentConversationRepository) AddTokenUsage added in v0.45.0

func (r *PersistentConversationRepository) AddTokenUsage(model string, inputTokens, outputTokens, totalTokens int) error

AddTokenUsage wraps the in-memory implementation with persistence and auto-save

func (*PersistentConversationRepository) Clear added in v0.45.0

Override Clear to handle conversation state

func (*PersistentConversationRepository) Close added in v0.45.0

Close closes the storage connection

func (*PersistentConversationRepository) DeleteSavedConversation added in v0.45.0

func (r *PersistentConversationRepository) DeleteSavedConversation(ctx context.Context, conversationID string) error

DeleteSavedConversation deletes a saved conversation

func (*PersistentConversationRepository) GetCurrentConversationID added in v0.45.0

func (r *PersistentConversationRepository) GetCurrentConversationID() string

GetCurrentConversationID returns the current conversation ID

func (*PersistentConversationRepository) GetCurrentConversationMetadata added in v0.45.0

func (r *PersistentConversationRepository) GetCurrentConversationMetadata() storage.ConversationMetadata

GetCurrentConversationMetadata returns the current conversation metadata

func (*PersistentConversationRepository) GetOptimizedMessages added in v0.48.0

func (r *PersistentConversationRepository) GetOptimizedMessages() []sdk.Message

GetOptimizedMessages retrieves the stored optimized conversation messages

func (*PersistentConversationRepository) ListSavedConversations added in v0.45.0

func (r *PersistentConversationRepository) ListSavedConversations(ctx context.Context, limit, offset int) ([]storage.ConversationSummary, error)

ListSavedConversations returns a list of saved conversations

func (*PersistentConversationRepository) LoadConversation added in v0.45.0

func (r *PersistentConversationRepository) LoadConversation(ctx context.Context, conversationID string) error

LoadConversation loads a conversation from persistent storage

func (*PersistentConversationRepository) SaveConversation added in v0.45.0

func (r *PersistentConversationRepository) SaveConversation(ctx context.Context) error

SaveConversation saves the current conversation to persistent storage

func (*PersistentConversationRepository) SetAutoSave added in v0.45.0

func (r *PersistentConversationRepository) SetAutoSave(enabled bool)

SetAutoSave enables or disables automatic saving after each operation

func (*PersistentConversationRepository) SetConversationTags added in v0.45.0

func (r *PersistentConversationRepository) SetConversationTags(tags []string)

SetConversationTags sets tags for the current conversation

func (*PersistentConversationRepository) SetConversationTitle added in v0.45.0

func (r *PersistentConversationRepository) SetConversationTitle(title string)

SetConversationTitle sets the title for the current conversation

func (*PersistentConversationRepository) SetOptimizedMessages added in v0.48.0

func (r *PersistentConversationRepository) SetOptimizedMessages(ctx context.Context, optimizedMessages []sdk.Message) error

SetOptimizedMessages stores the optimized conversation messages

func (*PersistentConversationRepository) SetTaskTracker added in v0.50.0

func (r *PersistentConversationRepository) SetTaskTracker(taskTracker domain.TaskTracker)

SetTaskTracker sets the task tracker for context ID persistence

func (*PersistentConversationRepository) SetTitleGenerator added in v0.46.0

func (r *PersistentConversationRepository) SetTitleGenerator(titleGenerator *ConversationTitleGenerator)

SetTitleGenerator sets the title generator for automatic title invalidation

func (*PersistentConversationRepository) StartNewConversation added in v0.45.0

func (r *PersistentConversationRepository) StartNewConversation(title string) error

StartNewConversation begins a new conversation with a unique ID

type PodmanRuntime added in v0.82.0

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

PodmanRuntime implements ContainerRuntime interface for Podman

func (*PodmanRuntime) CleanupNetwork added in v0.82.0

func (pr *PodmanRuntime) CleanupNetwork(ctx context.Context) error

CleanupNetwork removes the session-specific network

func (*PodmanRuntime) ContainerExists added in v0.82.0

func (pr *PodmanRuntime) ContainerExists(containerIDOrName string) bool

ContainerExists checks if a Podman container exists by ID or name (running or stopped)

func (*PodmanRuntime) EnsureNetwork added in v0.82.0

func (pr *PodmanRuntime) EnsureNetwork(ctx context.Context) error

EnsureNetwork creates the Podman network if it doesn't exist

func (*PodmanRuntime) GetContainerHealth added in v0.82.0

func (pr *PodmanRuntime) GetContainerHealth(ctx context.Context, containerIDOrName string) (domain.HealthStatus, error)

GetContainerHealth returns the health status of a container

func (*PodmanRuntime) GetNetworkName added in v0.82.0

func (pr *PodmanRuntime) GetNetworkName() string

GetNetworkName returns the session-specific network name

func (*PodmanRuntime) ListRunningContainers added in v0.82.0

func (pr *PodmanRuntime) ListRunningContainers(ctx context.Context, nameFilter string) ([]domain.ContainerInfo, error)

ListRunningContainers lists all running containers matching the name filter

func (*PodmanRuntime) PullImage added in v0.82.0

func (pr *PodmanRuntime) PullImage(ctx context.Context, image string) error

PullImage pulls a Podman image

func (*PodmanRuntime) RunContainer added in v0.82.0

func (pr *PodmanRuntime) RunContainer(ctx context.Context, opts domain.RunContainerOptions) (string, error)

RunContainer runs a Podman container with the given options

func (*PodmanRuntime) StopContainer added in v0.82.0

func (pr *PodmanRuntime) StopContainer(ctx context.Context, containerIDOrName string) error

StopContainer stops a Podman container

type PricingServiceImpl added in v0.86.0

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

PricingServiceImpl implements the PricingService interface.

func (*PricingServiceImpl) CalculateCost added in v0.86.0

func (p *PricingServiceImpl) CalculateCost(model string, inputTokens, outputTokens int) (inputCost, outputCost, totalCost float64)

CalculateCost computes the total cost for a given number of input and output tokens. Returns inputCost, outputCost, and totalCost in USD (or configured currency).

func (*PricingServiceImpl) GetInputPrice added in v0.86.0

func (p *PricingServiceImpl) GetInputPrice(model string) float64

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

func (*PricingServiceImpl) GetOutputPrice added in v0.86.0

func (p *PricingServiceImpl) GetOutputPrice(model string) float64

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

type RuntimeType added in v0.82.0

type RuntimeType string

RuntimeType represents the type of container runtime

const (
	RuntimeTypeDocker RuntimeType = "docker"
	RuntimeTypePodman RuntimeType = "podman"
)

type SSEHTTPClientTransport added in v0.80.0

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

SSEHTTPClientTransport implements an SSE-aware HTTP client transport for MCP This handles servers that respond with Server-Sent Events format

func NewSSEHTTPClientTransport added in v0.80.0

func NewSSEHTTPClientTransport(endpoint string) *SSEHTTPClientTransport

NewSSEHTTPClientTransport creates a new SSE-aware HTTP client transport

func (*SSEHTTPClientTransport) Close added in v0.80.0

func (t *SSEHTTPClientTransport) Close() error

Close implements Transport.Close

func (*SSEHTTPClientTransport) Send added in v0.80.0

Send implements Transport.Send

func (*SSEHTTPClientTransport) SetCloseHandler added in v0.80.0

func (t *SSEHTTPClientTransport) SetCloseHandler(handler func())

SetCloseHandler implements Transport.SetCloseHandler

func (*SSEHTTPClientTransport) SetErrorHandler added in v0.80.0

func (t *SSEHTTPClientTransport) SetErrorHandler(handler func(error))

SetErrorHandler implements Transport.SetErrorHandler

func (*SSEHTTPClientTransport) SetMessageHandler added in v0.80.0

func (t *SSEHTTPClientTransport) SetMessageHandler(handler func(ctx context.Context, message *transport.BaseJsonRpcMessage))

SetMessageHandler implements Transport.SetMessageHandler

func (*SSEHTTPClientTransport) Start added in v0.80.0

Start implements Transport.Start

func (*SSEHTTPClientTransport) WithHeader added in v0.80.0

func (t *SSEHTTPClientTransport) WithHeader(key, value string) *SSEHTTPClientTransport

WithHeader adds a header to the request

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) AddQueuedMessage added in v0.53.0

func (sm *StateManager) AddQueuedMessage(message sdk.Message, requestID string)

AddQueuedMessage adds a message to the input queue

func (*StateManager) AreAllAgentsReady added in v0.67.0

func (sm *StateManager) AreAllAgentsReady() bool

AreAllAgentsReady returns true if all agents are ready

func (*StateManager) ClearAgentReadiness added in v0.67.0

func (sm *StateManager) ClearAgentReadiness()

ClearAgentReadiness clears the agent readiness state

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) ClearPlanApprovalUIState added in v0.68.0

func (sm *StateManager) ClearPlanApprovalUIState()

ClearPlanApprovalUIState clears the plan approval UI state

func (*StateManager) ClearQueuedMessages added in v0.53.0

func (sm *StateManager) ClearQueuedMessages()

ClearQueuedMessages clears all queued messages

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) CycleAgentMode added in v0.56.0

func (sm *StateManager) CycleAgentMode() domain.AgentMode

CycleAgentMode cycles to the next agent mode

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) GetAgentMode added in v0.56.0

func (sm *StateManager) GetAgentMode() domain.AgentMode

GetAgentMode returns the current agent mode

func (*StateManager) GetAgentReadiness added in v0.67.0

func (sm *StateManager) GetAgentReadiness() *domain.AgentReadinessState

GetAgentReadiness returns the current agent readiness state

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) GetPlanApprovalUIState added in v0.68.0

func (sm *StateManager) GetPlanApprovalUIState() *domain.PlanApprovalUIState

GetPlanApprovalUIState returns the current plan approval UI state

func (*StateManager) GetPreviousView added in v0.86.0

func (sm *StateManager) GetPreviousView() domain.ViewState

GetPreviousView returns the previous view state

func (*StateManager) GetQueuedMessages added in v0.53.0

func (sm *StateManager) GetQueuedMessages() []domain.QueuedMessage

GetQueuedMessages returns the current queued messages

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) GetTodos added in v0.63.1

func (sm *StateManager) GetTodos() []domain.TodoItem

GetTodos returns the current todo list

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) InitializeAgentReadiness added in v0.67.0

func (sm *StateManager) InitializeAgentReadiness(totalAgents int)

InitializeAgentReadiness initializes the agent readiness tracking

func (*StateManager) IsAgentBusy added in v0.53.0

func (sm *StateManager) IsAgentBusy() bool

IsAgentBusy returns true if the agent is currently processing a request

func (*StateManager) IsDebugMode added in v0.27.0

func (sm *StateManager) IsDebugMode() bool

IsDebugMode returns whether debug mode is enabled

func (*StateManager) PopQueuedMessage added in v0.53.0

func (sm *StateManager) PopQueuedMessage() *domain.QueuedMessage

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

func (*StateManager) RecoverFromInconsistentState added in v0.27.0

func (sm *StateManager) RecoverFromInconsistentState() error

RecoverFromInconsistentState attempts to recover from an inconsistent state

func (*StateManager) RemoveAgent added in v0.67.0

func (sm *StateManager) RemoveAgent(name string)

RemoveAgent removes an agent from the readiness tracking

func (*StateManager) RemoveListener added in v0.27.0

func (sm *StateManager) RemoveListener(listener StateChangeListener)

RemoveListener removes a state change listener

func (*StateManager) SetAgentError added in v0.67.0

func (sm *StateManager) SetAgentError(name string, err error)

SetAgentError sets an error for a specific agent

func (*StateManager) SetAgentMode added in v0.56.0

func (sm *StateManager) SetAgentMode(mode domain.AgentMode)

SetAgentMode sets the agent mode

func (*StateManager) SetApprovalSelectedIndex added in v0.27.0

func (sm *StateManager) SetApprovalSelectedIndex(index int)

SetApprovalSelectedIndex sets the approval selection index

func (*StateManager) SetChatPending added in v0.63.1

func (sm *StateManager) SetChatPending()

SetChatPending marks the agent as busy before the chat actually starts. This prevents race conditions where messages might not be queued between the time we decide to start a chat and when StartChatSession is called.

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) SetPlanApprovalSelectedIndex added in v0.68.0

func (sm *StateManager) SetPlanApprovalSelectedIndex(index int)

SetPlanApprovalSelectedIndex sets the plan approval selection index

func (*StateManager) SetTodos added in v0.63.1

func (sm *StateManager) SetTodos(todos []domain.TodoItem)

SetTodos sets the todo list

func (*StateManager) SetupApprovalUIState added in v0.56.0

func (sm *StateManager) SetupApprovalUIState(toolCall *sdk.ChatCompletionMessageToolCall, responseChan chan domain.ApprovalAction)

SetupApprovalUIState 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) SetupPlanApprovalUIState added in v0.68.0

func (sm *StateManager) SetupPlanApprovalUIState(planContent string, responseChan chan domain.PlanApprovalAction)

SetupPlanApprovalUIState initializes plan approval UI 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) UpdateAgentStatus added in v0.67.0

func (sm *StateManager) UpdateAgentStatus(name string, state domain.AgentState, message string, url string, image string)

UpdateAgentStatus updates the status of a specific agent

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 by delegating to AgentService

func NewStreamingChatService

func NewStreamingChatService(agentService domain.AgentService) *StreamingChatService

NewStreamingChatService creates a new streaming chat service that delegates to AgentService

func (*StreamingChatService) CancelRequest

func (s *StreamingChatService) CancelRequest(requestID string) error

CancelRequest cancels an active request by delegating to AgentService

func (*StreamingChatService) GetMetrics

func (s *StreamingChatService) GetMetrics(requestID string) *domain.ChatMetrics

GetMetrics returns metrics for a completed request by delegating to AgentService

type TaskRetentionService added in v0.53.3

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

TaskRetentionService manages in-memory retention of completed/terminal A2A tasks

func NewTaskRetentionService added in v0.53.3

func NewTaskRetentionService(maxRetention int) *TaskRetentionService

NewTaskRetentionService creates a new task retention service

func (*TaskRetentionService) AddTask added in v0.53.3

func (t *TaskRetentionService) AddTask(task domain.TaskInfo)

AddTask adds a terminal task (completed, failed, canceled, etc.) to retention

func (*TaskRetentionService) Clear added in v0.53.3

func (t *TaskRetentionService) Clear()

Clear removes all retained tasks

func (*TaskRetentionService) GetMaxRetention added in v0.53.3

func (t *TaskRetentionService) GetMaxRetention() int

GetMaxRetention returns the current maximum retention count

func (*TaskRetentionService) GetTasks added in v0.53.3

func (t *TaskRetentionService) GetTasks() []domain.TaskInfo

GetTasks returns all retained tasks

func (*TaskRetentionService) SetMaxRetention added in v0.53.3

func (t *TaskRetentionService) SetMaxRetention(maxRetention int)

SetMaxRetention updates the maximum retention count

type TitleGenerator added in v0.46.0

type TitleGenerator interface {
	ProcessPendingTitles(ctx context.Context) error
}

TitleGenerator interface for conversation title generation

type TokenizerConfig added in v0.64.0

type TokenizerConfig struct {
	// CharsPerToken is the average characters per token (default: 4.0)
	CharsPerToken float64

	// MessageOverhead is tokens per message for formatting (default: 4)
	MessageOverhead int

	// ToolCallOverhead is extra tokens per tool call (default: 10)
	ToolCallOverhead int
}

TokenizerConfig holds configuration for the tokenizer service

func DefaultTokenizerConfig added in v0.64.0

func DefaultTokenizerConfig() TokenizerConfig

DefaultTokenizerConfig returns the default tokenizer configuration

type TokenizerService added in v0.64.0

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

TokenizerService provides token counting functionality for LLM messages. This is a polyfill for providers (like Ollama Cloud) that don't return token usage metrics in their API responses.

func NewTokenizerService added in v0.64.0

func NewTokenizerService(config TokenizerConfig) *TokenizerService

NewTokenizerService creates a new tokenizer service with the given configuration

func (*TokenizerService) AdjustedEstimate added in v0.64.0

func (t *TokenizerService) AdjustedEstimate(text string) int

AdjustedEstimate provides a more accurate estimate for code vs prose

func (*TokenizerService) CalculateUsagePolyfill added in v0.64.0

func (t *TokenizerService) CalculateUsagePolyfill(
	inputMessages []sdk.Message,
	outputContent string,
	outputToolCalls []sdk.ChatCompletionMessageToolCall,
	tools []sdk.ChatCompletionTool,
) *sdk.CompletionUsage

CalculateUsagePolyfill creates a CompletionUsage estimate for providers that don't return usage metrics. This is the main entry point for the polyfill.

func (*TokenizerService) EstimateMessageTokens added in v0.64.0

func (t *TokenizerService) EstimateMessageTokens(msg sdk.Message) int

EstimateMessageTokens estimates the total tokens for a single message

func (*TokenizerService) EstimateMessagesTokens added in v0.64.0

func (t *TokenizerService) EstimateMessagesTokens(messages []sdk.Message) int

EstimateMessagesTokens estimates the total tokens for a slice of messages. This is useful for estimating the prompt/input token count.

func (*TokenizerService) EstimateResponseTokens added in v0.64.0

func (t *TokenizerService) EstimateResponseTokens(response string) int

EstimateResponseTokens estimates the tokens in an LLM response string

func (*TokenizerService) EstimateTokenCount added in v0.64.0

func (t *TokenizerService) EstimateTokenCount(text string) int

EstimateTokenCount estimates the number of tokens in a text string. This uses a character-based heuristic that provides a reasonable approximation for most English text.

func (*TokenizerService) EstimateToolDefinitionsTokens added in v0.64.0

func (t *TokenizerService) EstimateToolDefinitionsTokens(tools []sdk.ChatCompletionTool) int

EstimateToolDefinitionsTokens estimates tokens for tool definitions

func (*TokenizerService) GetToolStats added in v0.81.0

func (t *TokenizerService) GetToolStats(toolService domain.ToolService, agentMode domain.AgentMode) (tokens int, count int)

GetToolStats returns token count and tool count for a given agent mode

func (*TokenizerService) IsLikelyCodeContent added in v0.64.0

func (t *TokenizerService) IsLikelyCodeContent(text string) bool

IsLikelyCodeContent checks if the text appears to be code Code typically has a higher tokens-per-character ratio

func (*TokenizerService) ShouldUsePolyfill added in v0.64.0

func (t *TokenizerService) ShouldUsePolyfill(usage *sdk.CompletionUsage) bool

ShouldUsePolyfill determines if token estimation should be used based on whether the provider returned valid usage metrics

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

func (*ToolFormatterService) ShouldAlwaysExpandTool added in v0.36.0

func (s *ToolFormatterService) ShouldAlwaysExpandTool(toolName string) bool

ShouldAlwaysExpandTool checks if a tool result should always be expanded

type ToolRegistry added in v0.33.4

type ToolRegistry interface {
	GetTool(name string) (domain.Tool, error)
	ListAvailableTools() []string
}

ToolRegistry interface for accessing tools (implemented by tools.Registry)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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