Documentation
¶
Overview ¶
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
Index ¶
- type AlertInfo
- type Config
- type Handler
- func (h *Handler) AgenticStep(ctx context.Context, req *pb.AgenticStepRequest) (*pb.AgenticStepResponse, error)
- func (h *Handler) AnalyzeIssue(ctx context.Context, req *pb.AnalyzeIssueRequest) (*pb.AnalyzeIssueResponse, error)
- func (h *Handler) DeleteSession(ctx context.Context, req *pb.DeleteSessionRequest) (*pb.DeleteSessionResponse, error)
- func (h *Handler) DownloadPlugin(req *pb.DownloadPluginRequest, stream pb.ChatCLIService_DownloadPluginServer) error
- func (h *Handler) ExecuteRemotePlugin(ctx context.Context, req *pb.ExecuteRemotePluginRequest) (*pb.ExecuteRemotePluginResponse, error)
- func (h *Handler) GetAgentDefinition(ctx context.Context, req *pb.GetAgentDefinitionRequest) (*pb.GetAgentDefinitionResponse, error)
- func (h *Handler) GetAlerts(ctx context.Context, req *pb.GetAlertsRequest) (*pb.GetAlertsResponse, error)
- func (h *Handler) GetServerInfo(ctx context.Context, req *pb.GetServerInfoRequest) (*pb.GetServerInfoResponse, error)
- func (h *Handler) GetSkillContent(ctx context.Context, req *pb.GetSkillContentRequest) (*pb.GetSkillContentResponse, error)
- func (h *Handler) GetWatcherStatus(ctx context.Context, req *pb.GetWatcherStatusRequest) (*pb.GetWatcherStatusResponse, error)
- func (h *Handler) Health(ctx context.Context, req *pb.HealthRequest) (*pb.HealthResponse, error)
- func (h *Handler) InteractiveSession(stream pb.ChatCLIService_InteractiveSessionServer) error
- func (h *Handler) ListRemoteAgents(ctx context.Context, req *pb.ListRemoteAgentsRequest) (*pb.ListRemoteAgentsResponse, error)
- func (h *Handler) ListRemotePlugins(ctx context.Context, req *pb.ListRemotePluginsRequest) (*pb.ListRemotePluginsResponse, error)
- func (h *Handler) ListRemoteSkills(ctx context.Context, req *pb.ListRemoteSkillsRequest) (*pb.ListRemoteSkillsResponse, error)
- func (h *Handler) ListSessions(ctx context.Context, req *pb.ListSessionsRequest) (*pb.ListSessionsResponse, error)
- func (h *Handler) LoadSession(ctx context.Context, req *pb.LoadSessionRequest) (*pb.LoadSessionResponse, error)
- func (h *Handler) SaveSession(ctx context.Context, req *pb.SaveSessionRequest) (*pb.SaveSessionResponse, error)
- func (h *Handler) SendPrompt(ctx context.Context, req *pb.SendPromptRequest) (*pb.SendPromptResponse, error)
- func (h *Handler) SetPersonaLoader(pl *persona.Loader)
- func (h *Handler) SetPluginManager(pm *plugins.Manager)
- func (h *Handler) SetWatcher(cfg WatcherConfig)
- func (h *Handler) SetWatcherContext(fn func() string)
- func (h *Handler) StreamPrompt(req *pb.StreamPromptRequest, stream pb.ChatCLIService_StreamPromptServer) error
- type Server
- type SessionStore
- type SessionStoreV2
- type TokenAuthInterceptor
- type WatcherConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertInfo ¶ added in v1.58.0
type AlertInfo struct {
Type string
Severity string
Message string
Object string
Namespace string
Deployment string
Timestamp time.Time
}
AlertInfo represents a watcher alert exposed to the AIOps operator.
type Config ¶
type Config struct {
Port int
Token string // auth token (empty = no auth)
TLSCertFile string
TLSKeyFile string
Provider string
Model string
EnableReflection bool // enable gRPC reflection (default: false, check CHATCLI_GRPC_REFLECTION env)
MetricsPort int // Prometheus metrics HTTP port (0 = disabled, default: 9090)
}
Config holds server configuration.
type Handler ¶
type Handler struct {
pb.UnimplementedChatCLIServiceServer
// contains filtered or unexported fields
}
Handler implements the ChatCLIService gRPC server.
func NewHandler ¶
func NewHandler(llmMgr manager.LLMManager, sessionStore SessionStore, logger *zap.Logger, provider, model string) *Handler
NewHandler creates a new gRPC handler.
func (*Handler) AgenticStep ¶ added in v1.59.4
func (h *Handler) AgenticStep(ctx context.Context, req *pb.AgenticStepRequest) (*pb.AgenticStepResponse, error)
AgenticStep runs one step of the AI-driven remediation loop.
func (*Handler) AnalyzeIssue ¶ added in v1.58.0
func (h *Handler) AnalyzeIssue(ctx context.Context, req *pb.AnalyzeIssueRequest) (*pb.AnalyzeIssueResponse, error)
AnalyzeIssue uses the LLM to analyze an AIOps issue and return recommendations.
func (*Handler) DeleteSession ¶
func (h *Handler) DeleteSession(ctx context.Context, req *pb.DeleteSessionRequest) (*pb.DeleteSessionResponse, error)
DeleteSession removes a saved session.
func (*Handler) DownloadPlugin ¶ added in v1.60.0
func (h *Handler) DownloadPlugin(req *pb.DownloadPluginRequest, stream pb.ChatCLIService_DownloadPluginServer) error
DownloadPlugin streams the plugin binary to the client.
func (*Handler) ExecuteRemotePlugin ¶ added in v1.60.0
func (h *Handler) ExecuteRemotePlugin(ctx context.Context, req *pb.ExecuteRemotePluginRequest) (*pb.ExecuteRemotePluginResponse, error)
ExecuteRemotePlugin executes a plugin on the server and returns the output.
func (*Handler) GetAgentDefinition ¶ added in v1.60.0
func (h *Handler) GetAgentDefinition(ctx context.Context, req *pb.GetAgentDefinitionRequest) (*pb.GetAgentDefinitionResponse, error)
GetAgentDefinition returns the full definition of a server-side agent.
func (*Handler) GetAlerts ¶ added in v1.58.0
func (h *Handler) GetAlerts(ctx context.Context, req *pb.GetAlertsRequest) (*pb.GetAlertsResponse, error)
GetAlerts returns current watcher alerts for the AIOps operator.
func (*Handler) GetServerInfo ¶
func (h *Handler) GetServerInfo(ctx context.Context, req *pb.GetServerInfoRequest) (*pb.GetServerInfoResponse, error)
GetServerInfo returns server metadata.
func (*Handler) GetSkillContent ¶ added in v1.60.0
func (h *Handler) GetSkillContent(ctx context.Context, req *pb.GetSkillContentRequest) (*pb.GetSkillContentResponse, error)
GetSkillContent returns the full content of a server-side skill.
func (*Handler) GetWatcherStatus ¶
func (h *Handler) GetWatcherStatus(ctx context.Context, req *pb.GetWatcherStatusRequest) (*pb.GetWatcherStatusResponse, error)
GetWatcherStatus returns the K8s watcher status.
func (*Handler) Health ¶
func (h *Handler) Health(ctx context.Context, req *pb.HealthRequest) (*pb.HealthResponse, error)
Health returns the server health status.
func (*Handler) InteractiveSession ¶
func (h *Handler) InteractiveSession(stream pb.ChatCLIService_InteractiveSessionServer) error
InteractiveSession handles bidirectional streaming for interactive mode.
func (*Handler) ListRemoteAgents ¶ added in v1.60.0
func (h *Handler) ListRemoteAgents(ctx context.Context, req *pb.ListRemoteAgentsRequest) (*pb.ListRemoteAgentsResponse, error)
ListRemoteAgents returns all agents available on the server.
func (*Handler) ListRemotePlugins ¶ added in v1.60.0
func (h *Handler) ListRemotePlugins(ctx context.Context, req *pb.ListRemotePluginsRequest) (*pb.ListRemotePluginsResponse, error)
ListRemotePlugins returns all plugins installed on the server.
func (*Handler) ListRemoteSkills ¶ added in v1.60.0
func (h *Handler) ListRemoteSkills(ctx context.Context, req *pb.ListRemoteSkillsRequest) (*pb.ListRemoteSkillsResponse, error)
ListRemoteSkills returns all skills available on the server.
func (*Handler) ListSessions ¶
func (h *Handler) ListSessions(ctx context.Context, req *pb.ListSessionsRequest) (*pb.ListSessionsResponse, error)
ListSessions returns all saved session names.
func (*Handler) LoadSession ¶
func (h *Handler) LoadSession(ctx context.Context, req *pb.LoadSessionRequest) (*pb.LoadSessionResponse, error)
LoadSession loads a saved session.
func (*Handler) SaveSession ¶
func (h *Handler) SaveSession(ctx context.Context, req *pb.SaveSessionRequest) (*pb.SaveSessionResponse, error)
SaveSession saves the conversation history.
func (*Handler) SendPrompt ¶
func (h *Handler) SendPrompt(ctx context.Context, req *pb.SendPromptRequest) (*pb.SendPromptResponse, error)
SendPrompt handles a single prompt request.
func (*Handler) SetPersonaLoader ¶ added in v1.60.0
SetPersonaLoader sets the persona loader for remote agent/skill discovery.
func (*Handler) SetPluginManager ¶ added in v1.60.0
SetPluginManager sets the plugin manager for remote plugin discovery.
func (*Handler) SetWatcher ¶
func (h *Handler) SetWatcher(cfg WatcherConfig)
SetWatcher configures full watcher integration with context, status, and stats.
func (*Handler) SetWatcherContext ¶
SetWatcherContext configures a function that provides K8s watcher context to be prepended to all LLM prompts.
func (*Handler) StreamPrompt ¶
func (h *Handler) StreamPrompt(req *pb.StreamPromptRequest, stream pb.ChatCLIService_StreamPromptServer) error
StreamPrompt handles a streaming prompt request.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the gRPC server and its dependencies.
func New ¶
func New(cfg Config, llmMgr manager.LLMManager, sessionStore SessionStore, logger *zap.Logger) *Server
New creates a new ChatCLI gRPC server.
func (*Server) SetPersonaLoader ¶ added in v1.60.0
SetPersonaLoader configures the persona loader for remote agent/skill discovery.
func (*Server) SetPluginManager ¶ added in v1.60.0
SetPluginManager configures plugin management for remote discovery and execution.
func (*Server) SetWatcher ¶
func (s *Server) SetWatcher(cfg WatcherConfig)
SetWatcher configures full K8s watcher integration with context, status, and stats.
func (*Server) SetWatcherContext ¶
SetWatcherContext configures K8s watcher context injection for all prompts.
type SessionStore ¶
type SessionStore interface {
SaveSession(name string, history []models.Message) error
LoadSession(name string) ([]models.Message, error)
ListSessions() ([]string, error)
DeleteSession(name string) error
}
SessionStore abstracts session persistence for testability.
type SessionStoreV2 ¶ added in v1.65.2
type SessionStoreV2 interface {
SaveSessionV2(name string, sd *models.SessionData) error
LoadSessionV2(name string) (*models.SessionData, error)
}
SessionStoreV2 extends SessionStore with v2 scoped-history support. Implementations that support v2 are detected via type assertion.
type TokenAuthInterceptor ¶
type TokenAuthInterceptor struct {
// contains filtered or unexported fields
}
TokenAuthInterceptor validates Bearer tokens from gRPC metadata.
func NewTokenAuthInterceptor ¶
func NewTokenAuthInterceptor(token string, logger *zap.Logger) *TokenAuthInterceptor
NewTokenAuthInterceptor creates a new auth interceptor. If token is empty, authentication is disabled (all requests allowed).
func (*TokenAuthInterceptor) Stream ¶
func (a *TokenAuthInterceptor) Stream() grpc.StreamServerInterceptor
Stream returns a grpc.StreamServerInterceptor that validates the Bearer token.
func (*TokenAuthInterceptor) Unary ¶
func (a *TokenAuthInterceptor) Unary() grpc.UnaryServerInterceptor
Unary returns a grpc.UnaryServerInterceptor that validates the Bearer token.
type WatcherConfig ¶
type WatcherConfig struct {
ContextFunc func() string // full context for LLM
StatusFunc func() string // compact status summary
StatsFunc func() (alertCount, snapshotCount, podCount int) // numeric stats
AlertsFunc func() []AlertInfo // raw alerts for AIOps operator
Deployment string
Namespace string
}
WatcherConfig holds the functions and metadata for K8s watcher integration.