repository

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package repository persists sandbox backend configuration.

Every read and write is scoped by tenant_id. Sandbox configs carry provider credentials, so a query that forgets the scope is a cross-workspace credential leak, not merely a bug.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAgentShareNotFound      = errors.New("agent share not found")
	ErrAgentShareAlreadyExists = errors.New("agent already shared to this organization")
)
View Source
var (
	ErrKBShareNotFound      = errors.New("knowledge base share not found")
	ErrKBShareAlreadyExists = errors.New("knowledge base already shared to this organization")
)
View Source
var (
	ErrOrganizationNotFound   = errors.New("organization not found")
	ErrOrgMemberNotFound      = errors.New("organization member not found")
	ErrOrgMemberAlreadyExists = errors.New("member already exists in organization")
	ErrOrgMemberLimitReached  = errors.New("organization member limit reached")
	ErrInviteCodeNotFound     = errors.New("invite code not found")
	ErrInviteCodeExpired      = errors.New("invite code has expired")
)
View Source
var (
	ErrTenantNotFound         = errors.New("tenant not found")
	ErrTenantHasKnowledgeBase = errors.New("tenant has associated knowledge bases")
)
View Source
var (
	// ErrCannotDisableSelf prevents administrators from disabling their own account.
	ErrCannotDisableSelf = errors.New("cannot disable your own account")
	// ErrCannotDisableLastAdmin preserves at least one active system administrator.
	ErrCannotDisableLastAdmin = errors.New("cannot disable the last system administrator")
	// ErrUserNotFound indicates that the requested user does not exist.
	ErrUserNotFound = errors.New("user not found")
	// ErrUserAlreadyExists indicates a duplicate user account.
	ErrUserAlreadyExists = errors.New("user already exists")
	// ErrTokenNotFound indicates that the requested token does not exist.
	ErrTokenNotFound = errors.New("token not found")
	// ErrCannotRevokeSelf prevents administrators from revoking their own role.
	ErrCannotRevokeSelf = errors.New("cannot revoke your own system admin privileges")
	// ErrLastSystemAdmin prevents revoking the last active system administrator's role.
	ErrLastSystemAdmin = errors.New("cannot revoke the last remaining system administrator")
	// ErrUserNotSystemAdmin indicates that the user has no system-admin role to revoke.
	ErrUserNotSystemAdmin = errors.New("user is not a system administrator")
)
View Source
var ErrCatalogVersionConflict = errors.New("model catalog changed; reload and preview again")

ErrCatalogVersionConflict reports a publish based on a stale version.

View Source
var ErrChunkNotFound = errors.New("chunk not found")

ErrChunkNotFound is returned when a chunk lookup finds no row. A typed sentinel (matching the ErrXNotFound convention used by the other repos) so callers can errors.Is it safely through wrapping — replacing the previous bare errors.New("chunk not found") that forced fragile string-equality matching in the service layer.

View Source
var ErrChunkRevisionConflict = errors.New("chunk revision conflict")
View Source
var ErrCustomAgentNotFound = errors.New("custom agent not found")

ErrCustomAgentNotFound is returned when a custom agent is not found

View Source
var ErrJoinRequestNotFound = errors.New("join request not found")
View Source
var ErrKnowledgeBaseNotFound = errors.New("knowledge base not found")
View Source
var ErrKnowledgeNotFound = errors.New("knowledge not found")
View Source
var ErrLastOwner = errors.New("repository: last active owner")

