model

package
v0.0.1-test9 Latest Latest
Warning

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

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

Documentation

Overview

Package model defines the database models used throughout the application. These models work with both PostgreSQL and SQLite via GORM.

Index

Constants

View Source
const (
	// AnonymousUserID is the reserved user ID for unauthenticated access.
	// This user is created during database seeding when auth is disabled.
	AnonymousUserID = "00000000-0000-0000-0000-000000000001"

	// AnonymousUserEmail is the email for the anonymous user.
	AnonymousUserEmail = "anonymous@local"

	// AnonymousUserName is the display name for the anonymous user.
	AnonymousUserName = "Anonymous User"

	// DefaultProjectID is the reserved project ID for the default project.
	// Created during seeding for the anonymous user.
	DefaultProjectID = "local"

	// DefaultProjectName is the name of the default project.
	DefaultProjectName = "Local Project"

	// DefaultProjectSlug is the slug for the default project.
	DefaultProjectSlug = "local"
)

Anonymous user constants for no-auth mode. These are well-known IDs used when AUTH_ENABLED=false.

View Source
const (
	WorkspaceStatusInitializing = "initializing" // Workspace just created, starting setup
	WorkspaceStatusCloning      = "cloning"      // Cloning git repository
	WorkspaceStatusReady        = "ready"        // Workspace is ready for use
	WorkspaceStatusRemoving     = "removing"     // Workspace is queued for deletion
	WorkspaceStatusError        = "error"        // Something failed during setup
)

Workspace status constants representing the lifecycle of a workspace

View Source
const (
	WorkspaceProviderVZ     = "vz"     // Run in Virtualization.framework VMs (macOS only)
	WorkspaceProviderDocker = "docker" // Run in Docker containers
	WorkspaceProviderLocal  = "local"  // Run in local directory without isolation
)

Workspace provider constants representing how sessions are executed. When a workspace has no provider set (empty string), the platform default is used at runtime: "vz" on macOS, "docker" on other platforms.

View Source
const (
	WorkspaceSourceTypeLocal   = "local"
	WorkspaceSourceTypeGit     = "git"
	WorkspaceSourceTypeManaged = "managed"
)
View Source
const (
	SessionStatusInitializing    = "initializing"     // Session just created, starting setup
	SessionStatusReinitializing  = "reinitializing"   // Recreating sandbox after it was deleted
	SessionStatusCloning         = "cloning"          // Cloning git repository
	SessionStatusPullingImage    = "pulling_image"    // Pulling runtime image
	SessionStatusCreatingSandbox = "creating_sandbox" // Creating sandbox environment
	SessionStatusReady           = "ready"            // Session is ready for use
	SessionStatusStopped         = "stopped"          // Sandbox is stopped, will restart on demand
	SessionStatusError           = "error"            // Something failed during setup
	SessionStatusRemoving        = "removing"         // Session is being deleted
	SessionStatusRemoved         = "removed"          // Session has been deleted
)

Session status constants representing the lifecycle of a session

View Source
const (
	CommitStatusNone       = ""           // No commit in progress (default)
	CommitStatusPending    = "pending"    // Commit requested, waiting to start
	CommitStatusCommitting = "committing" // Commit in progress
	CommitStatusCompleted  = "completed"  // Commit completed successfully
	CommitStatusFailed     = "failed"     // Commit failed
)

Commit status constants representing the commit state of a session (orthogonal to session status)

View Source
const (
	EventTypeSessionUpdated = "session_updated"
	EventTypeThreadUpdated  = "thread_updated"
)

Event type constants

View Source
const (
	PromptSubmissionStatusPending     = "pending"
	PromptSubmissionStatusDispatching = "dispatching"
	PromptSubmissionStatusAccepted    = "accepted"
	PromptSubmissionStatusFailed      = "failed"
)
View Source
const (
	CommitOperationCommit = "commit"
)

Commit operation constants representing the active operation using commit status fields.

View Source
const DispatcherLeaderSingletonID = "singleton"

DispatcherLeaderSingletonID is the ID used for the single leadership row.

Variables

This section is empty.

Functions

func AllModels

func AllModels() []any

AllModels returns all model types for migration.

func NewTextParts

func NewTextParts(text string) json.RawMessage

NewTextParts creates a JSON parts array with a single text part.

Types

type Agent

