handlers

package
v0.0.0-...-b5da06d Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(authorizer auth.Authorizer, r *http.Request, res auth.Resource) *errors.APIError

func CreateSecret

func CreateSecret(kubeClient client.Client, name string, namespace string, data map[string]string) (*corev1.Secret, error)

func DecodeJSONBody

func DecodeJSONBody(r *http.Request, target any) error

DecodeJSONBody decodes a JSON request body into the provided struct

func FlattenStructToMap

func FlattenStructToMap(data any, targetMap map[string]any)

flattenStructToMap uses reflection to add fields of a struct to a map, using json tags as keys.

func GetIntPathParam

func GetIntPathParam(r *http.Request, name string) (int, error)

GetIntPathParam gets an integer path parameter from the request

func GetPathParam

func GetPathParam(r *http.Request, name string) (string, error)

GetPathParam gets a path parameter from the request

func GetPrincipal

func GetPrincipal(r *http.Request) (auth.Principal, error)

func GetUserID

func GetUserID(r *http.Request) (string, error)

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, message string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload any)

Types

type AgentsHandler

type AgentsHandler struct {
	*Base
}

AgentsHandler handles agent-related requests

func NewAgentsHandler

func NewAgentsHandler(base *Base) *AgentsHandler

NewAgentsHandler creates a new AgentsHandler

func (*AgentsHandler) HandleCreateAgent

func (h *AgentsHandler) HandleCreateAgent(w ErrorResponseWriter, r *http.Request)

HandleCreateAgent handles POST /api/agents requests using database

func (*AgentsHandler) HandleDeleteAgent

func (h *AgentsHandler) HandleDeleteAgent(w ErrorResponseWriter, r *http.Request)

HandleDeleteAgent handles DELETE /api/agents/{namespace}/{name} requests using database

func (*AgentsHandler) HandleGetAgent

func (h *AgentsHandler) HandleGetAgent(w ErrorResponseWriter, r *http.Request)

HandleGetAgent handles GET /api/agents/{namespace}/{name} requests using database

func (*AgentsHandler) HandleListAgents

func (h *AgentsHandler) HandleListAgents(w ErrorResponseWriter, r *http.Request)

HandleListAgents handles GET /api/agents requests using database

func (*AgentsHandler) HandleUpdateAgent

func (h *AgentsHandler) HandleUpdateAgent(w ErrorResponseWriter, r *http.Request)

HandleUpdateAgent handles PUT /api/agents/{namespace}/{name} requests using database

type Base

type Base struct {
	KubeClient         client.Client
	DefaultModelConfig types.NamespacedName
	DatabaseService    database.Client
	Authorizer         auth.Authorizer // Interface for authorization checks
	ProxyURL           string
}

Base holds common dependencies for all handlers

type CheckpointsHandler

type CheckpointsHandler struct {
	*Base
}

CheckpointsHandler handles LangGraph checkpoint-related requests

func NewCheckpointsHandler

func NewCheckpointsHandler(base *Base) *CheckpointsHandler

NewCheckpointsHandler creates a new CheckpointsHandler

func (*CheckpointsHandler) HandleDeleteThread

func (h *CheckpointsHandler) HandleDeleteThread(w ErrorResponseWriter, r *http.Request)

HandleDeleteThread handles DELETE /api/langgraph/checkpoints/{thread_id} requests

func (*CheckpointsHandler) HandleListCheckpoints

func (h *CheckpointsHandler) HandleListCheckpoints(w ErrorResponseWriter, r *http.Request)

HandleListCheckpoints handles GET /api/langgraph/checkpoints requests

func (*CheckpointsHandler) HandlePutCheckpoint

func (h *CheckpointsHandler) HandlePutCheckpoint(w ErrorResponseWriter, r *http.Request)

HandlePutCheckpoint handles POST /api/langgraph/checkpoints requests

func (*CheckpointsHandler) HandlePutWrites

func (h *CheckpointsHandler) HandlePutWrites(w ErrorResponseWriter, r *http.Request)

HandlePutWrites handles POST /api/langgraph/checkpoints/writes requests

type CrewAIHandler

type CrewAIHandler struct {
	*Base
}

CrewAIHandler handles CrewAI-related requests

func NewCrewAIHandler

func NewCrewAIHandler(base *Base) *CrewAIHandler

