Help us shape the future of Go! Take the 2026 Go Developer Survey

memory

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

internal/memory/k8s_manager.go

internal/memory/mcp_server.go

internal/memory/mcp_tools.go

internal/memory/memory_store.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	Name         string    `json:"name"`
	EntityType   string    `json:"entityType"`
	Observations []string  `json:"observations"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

Entity represents a named entity in the knowledge graph

type K8sManager

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

K8sManager is a system manager for the memory service

func NewK8sManager

func NewK8sManager(cfg *config.ComposeConfig, k8sClient client.Client, namespace string) *K8sManager

NewK8sManager creates a new system memory manager

func NewManagerFromConfig

func NewManagerFromConfig(cfg *config.ComposeConfig, k8sClient client.Client, namespace string) *K8sManager

Helper function to convert the old Manager interface to the new K8sManager

func (*K8sManager) GetLogs

func (m *K8sManager) GetLogs() (string, error)

GetLogs returns logs from the memory service (placeholder for future implementation)

func (*K8sManager) GetMemoryInfo

func (m *K8sManager) GetMemoryInfo() (*MemoryInfo, error)

GetMemoryInfo returns detailed information about the memory service

func (*K8sManager) Restart

func (m *K8sManager) Restart() error

Restart restarts the memory service

func (*K8sManager) SetConfigFile

func (m *K8sManager) SetConfigFile(configFile string)

SetConfigFile sets the configuration file path

func (*K8sManager) Start

func (m *K8sManager) Start() error

Start starts the memory service using Kubernetes resources

func (*K8sManager) Status

func (m *K8sManager) Status() (string, error)

Status returns the status of the memory service

func (*K8sManager) Stop

func (m *K8sManager) Stop() error

Stop stops the memory service

type KnowledgeGraph

type KnowledgeGraph struct {
	Entities  []Entity   `json:"entities"`
	Relations []Relation `json:"relations"`
}

KnowledgeGraph represents the complete graph structure

type MCPContent

type MCPContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

MCPContent represents MCP content

type MCPError

type MCPError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

MCPError represents an MCP protocol error

type MCPMemoryServer

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

MCPMemoryServer provides HTTP/SSE/WebSocket endpoints for memory MCP tools

func NewMCPMemoryServer

func NewMCPMemoryServer(store *MemoryStore, logger logr.Logger) *MCPMemoryServer

func (*MCPMemoryServer) BroadcastToClients

func (s *MCPMemoryServer) BroadcastToClients(message interface{})

BroadcastToClients sends a message to all connected WebSocket clients

func (*MCPMemoryServer) GetClientIDs

func (s *MCPMemoryServer) GetClientIDs() []string

GetClientIDs returns a list of connected client IDs

func (*MCPMemoryServer) GetServerInfo

func (s *MCPMemoryServer) GetServerInfo() map[string]interface{}

GetServerInfo returns information about the MCP server

func (*MCPMemoryServer) Start

func (s *MCPMemoryServer) Start(host string, port int) error

func (*MCPMemoryServer) Stop

func (s *MCPMemoryServer) Stop() error

type MCPMemoryTools

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

MCPMemoryTools provides MCP protocol tools for memory management

func NewMCPMemoryTools

func NewMCPMemoryTools(store *MemoryStore, logger logr.Logger) *MCPMemoryTools

func (*MCPMemoryTools) ExecuteMCPTool

func (mt *MCPMemoryTools) ExecuteMCPTool(ctx context.Context, toolName string, parameters map[string]interface{}) (map[string]interface{}, error)

ExecuteMCPTool executes an MCP tool with the given parameters

func (*MCPMemoryTools) GetMCPTools

func (mt *MCPMemoryTools) GetMCPTools() []MCPToolDefinition

GetMCPTools returns all available memory MCP tools

type MCPRequest

type MCPRequest struct {
	JSONRPC string                 `json:"jsonrpc"`
	ID      interface{}            `json:"id"`
	Method  string                 `json:"method"`
	Params  map[string]interface{} `json:"params,omitempty"`
}

MCPRequest represents an MCP protocol request

type MCPResponse

type MCPResponse struct {
	JSONRPC string      `json:"jsonrpc"`
	ID      interface{} `json:"id"`
	Result  interface{} `json:"result,omitempty"`
	Error   *MCPError   `json:"error,omitempty"`
}

MCPResponse represents an MCP protocol response

type MCPToolCallRequest

type MCPToolCallRequest struct {
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

MCPToolCallRequest represents a tool call request

type MCPToolCallResponse

type MCPToolCallResponse struct {
	Content []MCPContent `json:"content"`
}

MCPToolCallResponse represents a tool call response

type MCPToolDefinition

type MCPToolDefinition struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"inputSchema"`
}

