Add a MemGPT-inspired memory architecture with three tiers: - Working context (hot): always-loaded buffer in system prompt - Recall (warm): scored memory items with FTS5 search - Archival (cold): chunked documents with vector/FTS retrieval Includes: - LibSQL/SQLite delegate with schema auto-migration - SQLC-generated query layer for type-safe DB access - Markdown-aware document chunker with overlap - Cached embedder with LRU for vector operations - Memory interface with pressure-aware offloading
299 lines
7 KiB
Go
299 lines
7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type Querier interface {
|
|
//CountArchivalChunks
|
|
//
|
|
// SELECT COUNT(*)
|
|
// FROM archival_chunks
|
|
CountArchivalChunks(ctx context.Context) (int64, error)
|
|
//CountRecallItems
|
|
//
|
|
// SELECT COUNT(*)
|
|
// FROM recall_items
|
|
// WHERE agent_id = ?1
|
|
// AND (
|
|
// session_key = ?2
|
|
// OR ?2 = ''
|
|
// )
|
|
CountRecallItems(ctx context.Context, arg CountRecallItemsParams) (int64, error)
|
|
//DeleteArchivalChunksByRecall
|
|
//
|
|
// DELETE FROM archival_chunks
|
|
// WHERE recall_id = ?1
|
|
DeleteArchivalChunksByRecall(ctx context.Context, arg DeleteArchivalChunksByRecallParams) error
|
|
//DeleteRecallItem
|
|
//
|
|
// DELETE FROM recall_items
|
|
// WHERE id = ?1
|
|
DeleteRecallItem(ctx context.Context, arg DeleteRecallItemParams) error
|
|
//GetArchivalChunk
|
|
//
|
|
// SELECT id,
|
|
// recall_id,
|
|
// chunk_index,
|
|
// content,
|
|
// embedding,
|
|
// source,
|
|
// hash,
|
|
// created_at
|
|
// FROM archival_chunks
|
|
// WHERE id = ?1
|
|
GetArchivalChunk(ctx context.Context, arg GetArchivalChunkParams) (ArchivalChunk, error)
|
|
//GetArchivalChunksByIDs
|
|
//
|
|
// SELECT id,
|
|
// recall_id,
|
|
// chunk_index,
|
|
// content,
|
|
// embedding,
|
|
// source,
|
|
// hash,
|
|
// created_at
|
|
// FROM archival_chunks
|
|
// WHERE id IN (/*SLICE:ids*/?)
|
|
GetArchivalChunksByIDs(ctx context.Context, arg GetArchivalChunksByIDsParams) ([]ArchivalChunk, error)
|
|
//GetRecallItem
|
|
//
|
|
// SELECT id,
|
|
// agent_id,
|
|
// session_key,
|
|
// role,
|
|
// sector,
|
|
// importance,
|
|
// salience,
|
|
// decay_rate,
|
|
// content,
|
|
// tags,
|
|
// created_at,
|
|
// updated_at
|
|
// FROM recall_items
|
|
// WHERE id = ?1
|
|
GetRecallItem(ctx context.Context, arg GetRecallItemParams) (RecallItem, error)
|
|
//GetRecallItemsByIDs
|
|
//
|
|
// SELECT id,
|
|
// agent_id,
|
|
// session_key,
|
|
// role,
|
|
// sector,
|
|
// importance,
|
|
// salience,
|
|
// decay_rate,
|
|
// content,
|
|
// tags,
|
|
// created_at,
|
|
// updated_at
|
|
// FROM recall_items
|
|
// WHERE id IN (/*SLICE:ids*/?)
|
|
GetRecallItemsByIDs(ctx context.Context, arg GetRecallItemsByIDsParams) ([]RecallItem, error)
|
|
// Working Context queries
|
|
//
|
|
// SELECT agent_id,
|
|
// session_key,
|
|
// content,
|
|
// updated_at
|
|
// FROM working_context
|
|
// WHERE agent_id = ?1
|
|
// AND session_key = ?2
|
|
GetWorkingContext(ctx context.Context, arg GetWorkingContextParams) (WorkingContext, error)
|
|
// Archival Chunk queries
|
|
//
|
|
// INSERT INTO archival_chunks (
|
|
// id,
|
|
// recall_id,
|
|
// chunk_index,
|
|
// content,
|
|
// embedding,
|
|
// source,
|
|
// hash,
|
|
// created_at
|
|
// )
|
|
// VALUES (
|
|
// ?1,
|
|
// ?2,
|
|
// ?3,
|
|
// ?4,
|
|
// ?5,
|
|
// ?6,
|
|
// ?7,
|
|
// datetime('now')
|
|
// )
|
|
InsertArchivalChunk(ctx context.Context, arg InsertArchivalChunkParams) error
|
|
// Recall Item queries
|
|
//
|
|
// INSERT INTO recall_items (
|
|
// id,
|
|
// agent_id,
|
|
// session_key,
|
|
// role,
|
|
// sector,
|
|
// importance,
|
|
// salience,
|
|
// decay_rate,
|
|
// content,
|
|
// tags,
|
|
// created_at,
|
|
// updated_at
|
|
// )
|
|
// VALUES (
|
|
// ?1,
|
|
// ?2,
|
|
// ?3,
|
|
// ?4,
|
|
// ?5,
|
|
// ?6,
|
|
// ?7,
|
|
// ?8,
|
|
// ?9,
|
|
// ?10,
|
|
// datetime('now'),
|
|
// datetime('now')
|
|
// )
|
|
InsertRecallItem(ctx context.Context, arg InsertRecallItemParams) error
|
|
// Memory Summary queries
|
|
//
|
|
// INSERT INTO memory_summaries (
|
|
// id,
|
|
// agent_id,
|
|
// session_key,
|
|
// content,
|
|
// from_msg_idx,
|
|
// to_msg_idx,
|
|
// created_at
|
|
// )
|
|
// VALUES (
|
|
// ?1,
|
|
// ?2,
|
|
// ?3,
|
|
// ?4,
|
|
// ?5,
|
|
// ?6,
|
|
// datetime('now')
|
|
// )
|
|
InsertSummary(ctx context.Context, arg InsertSummaryParams) error
|
|
//ListAllArchivalChunks
|
|
//
|
|
// SELECT id,
|
|
// recall_id,
|
|
// chunk_index,
|
|
// content,
|
|
// embedding,
|
|
// source,
|
|
// hash,
|
|
// created_at
|
|
// FROM archival_chunks
|
|
// ORDER BY created_at DESC
|
|
// LIMIT ?2 OFFSET ?1
|
|
ListAllArchivalChunks(ctx context.Context, arg ListAllArchivalChunksParams) ([]ArchivalChunk, error)
|
|
//ListArchivalChunks
|
|
//
|
|
// SELECT id,
|
|
// recall_id,
|
|
// chunk_index,
|
|
// content,
|
|
// embedding,
|
|
// source,
|
|
// hash,
|
|
// created_at
|
|
// FROM archival_chunks
|
|
// WHERE recall_id = ?1
|
|
// ORDER BY chunk_index
|
|
ListArchivalChunks(ctx context.Context, arg ListArchivalChunksParams) ([]ArchivalChunk, error)
|
|
//ListRecallItems
|
|
//
|
|
// SELECT id,
|
|
// agent_id,
|
|
// session_key,
|
|
// role,
|
|
// sector,
|
|
// importance,
|
|
// salience,
|
|
// decay_rate,
|
|
// content,
|
|
// tags,
|
|
// created_at,
|
|
// updated_at
|
|
// FROM recall_items
|
|
// WHERE agent_id = ?1
|
|
// AND (
|
|
// session_key = ?2
|
|
// OR ?2 = ''
|
|
// )
|
|
// ORDER BY created_at DESC
|
|
// LIMIT ?4 OFFSET ?3
|
|
ListRecallItems(ctx context.Context, arg ListRecallItemsParams) ([]RecallItem, error)
|
|
//ListSummaries
|
|
//
|
|
// SELECT id,
|
|
// agent_id,
|
|
// session_key,
|
|
// content,
|
|
// from_msg_idx,
|
|
// to_msg_idx,
|
|
// created_at
|
|
// FROM memory_summaries
|
|
// WHERE agent_id = ?1
|
|
// AND (
|
|
// session_key = ?2
|
|
// OR ?2 = ''
|
|
// )
|
|
// ORDER BY created_at DESC
|
|
// LIMIT ?3
|
|
ListSummaries(ctx context.Context, arg ListSummariesParams) ([]MemorySummary, error)
|
|
//SearchRecallByKeyword
|
|
//
|
|
// SELECT ri.id,
|
|
// ri.agent_id,
|
|
// ri.session_key,
|
|
// ri.role,
|
|
// ri.sector,
|
|
// ri.importance,
|
|
// ri.salience,
|
|
// ri.decay_rate,
|
|
// ri.content,
|
|
// ri.tags,
|
|
// ri.created_at,
|
|
// ri.updated_at
|
|
// FROM recall_items ri
|
|
// WHERE ri.content LIKE '%' || ?1 || '%'
|
|
// AND ri.agent_id = ?2
|
|
// ORDER BY ri.importance DESC
|
|
// LIMIT ?3
|
|
SearchRecallByKeyword(ctx context.Context, arg SearchRecallByKeywordParams) ([]RecallItem, error)
|
|
//UpdateRecallItem
|
|
//
|
|
// UPDATE recall_items
|
|
// SET role = ?1,
|
|
// sector = ?2,
|
|
// importance = ?3,
|
|
// salience = ?4,
|
|
// decay_rate = ?5,
|
|
// content = ?6,
|
|
// tags = ?7,
|
|
// updated_at = datetime('now')
|
|
// WHERE id = ?8
|
|
UpdateRecallItem(ctx context.Context, arg UpdateRecallItemParams) error
|
|
//UpsertWorkingContext
|
|
//
|
|
// INSERT INTO working_context (agent_id, session_key, content, updated_at)
|
|
// VALUES (
|
|
// ?1,
|
|
// ?2,
|
|
// ?3,
|
|
// datetime('now')
|
|
// ) ON CONFLICT (agent_id, session_key) DO
|
|
// UPDATE
|
|
// SET content = excluded.content,
|
|
// updated_at = excluded.updated_at
|
|
UpsertWorkingContext(ctx context.Context, arg UpsertWorkingContextParams) error
|
|
}
|
|
|
|
var _ Querier = (*Queries)(nil)
|