type Agent struct {
	ID        string    `gorm:"primaryKey;type:text" json:"id"`
	ProjectID string    `gorm:"column:project_id;not null;type:text;index" json:"project_id"`
	AgentType string    `gorm:"column:agent_type;not null;type:text" json:"agent_type"`
	IsDefault bool      `gorm:"column:is_default;default:false" json:"is_default"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Project *Project `gorm:"foreignKey:ProjectID" json:"-"`
}

Agent represents an AI agent configuration. Deprecated: Agent concept has been removed. This struct is kept only for DB migration compatibility.

func (*Agent) BeforeCreate

func (a *Agent) BeforeCreate(_ *gorm.DB) error

func (Agent) TableName

func (Agent) TableName() string

type Credential

type Credential struct {
	ID             string    `gorm:"primaryKey;type:text" json:"id"`
	ProjectID      string    `gorm:"column:project_id;not null;type:text;index:idx_credentials_project_provider" json:"project_id"`
	Provider       string    `gorm:"not null;type:text;index:idx_credentials_project_provider" json:"provider"`
	Name           string    `gorm:"not null;type:text" json:"name"`
	Description    *string   `gorm:"type:text" json:"description,omitempty"`
	AuthType       string    `gorm:"column:auth_type;not null;type:text" json:"auth_type"`
	EncryptedData  []byte    `gorm:"column:encrypted_data" json:"-"`
	IsConfigured   bool      `gorm:"column:is_configured;default:false" json:"is_configured"`
	Inactive       bool      `gorm:"column:inactive;not null;default:false" json:"inactive"`
	AgentVisible   bool      `gorm:"column:agent_visible;not null;default:false" json:"agent_visible"`
	ConsoleVisible bool      `gorm:"column:console_visible;not null;default:false" json:"console_visible"`
	ServiceVisible bool      `gorm:"column:service_visible;not null;default:false" json:"service_visible"`
	HookVisible    bool      `gorm:"column:hook_visible;not null;default:false" json:"hook_visible"`
	CreatedAt      time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt      time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Project *Project `gorm:"foreignKey:ProjectID" json:"-"`
}

Credential represents stored credentials for AI providers and custom env bundles.

func (*Credential) BeforeCreate

func (c *Credential) BeforeCreate(_ *gorm.DB) error

func (Credential) TableName

func (Credential) TableName() string

type DispatcherLeader

type DispatcherLeader struct {
	ID          string    `gorm:"primaryKey;type:text" json:"id"`
	ServerID    string    `gorm:"column:server_id;not null;type:text" json:"server_id"`
	HeartbeatAt time.Time `gorm:"column:heartbeat_at;not null" json:"heartbeat_at"`
	AcquiredAt  time.Time `gorm:"column:acquired_at;not null" json:"acquired_at"`
}

DispatcherLeader represents leadership for job processing. Only one row should exist with ID="singleton" - uses upsert pattern.

func (DispatcherLeader) TableName

func (DispatcherLeader) TableName() string

TableName returns the table name for DispatcherLeader.

type Installation

type Installation struct {
	ID             string    `gorm:"primaryKey;type:text" json:"id"`
	InstallationID string    `gorm:"column:installation_id;not null;type:text;uniqueIndex" json:"installation_id"`
	CreatedAt      time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt      time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}

Installation stores instance-wide Discobot installation metadata.

func (*Installation) BeforeCreate

func (i *Installation) BeforeCreate(_ *gorm.DB) error

func (Installation) TableName

func (Installation) TableName() string

type Job

type Job struct {
	ID          string          `gorm:"primaryKey;type:text" json:"id"`
	Type        string          `gorm:"not null;type:text;index:idx_job_status_type" json:"type"`
	Payload     json.RawMessage `gorm:"type:text;not null" json:"payload"`
	Status      string          `gorm:"not null;type:text;default:pending;index:idx_job_status_type" json:"status"`
	Priority    int             `gorm:"not null;default:0;index" json:"priority"`
	Attempts    int             `gorm:"not null;default:0" json:"attempts"`
	MaxAttempts int             `gorm:"column:max_attempts;not null;default:3" json:"max_attempts"`
	Error       *string         `gorm:"type:text" json:"error,omitempty"`
	WorkerID    *string         `gorm:"column:worker_id;type:text" json:"worker_id,omitempty"`
	ScheduledAt time.Time       `gorm:"column:scheduled_at;not null;index" json:"scheduled_at"`
	StartedAt   *time.Time      `gorm:"column:started_at" json:"started_at,omitempty"`
	CompletedAt *time.Time      `gorm:"column:completed_at" json:"completed_at,omitempty"`
	CreatedAt   time.Time       `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time       `gorm:"autoUpdateTime" json:"updated_at"`

	// ResourceType and ResourceID enable job deduplication per resource.
	// Only one pending or running job is allowed per (resource_type, resource_id).
	// Example: resource_type="session", resource_id="abc123"
	ResourceType *string `gorm:"column:resource_type;type:text;index:idx_job_resource" json:"resource_type,omitempty"`
	ResourceID   *string `gorm:"column:resource_id;type:text;index:idx_job_resource" json:"resource_id,omitempty"`
}

