database

package
v0.0.0-...-b3bbcd3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMessages

func ParseMessages(messages []Event) ([]*protocol.Message, error)

func ParseTasks

func ParseTasks(tasks []Task) ([]*protocol.Task, error)

Types

type Agent

type Agent struct {
	ID        string     `json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`

	Type         string                `json:"type"`
	WorkloadType v1alpha2.WorkloadMode `json:"workload_type"`
	Config       *adk.AgentConfig      `json:"config"`
}

type AgentMemorySearchResult

type AgentMemorySearchResult struct {
	Memory
	Score float64 `json:"score"`
}

AgentMemorySearchResult is the result of a vector similarity search over Memory.

type Client

type Client interface {
	// Store methods
	StoreFeedback(ctx context.Context, feedback *Feedback) error
	StoreSession(ctx context.Context, session *Session) error
	StoreAgent(ctx context.Context, agent *Agent) error
	StoreTask(ctx context.Context, task *protocol.Task) error
	StorePushNotification(ctx context.Context, config *protocol.TaskPushNotificationConfig) error
	StoreToolServer(ctx context.Context, toolServer *ToolServer) (*ToolServer, error)
	StoreEvents(ctx context.Context, messages ...*Event) error

	// Delete methods
	DeleteSession(ctx context.Context, sessionID string, userID string) error
	DeleteAgent(ctx context.Context, agentID string) error
	DeleteToolServer(ctx context.Context, serverName string, groupKind string) error
	DeleteTask(ctx context.Context, taskID string) error
	DeletePushNotification(ctx context.Context, taskID string) error
	DeleteToolsForServer(ctx context.Context, serverName string, groupKind string) error

	// Get methods
	GetSession(ctx context.Context, sessionID string, userID string) (*Session, error)
	GetSessionByID(ctx context.Context, sessionID string) (*Session, error)
	GetAgent(ctx context.Context, name string) (*Agent, error)
	GetTask(ctx context.Context, id string) (*protocol.Task, error)
	GetTool(ctx context.Context, name string) (*Tool, error)
	GetToolServer(ctx context.Context, name string) (*ToolServer, error)
	GetPushNotification(ctx context.Context, taskID string, configID string) (*protocol.TaskPushNotificationConfig, error)

	// List methods
	ListTools(ctx context.Context) ([]Tool, error)
	ListFeedback(ctx context.Context, userID string) ([]Feedback, error)
	ListTasksForSession(ctx context.Context, sessionID string) ([]*protocol.Task, error)
	ListSessions(ctx context.Context, userID string) ([]Session, error)
	ListSessionsForAgent(ctx context.Context, agentID string, userID string) ([]Session, error)
	ListSessionsForAgentAllUsers(ctx context.Context, agentID string) ([]Session, error)
	ListAgents(ctx context.Context) ([]Agent, error)
	ListToolServers(ctx context.Context) ([]ToolServer, error)
	ListToolsForServer(ctx context.Context, serverName string, groupKind string) ([]Tool, error)
	ListEventsForSession(ctx context.Context, sessionID, userID string, options QueryOptions) ([]*Event, error)
	ListPushNotifications(ctx context.Context, taskID string) ([]*protocol.TaskPushNotificationConfig, error)

	// Helper methods
	RefreshToolsForServer(ctx context.Context, serverName string, groupKind string, tools ...*v1alpha2.MCPTool) error

	// LangGraph Checkpoint methods
	StoreCheckpoint(ctx context.Context, checkpoint *LangGraphCheckpoint) error
	StoreCheckpointWrites(ctx context.Context, writes []*LangGraphCheckpointWrite) error
	ListCheckpoints(ctx context.Context, userID, threadID, checkpointNS string, checkpointID *string, limit int) ([]*LangGraphCheckpointTuple, error)
	DeleteCheckpoint(ctx context.Context, userID, threadID string) error

	// CrewAI methods
	StoreCrewAIMemory(ctx context.Context, memory *CrewAIAgentMemory) error
	SearchCrewAIMemoryByTask(ctx context.Context, userID, threadID, taskDescription string, limit int) ([]*CrewAIAgentMemory, error)
	ResetCrewAIMemory(ctx context.Context, userID, threadID string) error
	StoreCrewAIFlowState(ctx context.Context, state *CrewAIFlowState) error
	GetCrewAIFlowState(ctx context.Context, userID, threadID string) (*CrewAIFlowState, error)

	// Agent memory (vector search) methods
	StoreAgentMemory(ctx context.Context, memory *Memory) error
	StoreAgentMemories(ctx context.Context, memories []*Memory) error
	SearchAgentMemory(ctx context.Context, agentName, userID string, embedding pgvector.Vector, limit int) ([]AgentMemorySearchResult, error)
	ListAgentMemories(ctx context.Context, agentName, userID string) ([]Memory, error)
	DeleteAgentMemory(ctx context.Context, agentName, userID string) error
	PruneExpiredMemories(ctx context.Context) error
}

type CrewAIAgentMemory

type CrewAIAgentMemory struct {
	UserID     string     `json:"user_id"`
	ThreadID   string     `json:"thread_id"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	DeletedAt  *time.Time `json:"deleted_at,omitempty"`
	MemoryData string     `json:"memory_data"`
}

type CrewAIFlowState

type CrewAIFlowState struct {
	UserID     string     `json:"user_id"`
	ThreadID   string     `json:"thread_id"`
	MethodName string     `json:"method_name"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	DeletedAt  *time.Time `json:"deleted_at,omitempty"`
	StateData  string     `json:"state_data"`
}

