{"modulePath":"github.com/kagent-dev/kagent/go/api","version":"v0.0.0-20260311182216-791b03afc1bc","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package database\n\n## Functions\n\n```go\nfunc ParseMessages(messages []Event) ([]*protocol.Message, error)\n```\n\n```go\nfunc ParseTasks(tasks []Task) ([]*protocol.Task, error)\n```\n\n## Types\n\n```go\ntype Agent struct {\n\tID        string         `gorm:\"primaryKey\" json:\"id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\n\tType string `gorm:\"not null\" json:\"type\"`\n\t// Config is optional and may be nil for some agent types.\n\t// For agent types that require configuration, this field should be populated.\n\t// For agent types that do not require configuration, this field should be nil.\n\tConfig *adk.AgentConfig `gorm:\"type:json\" json:\"config\"`\n}\n```\nAgent represents an agent configuration\n\n```go\nfunc (Agent) TableName() string\n```\nTableName methods to match Python table names\n\n```go\ntype AgentMemorySearchResult struct {\n\tMemory\n\tScore float64 `gorm:\"column:score\" json:\"score\"`\n}\n```\nAgentMemorySearchResult is the result of a vector similarity search over Memory (e.g. SELECT \\*, 1 - (embedding \\\u003c=\u003e ?) as score).\n\n```go\ntype Client interface {\n\t// Store methods\n\tStoreFeedback(feedback *Feedback) error\n\tStoreSession(session *Session) error\n\tStoreAgent(agent *Agent) error\n\tStoreTask(task *protocol.Task) error\n\tStorePushNotification(config *protocol.TaskPushNotificationConfig) error\n\tStoreToolServer(toolServer *ToolServer) (*ToolServer, error)\n\tStoreEvents(messages ...*Event) error\n\n\t// Delete methods\n\tDeleteSession(sessionID string, userID string) error\n\tDeleteAgent(agentID string) error\n\tDeleteToolServer(serverName string, groupKind string) error\n\tDeleteTask(taskID string) error\n\tDeletePushNotification(taskID string) error\n\tDeleteToolsForServer(serverName string, groupKind string) error\n\n\t// Get methods\n\tGetSession(sessionID string, userID string) (*Session, error)\n\tGetAgent(name string) (*Agent, error)\n\tGetTask(id string) (*protocol.Task, error)\n\tGetTool(name string) (*Tool, error)\n\tGetToolServer(name string) (*ToolServer, error)\n\tGetPushNotification(taskID string, configID string) (*protocol.TaskPushNotificationConfig, error)\n\n\t// List methods\n\tListTools() ([]Tool, error)\n\tListFeedback(userID string) ([]Feedback, error)\n\tListTasksForSession(sessionID string) ([]*protocol.Task, error)\n\tListSessions(userID string) ([]Session, error)\n\tListSessionsForAgent(agentID string, userID string) ([]Session, error)\n\tListAgents() ([]Agent, error)\n\tListToolServers() ([]ToolServer, error)\n\tListToolsForServer(serverName string, groupKind string) ([]Tool, error)\n\tListEventsForSession(sessionID, userID string, options QueryOptions) ([]*Event, error)\n\tListPushNotifications(taskID string) ([]*protocol.TaskPushNotificationConfig, error)\n\n\t// Helper methods\n\tRefreshToolsForServer(serverName string, groupKind string, tools ...*v1alpha2.MCPTool) error\n\n\t// LangGraph Checkpoint methods\n\tStoreCheckpoint(checkpoint *LangGraphCheckpoint) error\n\tStoreCheckpointWrites(writes []*LangGraphCheckpointWrite) error\n\tListCheckpoints(userID, threadID, checkpointNS string, checkpointID *string, limit int) ([]*LangGraphCheckpointTuple, error)\n\tDeleteCheckpoint(userID, threadID string) error\n\n\t// CrewAI methods\n\tStoreCrewAIMemory(memory *CrewAIAgentMemory) error\n\tSearchCrewAIMemoryByTask(userID, threadID, taskDescription string, limit int) ([]*CrewAIAgentMemory, error)\n\tResetCrewAIMemory(userID, threadID string) error\n\tStoreCrewAIFlowState(state *CrewAIFlowState) error\n\tGetCrewAIFlowState(userID, threadID string) (*CrewAIFlowState, error)\n\n\t// Agent memory (vector search) methods\n\tStoreAgentMemory(memory *Memory) error\n\tStoreAgentMemories(memories []*Memory) error\n\tSearchAgentMemory(agentName, userID string, embedding pgvector.Vector, limit int) ([]AgentMemorySearchResult, error)\n\tListAgentMemories(agentName, userID string) ([]Memory, error)\n\tDeleteAgentMemory(agentName, userID string) error\n\tPruneExpiredMemories() error\n}\n```\n\n```go\ntype CrewAIAgentMemory struct {\n\tUserID    string         `gorm:\"primaryKey;not null\" json:\"user_id\"`\n\tThreadID  string         `gorm:\"primaryKey;not null\" json:\"thread_id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime;index:idx_crewai_memory_list\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\t// MemoryData contains JSON serialized memory data including task_description, score, metadata, datetime\n\tMemoryData string `gorm:\"type:text;not null\" json:\"memory_data\"`\n}\n```\nCrewAIAgentMemory represents long-term memory for CrewAI agents\n\n```go\nfunc (CrewAIAgentMemory) TableName() string\n```\n\n```go\ntype CrewAIFlowState struct {\n\tUserID     string         `gorm:\"primaryKey;not null\" json:\"user_id\"`\n\tThreadID   string         `gorm:\"primaryKey;not null\" json:\"thread_id\"`\n\tMethodName string         `gorm:\"primaryKey;not null\" json:\"method_name\"`\n\tCreatedAt  time.Time      `gorm:\"autoCreateTime;index:idx_crewai_flow_state_list\" json:\"created_at\"`\n\tUpdatedAt  time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt  gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\t// StateData contains JSON serialized flow state data\n\tStateData string `gorm:\"type:text;not null\" json:\"state_data\"`\n}\n```\nCrewAIFlowState represents flow state for CrewAI flows\n\n```go\nfunc (CrewAIFlowState) TableName() string\n```\n\n```go\ntype Event struct {\n\tID        string         `gorm:\"primaryKey;not null\" json:\"id\"`\n\tSessionID string         `gorm:\"index\" json:\"session_id\"`\n\tUserID    string         `gorm:\"primaryKey;not null\" json:\"user_id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\n\tData string `gorm:\"type:text;not null\" json:\"data\"` // JSON serialized protocol.Message\n}\n```\n\n```go\nfunc (m *Event) Parse() (protocol.Message, error)\n```\n\n```go\nfunc (Event) TableName() string\n```\n\n```go\ntype Feedback struct {\n\tgorm.Model\n\tUserID       string             `gorm:\"not null;index\" json:\"user_id\"`\n\tMessageID    uint               `gorm:\"index;constraint:OnDelete:CASCADE\" json:\"message_id\"`\n\tIsPositive   bool               `gorm:\"default:false\" json:\"is_positive\"`\n\tFeedbackText string             `gorm:\"not null\" json:\"feedback_text\"`\n\tIssueType    *FeedbackIssueType `json:\"issue_type,omitempty\"`\n}\n```\nFeedback represents user feedback on agent responses\n\n```go\nfunc (Feedback) TableName() string\n```\n\n```go\ntype FeedbackIssueType string\n```\nFeedbackIssueType represents the category of feedback issue\n\n```go\nconst (\n\tFeedbackIssueTypeInstructions FeedbackIssueType = \"instructions\" // Did not follow instructions\n\tFeedbackIssueTypeFactual      FeedbackIssueType = \"factual\"      // Not factually correct\n\tFeedbackIssueTypeIncomplete   FeedbackIssueType = \"incomplete\"   // Incomplete response\n\tFeedbackIssueTypeTool         FeedbackIssueType = \"tool\"         // Should have run the tool\n)\n```\n\n```go\ntype LangGraphCheckpoint struct {\n\tUserID             string         `gorm:\"primaryKey;not null\" json:\"user_id\"`\n\tThreadID           string         `gorm:\"primaryKey;not null\" json:\"thread_id\"`\n\tCheckpointNS       string         `gorm:\"primaryKey;not null;default:''\" json:\"checkpoint_ns\"`\n\tCheckpointID       string         `gorm:\"primaryKey;not null\" json:\"checkpoint_id\"`\n\tParentCheckpointID *string        `gorm:\"index\" json:\"parent_checkpoint_id,omitempty\"`\n\tCreatedAt          time.Time      `gorm:\"autoCreateTime;index:idx_lgcp_list\" json:\"created_at\"`\n\tUpdatedAt          time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt          gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\tMetadata           string         `gorm:\"type:text;not null\" json:\"metadata\"`   // JSON serialized metadata\n\tCheckpoint         string         `gorm:\"type:text;not null\" json:\"checkpoint\"` // JSON serialized checkpoint\n\tCheckpointType     string         `gorm:\"not null\" json:\"checkpoint_type\"`\n\tVersion            int            `gorm:\"default:1\" json:\"version\"`\n}\n```\nLangGraphCheckpoint represents a LangGraph checkpoint\n\n```go\nfunc (LangGraphCheckpoint) TableName() string\n```\n\n```go\ntype LangGraphCheckpointTuple struct {\n\tCheckpoint *LangGraphCheckpoint\n\tWrites     []*LangGraphCheckpointWrite\n}\n```\n\n```go\ntype LangGraphCheckpointWrite struct {\n\tUserID       string         `gorm:\"primaryKey;not null\" json:\"user_id\"`\n\tThreadID     string         `gorm:\"primaryKey;not null\" json:\"thread_id\"`\n\tCheckpointNS string         `gorm:\"primaryKey;not null;default:''\" json:\"checkpoint_ns\"`\n\tCheckpointID string         `gorm:\"primaryKey;not null\" json:\"checkpoint_id\"`\n\tWriteIdx     int            `gorm:\"primaryKey;not null\" json:\"write_idx\"`\n\tValue        string         `gorm:\"type:text;not null\" json:\"value\"` // JSON serialized value\n\tValueType    string         `gorm:\"not null\" json:\"value_type\"`\n\tChannel      string         `gorm:\"not null\" json:\"channel\"`\n\tTaskID       string         `gorm:\"not null\" json:\"task_id\"`\n\tCreatedAt    time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt    time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt    gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n}\n```\nLangGraphCheckpointWrite represents a write operation for a checkpoint\n\n```go\nfunc (LangGraphCheckpointWrite) TableName() string\n```\n\n```go\ntype Memory struct {\n\t// ID is a UUID generated by the application layer before insert, ensuring\n\t// compatibility with both Postgres and SQLite/libSQL backends.\n\tID          string          `gorm:\"primaryKey\" json:\"id\"`\n\tAgentName   string          `gorm:\"index:idx_memory_agent_user,composite:agent_name\" json:\"agent_name\"`\n\tUserID      string          `gorm:\"index:idx_memory_agent_user,composite:user_id\" json:\"user_id\"`\n\tContent     string          `gorm:\"type:text\" json:\"content\"`\n\tEmbedding   pgvector.Vector `gorm:\"type:vector(768)\" json:\"embedding\"`\n\tMetadata    string          `gorm:\"type:text\" json:\"metadata\"`\n\tCreatedAt   time.Time       `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tExpiresAt   *time.Time      `gorm:\"index\" json:\"expires_at,omitempty\"`\n\tAccessCount int             `gorm:\"default:0\" json:\"access_count\"`\n}\n```\nMemory represents a memory/session embedding with TTL support\n\n```go\nfunc (m *Memory) BeforeCreate(tx *gorm.DB) error\n```\nBeforeCreate generates a UUID for the Memory ID if one has not been set, making ID generation database-agnostic (works for both Postgres and SQLite).\n\n```go\nfunc (Memory) TableName() string\n```\n\n```go\ntype PushNotification struct {\n\tID        string         `gorm:\"primaryKey;not null\" json:\"id\"`\n\tTaskID    string         `gorm:\"not null;index\" json:\"task_id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\tData      string         `gorm:\"type:text;not null\" json:\"data\"` // JSON serialized push notification config\n}\n```\n\n```go\nfunc (PushNotification) TableName() string\n```\n\n```go\ntype QueryOptions struct {\n\tLimit    int\n\tAfter    time.Time\n\tOrderAsc bool // When true, order results by created_at ASC (chronological). Default is DESC (newest first).\n}\n```\n\n```go\ntype Session struct {\n\tID        string         `gorm:\"primaryKey;not null\" json:\"id\"`\n\tName      *string        `gorm:\"index\" json:\"name,omitempty\"`\n\tUserID    string         `gorm:\"primaryKey\" json:\"user_id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\n\tAgentID *string `gorm:\"index\" json:\"agent_id\"`\n}\n```\n\n```go\nfunc (Session) TableName() string\n```\n\n```go\ntype Task struct {\n\tID        string         `gorm:\"primaryKey;not null\" json:\"id\"`\n\tCreatedAt time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\tData      string         `gorm:\"type:text;not null\" json:\"data\"` // JSON serialized task data\n\tSessionID string         `gorm:\"index\" json:\"session_id\"`\n}\n```\n\n```go\nfunc (t *Task) Parse() (protocol.Task, error)\n```\n\n```go\nfunc (Task) TableName() string\n```\n\n```go\ntype Tool struct {\n\tID          string         `gorm:\"primaryKey;not null\" json:\"id\"`\n\tServerName  string         `gorm:\"primaryKey;not null\" json:\"server_name\"`\n\tGroupKind   string         `gorm:\"primaryKey;not null\" json:\"group_kind\"`\n\tCreatedAt   time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt   time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt   gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\tDescription string         `json:\"description\"`\n}\n```\nTool represents a single tool that can be used by an agent\n\n```go\nfunc (Tool) TableName() string\n```\n\n```go\ntype ToolServer struct {\n\tCreatedAt     time.Time      `gorm:\"autoCreateTime\" json:\"created_at\"`\n\tUpdatedAt     time.Time      `gorm:\"autoUpdateTime\" json:\"updated_at\"`\n\tDeletedAt     gorm.DeletedAt `gorm:\"index\" json:\"deleted_at\"`\n\tName          string         `gorm:\"primaryKey;not null\" json:\"name\"`\n\tGroupKind     string         `gorm:\"primaryKey;not null\" json:\"group_kind\"`\n\tDescription   string         `json:\"description\"`\n\tLastConnected *time.Time     `json:\"last_connected,omitempty\"`\n}\n```\nToolServer represents a tool server that provides tools\n\n```go\nfunc (ToolServer) TableName() string\n```\n\n","path":"github.com/kagent-dev/kagent/go/api/database","name":"database","synopsis":"","isRedistributable":true}