NewCrewAIHandler creates a new CrewAIHandler

func (*CrewAIHandler) HandleGetFlowState

func (h *CrewAIHandler) HandleGetFlowState(w ErrorResponseWriter, r *http.Request)

HandleGetFlowState handles GET /api/crewai/flows/state requests

func (*CrewAIHandler) HandleGetMemory

func (h *CrewAIHandler) HandleGetMemory(w ErrorResponseWriter, r *http.Request)

HandleGetMemory handles GET /api/crewai/memory requests

func (*CrewAIHandler) HandleResetMemory

func (h *CrewAIHandler) HandleResetMemory(w ErrorResponseWriter, r *http.Request)

HandleResetMemory handles DELETE /api/crewai/memory requests

func (*CrewAIHandler) HandleStoreFlowState

func (h *CrewAIHandler) HandleStoreFlowState(w ErrorResponseWriter, r *http.Request)

HandleStoreFlowState handles POST /api/crewai/flows/state requests

func (*CrewAIHandler) HandleStoreMemory

func (h *CrewAIHandler) HandleStoreMemory(w ErrorResponseWriter, r *http.Request)

HandleStoreMemory handles POST /api/crewai/memory requests

type ErrorResponseWriter

type ErrorResponseWriter interface {
	http.ResponseWriter
	RespondWithError(err error)
	Flush()
}

type FeedbackHandler

type FeedbackHandler struct {
	*Base
}

FeedbackHandler handles user feedback submissions

func NewFeedbackHandler

func NewFeedbackHandler(base *Base) *FeedbackHandler

NewFeedbackHandler creates a new feedback handler

func (*FeedbackHandler) HandleCreateFeedback

func (h *FeedbackHandler) HandleCreateFeedback(w ErrorResponseWriter, r *http.Request)

HandleCreateFeedback handles the submission of user feedback and forwards it to the Python backend

func (*FeedbackHandler) HandleListFeedback

func (h *FeedbackHandler) HandleListFeedback(w ErrorResponseWriter, r *http.Request)

type Handlers

type Handlers struct {
	Health          *HealthHandler
	ModelConfig     *ModelConfigHandler
	Model           *ModelHandler
	Provider        *ProviderHandler
	Sessions        *SessionsHandler
	Agents          *AgentsHandler
	Tools           *ToolsHandler
	ToolServers     *ToolServersHandler
	ToolServerTypes *ToolServerTypesHandler
	Memory          *MemoryHandler
	Feedback        *FeedbackHandler
	Namespaces      *NamespacesHandler
	Tasks           *TasksHandler
	Checkpoints     *CheckpointsHandler
	CrewAI          *CrewAIHandler
}

Handlers holds all the HTTP handler components

func NewHandlers

func NewHandlers(kubeClient client.Client, defaultModelConfig types.NamespacedName, dbService database.Client, watchedNamespaces []string, authorizer auth.Authorizer, proxyURL string) *Handlers

NewHandlers creates a new Handlers instance with all handler components

type HealthHandler

type HealthHandler struct{}

HealthHandler handles health check requests

func NewHealthHandler

func NewHealthHandler() *HealthHandler

NewHealthHandler creates a new HealthHandler

func (*HealthHandler) HandleHealth

func (h *HealthHandler) HandleHealth(w http.ResponseWriter, r *http.Request)

HandleHealth handles GET /health requests

type KAgentCheckpointPayload

type KAgentCheckpointPayload struct {
	ThreadID           string  `json:"thread_id"`
	CheckpointNS       string  `json:"checkpoint_ns"`
	CheckpointID       string  `json:"checkpoint_id"`
	ParentCheckpointID *string `json:"parent_checkpoint_id"`
	Checkpoint         string  `json:"checkpoint"`
	Metadata           string  `json:"metadata"`
	Type               string  `json:"type_"`
	Version            int     `json:"version"`
}

KAgentCheckpointPayload represents checkpoint payload data

type KAgentCheckpointTuple

type KAgentCheckpointTuple struct {
	ThreadID           string                        `json:"thread_id"`
	CheckpointNS       string                        `json:"checkpoint_ns"`
	CheckpointID       string                        `json:"checkpoint_id"`
	ParentCheckpointID *string                       `json:"parent_checkpoint_id"`
	Checkpoint         string                        `json:"checkpoint"`
	Metadata           string                        `json:"metadata"`
	Type               string                        `json:"type_"`
	Writes             *KAgentCheckpointWritePayload `json:"writes"`
}

