Documentation
¶
Overview ¶
Package aicommand provides AI-powered command interpretation for the command palette.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotConfigured = fmt.Errorf("AI is not configured — add a Claude API key in Settings > App")
ErrNotConfigured is returned when no API key is set.
var ErrRateLimited = fmt.Errorf("rate limit exceeded, try again in a moment")
ErrRateLimited is returned when the rate limit is exceeded.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType string
ActionType identifies the kind of action the AI determined.
const ( // Read-only actions (execute immediately). ActionSearchMovie ActionType = "search_movie" ActionQueryLibrary ActionType = "query_library" ActionSearchRelease ActionType = "search_releases" ActionExplain ActionType = "explain" ActionFallback ActionType = "fallback" // State-modifying actions (require confirmation). ActionAutoSearch ActionType = "auto_search" ActionRunTask ActionType = "run_task" )
func (ActionType) RequiresConfirmation ¶
func (a ActionType) RequiresConfirmation() bool
RequiresConfirmation returns true for state-modifying actions.
type CommandResponse ¶
type CommandResponse struct {
Action ActionType `json:"action"`
Params map[string]any `json:"params,omitempty"`
Result map[string]any `json:"result,omitempty"`
Explanation string `json:"explanation"`
RequiresConfirm bool `json:"requires_confirmation,omitempty"`
PendingActionID string `json:"pending_action_id,omitempty"`
ConfirmationMessage string `json:"confirmation_message,omitempty"`
}
CommandResponse is the structured response returned to the frontend.
type PendingAction ¶
PendingAction is a state-modifying action awaiting user confirmation.
type PendingStore ¶
type PendingStore struct {
// contains filtered or unexported fields
}
PendingStore holds actions awaiting confirmation. Entries expire after 5 minutes.
func NewPendingStore ¶
func NewPendingStore() *PendingStore
NewPendingStore creates an empty pending action store.
func (*PendingStore) Add ¶
func (s *PendingStore) Add(action ActionType, params map[string]any) string
Add stores a pending action and returns its ID.
func (*PendingStore) Take ¶
func (s *PendingStore) Take(id string) *PendingAction
Take retrieves and removes a pending action. Returns nil if not found or expired.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service orchestrates AI command processing.
func NewService ¶
func NewService(client *anthropic.Client, movieSvc *movie.Service, statsSvc *stats.Service, autoSvc *autosearch.Service, librarySvc *library.Service, qualitySvc *quality.Service, logger *slog.Logger) *Service
NewService creates a new AI command service. The client may be nil; use SetClient to configure it later (e.g. when the user sets an API key at runtime).
func (*Service) ConfirmAction ¶
ConfirmAction executes a previously stored pending action.
func (*Service) ProcessCommand ¶
ProcessCommand interprets a natural language command and returns a structured action.