server

package
v1.65.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 30 Imported by: 0

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

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

DownloadPlugin streams the plugin binary to the client.

func (*Handler) ExecuteRemotePlugin added in v1.60.0

ExecuteRemotePlugin executes a plugin on the server and returns the output.

func (*Handler) GetAgentDefinition added in v1.60.0

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

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

ListRemoteAgents returns all agents available on the server.

func (*Handler) ListRemotePlugins added in v1.60.0

ListRemotePlugins returns all plugins installed on the server.

func (*Handler) ListRemoteSkills added in v1.60.0

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

func (h *Handler) SetPersonaLoader(pl *persona.Loader)

SetPersonaLoader sets the persona loader for remote agent/skill discovery.

func (*Handler) SetPluginManager added in v1.60.0

func (h *Handler) SetPluginManager(pm *plugins.Manager)

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

func (h *Handler) SetWatcherContext(fn func() string)

SetWatcherContext configures a function that provides K8s watcher context to be prepended to all LLM prompts.

func (*Handler) StreamPrompt

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

func (s *Server) SetPersonaLoader(pl *persona.Loader)

SetPersonaLoader configures the persona loader for remote agent/skill discovery.

func (*Server) SetPluginManager added in v1.60.0

func (s *Server) SetPluginManager(pm *plugins.Manager)

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

func (s *Server) SetWatcherContext(fn func() string)

SetWatcherContext configures K8s watcher context injection for all prompts.

func (*Server) Start

func (s *Server) Start() error

Start begins listening and serving gRPC requests. It blocks until the server is stopped via signal or Stop().

func (*Server) Stop

func (s *Server) Stop()

Stop gracefully stops the server.

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

Stream returns a grpc.StreamServerInterceptor that validates the Bearer token.

func (*TokenAuthInterceptor) Unary

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.

Jump to

Keyboard shortcuts

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