Job represents a background job in the queue.

func (*Job) BeforeCreate

func (j *Job) BeforeCreate(_ *gorm.DB) error

BeforeCreate generates a UUID if not set.

func (Job) TableName

func (Job) TableName() string

TableName returns the table name for Job.

type JobStatus

type JobStatus string

JobStatus represents the current state of a job.

const (
	JobStatusPending   JobStatus = "pending"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
)

type Message

type Message struct {
	ID        string          `gorm:"primaryKey;type:text" json:"id"`
	SessionID string          `gorm:"column:session_id;not null;type:text;index" json:"sessionId"`
	Role      string          `gorm:"not null;type:text" json:"role"`
	Parts     json.RawMessage `gorm:"type:text;not null" json:"parts"`
	CreatedAt time.Time       `gorm:"autoCreateTime" json:"createdAt"`

	Session *Session `gorm:"foreignKey:SessionID" json:"-"`
}

Message represents a chat message in a session. Stored in UIMessage format compatible with AI SDK.

func (*Message) BeforeCreate

func (m *Message) BeforeCreate(_ *gorm.DB) error

func (Message) TableName

func (Message) TableName() string

type OIDCClientRegistration

type OIDCClientRegistration struct {
	ID                        string    `gorm:"primaryKey;type:text" json:"id"`
	IssuerURL                 string    `gorm:"column:issuer_url;not null;type:text;uniqueIndex:idx_oidc_registration" json:"issuer_url"`
	RedirectBaseURL           string    `gorm:"column:redirect_base_url;not null;type:text;uniqueIndex:idx_oidc_registration" json:"redirect_base_url"`
	ClientID                  string    `gorm:"column:client_id;not null;type:text" json:"client_id"`
	ClientSecretEncryptedData []byte    `gorm:"column:client_secret_encrypted_data" json:"-"`
	TokenEndpointAuthMethod   *string   `gorm:"column:token_endpoint_auth_method;type:text" json:"token_endpoint_auth_method,omitempty"`
	RegistrationClientURI     *string   `gorm:"column:registration_client_uri;type:text" json:"registration_client_uri,omitempty"`
	RegistrationAccessToken   []byte    `gorm:"column:registration_access_token_encrypted_data" json:"-"`
	ClientIDIssuedAt          *int64    `gorm:"column:client_id_issued_at" json:"client_id_issued_at,omitempty"`
	ClientSecretExpiresAt     *int64    `gorm:"column:client_secret_expires_at" json:"client_secret_expires_at,omitempty"`
	RegistrationResponseJSON  []byte    `gorm:"column:registration_response_json" json:"-"`
	CreatedAt                 time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt                 time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}

OIDCClientRegistration stores a dynamically registered OIDC client for a specific issuer and Discobot public base URL.

func (*OIDCClientRegistration) BeforeCreate

func (r *OIDCClientRegistration) BeforeCreate(_ *gorm.DB) error

func (OIDCClientRegistration) TableName

func (OIDCClientRegistration) TableName() string

type Project

type Project struct {
	ID           string    `gorm:"primaryKey;type:text" json:"id"`
	Name         string    `gorm:"not null;type:text" json:"name"`
	Slug         string    `gorm:"uniqueIndex;not null;type:text" json:"slug"`
	VZMemoryMB   *int      `gorm:"column:vz_memory_mb" json:"vz_memory_mb,omitempty"`
	VZDataDiskGB *int      `gorm:"column:vz_data_disk_gb" json:"vz_data_disk_gb,omitempty"`
	CreatedAt    time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt    time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Members    []ProjectMember `gorm:"foreignKey:ProjectID" json:"-"`
	Workspaces []Workspace     `gorm:"foreignKey:ProjectID" json:"-"`
}