KAgentCheckpointTuple represents a complete checkpoint tuple

type KAgentCheckpointTupleResponse

type KAgentCheckpointTupleResponse struct {
	Data []KAgentCheckpointTuple `json:"data"`
}

KAgentCheckpointTupleResponse represents the response containing checkpoint tuples

type KAgentCheckpointWritePayload

type KAgentCheckpointWritePayload struct {
	ThreadID     string                  `json:"thread_id"`
	CheckpointNS string                  `json:"checkpoint_ns"`
	CheckpointID string                  `json:"checkpoint_id"`
	TaskID       string                  `json:"task_id"`
	Writes       []KagentCheckpointWrite `json:"writes"`
}

KAgentCheckpointWritePayload represents checkpoint write payload data

type KagentCheckpointWrite

type KagentCheckpointWrite struct {
	Idx     int    `json:"idx"`
	Channel string `json:"channel"`
	Type    string `json:"type_"`
	Value   string `json:"value"`
}

KagentCheckpointWrite represents a single checkpoint write operation

type KagentFlowStatePayload

type KagentFlowStatePayload struct {
	ThreadID   string         `json:"thread_id"`
	MethodName string         `json:"method_name"`
	StateData  map[string]any `json:"state_data"`
}

KagentFlowStatePayload represents flow state payload data

type KagentFlowStateResponse

type KagentFlowStateResponse struct {
	Data KagentFlowStatePayload `json:"data"`
}

KagentFlowStateResponse represents flow state response data

type KagentMemoryPayload

type KagentMemoryPayload struct {
	ThreadID   string         `json:"thread_id"`
	UserID     string         `json:"user_id"`
	MemoryData map[string]any `json:"memory_data"`
}

KagentMemoryPayload represents memory payload data from Python

type KagentMemoryResponse

type KagentMemoryResponse struct {
	Data []KagentMemoryPayload `json:"data"`
}

KagentMemoryResponse represents memory response data

type MemoryHandler

type MemoryHandler struct {
	*Base
}

MemoryHandler handles Memory requests

func NewMemoryHandler

func NewMemoryHandler(base *Base) *MemoryHandler

NewMemoryHandler creates a new MemoryHandler

func (*MemoryHandler) HandleCreateMemory

func (h *MemoryHandler) HandleCreateMemory(w ErrorResponseWriter, r *http.Request)

HandleCreateMemory handles POST /api/memories/ requests

func (*MemoryHandler) HandleDeleteMemory

func (h *MemoryHandler) HandleDeleteMemory(w ErrorResponseWriter, r *http.Request)

HandleDeleteMemory handles DELETE /api/memories/{namespace}/{name} requests

func (*MemoryHandler) HandleGetMemory

func (h *MemoryHandler) HandleGetMemory(w ErrorResponseWriter, r *http.Request)

HandleGetMemory handles GET /api/memories/{namespace}/{name} requests

func (*MemoryHandler) HandleListMemories

func (h *MemoryHandler) HandleListMemories(w ErrorResponseWriter, r *http.Request)

HandleListMemories handles GET /api/memories/ requests

func (*MemoryHandler) HandleUpdateMemory

func (h *MemoryHandler) HandleUpdateMemory(w ErrorResponseWriter, r *http.Request)

HandleUpdateMemory handles PUT /api/memories/{namespace}/{name} requests

type ModelConfigHandler

type ModelConfigHandler struct {
	*Base
}

ModelConfigHandler handles ModelConfiguration requests

func NewModelConfigHandler

func NewModelConfigHandler(base *Base) *ModelConfigHandler

NewModelConfigHandler creates a new ModelConfigHandler

func (*ModelConfigHandler) HandleCreateModelConfig

func (h *ModelConfigHandler) HandleCreateModelConfig(w ErrorResponseWriter, r *http.Request)

HandleCreateToolServer handles POST /api/modelconfigs requests

func (*ModelConfigHandler) HandleDeleteModelConfig

func (h *ModelConfigHandler) HandleDeleteModelConfig(w ErrorResponseWriter, r *http.Request)

HandleDeleteModelConfig handles DELETE /api/modelconfigs/{namespace}/{name} requests

