repo

package
v0.0.0-...-287a3c7 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetAssistantMemoryByIDParams

type GetAssistantMemoryByIDParams struct {
	ID        uuid.UUID
	ProjectID uuid.UUID
}

type GetAssistantMemoryByIDRow

type GetAssistantMemoryByIDRow struct {
	ID             uuid.UUID
	AssistantID    uuid.NullUUID
	ProjectID      uuid.NullUUID
	OrganizationID string
	Content        string
	SupersedesID   uuid.NullUUID
	SupersededAt   pgtype.Timestamptz
	ValidAt        pgtype.Timestamptz
	Tags           []string
	OriginThreadID uuid.NullUUID
	OriginChatID   uuid.NullUUID
	CreatedAt      pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
	LastAccess     pgtype.Timestamptz
	DeletedAt      pgtype.Timestamptz
}

type GetNearestActiveAssistantMemoryParams

type GetNearestActiveAssistantMemoryParams struct {
	QueryEmbedding pgvector_go.HalfVector
	AssistantID    uuid.UUID
}

type GetNearestActiveAssistantMemoryRow

type GetNearestActiveAssistantMemoryRow struct {
	ID         uuid.UUID
	Content    string
	Similarity float64
}

type InsertAssistantMemoryParams

type InsertAssistantMemoryParams struct {
	AssistantID    uuid.UUID
	ProjectID      uuid.UUID
	OrganizationID string
	Content        string
	Embedding      pgvector_go.HalfVector
	Tags           []string
	OriginThreadID uuid.NullUUID
	OriginChatID   uuid.NullUUID
	SupersedesID   uuid.NullUUID
}

type InsertAssistantMemoryRow

type InsertAssistantMemoryRow struct {
	ID        uuid.UUID
	CreatedAt pgtype.Timestamptz
}

type ListAssistantMemoriesForAdminParams

type ListAssistantMemoriesForAdminParams struct {
	AssistantID     uuid.UUID
	ProjectID       uuid.UUID
	Tags            []string
	IncludeDeleted  bool
	CursorCreatedAt pgtype.Timestamptz
	CursorID        uuid.NullUUID
	PageLimit       int32
}

type ListAssistantMemoriesForAdminRow

type ListAssistantMemoriesForAdminRow struct {
	ID             uuid.UUID
	AssistantID    uuid.NullUUID
	ProjectID      uuid.NullUUID
	OrganizationID string
	Content        string
	SupersedesID   uuid.NullUUID
	SupersededAt   pgtype.Timestamptz
	ValidAt        pgtype.Timestamptz
	Tags           []string
	OriginThreadID uuid.NullUUID
	OriginChatID   uuid.NullUUID
	CreatedAt      pgtype.Timestamptz
	UpdatedAt      pgtype.Timestamptz
	LastAccess     pgtype.Timestamptz
	DeletedAt      pgtype.Timestamptz
}

type ListNearestAssistantMemoriesParams

type ListNearestAssistantMemoriesParams struct {
	QueryEmbedding pgvector_go.HalfVector
	AssistantID    uuid.UUID
	Tags           []string
	ResultLimit    int32
}

type ListNearestAssistantMemoriesRow

type ListNearestAssistantMemoriesRow struct {
	ID         uuid.UUID
	Content    string
	Tags       []string
	CreatedAt  pgtype.Timestamptz
	LastAccess pgtype.Timestamptz
	Similarity float64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) BumpAssistantMemoryLastAccess

func (q *Queries) BumpAssistantMemoryLastAccess(ctx context.Context, ids []uuid.UUID) error

func (*Queries) CountActiveAssistantMemories

func (q *Queries) CountActiveAssistantMemories(ctx context.Context, assistantID uuid.UUID) (int64, error)

func (*Queries) GetAssistantMemoryByID

func (q *Queries) GetAssistantMemoryByID(ctx context.Context, arg GetAssistantMemoryByIDParams) (GetAssistantMemoryByIDRow, error)

Fetches a row by id scoped to a project, without a soft-delete filter so the management API can expose deleted rows when include_deleted=true; callers filter in Go. Embedding column is omitted to keep payloads small.

func (*Queries) GetNearestActiveAssistantMemory

Top-1 nearest active memory for an assistant, used by Remember to dedup against the closest existing memory regardless of tag.

func (*Queries) InsertAssistantMemory

func (q *Queries) InsertAssistantMemory(ctx context.Context, arg InsertAssistantMemoryParams) (InsertAssistantMemoryRow, error)

func (*Queries) ListAssistantMemoriesForAdmin

func (q *Queries) ListAssistantMemoriesForAdmin(ctx context.Context, arg ListAssistantMemoriesForAdminParams) ([]ListAssistantMemoriesForAdminRow, error)

Management API listing for an assistant scoped to its project. Returns superseded rows because they are part of the audit trail. Filters:

  • tags overlap (skipped when an empty array is passed)
  • include_deleted=false restricts to live rows

Cursor pagination is keyset on (created_at DESC, id DESC). Embedding column is omitted to keep payloads small.

func (*Queries) ListNearestAssistantMemories

func (q *Queries) ListNearestAssistantMemories(ctx context.Context, arg ListNearestAssistantMemoriesParams) ([]ListNearestAssistantMemoriesRow, error)

Top-K nearest active memories with an optional tag overlap filter. Caller passes an empty array to skip the tag filter; otherwise rows must overlap.

func (*Queries) LockAssistantForMemoryWrite

func (q *Queries) LockAssistantForMemoryWrite(ctx context.Context, assistantID string) error

Acquire a transaction-scoped advisory lock keyed on the assistant ID so Remember/Forget mutations on the same assistant serialize across processes.

func (*Queries) MarkAssistantMemorySuperseded

func (q *Queries) MarkAssistantMemorySuperseded(ctx context.Context, id uuid.UUID) error

func (*Queries) ReapSoftDeletedAssistantMemoriesOlderThan

func (q *Queries) ReapSoftDeletedAssistantMemoriesOlderThan(ctx context.Context, cutoff pgtype.Timestamptz) (int64, error)

Hard-deletes all rows whose deleted_at is older than the cutoff, plus every predecessor reachable via the supersedes_id chain. The recursive CTE walks backwards from each soft-deleted head so historical superseded rows that only existed to support the deleted head also drop on the same schedule.

func (*Queries) SoftDeleteAssistantMemory

func (q *Queries) SoftDeleteAssistantMemory(ctx context.Context, id uuid.UUID) (SoftDeleteAssistantMemoryRow, error)

Returns the deleted row's audit-relevant fields so callers do not need a separate SELECT for the audit log entry.

func (*Queries) SoftDeleteAssistantMemoryByProject

Project-scoped variant for the management API: filters on (id, project_id) so a delete cannot escape the caller's project boundary.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SoftDeleteAssistantMemoryByProjectParams

type SoftDeleteAssistantMemoryByProjectParams struct {
	ID        uuid.UUID
	ProjectID uuid.UUID
}

type SoftDeleteAssistantMemoryByProjectRow

type SoftDeleteAssistantMemoryByProjectRow struct {
	ID             uuid.UUID
	OrganizationID string
	ProjectID      uuid.NullUUID
	AssistantID    uuid.NullUUID
}

type SoftDeleteAssistantMemoryRow

type SoftDeleteAssistantMemoryRow struct {
	ID             uuid.UUID
	OrganizationID string
	ProjectID      uuid.NullUUID
	AssistantID    uuid.NullUUID
}

Jump to

Keyboard shortcuts

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