Project represents a multi-tenant container.

func NewDefaultProject

func NewDefaultProject() *Project

NewDefaultProject creates the default project model.

func (*Project) BeforeCreate

func (p *Project) BeforeCreate(_ *gorm.DB) error

func (Project) TableName

func (Project) TableName() string

type ProjectEvent

type ProjectEvent struct {
	ID        string          `gorm:"primaryKey;type:text" json:"id"`
	Seq       int64           `gorm:"column:seq;autoIncrement;uniqueIndex" json:"seq"`
	ProjectID string          `gorm:"column:project_id;not null;type:text;index:idx_project_seq,priority:1" json:"projectId"`
	Type      string          `gorm:"not null;type:text" json:"type"`
	Data      json.RawMessage `gorm:"type:text;not null" json:"data"`
	CreatedAt time.Time       `gorm:"autoCreateTime;index:idx_project_seq,priority:2" json:"createdAt"`

	Project *Project `gorm:"foreignKey:ProjectID" json:"-"`
}

ProjectEvent represents a persisted event for a project. Events are used for SSE streaming to clients.

func (*ProjectEvent) BeforeCreate

func (e *ProjectEvent) BeforeCreate(_ *gorm.DB) error

func (ProjectEvent) TableName

func (ProjectEvent) TableName() string

type ProjectInvitation

type ProjectInvitation struct {
	ID        string    `gorm:"primaryKey;type:text" json:"id"`
	ProjectID string    `gorm:"column:project_id;not null;type:text;uniqueIndex:idx_project_email" json:"project_id"`
	Email     string    `gorm:"not null;type:text;uniqueIndex:idx_project_email" json:"email"`
	Role      string    `gorm:"not null;type:text;default:member" json:"role"`
	InvitedBy *string   `gorm:"column:invited_by;type:text" json:"invited_by,omitempty"`
	Token     string    `gorm:"uniqueIndex;not null;type:text" json:"token"`
	ExpiresAt time.Time `gorm:"column:expires_at;not null" json:"expires_at"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`

	Project *Project `gorm:"foreignKey:ProjectID" json:"-"`
}

ProjectInvitation represents a pending invitation to join a project.

func (*ProjectInvitation) BeforeCreate

func (i *ProjectInvitation) BeforeCreate(_ *gorm.DB) error

func (ProjectInvitation) TableName

func (ProjectInvitation) TableName() string

type ProjectMember

type ProjectMember struct {
	ID         string     `gorm:"primaryKey;type:text" json:"id"`
	ProjectID  string     `gorm:"column:project_id;not null;type:text;uniqueIndex:idx_project_user" json:"project_id"`
	UserID     string     `gorm:"column:user_id;not null;type:text;uniqueIndex:idx_project_user;index" json:"user_id"`
	Role       string     `gorm:"not null;type:text;default:member" json:"role"`
	InvitedBy  *string    `gorm:"column:invited_by;type:text" json:"invited_by,omitempty"`
	InvitedAt  *time.Time `gorm:"column:invited_at" json:"invited_at,omitempty"`
	AcceptedAt *time.Time `gorm:"column:accepted_at" json:"accepted_at,omitempty"`

	Project *Project `gorm:"foreignKey:ProjectID" json:"-"`
	User    *User    `gorm:"foreignKey:UserID" json:"-"`
}

ProjectMember represents a user's membership in a project.

func (*ProjectMember) BeforeCreate

func (m *ProjectMember) BeforeCreate(_ *gorm.DB) error

func (ProjectMember) TableName

func (ProjectMember) TableName() string

type PromptSubmission