func (*ModelConfigHandler) HandleGetModelConfig

func (h *ModelConfigHandler) HandleGetModelConfig(w ErrorResponseWriter, r *http.Request)

HandleGetModelConfig handles GET /api/modelconfigs/{namespace}/{name} requests

func (*ModelConfigHandler) HandleListModelConfigs

func (h *ModelConfigHandler) HandleListModelConfigs(w ErrorResponseWriter, r *http.Request)

HandleListModelConfigs handles GET /api/modelconfigs requests

func (*ModelConfigHandler) HandleUpdateModelConfig

func (h *ModelConfigHandler) HandleUpdateModelConfig(w ErrorResponseWriter, r *http.Request)

HandleUpdateModelConfig handles POST /api/modelconfigs/{namespace}/{name} requests

type ModelHandler

type ModelHandler struct {
	*Base
}

ModelHandler handles model requests

func NewModelHandler

func NewModelHandler(base *Base) *ModelHandler

NewModelHandler creates a new ModelHandler

func (*ModelHandler) HandleListSupportedModels

func (h *ModelHandler) HandleListSupportedModels(w ErrorResponseWriter, r *http.Request)

type NamespacesHandler

type NamespacesHandler struct {
	*Base
	// List of namespaces being watched, empty means watch all. Used for listing namespaces.
	// Can be moved to the base handler if any other handlers need it
	WatchedNamespaces []string
}

NamespacesHandler handles namespace-related requests

func NewNamespacesHandler

func NewNamespacesHandler(base *Base, watchedNamespaces []string) *NamespacesHandler

NewNamespacesHandler creates a new NamespacesHandler

func (*NamespacesHandler) HandleListNamespaces

func (h *NamespacesHandler) HandleListNamespaces(w ErrorResponseWriter, r *http.Request)

HandleListNamespaces returns a list of namespaces based on the watch configuration

type Provider

type Provider struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type ProviderHandler

type ProviderHandler struct {
	*Base
}

ProviderHandler handles provider requests

func NewProviderHandler

func NewProviderHandler(base *Base) *ProviderHandler

NewProviderHandler creates a new ProviderHandler

func (*ProviderHandler) HandleListSupportedMemoryProviders

func (h *ProviderHandler) HandleListSupportedMemoryProviders(w ErrorResponseWriter, r *http.Request)

func (*ProviderHandler) HandleListSupportedModelProviders

func (h *ProviderHandler) HandleListSupportedModelProviders(w ErrorResponseWriter, r *http.Request)

type RunRequest

type RunRequest struct {
	Task string `json:"task"`
}

RunRequest represents a run creation request

type SessionResponse

type SessionResponse struct {
	Session *database.Session `json:"session"`
	Events  []*database.Event `json:"events"`
}

type SessionsHandler

type SessionsHandler struct {
	*Base
}

SessionsHandler handles session-related requests

func NewSessionsHandler

func NewSessionsHandler(base *Base) *SessionsHandler

NewSessionsHandler creates a new SessionsHandler

func (*SessionsHandler) HandleAddEventToSession

func (h *SessionsHandler) HandleAddEventToSession(w ErrorResponseWriter, r *http.Request)

func (*SessionsHandler) HandleCreateSession

func (h *SessionsHandler) HandleCreateSession(w ErrorResponseWriter, r *http.Request)

HandleCreateSession handles POST /api/sessions requests using database

func (*SessionsHandler) HandleDeleteSession

func (h *SessionsHandler) HandleDeleteSession(w ErrorResponseWriter, r *http.Request)

HandleDeleteSession handles DELETE /api/sessions/{session_id} requests using database

func (*SessionsHandler) HandleGetSession

func (h *SessionsHandler) HandleGetSession(w ErrorResponseWriter, r *http.Request)

HandleGetSession handles GET /api/sessions/{session_id} requests using database

func (*SessionsHandler) HandleGetSessionsForAgent

func (h *SessionsHandler) HandleGetSessionsForAgent(w ErrorResponseWriter, r *http.Request)

func (*SessionsHandler) HandleListSessions

func (h *SessionsHandler) HandleListSessions(w ErrorResponseWriter, r *http.Request)

HandleListSessions handles GET /api/sessions requests using database

func (*SessionsHandler) HandleListTasksForSession