type Event

type Event struct {
	ID        string     `json:"id"`
	SessionID string     `json:"session_id"`
	UserID    string     `json:"user_id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`

	Data string `json:"data"` // JSON-serialized protocol.Message
}

func (*Event) Parse

func (m *Event) Parse() (protocol.Message, error)

type Feedback

type Feedback struct {
	ID           int64              `json:"id"`
	CreatedAt    *time.Time         `json:"created_at,omitempty"`
	UpdatedAt    *time.Time         `json:"updated_at,omitempty"`
	DeletedAt    *time.Time         `json:"deleted_at,omitempty"`
	UserID       string             `json:"user_id"`
	MessageID    *int64             `json:"message_id,omitempty"`
	IsPositive   bool               `json:"is_positive"`
	FeedbackText string             `json:"feedback_text"`
	IssueType    *FeedbackIssueType `json:"issue_type,omitempty"`
}

type FeedbackIssueType

type FeedbackIssueType string

FeedbackIssueType represents the category of feedback issue

const (
	FeedbackIssueTypeInstructions FeedbackIssueType = "instructions"
	FeedbackIssueTypeFactual      FeedbackIssueType = "factual"
	FeedbackIssueTypeIncomplete   FeedbackIssueType = "incomplete"
	FeedbackIssueTypeTool         FeedbackIssueType = "tool"
)

type LangGraphCheckpoint

type LangGraphCheckpoint struct {
	UserID             string     `json:"user_id"`
	ThreadID           string     `json:"thread_id"`
	CheckpointNS       string     `json:"checkpoint_ns"`
	CheckpointID       string     `json:"checkpoint_id"`
	ParentCheckpointID *string    `json:"parent_checkpoint_id,omitempty"`
	CreatedAt          time.Time  `json:"created_at"`
	UpdatedAt          time.Time  `json:"updated_at"`
	DeletedAt          *time.Time `json:"deleted_at,omitempty"`
	Metadata           string     `json:"metadata"`
	Checkpoint         string     `json:"checkpoint"`
	CheckpointType     string     `json:"checkpoint_type"`
	Version            int64      `json:"version"`
}

type LangGraphCheckpointTuple

type LangGraphCheckpointTuple struct {
	Checkpoint *LangGraphCheckpoint
	Writes     []*LangGraphCheckpointWrite
}

type LangGraphCheckpointWrite

type LangGraphCheckpointWrite struct {
	UserID       string     `json:"user_id"`
	ThreadID     string     `json:"thread_id"`
	CheckpointNS string     `json:"checkpoint_ns"`
	CheckpointID string     `json:"checkpoint_id"`
	WriteIdx     int64      `json:"write_idx"`
	Value        string     `json:"value"`
	ValueType    string     `json:"value_type"`
	Channel      string     `json:"channel"`
	TaskID       string     `json:"task_id"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	DeletedAt    *time.Time `json:"deleted_at,omitempty"`
}

type Memory

type Memory struct {
	ID          string          `json:"id"`
	AgentName   string          `json:"agent_name"`
	UserID      string          `json:"user_id"`
	Content     string          `json:"content"`
	Embedding   pgvector.Vector `json:"embedding"`
	Metadata    string          `json:"metadata"`
	CreatedAt   time.Time       `json:"created_at"`
	ExpiresAt   *time.Time      `json:"expires_at,omitempty"`
	AccessCount int64           `json:"access_count"`
}

type PushNotification

type PushNotification struct {
	ID        string     `json:"id"`
	TaskID    string     `json:"task_id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	Data      string     `json:"data"` // JSON-serialized push notification config
}

type QueryOptions

type QueryOptions struct {
	Limit    int
	After    time.Time
	OrderAsc bool // When true, order results by created_at ASC (chronological). Default is DESC (newest first).
}

type Session

type Session struct {
	ID        string     `json:"id"`
	Name      *string    `json:"name,omitempty"`
	UserID    string     `json:"user_id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`

	AgentID *string `json:"agent_id,omitempty"`
	// Source indicates how this session was created.
	// SessionSourceUser = user-initiated, SessionSourceAgent = created by a parent agent's A2A call.
	Source *SessionSource `json:"source,omitempty"`
}

type SessionSource

type SessionSource string

SessionSource represents the origin of a session.

const (
	// SessionSourceUser indicates the session was initiated by a user.
	SessionSourceUser SessionSource = "user"
	// SessionSourceAgent indicates the session was created by a parent agent's A2A call.
	SessionSourceAgent SessionSource = "agent"
)

type Task

type Task struct {
	ID        string     `json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	Data      string     `json:"data"` // JSON-serialized task data
	SessionID string     `json:"session_id"`
}

func (*Task) Parse

func (t *Task) Parse() (protocol.Task, error)

type Tool

type Tool struct {
	ID          string     `json:"id"`
	ServerName  string     `json:"server_name"`
	GroupKind   string     `json:"group_kind"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	DeletedAt   *time.Time `json:"deleted_at,omitempty"`
	Description string     `json:"description"`
}

type ToolServer

type ToolServer struct {
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
	DeletedAt     *time.Time `json:"deleted_at,omitempty"`
	Name          string     `json:"name"`
	GroupKind     string     `json:"group_kind"`
	Description   string     `json:"description"`
	LastConnected *time.Time `json:"last_connected,omitempty"`
}

Jump to

Keyboard shortcuts

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