type PromptSubmission struct {
	ID                    string     `gorm:"primaryKey;type:text" json:"id"`
	ProjectID             string     `gorm:"column:project_id;not null;type:text;index" json:"projectId"`
	SessionID             string     `gorm:"column:session_id;not null;type:text;index;uniqueIndex:idx_prompt_submission_key" json:"sessionId"`
	ThreadID              string     `gorm:"column:thread_id;not null;type:text;uniqueIndex:idx_prompt_submission_key" json:"threadId"`
	ClientMessageID       string     `gorm:"column:client_message_id;not null;type:text;uniqueIndex:idx_prompt_submission_key" json:"clientMessageId"`
	MessageID             string     `gorm:"column:message_id;not null;type:text" json:"messageId"`
	MessagesEncryptedData []byte     `gorm:"column:messages_encrypted_data" json:"-"`
	Model                 string     `gorm:"type:text" json:"model,omitempty"`
	Reasoning             string     `gorm:"type:text" json:"reasoning,omitempty"`
	Mode                  string     `gorm:"type:text" json:"mode,omitempty"`
	RunAfter              string     `gorm:"column:run_after;type:text" json:"runAfter,omitempty"`
	Status                string     `gorm:"not null;type:text;default:pending;index" json:"status"`
	CompletionID          *string    `gorm:"column:completion_id;type:text" json:"completionId,omitempty"`
	QueuedPromptID        *string    `gorm:"column:queued_prompt_id;type:text" json:"queuedPromptId,omitempty"`
	ErrorMessage          *string    `gorm:"column:error_message;type:text" json:"errorMessage,omitempty"`
	AcceptedAt            *time.Time `gorm:"column:accepted_at" json:"acceptedAt,omitempty"`
	CreatedAt             time.Time  `gorm:"autoCreateTime" json:"createdAt"`
	UpdatedAt             time.Time  `gorm:"autoUpdateTime" json:"updatedAt"`
}

PromptSubmission persists a prompt intent until the sandbox accepts it.

func (*PromptSubmission) BeforeCreate

func (p *PromptSubmission) BeforeCreate(_ *gorm.DB) error

func (PromptSubmission) TableName

func (PromptSubmission) TableName() string

type Session

type Session struct {
	ID                  string         `gorm:"primaryKey;type:text" json:"id"`
	ProjectID           string         `gorm:"column:project_id;not null;type:text;index" json:"projectId"`
	WorkspaceID         string         `gorm:"column:workspace_id;not null;type:text;index" json:"workspaceId"`
	Name                string         `gorm:"not null;type:text" json:"name"`
	DisplayName         *string        `gorm:"column:display_name;type:text" json:"displayName,omitempty"`
	Description         *string        `gorm:"type:text" json:"description,omitempty"`
	Status              string         `gorm:"not null;type:text;default:initializing" json:"status"`
	CommitStatus        string         `gorm:"column:commit_status;type:text;default:''" json:"commitStatus"`
	CommitOperation     *string        `gorm:"column:commit_operation;type:text" json:"commitOperation,omitempty"`
	CommitError         *string        `gorm:"column:commit_error;type:text" json:"commitError,omitempty"`
	TargetRef           *string        `gorm:"column:target_ref;type:text" json:"targetRef,omitempty"`
	AppliedCommit       *string        `gorm:"column:applied_commit;type:text" json:"appliedCommit,omitempty"`
	ErrorMessage        *string        `gorm:"column:error_message;type:text" json:"errorMessage,omitempty"`
	WorkspacePath       *string        `gorm:"column:workspace_path;type:text" json:"workspacePath,omitempty"`
	SSHKeyEncryptedData []byte         `gorm:"column:ssh_key_encrypted_data" json:"-"`
	CreatedAt           time.Time      `gorm:"autoCreateTime" json:"createdAt"`
	UpdatedAt           time.Time      `gorm:"autoUpdateTime" json:"updatedAt"`
	DeletedAt           gorm.DeletedAt `gorm:"index" json:"-"`

	Project           *Project           `gorm:"foreignKey:ProjectID" json:"-"`
	Workspace         *Workspace         `gorm:"foreignKey:WorkspaceID" json:"-"`
	Messages          []Message          `gorm:"foreignKey:SessionID" json:"-"`
	SessionCommitLogs []SessionCommitLog `gorm:"foreignKey:SessionID" json:"-"`
}

Session represents a chat thread within a workspace.

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(_ *gorm.DB) error

func (Session) TableName

func (Session) TableName() string

type SessionCommitLog