func (h *SessionsHandler) HandleListTasksForSession(w ErrorResponseWriter, r *http.Request)

HandleListSessionRuns handles GET /api/sessions/{session_id}/tasks requests using database

func (*SessionsHandler) HandleUpdateSession

func (h *SessionsHandler) HandleUpdateSession(w ErrorResponseWriter, r *http.Request)

HandleUpdateSession handles PUT /api/sessions requests using database

type TasksHandler

type TasksHandler struct {
	*Base
}

TasksHandler handles task-related requests

func NewTasksHandler

func NewTasksHandler(base *Base) *TasksHandler

NewTasksHandler creates a new TasksHandler

func (*TasksHandler) HandleCreateTask

func (h *TasksHandler) HandleCreateTask(w ErrorResponseWriter, r *http.Request)

func (*TasksHandler) HandleDeleteTask

func (h *TasksHandler) HandleDeleteTask(w ErrorResponseWriter, r *http.Request)

func (*TasksHandler) HandleGetTask

func (h *TasksHandler) HandleGetTask(w ErrorResponseWriter, r *http.Request)

type ToolServerCreateRequest

type ToolServerCreateRequest struct {
	// Type specifies which kind of tool server to create
	Type ToolServerType `json:"type"`

	// RemoteMCPServer is used when Type is "RemoteMCPServer"
	RemoteMCPServer *v1alpha2.RemoteMCPServer `json:"remoteMCPServer,omitempty"`

	// MCPServer is used when Type is "MCPServer"
	MCPServer *v1alpha1.MCPServer `json:"mcpServer,omitempty"`
}

ToolServerCreateRequest represents a request to create either a RemoteMCPServer or MCPServer

type ToolServerType

type ToolServerType string

ToolServerType represents the type of tool server to create

const (
	ToolServerTypeRemoteMCPServer ToolServerType = "RemoteMCPServer"
	ToolServerTypeMCPServer       ToolServerType = "MCPServer"
)

type ToolServerTypes

type ToolServerTypes []ToolServerType

func GetSupportedToolServerTypes

func GetSupportedToolServerTypes(cli client.Client) (ToolServerTypes, error)

func (ToolServerTypes) Join

func (t ToolServerTypes) Join(sep string) string

type ToolServerTypesHandler

type ToolServerTypesHandler struct {
	*Base
}

ToolServerTypesHandler handles ToolServerType-related requests

func NewToolServerTypesHandler

func NewToolServerTypesHandler(base *Base) *ToolServerTypesHandler

NewToolServerTypesHandler creates a new ToolServerTypesHandler

func (*ToolServerTypesHandler) HandleListToolServerTypes

func (h *ToolServerTypesHandler) HandleListToolServerTypes(w ErrorResponseWriter, r *http.Request)

HandleListToolServerTypes handles GET /api/toolservertypes requests

type ToolServersHandler

type ToolServersHandler struct {
	*Base
}

ToolServersHandler handles ToolServer-related requests

func NewToolServersHandler

func NewToolServersHandler(base *Base) *ToolServersHandler

NewToolServersHandler creates a new ToolServersHandler

func (*ToolServersHandler) HandleCreateToolServer

func (h *ToolServersHandler) HandleCreateToolServer(w ErrorResponseWriter, r *http.Request)

HandleCreateToolServer handles POST /api/toolservers requests

func (*ToolServersHandler) HandleDeleteToolServer

func (h *ToolServersHandler) HandleDeleteToolServer(w ErrorResponseWriter, r *http.Request)

HandleDeleteToolServer handles DELETE /api/toolservers/{namespace}/{name} requests

func (*ToolServersHandler) HandleListToolServers

func (h *ToolServersHandler) HandleListToolServers(w ErrorResponseWriter, r *http.Request)

HandleListToolServers handles GET /api/toolservers requests

type ToolsHandler

type ToolsHandler struct {
	*Base
}

ToolsHandler handles tool-related requests

func NewToolsHandler

func NewToolsHandler(base *Base) *ToolsHandler

NewToolsHandler creates a new ToolsHandler

func (*ToolsHandler) HandleListTools

func (h *ToolsHandler) HandleListTools(w ErrorResponseWriter, r *http.Request)

HandleListTools handles GET /api/tools requests using database

Jump to

Keyboard shortcuts

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