ErrLastOwner is returned by the atomic demote / remove repo helpers when the operation would leave the tenant without an active Owner. The service layer maps this to its own ErrLastOwner sentinel (same semantic; just kept separate so the repo doesn't import service).

View Source
var ErrPendingInvitationExists = errors.New("repository: pending invitation already exists")

ErrPendingInvitationExists is returned by Create when a pending invitation for (tenant_id, invitee_user_id) already exists. The service layer maps it to its own sentinel for the handler.

View Source
var ErrSandboxConfigCordoned = errors.New("sandbox config is being modified by another request")

ErrSandboxConfigCordoned is returned by SetCordon when another request already holds a fresh cordon lease on the same config row.

View Source
var ErrTenantAPIKeyNotFound = errors.New("tenant api key not found")
View Source
var ErrWikiFolderConflict = errors.New("wiki folder name conflict")

ErrWikiFolderConflict is returned when a sibling folder with the same name already exists under the same parent.

View Source
var ErrWikiFolderNotEmpty = errors.New("wiki folder is not empty")

ErrWikiFolderNotEmpty is returned when a folder still has a live page or child folder at the instant an atomic delete is attempted.

View Source
var ErrWikiFolderNotFound = errors.New("wiki folder not found")

ErrWikiFolderNotFound is returned when a wiki folder is not found.

View Source
var ErrWikiIssueNotFound = errors.New("wiki issue not found")

ErrWikiIssueNotFound means no issue with that ID belongs to the knowledge base.

View Source
var ErrWikiPageConflict = errors.New("wiki page version conflict")

ErrWikiPageConflict is returned when an optimistic lock conflict is detected

View Source
var ErrWikiPageNotFound = errors.New("wiki page not found")

ErrWikiPageNotFound is returned when a wiki page is not found

Functions

func NewAgentShareRepository

func NewAgentShareRepository(db *gorm.DB) interfaces.AgentShareRepository

NewAgentShareRepository creates a new agent share repository

func NewAttachmentDescriptionRepository

func NewAttachmentDescriptionRepository(db *gorm.DB, tenantID uint64) attachment.DescriptionCache

NewAttachmentDescriptionRepository binds the observation cache to its owning tenant.

func NewAuditLogRepository

func NewAuditLogRepository(db *gorm.DB) interfaces.AuditLogRepository

NewAuditLogRepository constructs the production audit log repository backed by the shared GORM connection.

func NewAuthTokenRepository

func NewAuthTokenRepository(db *gorm.DB) interfaces.AuthTokenRepository

NewAuthTokenRepository creates a new auth token repository

func NewChunkRepository

func NewChunkRepository(db *gorm.DB) interfaces.ChunkRepository

NewChunkRepository creates a new chunk repository

func NewCustomAgentRepository

func NewCustomAgentRepository(db *gorm.DB) interfaces.CustomAgentRepository

NewCustomAgentRepository creates a new custom agent repository

func NewDataSourceRepository

func NewDataSourceRepository(db *gorm.DB) interfaces.DataSourceRepository

NewDataSourceRepository creates a new data source repository

func NewEmbedChannelRepository

func NewEmbedChannelRepository(db *gorm.DB) interfaces.EmbedChannelRepository

func NewKBShareRepository

func NewKBShareRepository(db *gorm.DB) interfaces.KBShareRepository

NewKBShareRepository creates a new knowledge base share repository

func NewKnowledgeBaseRepository

func NewKnowledgeBaseRepository(db *gorm.DB) interfaces.KnowledgeBaseRepository

NewKnowledgeBaseRepository creates a new knowledge base repository

func NewKnowledgeRepository

func NewKnowledgeRepository(db *gorm.DB) interfaces.KnowledgeRepository

NewKnowledgeRepository creates a new knowledge repository

func NewKnowledgeTagRepository

func NewKnowledgeTagRepository(db *gorm.DB) interfaces.KnowledgeTagRepository

NewKnowledgeTagRepository creates a new tag repository.

func NewMCPEndpointRepository

func NewMCPEndpointRepository(db *gorm.DB) interfaces.MCPEndpointRepository

NewMCPEndpointRepository creates a GORM-backed MCP endpoint repository.

func NewMCPOAuthRepository

func NewMCPOAuthRepository(db *gorm.DB) interfaces.MCPOAuthRepository

NewMCPOAuthRepository creates a new MCP OAuth repository.

func NewMCPServiceRepository

func NewMCPServiceRepository(db *gorm.DB) interfaces.MCPServiceRepository

NewMCPServiceRepository creates a new MCP service repository

func NewMCPToolApprovalRepository

func NewMCPToolApprovalRepository(db *gorm.DB) interfaces.MCPToolApprovalRepository

NewMCPToolApprovalRepository creates a repository backed by GORM.

func NewMemoryRepository

func NewMemoryRepository(db *gorm.DB) interfaces.MemoryRepository

NewMemoryRepository creates the long-term memory repository.

func NewMessageRepository

func NewMessageRepository(db *gorm.DB) interfaces.MessageRepository

NewMessageRepository creates a new message repository

func NewMessageSuggestionRepository

func NewMessageSuggestionRepository(db *gorm.DB) interfaces.MessageSuggestionRepository

func NewModelRepository

func NewModelRepository(db *gorm.DB) interfaces.ModelRepository

NewModelRepository creates a new model repository

func NewOrganizationRepository

func NewOrganizationRepository(db *gorm.DB) interfaces.OrganizationRepository

NewOrganizationRepository creates a new organization repository

func NewResourceRepository

func NewResourceRepository(db *gorm.DB) interfaces.ResourceRepository

NewResourceRepository creates the persistence adapter for resource metadata.

func NewSessionRepository

func NewSessionRepository(db *gorm.DB) interfaces.SessionRepository

NewSessionRepository creates a new session repository instance

func NewStorageBackendRepository

func NewStorageBackendRepository(db *gorm.DB) interfaces.StorageBackendRepository

func NewSyncLogRepository

func NewSyncLogRepository(db *gorm.DB) interfaces.SyncLogRepository

NewSyncLogRepository creates a new sync log repository

func NewSystemSettingRepository

func NewSystemSettingRepository(db *gorm.DB) interfaces.SystemSettingRepository

NewSystemSettingRepository wires the repo into the dig container. Receives the shared *gorm.DB; no other deps.

func NewTaskDeadLetterRepository

func NewTaskDeadLetterRepository(db *gorm.DB) interfaces.TaskDeadLetterRepository

NewTaskDeadLetterRepository constructs a GORM-backed implementation.

func NewTaskPendingOpsRepository

func NewTaskPendingOpsRepository(db *gorm.DB) interfaces.TaskPendingOpsRepository

NewTaskPendingOpsRepository constructs a GORM-backed implementation.

func NewTemporaryDocumentRepository

func NewTemporaryDocumentRepository(db *gorm.DB) interfaces.TemporaryDocumentRepository

func NewTenantAPIKeyRepository

func NewTenantAPIKeyRepository(db *gorm.DB) interfaces.TenantAPIKeyRepository

func NewTenantDisabledSharedAgentRepository

func NewTenantDisabledSharedAgentRepository(db *gorm.DB) interfaces.TenantDisabledSharedAgentRepository

NewTenantDisabledSharedAgentRepository creates a new repository

func NewTenantInvitationRepository

func NewTenantInvitationRepository(db *gorm.DB) interfaces.TenantInvitationRepository

NewTenantInvitationRepository constructs the repo against db. Wired up via the dig container alongside other repositories.

func NewTenantMemberRepository

func NewTenantMemberRepository(db *gorm.DB) interfaces.TenantMemberRepository

NewTenantMemberRepository creates a new tenant member repository.

func NewTenantRepository

func NewTenantRepository(db *gorm.DB) interfaces.TenantRepository

NewTenantRepository creates a new tenant repository

func NewUserRepository

func NewUserRepository(db *gorm.DB) interfaces.UserRepository

NewUserRepository creates a new user repository

func NewUserResourceFavoriteRepository

func NewUserResourceFavoriteRepository(db *gorm.DB) interfaces.UserResourceFavoriteRepository

NewUserResourceFavoriteRepository constructs the GORM-backed implementation.

func NewVectorStoreRepository

func NewVectorStoreRepository(db *gorm.DB) interfaces.VectorStoreRepository

NewVectorStoreRepository creates a new vector store repository

func NewWebSearchProviderRepository

func NewWebSearchProviderRepository(db *gorm.DB) interfaces.WebSearchProviderRepository

NewWebSearchProviderRepository creates a new web search provider repository

func NewWikiPageRepository

func NewWikiPageRepository(db *gorm.DB) interfaces.WikiPageRepository

NewWikiPageRepository creates a new wiki page repository

func ParseAggregateTime

func ParseAggregateTime(s string) (time.Time, bool)

ParseAggregateTime parses a timestamp read back through an SQL aggregate, in the formats Postgres and SQLite emit.

Types

type DataSourceRepository

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

DataSourceRepository provides data access for data sources

func (*DataSourceRepository) Create

Create inserts a new data source record

func (*DataSourceRepository) Delete

func (r *DataSourceRepository) Delete(ctx context.Context, id string) error

Delete performs a soft delete

func (*DataSourceRepository) FindActive

func (r *DataSourceRepository) FindActive(ctx context.Context) ([]*types.DataSource, error)

FindActive retrieves all active data sources (used for scheduling)

func (*DataSourceRepository) FindByID

func (r *DataSourceRepository) FindByID(ctx context.Context, id string) (*types.DataSource, error)

FindByID retrieves a data source by ID

func (*DataSourceRepository) FindByKnowledgeBase

func (r *DataSourceRepository) FindByKnowledgeBase(ctx context.Context, kbID string) ([]*types.DataSource, error)

FindByKnowledgeBase lists all data sources for a knowledge base

func (*DataSourceRepository) Update

Update updates an existing data source

func (*DataSourceRepository) UpdateSyncState

func (r *DataSourceRepository) UpdateSyncState(ctx context.Context, ds *types.DataSource) error

UpdateSyncState updates only fields managed by sync execution. GORM's Updates(struct) skips zero values, so use a map here to persist cleared error messages without broadening the generic Update method.

type KnowledgeSpanRepository

type KnowledgeSpanRepository interface {
	Upsert(ctx context.Context, row *types.KnowledgeProcessingSpan) error
	NextAttempt(ctx context.Context, knowledgeID string) (int, error)
	LatestAttempt(ctx context.Context, knowledgeID string) (int, error)
	ListByAttempt(ctx context.Context, knowledgeID string, attempt int) ([]types.KnowledgeProcessingSpan, error)
	GetSpan(ctx context.Context, knowledgeID string, attempt int, spanID string) (*types.KnowledgeProcessingSpan, error)
	// CancelDescendants marks every descendant of a parent span as
	// "cancelled" with the given reason. Used by the tracker to
	// cascade an upstream failure across a stage's downstream subtree
	// without iterating in Go memory.
	CancelDescendants(ctx context.Context, knowledgeID string, attempt int, parentSpanID, reason string) (int64, error)
	// CancelAllOpenSpans flips every non-terminal (pending/running) span
	// for (knowledgeID, attempt) to "cancelled" in one statement,
	// regardless of tree position. Used by the user-cancel path where
	// fan-out stages (e.g. "多模态识别") flip themselves to done as soon
	// as they finish dispatching, while their async children are still
	// running — a tree walk that stops at terminal parents would miss
	// those orphan leaves.
	CancelAllOpenSpans(ctx context.Context, knowledgeID string, attempt int, errorCode, reason string) (int64, error)
	// CancelOpenSpansBeforeAttempt flips every pending/running span belonging to
	// an attempt strictly older than `attempt` to cancelled. Reparse calls it so a
	// superseded attempt cannot leave a "running" root behind.
	CancelOpenSpansBeforeAttempt(
		ctx context.Context, knowledgeID string, attempt int, errorCode, reason string,
	) (int64, error)
	// CancelOpenSpansByName flips pending/running rows with the given span
	// name for (knowledgeID, attempt). Used before re-opening a subspan
	// after asynq retry or server restart so the trace tree does not
	// accumulate duplicate postprocess.summary / question rows.
	CancelOpenSpansByName(ctx context.Context, knowledgeID string, attempt int, name, errorCode, reason string) (int64, error)
	// LastActivity returns each knowledge's most recent span write, across
	// attempts. Knowledge without spans is absent from the map.
	LastActivity(ctx context.Context, knowledgeIDs []string) (map[string]time.Time, error)
}

KnowledgeSpanRepository persists the per-attempt span tree used by the processing pipeline. Operations are deliberately narrow:

  • Upsert covers Begin/End/Fail/Skip — every state transition routes through the same write so the row stays internally consistent.
  • NextAttempt allocates a new attempt for re-parses without touching historical rows. Old attempts stay queryable for post-mortem.
  • ListByAttempt is the only read path; the handler builds the tree in memory rather than recursing through the DB.

func NewKnowledgeSpanRepository

func NewKnowledgeSpanRepository(db *gorm.DB) KnowledgeSpanRepository

NewKnowledgeSpanRepository wires the GORM-backed implementation.

type MCPToolApprovalRepository

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

MCPToolApprovalRepository implements interfaces.MCPToolApprovalRepository.

func (*MCPToolApprovalRepository) IsEnabled

func (r *MCPToolApprovalRepository) IsEnabled(ctx context.Context, tenantID uint64, serviceID, toolName string) (bool, error)

IsEnabled returns true when a tool has no stored policy row. This preserves the historical behaviour for tools discovered before per-tool settings.

func (*MCPToolApprovalRepository) IsRequired

func (r *MCPToolApprovalRepository) IsRequired(ctx context.Context, tenantID uint64, serviceID, toolName string) (bool, error)

IsRequired returns true when a row exists with require_approval = true.

func (*MCPToolApprovalRepository) ListByService

func (r *MCPToolApprovalRepository) ListByService(ctx context.Context, tenantID uint64, serviceID string) ([]*types.MCPToolApproval, error)

ListByService returns all stored approval rows for an MCP service (may be empty).

func (*MCPToolApprovalRepository) UpsertPolicy

func (r *MCPToolApprovalRepository) UpsertPolicy(
	ctx context.Context, tenantID uint64, serviceID, toolName string, patch types.MCPToolPolicyPatch,
) error

UpsertPolicy creates or updates only the supplied policy columns. Concurrent patches of different fields cannot clobber each other because ON CONFLICT updates omit unchanged columns. A first insert uses require_approval=false and enabled=true for any field the patch omits.

type ModelCatalogRepository

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

ModelCatalogRepository stores the singleton console overlay row.

func NewModelCatalogRepository

func NewModelCatalogRepository(db *gorm.DB) *ModelCatalogRepository

NewModelCatalogRepository creates a repository on db.

func (*ModelCatalogRepository) Get

Get loads the overlay row, including its bounded history.

func (*ModelCatalogRepository) Save

Save replaces the row only if it is still at the expected version.

func (*ModelCatalogRepository) Version

func (r *ModelCatalogRepository) Version(ctx context.Context) (uint64, error)

Version avoids transferring the bounded configuration history on every poll.

type SyncLogRepository

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

SyncLogRepository provides data access for sync logs

func (*SyncLogRepository) CancelPendingByDataSource

func (r *SyncLogRepository) CancelPendingByDataSource(ctx context.Context, dsID string) error

CancelPendingByDataSource marks all non-terminal sync logs for a data source as canceled.

func (*SyncLogRepository) CleanupOldLogs

func (r *SyncLogRepository) CleanupOldLogs(ctx context.Context, retentionDays int) error

CleanupOldLogs deletes sync logs older than the retention period

func (*SyncLogRepository) Create

func (r *SyncLogRepository) Create(ctx context.Context, log *types.SyncLog) error

Create inserts a new sync log entry

func (*SyncLogRepository) FindByDataSource

func (r *SyncLogRepository) FindByDataSource(ctx context.Context, dsID string, limit int, offset int) ([]*types.SyncLog, error)

FindByDataSource lists sync logs for a data source with pagination

func (*SyncLogRepository) FindByID

func (r *SyncLogRepository) FindByID(ctx context.Context, id string) (*types.SyncLog, error)

FindByID retrieves a sync log by ID

func (*SyncLogRepository) FindLatest

func (r *SyncLogRepository) FindLatest(ctx context.Context, dsID string) (*types.SyncLog, error)

FindLatest retrieves the most recent sync log for a data source

func (*SyncLogRepository) HasRunningSync

func (r *SyncLogRepository) HasRunningSync(ctx context.Context, dsID string) (bool, error)

HasRunningSync checks if a data source has any sync currently in "running" status.

func (*SyncLogRepository) Update

func (r *SyncLogRepository) Update(ctx context.Context, log *types.SyncLog) error

Update updates an existing sync log entry

func (*SyncLogRepository) UpdateResult

func (r *SyncLogRepository) UpdateResult(ctx context.Context, log *types.SyncLog) error

UpdateResult updates only fields produced by sync execution. Use an explicit map so empty error messages are written when a later sync succeeds.

type TenantSandboxConfigRepository

type TenantSandboxConfigRepository interface {
	Create(ctx context.Context, e *types.TenantSandboxConfigEntity) error
	GetByID(ctx context.Context, tenantID uint64, id string) (*types.TenantSandboxConfigEntity, error)
	ListByTenant(ctx context.Context, tenantID uint64) ([]*types.TenantSandboxConfigEntity, error)
	// ListAll is the housekeeping scan. Unlike every other method it is not
	// tenant-scoped: the stuck-run reaper and snapshot reconcile have to walk
	// every workspace. Do not use it on a request path.
	ListAll(ctx context.Context) ([]*types.TenantSandboxConfigEntity, error)
	Update(ctx context.Context, e *types.TenantSandboxConfigEntity) error
	SoftDelete(ctx context.Context, tenantID uint64, id string) error
	SetCordon(ctx context.Context, tenantID uint64, id string, at time.Time) error
	ClearCordon(ctx context.Context, tenantID uint64, id string) error
}

TenantSandboxConfigRepository persists named sandbox backend configs.

func NewTenantSandboxConfigRepository

func NewTenantSandboxConfigRepository(db *gorm.DB) TenantSandboxConfigRepository

NewTenantSandboxConfigRepository returns a GORM-backed implementation.

type TenantSkillRepository

type TenantSkillRepository interface {
	// CreateSkill inserts a metadata projection row before provider-side image work starts.
	CreateSkill(ctx context.Context, e *types.TenantSkillEntity) error
	// GetSkill returns nil (no error) when the skill does not exist or belongs
	// to another workspace/config, so callers can render a 404 directly.
	GetSkill(ctx context.Context, tenantID uint64, configID, skillID string) (*types.TenantSkillEntity, error)
	// GetSkillByName scopes lookup by config because skill names are only unique within a config.
	GetSkillByName(ctx context.Context, tenantID uint64, configID, name string) (*types.TenantSkillEntity, error)
	// ListSkillsByConfig returns the installed skill projection for one sandbox config.
	ListSkillsByConfig(ctx context.Context, tenantID uint64, configID string) ([]*types.TenantSkillEntity, error)
	// ListSkillsByTenant spans every sandbox config of one workspace, for the
	// views that are about the user rather than about a config.
	ListSkillsByTenant(ctx context.Context, tenantID uint64) ([]*types.TenantSkillEntity, error)
	// UpdateSkill writes the mutable projection fields after install/remove
	// state changes. It never touches envs; see the implementation.
	UpdateSkill(ctx context.Context, e *types.TenantSkillEntity) error
	// UpdateSkillEnvs writes the declared environment variables alone.
	UpdateSkillEnvs(
		ctx context.Context, tenantID uint64, configID, skillID string, envs types.SkillEnvVars,
	) error
	// UpdateSkillAdminState writes visibility and declared values together, as
	// one admin request.
	UpdateSkillAdminState(
		ctx context.Context,
		tenantID uint64,
		configID, skillID string,
		enabled bool,
		envs types.SkillEnvVars,
	) error
	// DeleteSkill soft-deletes the metadata row and, in the same transaction,
	// hard-deletes the per-principal env values hanging off it. Image cleanup is
	// represented by snapshots. When the scoped key matches no skill, nothing is
	// deleted and the call succeeds.
	DeleteSkill(ctx context.Context, tenantID uint64, configID, skillID string) error
	// ListStaleInstalling finds abandoned install/remove runs for the reaper.
	ListStaleInstalling(ctx context.Context, olderThan time.Time) ([]*types.TenantSkillEntity, error)

	// CreateSnapshotRow records provider work before creating the billable snapshot.
	CreateSnapshotRow(ctx context.Context, e *types.TenantSkillSnapshotEntity) error
	// MarkSnapshotState updates ledger state and stores the provider snapshot ID once known.
	MarkSnapshotState(ctx context.Context, tenantID uint64, id, state, snapshotID string) error
	// ListSnapshotsByConfig returns the full chain for audit and troubleshooting.
	ListSnapshotsByConfig(ctx context.Context, tenantID uint64, configID string) ([]*types.TenantSkillSnapshotEntity, error)
	// DeleteSnapshotRowsByConfig removes ledger rows only when an entire sandbox
	// config is deleted and its provider-side snapshots are already gone; never
	// call this during an ordinary image switch (old snapshots stay in the ledger).
	DeleteSnapshotRowsByConfig(ctx context.Context, tenantID uint64, configID string) error

	// ListUserEnvVars returns one principal's own values for one scope,
	// decrypted. An empty skillID selects the config-wide variables.
	ListUserEnvVars(
		ctx context.Context, tenantID uint64, p types.Principal, configID, skillID string,
	) ([]*types.TenantUserEnvVar, error)
	// ListUserEnvVarsByConfig returns every scope at once, for the settings
	// page that renders a whole config in one go.
	ListUserEnvVarsByConfig(
		ctx context.Context, tenantID uint64, p types.Principal, configID string,
	) ([]*types.TenantUserEnvVar, error)
	// UpsertUserEnvVar writes a principal's value, replacing any previous one
	// for the same (tenant, principal, config, skill, name).
	UpsertUserEnvVar(ctx context.Context, e *types.TenantUserEnvVar) error
	// DeleteUserEnvVar removes one value, returning types.ErrEnvVarNotFound
	// when there was nothing to remove.
	DeleteUserEnvVar(
		ctx context.Context, tenantID uint64, p types.Principal, configID, skillID, name string,
	) error
	// DeleteUserEnvVarsByConfig removes every principal's values for a config,
	// including the config-wide ones DeleteSkill never sees.
	DeleteUserEnvVarsByConfig(ctx context.Context, tenantID uint64, configID string) error

	// CreateCatalog inserts a tenant-level skill definition.
	CreateCatalog(ctx context.Context, e *types.TenantSkillCatalogEntity) error
	// GetCatalog returns nil when the row is missing or belongs to another workspace.
	GetCatalog(ctx context.Context, tenantID uint64, catalogID string) (*types.TenantSkillCatalogEntity, error)
	// GetCatalogByName scopes lookup by workspace because names are unique per tenant.
	GetCatalogByName(ctx context.Context, tenantID uint64, name string) (*types.TenantSkillCatalogEntity, error)
	// ListCatalogsByTenant returns every live catalog row of one workspace.
	ListCatalogsByTenant(ctx context.Context, tenantID uint64) ([]*types.TenantSkillCatalogEntity, error)
	// UpdateCatalog writes mutable definition fields (bundle, description, version).
	UpdateCatalog(ctx context.Context, e *types.TenantSkillCatalogEntity) error
	// DeleteCatalog soft-deletes a definition. Install rows are not touched.
	DeleteCatalog(ctx context.Context, tenantID uint64, catalogID string) error
	// ListSkillsByCatalog returns installations of one catalog skill.
	ListSkillsByCatalog(ctx context.Context, tenantID uint64, catalogID string) ([]*types.TenantSkillEntity, error)
}

TenantSkillRepository persists skills installed onto sandbox configs and the snapshot chain ledger.

func NewTenantSkillRepository

func NewTenantSkillRepository(db *gorm.DB) TenantSkillRepository

NewTenantSkillRepository returns a GORM-backed implementation.

Directories

Path Synopsis
retriever
elasticsearch/v7
Package v7 implements the Elasticsearch v7 retriever engine repository It provides functionality for storing and retrieving embeddings using Elasticsearch v7 The repository supports both single and batch operations for saving and deleting embeddings It also supports retrieving embeddings using different retrieval methods The repository is used to store and retrieve embeddings for different tasks It is used to store and retrieve embeddings for different tasks
Package v7 implements the Elasticsearch v7 retriever engine repository It provides functionality for storing and retrieving embeddings using Elasticsearch v7 The repository supports both single and batch operations for saving and deleting embeddings It also supports retrieving embeddings using different retrieval methods The repository is used to store and retrieve embeddings for different tasks It is used to store and retrieve embeddings for different tasks
elasticsearch/v8
Package v8 implements retrieval against its configured vector backend.
Package v8 implements retrieval against its configured vector backend.
milvus
Package milvus implements the Milvus retrieve engine, including multilingual BM25.
Package milvus implements the Milvus retrieve engine, including multilingual BM25.
opensearch
Package opensearch implements the RetrieveEngineRepository interface for OpenSearch k-NN native vector search.
Package opensearch implements the RetrieveEngineRepository interface for OpenSearch k-NN native vector search.
postgres
Package postgres implements retrieval against its configured vector backend.
Package postgres implements retrieval against its configured vector backend.
qdrant
Package qdrant implements vector retrieval and metadata updates in Qdrant.
Package qdrant implements vector retrieval and metadata updates in Qdrant.
sqlite
Package sqlite implements local retrieval with SQLite FTS and vectors.
Package sqlite implements local retrieval with SQLite FTS and vectors.
tencentvectordb
Package tencentvectordb implements retrieval against its configured vector backend.
Package tencentvectordb implements retrieval against its configured vector backend.
weaviate
Package weaviate implements retrieval and metadata updates in Weaviate.
Package weaviate implements retrieval and metadata updates in Weaviate.

Jump to

Keyboard shortcuts

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