type SessionCommitLog struct {
	ID                  string    `gorm:"primaryKey;type:text" json:"id"`
	SessionID           string    `gorm:"column:session_id;not null;type:text;index" json:"sessionId"`
	Operation           string    `gorm:"column:operation;not null;type:text" json:"operation"`
	TargetRef           *string   `gorm:"column:target_ref;type:text" json:"targetRef,omitempty"`
	TargetCommit        *string   `gorm:"column:target_commit;type:text" json:"targetCommit,omitempty"`
	SandboxHeadCommit   *string   `gorm:"column:sandbox_head_commit;type:text" json:"sandboxHeadCommit,omitempty"`
	RequestedCommitHash *string   `gorm:"column:requested_commit_hash;type:text" json:"requestedCommitHash,omitempty"`
	RequestedDirectory  *string   `gorm:"column:requested_directory;type:text" json:"requestedDirectory,omitempty"`
	AppliedCommit       *string   `gorm:"column:applied_commit;type:text" json:"appliedCommit,omitempty"`
	CommitCount         int       `gorm:"column:commit_count;not null;default:0" json:"commitCount"`
	Patches             string    `gorm:"column:patches;type:text;not null;default:''" json:"patches"`
	CreatedAt           time.Time `gorm:"autoCreateTime" json:"createdAt"`

	Session *Session `gorm:"foreignKey:SessionID" json:"-"`
}

SessionCommitLog stores the patch bundle and commit references for a successful session pull into the host workspace.

func (*SessionCommitLog) BeforeCreate

func (s *SessionCommitLog) BeforeCreate(_ *gorm.DB) error

func (SessionCommitLog) TableName

func (SessionCommitLog) TableName() string

type SessionCredentialAssignment

type SessionCredentialAssignment struct {
	ID                  string          `gorm:"primaryKey;type:text" json:"id"`
	SessionID           string          `` /* 131-byte string literal not displayed */
	CredentialID        string          `` /* 137-byte string literal not displayed */
	SessionCredentialID string          `gorm:"column:session_credential_id;type:text;index" json:"sessionCredentialId"`
	EnvVar              string          `gorm:"column:env_var;type:text;uniqueIndex:idx_session_credential_assignment_binding,priority:3" json:"envVar,omitempty"`
	SourceEnvVar        string          `gorm:"column:source_env_var;type:text" json:"sourceEnvVar,omitempty"`
	AgentVisible        bool            `gorm:"column:agent_visible;not null;default:false" json:"agentVisible"`
	ConsoleVisible      bool            `gorm:"column:console_visible;not null;default:false" json:"consoleVisible"`
	ServiceVisible      bool            `gorm:"column:service_visible;not null;default:false" json:"serviceVisible"`
	HookVisible         bool            `gorm:"column:hook_visible;not null;default:false" json:"hookVisible"`
	UsesJSON            json.RawMessage `gorm:"column:uses_json;type:text" json:"uses,omitempty"`
	CreatedAt           time.Time       `gorm:"autoCreateTime" json:"createdAt"`
	UpdatedAt           time.Time       `gorm:"autoUpdateTime" json:"updatedAt"`

	Session    *Session    `gorm:"foreignKey:SessionID" json:"-"`
	Credential *Credential `gorm:"foreignKey:CredentialID" json:"-"`
}

SessionCredentialAssignment stores which credentials are assigned to a session and whether each assignment is visible to the agent/LLM environment.

func (*SessionCredentialAssignment) BeforeCreate

func (a *SessionCredentialAssignment) BeforeCreate(_ *gorm.DB) error

func (SessionCredentialAssignment) TableName

func (SessionCredentialAssignment) TableName() string

type TLSCacheEntry

type TLSCacheEntry struct {
	ID            string    `gorm:"primaryKey;type:text" json:"id"`
	CacheKey      string    `gorm:"column:cache_key;not null;type:text;uniqueIndex" json:"cacheKey"`
	EncryptedData []byte    `gorm:"column:encrypted_data" json:"-"`
	CreatedAt     time.Time `gorm:"autoCreateTime" json:"createdAt"`
	UpdatedAt     time.Time `gorm:"autoUpdateTime" json:"updatedAt"`
}

TLSCacheEntry stores encrypted TLS state blobs, such as ACME/autocert cache data.

func (*TLSCacheEntry) BeforeCreate

func (e *TLSCacheEntry) BeforeCreate(_ *gorm.DB) error

func (TLSCacheEntry) TableName

func (TLSCacheEntry) TableName() string

type TerminalHistory

type TerminalHistory struct {
	ID        string    `gorm:"primaryKey;type:text" json:"id"`
	SessionID string    `gorm:"column:session_id;not null;type:text;index" json:"session_id"`
	EntryType string    `gorm:"column:entry_type;not null;type:text" json:"entry_type"`
	Content   string    `gorm:"not null;type:text" json:"content"`
	ExitCode  *int      `gorm:"column:exit_code" json:"exit_code,omitempty"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`

	Session *Session `gorm:"foreignKey:SessionID" json:"-"`
}