MCPToolDefinition represents an MCP tool definition for memory

type MCPToolsListResponse

type MCPToolsListResponse struct {
	Tools []MCPToolDefinition `json:"tools"`
}

MCPToolsListResponse represents the response to tools/list

type MemoryInfo

type MemoryInfo struct {
	Status         string   `json:"status"`
	ReadyReplicas  int32    `json:"readyReplicas"`
	TotalReplicas  int32    `json:"totalReplicas"`
	PostgresStatus string   `json:"postgresStatus"`
	Conditions     []string `json:"conditions"`
	Endpoint       string   `json:"endpoint,omitempty"`
}

MemoryInfo represents detailed information about the memory service

type MemoryStore

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

MemoryStore provides PostgreSQL-backed knowledge graph storage

func NewMemoryStore

func NewMemoryStore(databaseURL string, logger logr.Logger) (*MemoryStore, error)

func (*MemoryStore) AddObservations

func (ms *MemoryStore) AddObservations(observations map[string][]string) error

AddObservations adds new observations to existing entities

func (*MemoryStore) Close

func (ms *MemoryStore) Close() error

func (*MemoryStore) CreateEntities

func (ms *MemoryStore) CreateEntities(entities []Entity) error

CreateEntities creates multiple entities in the knowledge graph

func (*MemoryStore) CreateRelations

func (ms *MemoryStore) CreateRelations(relations []Relation) error

CreateRelations creates typed relationships between entities

func (*MemoryStore) DeleteEntities

func (ms *MemoryStore) DeleteEntities(entityNames []string) error

DeleteEntities deletes entities and their associated data

func (*MemoryStore) DeleteObservations

func (ms *MemoryStore) DeleteObservations(deletions map[string][]string) error

DeleteObservations removes specific observations from entities

func (*MemoryStore) DeleteRelations

func (ms *MemoryStore) DeleteRelations(relations []Relation) error

DeleteRelations removes specific relationships

func (*MemoryStore) GetStats

func (ms *MemoryStore) GetStats() (map[string]interface{}, error)

GetStats returns statistics about the knowledge graph

func (*MemoryStore) HealthCheck

func (ms *MemoryStore) HealthCheck() error

HealthCheck verifies database connectivity

func (*MemoryStore) OpenNodes

func (ms *MemoryStore) OpenNodes(names []string) ([]Entity, error)

OpenNodes retrieves specific nodes by their names

func (*MemoryStore) ReadGraph

func (ms *MemoryStore) ReadGraph() (*KnowledgeGraph, error)

ReadGraph retrieves the entire knowledge graph

func (*MemoryStore) SearchNodes

func (ms *MemoryStore) SearchNodes(query string) ([]SearchResult, error)

SearchNodes searches for nodes using full-text search

type Relation

type Relation struct {
	From         string    `json:"from"`
	To           string    `json:"to"`
	RelationType string    `json:"relationType"`
	CreatedAt    time.Time `json:"createdAt"`
}

Relation represents a typed relationship between entities

type SearchResult

type SearchResult struct {
	Entity    Entity   `json:"entity"`
	Relevance float64  `json:"relevance"`
	Matches   []string `json:"matches"`
}

SearchResult represents search results with relevance

Jump to

Keyboard shortcuts

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