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 ¶
- Variables
- func DeleteUserMachinesAndSandboxConfig(ctx context.Context, db *gorm.DB, tenantID uint64, configID string) error
- func GormDB(repo any) *gorm.DB
- func InsertSandboxAssignmentTx(tx *gorm.DB, a *types.SessionSandboxAssignment, ...) (bool, error)
- func NewAgentGrantRepository(db *gorm.DB) interfaces.AgentGrantRepository
- func NewAgentPromptRepository(db *gorm.DB) interfaces.AgentPromptRepository
- func NewAgentRunSuspensionRepository(db *gorm.DB) interfaces.AgentRunSuspensionRepository
- func NewAgentShareRepository(db *gorm.DB) interfaces.AgentShareRepository
- func NewAttachmentDescriptionRepository(db *gorm.DB, tenantID uint64) attachment.DescriptionCache
- func NewAuditLogRepository(db *gorm.DB) interfaces.AuditLogRepository
- func NewAuthTokenRepository(db *gorm.DB) interfaces.AuthTokenRepository
- func NewChunkRepository(db *gorm.DB) interfaces.ChunkRepository
- func NewCustomAgentRepository(db *gorm.DB) interfaces.CustomAgentRepository
- func NewDataSourceRepository(db *gorm.DB) interfaces.DataSourceRepository
- func NewEmbedChannelRepository(db *gorm.DB) interfaces.EmbedChannelRepository
- func NewGraphSearchEvidenceRepository(db *gorm.DB) interfaces.GraphSearchEvidenceRepository
- func NewKBShareRepository(db *gorm.DB) interfaces.KBShareRepository
- func NewKnowledgeBaseRepository(db *gorm.DB) interfaces.KnowledgeBaseRepository
- func NewKnowledgeRepository(db *gorm.DB) interfaces.KnowledgeRepository
- func NewKnowledgeTagRepository(db *gorm.DB) interfaces.KnowledgeTagRepository
- func NewMCPEndpointRepository(db *gorm.DB) interfaces.MCPEndpointRepository
- func NewMCPOAuthRepository(db *gorm.DB) interfaces.MCPOAuthRepository
- func NewMCPServiceRepository(db *gorm.DB) interfaces.MCPServiceRepository
- func NewMCPToolApprovalRepository(db *gorm.DB) interfaces.MCPToolApprovalRepository
- func NewMemoryRepository(db *gorm.DB) interfaces.MemoryRepository
- func NewMessageRepository(db *gorm.DB) interfaces.MessageRepository
- func NewMessageSuggestionRepository(db *gorm.DB) interfaces.MessageSuggestionRepository
- func NewModelRepository(db *gorm.DB) interfaces.ModelRepository
- func NewOrganizationRepository(db *gorm.DB) interfaces.OrganizationRepository
- func NewResourceRepository(db *gorm.DB) interfaces.ResourceRepository
- func NewSandboxAllocationRepository(db *gorm.DB) interfaces.SandboxAllocationRepository
- func NewSessionRepository(db *gorm.DB) interfaces.SessionRepository
- func NewStorageBackendRepository(db *gorm.DB) interfaces.StorageBackendRepository
- func NewSyncLogRepository(db *gorm.DB) interfaces.SyncLogRepository
- func NewSystemSettingRepository(db *gorm.DB) interfaces.SystemSettingRepository
- func NewTaskDeadLetterRepository(db *gorm.DB) interfaces.TaskDeadLetterRepository
- func NewTaskPendingOpsRepository(db *gorm.DB) interfaces.TaskPendingOpsRepository
- func NewTemporaryDocumentRepository(db *gorm.DB) interfaces.TemporaryDocumentRepository
- func NewTenantAPIKeyRepository(db *gorm.DB) interfaces.TenantAPIKeyRepository
- func NewTenantDisabledSharedAgentRepository(db *gorm.DB) interfaces.TenantDisabledSharedAgentRepository
- func NewTenantInvitationRepository(db *gorm.DB) interfaces.TenantInvitationRepository
- func NewTenantMemberRepository(db *gorm.DB) interfaces.TenantMemberRepository
- func NewTenantRepository(db *gorm.DB) interfaces.TenantRepository
- func NewUserRepository(db *gorm.DB) interfaces.UserRepository
- func NewUserResourceFavoriteRepository(db *gorm.DB) interfaces.UserResourceFavoriteRepository
- func NewVectorStoreRepository(db *gorm.DB) interfaces.VectorStoreRepository
- func NewWebSearchProviderRepository(db *gorm.DB) interfaces.WebSearchProviderRepository
- func NewWikiPageRepository(db *gorm.DB) interfaces.WikiPageRepository
- func ParseAggregateTime(s string) (time.Time, bool)
- func RetireSessionsTx(tx *gorm.DB, sessionIDs []string, at time.Time) ([]interfaces.RetiredSession, error)
- type AgentPromptRepository
- func (r *AgentPromptRepository) Create(ctx context.Context, row *types.AgentPrompt) error
- func (r *AgentPromptRepository) Get(ctx context.Context, id string) (*types.AgentPrompt, error)
- func (r *AgentPromptRepository) ListByMessages(ctx context.Context, sessionID string, messageIDs, statuses []string) ([]*types.AgentPrompt, error)
- func (r *AgentPromptRepository) ListBySession(ctx context.Context, sessionID string, statuses []string) ([]*types.AgentPrompt, error)
- func (r *AgentPromptRepository) ListExpired(ctx context.Context, before time.Time, limit int) ([]*types.AgentPrompt, error)
- func (r *AgentPromptRepository) ListStaleLeases(ctx context.Context, statuses []string, before time.Time, limit int) ([]*types.AgentPrompt, error)
- func (r *AgentPromptRepository) RenewLease(ctx context.Context, id, owner string, until time.Time) (bool, error)
- func (r *AgentPromptRepository) Transition(ctx context.Context, id string, t types.AgentPromptTransition) (bool, error)
- type AgentRunSuspensionRepository
- func (r *AgentRunSuspensionRepository) Delete(ctx context.Context, assistantMessageID, promptID string) error
- func (r *AgentRunSuspensionRepository) Get(ctx context.Context, assistantMessageID string) (*types.AgentRunSuspension, error)
- func (r *AgentRunSuspensionRepository) Save(ctx context.Context, row *types.AgentRunSuspension) error
- type DataSourceRepository
- func (r *DataSourceRepository) Create(ctx context.Context, ds *types.DataSource) error
- func (r *DataSourceRepository) Delete(ctx context.Context, id string) error
- func (r *DataSourceRepository) FindActive(ctx context.Context) ([]*types.DataSource, error)
- func (r *DataSourceRepository) FindByID(ctx context.Context, id string) (*types.DataSource, error)
- func (r *DataSourceRepository) FindByKnowledgeBase(ctx context.Context, kbID string) ([]*types.DataSource, error)
- func (r *DataSourceRepository) PatchSyncSettings(ctx context.Context, ds *types.DataSource, expectedConfig types.JSON, ...) error
- func (r *DataSourceRepository) Update(ctx context.Context, ds *types.DataSource) error
- func (r *DataSourceRepository) UpdateSyncState(ctx context.Context, ds *types.DataSource) error
- type KnowledgeSpanRepository
- type MCPToolApprovalRepository
- func (r *MCPToolApprovalRepository) Get(ctx context.Context, tenantID uint64, serviceID, toolName string) (*types.MCPToolApproval, error)
- func (r *MCPToolApprovalRepository) IsEnabled(ctx context.Context, tenantID uint64, serviceID, toolName string) (bool, error)
- func (r *MCPToolApprovalRepository) IsRequired(ctx context.Context, tenantID uint64, serviceID, toolName string) (bool, error)
- func (r *MCPToolApprovalRepository) ListByService(ctx context.Context, tenantID uint64, serviceID string) ([]*types.MCPToolApproval, error)
- func (r *MCPToolApprovalRepository) UpsertPolicy(ctx context.Context, tenantID uint64, serviceID, toolName string, ...) error
- type ModelCatalogRepository
- type SyncLogRepository
- func (r *SyncLogRepository) CancelPendingByDataSource(ctx context.Context, dsID string) error
- func (r *SyncLogRepository) CleanupOldLogs(ctx context.Context, defaultRetentionDays int) error
- func (r *SyncLogRepository) Create(ctx context.Context, log *types.SyncLog) error
- func (r *SyncLogRepository) FindByDataSource(ctx context.Context, dsID string, limit int, offset int) ([]*types.SyncLog, error)
- func (r *SyncLogRepository) FindByID(ctx context.Context, id string) (*types.SyncLog, error)
- func (r *SyncLogRepository) FindLatest(ctx context.Context, dsID string) (*types.SyncLog, error)
- func (r *SyncLogRepository) HasRunningSync(ctx context.Context, dsID string) (bool, error)
- func (r *SyncLogRepository) Update(ctx context.Context, log *types.SyncLog) error
- func (r *SyncLogRepository) UpdateResult(ctx context.Context, log *types.SyncLog) error
- type TenantSandboxConfigRepository
- type TenantSkillRepository
Constants ¶
This section is empty.
Variables ¶
var ( )
var ( )
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") )
var ( ErrTenantNotFound = errors.New("tenant not found") ErrTenantHasKnowledgeBase = errors.New("tenant has associated knowledge bases") )
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") )
var ErrCatalogVersionConflict = errors.New("model catalog changed; reload and preview again")
ErrCatalogVersionConflict reports a publish based on a stale version.
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.
var ErrChunkRevisionConflict = errors.New("chunk revision conflict")
var ErrCustomAgentNotFound = errors.New("custom agent not found")
ErrCustomAgentNotFound is returned when a custom agent is not found
var ErrJoinRequestNotFound = errors.New("join request not found")
var ErrKnowledgeBaseNotFound = errors.New("knowledge base not found")
var ErrKnowledgeNotFound = errors.New("knowledge not found")
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).
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.
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.
var ErrTenantAPIKeyNotFound = errors.New("tenant api key not found")
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.
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.
var ErrWikiFolderNotFound = errors.New("wiki folder not found")
ErrWikiFolderNotFound is returned when a wiki folder is not found.
var ErrWikiIssueNotFound = errors.New("wiki issue not found")
ErrWikiIssueNotFound means no issue with that ID belongs to the knowledge base.
var ErrWikiPageConflict = errors.New("wiki page version conflict")
ErrWikiPageConflict is returned when an optimistic lock conflict is detected
var ErrWikiPageNotFound = errors.New("wiki page not found")
ErrWikiPageNotFound is returned when a wiki page is not found
Functions ¶
func DeleteUserMachinesAndSandboxConfig ¶ added in v0.9.0
func DeleteUserMachinesAndSandboxConfig( ctx context.Context, db *gorm.DB, tenantID uint64, configID string, ) error
DeleteUserMachinesAndSandboxConfig removes the config's user-machine rows and soft-deletes the config in one transaction. A missing config rolls the machine delete back, so a failed config delete cannot leave sessions pointing at a registry that cleanup treats as already gone.
func InsertSandboxAssignmentTx ¶ added in v0.9.0
func InsertSandboxAssignmentTx( tx *gorm.DB, a *types.SessionSandboxAssignment, machine *types.SandboxUserMachine, ) (bool, error)
InsertSandboxAssignmentTx inserts a unless the session already has one, and for a user-mode row registers (or re-opens) machine. The fork path shares it so a forked session and its assignment commit together.
func NewAgentGrantRepository ¶ added in v0.9.0
func NewAgentGrantRepository(db *gorm.DB) interfaces.AgentGrantRepository
NewAgentGrantRepository creates a repository backed by GORM.
func NewAgentPromptRepository ¶ added in v0.9.0
func NewAgentPromptRepository(db *gorm.DB) interfaces.AgentPromptRepository
NewAgentPromptRepository creates a repository backed by GORM.
func NewAgentRunSuspensionRepository ¶ added in v0.9.0
func NewAgentRunSuspensionRepository(db *gorm.DB) interfaces.AgentRunSuspensionRepository
NewAgentRunSuspensionRepository creates a repository backed by GORM.
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 NewGraphSearchEvidenceRepository ¶ added in v0.9.0
func NewGraphSearchEvidenceRepository(db *gorm.DB) interfaces.GraphSearchEvidenceRepository
NewGraphSearchEvidenceRepository constructs the scoped live-source projection.
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 NewSandboxAllocationRepository ¶ added in v0.9.0
func NewSandboxAllocationRepository(db *gorm.DB) interfaces.SandboxAllocationRepository
NewSandboxAllocationRepository builds the allocation repository.
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 ¶
ParseAggregateTime parses a timestamp read back through an SQL aggregate, in the formats Postgres and SQLite emit.
func RetireSessionsTx ¶ added in v0.9.0
func RetireSessionsTx(tx *gorm.DB, sessionIDs []string, at time.Time) ([]interfaces.RetiredSession, error)
RetireSessionsTx is RetireSessions inside the caller's transaction (T14 retires a deleted account's sessions with it). Locks are session rows by id, then machine rows by digest. A caller that also locks the user row must do that first: user, then sessions, then machines.
Types ¶
type AgentPromptRepository ¶ added in v0.9.0
type AgentPromptRepository struct {
// contains filtered or unexported fields
}
AgentPromptRepository implements interfaces.AgentPromptRepository.
func (*AgentPromptRepository) Create ¶ added in v0.9.0
func (r *AgentPromptRepository) Create(ctx context.Context, row *types.AgentPrompt) error
Create inserts a new prompt row.
func (*AgentPromptRepository) Get ¶ added in v0.9.0
func (r *AgentPromptRepository) Get(ctx context.Context, id string) (*types.AgentPrompt, error)
Get returns the row, or nil when it does not exist.
func (*AgentPromptRepository) ListByMessages ¶ added in v0.9.0
func (r *AgentPromptRepository) ListByMessages( ctx context.Context, sessionID string, messageIDs, statuses []string, ) ([]*types.AgentPrompt, error)
ListByMessages returns the session's rows in one of statuses raised by one of the assistant messages.
func (*AgentPromptRepository) ListBySession ¶ added in v0.9.0
func (r *AgentPromptRepository) ListBySession( ctx context.Context, sessionID string, statuses []string, ) ([]*types.AgentPrompt, error)
ListBySession returns the session's rows in statuses.
func (*AgentPromptRepository) ListExpired ¶ added in v0.9.0
func (r *AgentPromptRepository) ListExpired( ctx context.Context, before time.Time, limit int, ) ([]*types.AgentPrompt, error)
ListExpired returns suspended rows past their expiry.
func (*AgentPromptRepository) ListStaleLeases ¶ added in v0.9.0
func (r *AgentPromptRepository) ListStaleLeases( ctx context.Context, statuses []string, before time.Time, limit int, ) ([]*types.AgentPrompt, error)
ListStaleLeases returns rows in statuses whose owner stopped renewing.
func (*AgentPromptRepository) RenewLease ¶ added in v0.9.0
func (r *AgentPromptRepository) RenewLease( ctx context.Context, id, owner string, until time.Time, ) (bool, error)
RenewLease extends the lease of a leased row still held by owner.
func (*AgentPromptRepository) Transition ¶ added in v0.9.0
func (r *AgentPromptRepository) Transition( ctx context.Context, id string, t types.AgentPromptTransition, ) (bool, error)
Transition applies a compare-and-set state change.
type AgentRunSuspensionRepository ¶ added in v0.9.0
type AgentRunSuspensionRepository struct {
// contains filtered or unexported fields
}
AgentRunSuspensionRepository implements interfaces.AgentRunSuspensionRepository.
func (*AgentRunSuspensionRepository) Delete ¶ added in v0.9.0
func (r *AgentRunSuspensionRepository) Delete(ctx context.Context, assistantMessageID, promptID string) error
Delete removes the run state while it still belongs to promptID.
func (*AgentRunSuspensionRepository) Get ¶ added in v0.9.0
func (r *AgentRunSuspensionRepository) Get( ctx context.Context, assistantMessageID string, ) (*types.AgentRunSuspension, error)
Get returns the run state of a message, or nil when there is none.
func (*AgentRunSuspensionRepository) Save ¶ added in v0.9.0
func (r *AgentRunSuspensionRepository) Save(ctx context.Context, row *types.AgentRunSuspension) error
Save inserts or replaces the run state of a message.
type DataSourceRepository ¶
type DataSourceRepository struct {
// contains filtered or unexported fields
}
DataSourceRepository provides data access for data sources
func (*DataSourceRepository) Create ¶
func (r *DataSourceRepository) Create(ctx context.Context, ds *types.DataSource) error
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) PatchSyncSettings ¶ added in v0.9.0
func (r *DataSourceRepository) PatchSyncSettings( ctx context.Context, ds *types.DataSource, expectedConfig types.JSON, fields []string, ) error
PatchSyncSettings never writes runtime state or fields omitted by the request.
func (*DataSourceRepository) Update ¶
func (r *DataSourceRepository) Update(ctx context.Context, ds *types.DataSource) error
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) Get ¶ added in v0.9.0
func (r *MCPToolApprovalRepository) Get( ctx context.Context, tenantID uint64, serviceID, toolName string, ) (*types.MCPToolApproval, error)
Get returns the stored policy of a tool, or nil when it has none.
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. ObservedRisk only ever raises the stored value. 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 ¶
func (r *ModelCatalogRepository) Get(ctx context.Context) (*types.ModelCatalogConfig, error)
Get loads the overlay row, including its bounded history.
func (*ModelCatalogRepository) Save ¶
func (r *ModelCatalogRepository) Save(ctx context.Context, expected uint64, row *types.ModelCatalogConfig) error
Save replaces the row only if it is still at the expected version.
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, defaultRetentionDays int) error
CleanupOldLogs applies each source's retention policy, including soft-deleted sources. Missing sources and non-positive policies use the default (normally 30 days). Failed logs of live sources may still be retried by Asynq.
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) FindLatest ¶
FindLatest retrieves the most recent sync log for a data source
func (*SyncLogRepository) HasRunningSync ¶
HasRunningSync checks if a data source has any sync currently in "running" status.
func (*SyncLogRepository) UpdateResult ¶
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
// RefreshCordon moves cordoned_at from previous to next only while the
// row still holds previous. Zero rows means another request owns the cordon.
RefreshCordon(ctx context.Context, tenantID uint64, id string, previous, next time.Time) error
ClearCordon(ctx context.Context, tenantID uint64, id string) error
// ClearCordonIf clears cordoned_at only when it still equals at. Zero
// rows is success: someone else owns the cordon.
ClearCordonIf(ctx context.Context, tenantID uint64, id string, at time.Time) 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.
Source Files
¶
- agent_grant_repository.go
- agent_prompt_repository.go
- agent_share.go
- attachment_descriptions.go
- audit_log.go
- chunk.go
- chunk_image_assets.go
- custom_agent.go
- datasource_repo.go
- embed_channel.go
- graph_search.go
- kbshare.go
- knowledge.go
- knowledge_replace.go
- knowledge_span_repo.go
- knowledge_tag.go
- knowledge_transfer.go
- knowledgebase.go
- mcp_endpoint.go
- mcp_metadata.go
- mcp_oauth.go
- mcp_service.go
- mcp_tool_approval_repository.go
- memory.go
- memory_extraction.go
- memory_lifecycle.go
- memory_vector.go
- message.go
- message_artifact.go
- message_checkpoint_deletion.go
- message_suggestion.go
- model.go
- model_catalog_config.go
- model_usage.go
- organization.go
- resource.go
- resource_references.go
- sandbox_allocation.go
- session.go
- storagebackend.go
- system_setting.go
- tag.go
- task_queue.go
- temporary_document.go
- tenant.go
- tenant_api_key.go
- tenant_disabled_shared_agent.go
- tenant_invitation.go
- tenant_member.go
- tenant_sandbox_config.go
- tenant_skill.go
- user.go
- user_resource_favorite.go
- vectorstore.go
- web_search_provider.go
- wiki_page.go
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. |
|
neo4j
Package neo4j implements the knowledge graph storage and query adapters.
|
Package neo4j implements the knowledge graph storage and query adapters. |
|
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. |