TerminalHistory represents a terminal command/output entry.

func (*TerminalHistory) BeforeCreate

func (t *TerminalHistory) BeforeCreate(_ *gorm.DB) error

func (TerminalHistory) TableName

func (TerminalHistory) TableName() string

type TextPart

type TextPart struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

TextPart represents a text part in a UIMessage.

type User

type User struct {
	ID         string    `gorm:"primaryKey;type:text" json:"id"`
	Email      string    `gorm:"uniqueIndex;not null;type:text" json:"email"`
	Name       *string   `gorm:"type:text" json:"name,omitempty"`
	AvatarURL  *string   `gorm:"column:avatar_url;type:text" json:"avatar_url,omitempty"`
	Provider   string    `gorm:"not null;type:text" json:"provider"`
	ProviderID string    `gorm:"column:provider_id;not null;type:text" json:"provider_id"`
	CreatedAt  time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt  time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}

User represents an authenticated user.

func NewAnonymousUser

func NewAnonymousUser() *User

NewAnonymousUser creates the anonymous user model.

func (*User) BeforeCreate

func (u *User) BeforeCreate(_ *gorm.DB) error

func (User) TableName

func (User) TableName() string

type UserPreference

type UserPreference struct {
	ID        string    `gorm:"primaryKey;type:text" json:"id"`
	UserID    string    `gorm:"column:user_id;not null;type:text;uniqueIndex:idx_user_key" json:"user_id"`
	Key       string    `gorm:"not null;type:text;uniqueIndex:idx_user_key" json:"key"`
	Value     string    `gorm:"not null;type:text" json:"value"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	User *User `gorm:"foreignKey:UserID" json:"-"`
}

UserPreference represents a user preference (key/value store scoped to user).

func (*UserPreference) BeforeCreate

func (p *UserPreference) BeforeCreate(_ *gorm.DB) error

func (UserPreference) TableName

func (UserPreference) TableName() string

type UserSession

type UserSession struct {
	ID        string    `gorm:"primaryKey;type:text" json:"id"`
	UserID    string    `gorm:"column:user_id;not null;type:text;index" json:"user_id"`
	TokenHash string    `gorm:"column:token_hash;uniqueIndex;not null;type:text" json:"token_hash"`
	ExpiresAt time.Time `gorm:"column:expires_at;not null;index" json:"expires_at"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`

	User *User `gorm:"foreignKey:UserID" json:"-"`
}

UserSession represents an authentication session (cookie-based).

func (*UserSession) BeforeCreate

func (s *UserSession) BeforeCreate(_ *gorm.DB) error

func (UserSession) TableName

func (UserSession) TableName() string

type Workspace

type Workspace struct {
	ID            string    `gorm:"primaryKey;type:text" json:"id"`
	ProjectID     string    `gorm:"column:project_id;not null;type:text;index" json:"projectId"`
	Path          string    `gorm:"not null;type:text" json:"path"`
	DisplayName   *string   `gorm:"column:display_name;type:text" json:"displayName,omitempty"`
	SourceType    string    `gorm:"column:source_type;not null;type:text" json:"sourceType"`
	Provider      string    `gorm:"type:text;default:''" json:"provider,omitempty"`
	AutoGenerated bool      `gorm:"column:auto_generated;not null;default:false" json:"autoGenerated"`
	Status        string    `gorm:"not null;type:text;default:initializing" json:"status"`
	ErrorMessage  *string   `gorm:"column:error_message;type:text" json:"errorMessage,omitempty"`
	CreatedAt     time.Time `gorm:"autoCreateTime" json:"createdAt"`
	UpdatedAt     time.Time `gorm:"autoUpdateTime" json:"updatedAt"`

	Project  *Project  `gorm:"foreignKey:ProjectID" json:"-"`
	Sessions []Session `gorm:"foreignKey:WorkspaceID" json:"-"`
}

Workspace represents a working directory (local folder or git repo).

func (*Workspace) BeforeCreate

func (w *Workspace) BeforeCreate(_ *gorm.DB) error

func (Workspace) TableName

func (Workspace) TableName() string

Jump to

Keyboard shortcuts

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