types

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAPIActivity added in v0.7.1

func ConvertAPIActivity(a APIActivity) types2.APIActivity

func ConvertDeviceScan added in v0.22.0

func ConvertDeviceScan(s DeviceScan) types2.DeviceScan

ConvertDeviceScan converts internal DeviceScan to API type. Children must already be loaded (via Preload) for them to appear in the result.

func ConvertDeviceScanClient added in v0.22.0

func ConvertDeviceScanClient(c DeviceScanClient) types2.DeviceScanClient

func ConvertDeviceScanFile added in v0.22.0

func ConvertDeviceScanFile(f DeviceScanFile) types2.DeviceScanFile

ConvertDeviceScanFile converts a stored file row to its wire form. Content is included only when the file wasn't flagged as oversized.

func ConvertDeviceScanMCPServer added in v0.22.0

func ConvertDeviceScanMCPServer(m DeviceScanMCPServer) types2.DeviceScanMCPServer

func ConvertDeviceScanPlugin added in v0.22.0

func ConvertDeviceScanPlugin(p DeviceScanPlugin) types2.DeviceScanPlugin

func ConvertDeviceScanSkill added in v0.22.0

func ConvertDeviceScanSkill(s DeviceScanSkill) types2.DeviceScanSkill

func ConvertMCPAuditLog added in v0.8.0

func ConvertMCPAuditLog(a MCPAuditLog) types2.MCPAuditLog

ConvertMCPAuditLog converts internal MCPAuditLog to API type

func ConvertMCPUsageStats added in v0.8.0

func ConvertMCPUsageStats(s MCPUsageStatItem) types2.MCPUsageStatItem

ConvertMCPUsageStats converts internal MCPUsageStatItem to API type

func ConvertRemainingTokenUsage added in v0.8.0

func ConvertRemainingTokenUsage(userID string, r *RemainingTokenUsage) types2.RemainingTokenUsage

func ConvertTokenActivity added in v0.8.0

func ConvertTokenActivity(a RunTokenActivity) types2.TokenUsage

func ConvertUser

func ConvertUser(u *User, roleFixed bool, authProviderName string) *types2.User

func ConvertUserWithEffectiveRole added in v0.15.0

func ConvertUserWithEffectiveRole(u *User, roleFixed bool, authProviderName string, effectiveRole types2.Role) *types2.User

Types

type APIActivity added in v0.7.1

type APIActivity struct {
	ID     uint
	UserID string
	Date   time.Time
}

type APIKey added in v0.16.0

type APIKey struct {
	ID              uint       `json:"id" gorm:"primaryKey;autoIncrement"`
	UserID          uint       `json:"userId" gorm:"index"`
	Name            string     `json:"name"`                  // User-provided name for the key
	Description     string     `json:"description,omitempty"` // Optional description
	HashedSecret    string     `json:"-"`                     // bcrypt hash of the secret portion only
	CanAccessSkills bool       `json:"canAccessSkills" gorm:"default:false;not null"`
	CreatedAt       time.Time  `json:"createdAt"`
	LastUsedAt      *time.Time `json:"lastUsedAt,omitempty"`
	ExpiresAt       *time.Time `json:"expiresAt,omitempty"` // nil means no expiration

	// MCPServerIDs contains Kubernetes resource names of MCPServers this key can access.
	// Supports all server types: single-user, multi-user, remote, and composite.
	// Use "*" as a wildcard to grant access to all servers the user can access.
	// This may be empty for skills-only API keys.
	MCPServerIDs []string `json:"mcpServerIds,omitempty" gorm:"serializer:json"`
}

APIKey represents an API key for a user to access the Obot API. The key format is: ok1-<user_id>-<key_id>-<secret> Lookups are done by key ID (extracted from the token), then bcrypt.CompareHashAndPassword is used to verify the secret portion.

type APIKeyCreateResponse added in v0.16.0

type APIKeyCreateResponse struct {
	APIKey
	Key string `json:"key"` // The full key, only shown once
}

APIKeyCreateResponse is returned when creating an API key. This is the only time the full key is visible.

type AuthToken

type AuthToken struct {
	ID                    string    `json:"id" gorm:"index:idx_id_hashed_token"`
	UserID                uint      `json:"-" gorm:"index"`
	AuthProviderNamespace string    `json:"-" gorm:"index"`
	AuthProviderName      string    `json:"-" gorm:"index"`
	AuthProviderUserID    string    `json:"-"`
	HashedToken           string    `json:"-" gorm:"index:idx_id_hashed_token"`
	CreatedAt             time.Time `json:"createdAt"`
	ExpiresAt             time.Time `json:"expiresAt,omitzero"`
	NoExpiration          bool      `json:"noExpiration"`
}

type ClientStat added in v0.22.0

type ClientStat struct {
	Name             string `gorm:"column:name"`
	DeviceCount      int64  `gorm:"column:device_count"`
	UserCount        int64  `gorm:"column:user_count"`
	ObservationCount int64  `gorm:"column:observation_count"`
}

ClientStat is one row of the per-client rollup.

type DeviceScan added in v0.22.0

type DeviceScan struct {
	ID             uint      `json:"id" gorm:"primaryKey"`
	CreatedAt      time.Time `json:"createdAt" gorm:"index:idx_ds_user_time,priority:2;index:idx_ds_device_time,priority:2"`
	SubmittedBy    string    `json:"submittedBy" gorm:"index:idx_ds_user_time,priority:1"`
	DeviceID       string    `json:"deviceID" gorm:"index:idx_ds_device_time,priority:1"`
	Hostname       string    `json:"hostname"`
	Username       string    `json:"username"`
	OS             string    `json:"os"`
	Arch           string    `json:"arch"`
	ScannerVersion string    `json:"scannerVersion"`
	ScannedAt      time.Time `json:"scannedAt" gorm:"index"`

	MCPServers []DeviceScanMCPServer `json:"mcpServers,omitempty" gorm:"foreignKey:DeviceScanID;constraint:OnDelete:CASCADE"`
	Skills     []DeviceScanSkill     `json:"skills,omitempty"     gorm:"foreignKey:DeviceScanID;constraint:OnDelete:CASCADE"`
	Plugins    []DeviceScanPlugin    `json:"plugins,omitempty"    gorm:"foreignKey:DeviceScanID;constraint:OnDelete:CASCADE"`
	Files      []DeviceScanFile      `json:"files,omitempty"      gorm:"foreignKey:DeviceScanID;constraint:OnDelete:CASCADE"`
	Clients    []DeviceScanClient    `json:"clients,omitempty"    gorm:"foreignKey:DeviceScanID;constraint:OnDelete:CASCADE"`
}

DeviceScan is the parent envelope. Children (MCPServers, Skills, Plugins, Files) are GORM associations — db.Create(&scan) inserts everything atomically; db.Preload(...).First(...) loads them back.

Composite indexes:

  • idx_ds_user_time (submitted_by, created_at) — list scans for a user
  • idx_ds_device_time (device_id, created_at) — list scans for a device

func DeviceScanFromManifest added in v0.22.0

func DeviceScanFromManifest(p types2.DeviceScanManifest) DeviceScan

DeviceScanFromManifest builds a gateway DeviceScan + its children from a submission manifest. Caller is responsible for setting SubmittedBy on the returned struct before passing it to InsertDeviceScan.

type DeviceScanClient added in v0.22.0

type DeviceScanClient struct {
	ID            uint      `json:"id" gorm:"primaryKey"`
	DeviceScanID  uint      `json:"deviceScanID" gorm:"index;not null"`
	CreatedAt     time.Time `json:"createdAt" gorm:"index"`
	Name          string    `json:"name" gorm:"index"`
	Version       string    `json:"version"`
	BinaryPath    string    `json:"binaryPath"`
	InstallPath   string    `json:"installPath"`
	ConfigPath    string    `json:"configPath"`
	HasMCPServers bool      `json:"hasMCPServers"`
	HasSkills     bool      `json:"hasSkills"`
	HasPlugins    bool      `json:"hasPlugins"`
}

DeviceScanClient is a per-scan record for an AI client observed on the device. Presence facts (BinaryPath, InstallPath, StateDir, Version) come from generic per-client detection. Has{MCPServers, Skills,Plugins} are roll-ups derived from observations attributed to this client name in the same scan.

type DeviceScanFile added in v0.22.0

type DeviceScanFile struct {
	ID           uint      `json:"id" gorm:"primaryKey"`
	DeviceScanID uint      `json:"deviceScanID" gorm:"index;not null"`
	CreatedAt    time.Time `json:"createdAt" gorm:"index"`
	Path         string    `json:"path" gorm:"index"`
	SizeBytes    int64     `json:"sizeBytes"`
	Oversized    bool      `json:"oversized"`
	Content      string    `json:"content" gorm:"type:text"`
}

type DeviceScanMCPServer added in v0.22.0

type DeviceScanMCPServer struct {
	ID           uint                        `json:"id" gorm:"primaryKey"`
	DeviceScanID uint                        `json:"deviceScanID" gorm:"index;not null"`
	CreatedAt    time.Time                   `json:"createdAt" gorm:"index"`
	Client       string                      `json:"client" gorm:"index"`
	Scope        string                      `json:"scope" gorm:"index"`
	ProjectPath  string                      `json:"projectPath" gorm:"index"`
	File         string                      `json:"file"`
	Name         string                      `json:"name" gorm:"index"`
	Transport    string                      `json:"transport" gorm:"index"`
	Command      string                      `json:"command"`
	Args         datatypes.JSONSlice[string] `json:"args"`
	URL          string                      `json:"url"`
	EnvKeys      datatypes.JSONSlice[string] `json:"envKeys"`
	HeaderKeys   datatypes.JSONSlice[string] `json:"headerKeys"`
	ConfigHash   string                      `json:"configHash" gorm:"index"`
}

DeviceScanMCPServer is one MCP server observation. Scope is derived at insert time from ProjectPath ("" → "global", non-empty → "project") and persisted denormalized so list queries hit a single table.

type DeviceScanPlugin added in v0.22.0

type DeviceScanPlugin struct {
	ID            uint                        `json:"id" gorm:"primaryKey"`
	DeviceScanID  uint                        `json:"deviceScanID" gorm:"index;not null"`
	CreatedAt     time.Time                   `json:"createdAt" gorm:"index"`
	Client        string                      `json:"client" gorm:"index"`
	Scope         string                      `json:"scope" gorm:"index"`
	ProjectPath   string                      `json:"projectPath" gorm:"index"`
	ConfigPath    string                      `json:"configPath"`
	Name          string                      `json:"name" gorm:"index"`
	PluginType    string                      `json:"pluginType" gorm:"index"`
	Version       string                      `json:"version"`
	Description   string                      `json:"description"`
	Author        string                      `json:"author"`
	Enabled       bool                        `json:"enabled"`
	Marketplace   string                      `json:"marketplace"`
	Files         datatypes.JSONSlice[string] `json:"files"`
	HasMCPServers bool                        `json:"hasMCPServers"`
	HasSkills     bool                        `json:"hasSkills"`
	HasRules      bool                        `json:"hasRules"`
	HasCommands   bool                        `json:"hasCommands"`
	HasHooks      bool                        `json:"hasHooks"`
}

type DeviceScanSkill added in v0.22.0

type DeviceScanSkill struct {
	ID           uint                        `json:"id" gorm:"primaryKey"`
	DeviceScanID uint                        `json:"deviceScanID" gorm:"index;not null"`
	CreatedAt    time.Time                   `json:"createdAt" gorm:"index"`
	Client       string                      `json:"client" gorm:"index"`
	Scope        string                      `json:"scope" gorm:"index"`
	ProjectPath  string                      `json:"projectPath" gorm:"index"`
	File         string                      `json:"file"`
	Name         string                      `json:"name" gorm:"index"`
	Description  string                      `json:"description"`
	HasScripts   bool                        `json:"hasScripts"`
	GitRemoteURL string                      `json:"gitRemoteURL" gorm:"index"`
	Files        datatypes.JSONSlice[string] `json:"files"`
}

type Group added in v0.9.0

type Group struct {
	// ID is the globally unique identifier for the group.
	// Each auth provider should use a different prefix for their groups to avoid collisions with other providers.
	ID string `json:"id" gorm:"primaryKey;unique"`

	// AuthProviderName is the name of the auth provider that the group belongs to.
	// This is used to identify the auth provider that the group belongs to.
	AuthProviderName string `json:"authProviderName" gorm:"primaryKey;index:idx_group_auth_provider"`

	// AuthProviderNamespace is the namespace of the auth provider that the group belongs to.
	// Note: This is pretty much always "default", but we're keeping it here for parity with the Identity type.
	AuthProviderNamespace string `json:"authProviderNamespace" gorm:"primaryKey;index:idx_group_auth_provider"`

	// Name is the display name of the group.
	Name string `json:"name"`

	// IconURL is the URL of the group's icon.
	IconURL *string `json:"iconURL"`
}

Group represents a group that users can belong to in an auth provider.

type GroupMemberships added in v0.9.0

type GroupMemberships struct {
	// UserID is the ID of the user that is a member of the group.
	UserID uint `json:"userID" gorm:"primaryKey"`

	// GroupID is the globally unique identifier for the group.
	GroupID string `json:"groupID" gorm:"primaryKey"`

	// CreatedAt is when the group membership was created.
	CreatedAt time.Time `json:"createdAt" gorm:"autoCreateTime"`
}

GroupMemberships represents a user's membership in a group.

type GroupRoleAssignment added in v0.15.0

type GroupRoleAssignment struct {
	// GroupName is the name of the auth provider group (used as primary key)
	GroupName string `json:"groupName" gorm:"primaryKey"`

	// CreatedAt is when the assignment was created
	CreatedAt time.Time `json:"createdAt" gorm:"autoCreateTime"`

	// UpdatedAt is when the assignment was last modified
	UpdatedAt time.Time `json:"updatedAt" gorm:"autoUpdateTime"`

	// Role is the role to assign to all members of the group
	Role types2.Role `json:"role" gorm:"not null"`

	// Description is an optional description of why this assignment exists
	Description string `json:"description"`
}

GroupRoleAssignment assigns a role to all members of an auth provider group.

type Identity

type Identity struct {
	AuthProviderName      string    `json:"authProviderName" gorm:"primaryKey;index:idx_user_auth_id"`
	AuthProviderNamespace string    `json:"authProviderNamespace" gorm:"primaryKey;index:idx_user_auth_id"`
	ProviderUsername      string    `json:"providerUsername"`
	ProviderUserID        string    `json:"providerUserID"`
	HashedProviderUserID  string    `json:"hashedProviderUserID" gorm:"primaryKey"`
	ProviderGroupLookupID string    `json:"providerGroupLookupID"`
	Email                 string    `json:"email"`
	HashedEmail           string    `json:"hashedEmail"`
	UserID                uint      `json:"userID" gorm:"index:idx_user_auth_id"`
	IconURL               string    `json:"iconURL"`
	IconLastChecked       time.Time `json:"iconLastChecked"`
	Encrypted             bool      `json:"encrypted"`

	// AuthProviderGroupsLastChecked is the last time the identity's auth provider groups were checked.
	AuthProviderGroupsLastChecked time.Time `json:"authProviderGroupsLastChecked"`

	// AuthProviderGroups is the set of auth provider groups that the identity is a member of.
	AuthProviderGroups []Group `json:"groups" gorm:"-"`
}

func (Identity) GetAuthProviderGroupIDs added in v0.9.0

func (i Identity) GetAuthProviderGroupIDs() []string

func (Identity) GroupLookupID added in v0.18.0

func (i Identity) GroupLookupID() string

type Image added in v0.7.0

type Image struct {
	ID        string    `json:"id" gorm:"primaryKey;autoIncrement:false"`
	CreatedAt time.Time `json:"createdAt"`
	Data      []byte    `json:"-" gorm:"type:bytea;not null"`
	MIMEType  string    `json:"mimeType" gorm:"type:varchar(100);not null"`
}

func (*Image) BeforeCreate added in v0.7.0

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

BeforeCreate will set the ID to a UUID v4.

type LLMProxyActivity

type LLMProxyActivity struct {
	ID             uint
	UserID         string
	CreatedAt      time.Time
	WorkflowID     string
	WorkflowStepID string
	AgentID        string
	ProjectID      string
	ThreadID       string
	RunID          string
	Path           string
}

type MCPAuditLog added in v0.8.0

type MCPAuditLog struct {
	ID                        uint                                  `json:"id" gorm:"primaryKey"`
	CreatedAt                 time.Time                             `json:"createdAt" gorm:"index"`
	APIKey                    string                                `json:"apiKey,omitempty"`
	UserID                    string                                `json:"userID" gorm:"index"`
	MCPID                     string                                `json:"mcpID" gorm:"index"`
	PowerUserWorkspaceID      string                                `json:"powerUserWorkspaceID,omitempty" gorm:"index"`
	MCPServerDisplayName      string                                `json:"mcpServerDisplayName" gorm:"index"`
	MCPServerCatalogEntryName string                                `json:"mcpServerCatalogEntryName" gorm:"index"`
	ClientName                string                                `json:"clientName" gorm:"index"`
	ClientVersion             string                                `json:"clientVersion" gorm:"index"`
	ClientIP                  string                                `json:"clientIP" gorm:"index"`
	CallType                  string                                `json:"callType" gorm:"index"`
	CallIdentifier            string                                `json:"callIdentifier,omitempty" gorm:"index"`
	RequestMutated            bool                                  `json:"requestMutated"`
	RequestBody               json.RawMessage                       `json:"requestBody,omitempty"`
	MutatedRequestBody        json.RawMessage                       `json:"mutatedRequestBody,omitempty"`
	ResponseMutated           bool                                  `json:"responseMutated"`
	ResponseBody              json.RawMessage                       `json:"responseBody,omitempty"`
	OriginalResponseBody      json.RawMessage                       `json:"originalResponseBody,omitempty"`
	ResponseStatus            int                                   `json:"responseStatus" gorm:"index"`
	Error                     string                                `json:"error,omitempty"`
	ProcessingTimeMs          int64                                 `json:"processingTimeMs" gorm:"index"`
	SessionID                 string                                `json:"sessionID,omitempty" gorm:"index"`
	WebhookStatuses           datatypes.JSONSlice[MCPWebhookStatus] `json:"webhookStatuses,omitempty"`

	// Additional metadata
	RequestID       string          `json:"requestID,omitempty" gorm:"index"`
	UserAgent       string          `json:"userAgent,omitempty"`
	RequestHeaders  json.RawMessage `json:"requestHeaders,omitempty"`
	ResponseHeaders json.RawMessage `json:"responseHeaders,omitempty"`

	ResponseReceived bool `json:"responseReceived"`
	Encrypted        bool `json:"encrypted"`
}

MCPAuditLog represents an audit log entry for MCP API calls

type MCPOAuthPendingState added in v0.17.0

type MCPOAuthPendingState struct {
	HashedState        string `gorm:"primaryKey"`
	State              string
	Verifier           string
	UserID             string `gorm:"index:idx_pending_user_mcp"`
	MCPID              string `gorm:"index:idx_pending_user_mcp"`
	URL                string
	OAuthAuthRequestID string
	ClientID           string
	ClientSecret       string
	AuthURL            string
	TokenURL           string
	AuthStyle          oauth2.AuthStyle
	RedirectURL        string
	Scopes             string
	Encrypted          bool
	CreatedAt          time.Time
}

type MCPOAuthToken added in v0.8.0

type MCPOAuthToken struct {
	oauth2.Endpoint
	ClientID     string
	ClientSecret string
	RedirectURL  string
	Scopes       string

	MCPID              string `gorm:"primaryKey"`
	UserID             string `gorm:"primaryKey"`
	URL                string
	OAuthAuthRequestID string `gorm:"index"`
	AccessToken        string
	TokenType          string
	RefreshToken       string
	Expiry             time.Time
	ExpiresIn          int64

	Encrypted bool
}

type MCPPromptReadStats added in v0.8.0

type MCPPromptReadStats struct {
	PromptName string `json:"promptName"`
	ReadCount  int64  `json:"readCount"`
}

MCPPromptReadStats represents statistics for individual prompt reads

type MCPResourceReadStats added in v0.8.0

type MCPResourceReadStats struct {
	ResourceURI string `json:"resourceUri"`
	ReadCount   int64  `json:"readCount"`
}

MCPResourceReadStats represents statistics for individual resource reads

type MCPServerDetail added in v0.22.0

type MCPServerDetail struct {
	MCPServerStat
	EnvKeys    []string
	HeaderKeys []string
}

MCPServerDetail is the per-hash detail payload: an aggregated row plus the union of EnvKeys / HeaderKeys observed across every occurrence (those are deliberately excluded from the hash).

type MCPServerOccurrence added in v0.22.0

type MCPServerOccurrence struct {
	DeviceScanID uint      `gorm:"column:device_scan_id"`
	DeviceID     string    `gorm:"column:device_id"`
	Client       string    `gorm:"column:client"`
	Scope        string    `gorm:"column:scope"`
	ScannedAt    time.Time `gorm:"column:scanned_at"`
	ID           uint      `gorm:"column:id"`
}

MCPServerOccurrence is one device's latest-scan instance of a given ConfigHash.

type MCPServerStat added in v0.22.0

type MCPServerStat struct {
	ConfigHash       string                      `gorm:"column:config_hash"`
	Name             string                      `gorm:"column:name"`
	Transport        string                      `gorm:"column:transport"`
	Command          string                      `gorm:"column:command"`
	Args             datatypes.JSONSlice[string] `gorm:"-"`
	URL              string                      `gorm:"column:url"`
	DeviceCount      int64                       `gorm:"column:device_count"`
	UserCount        int64                       `gorm:"column:user_count"`
	ClientCount      int64                       `gorm:"column:client_count"`
	ObservationCount int64                       `gorm:"column:observation_count"`
}

MCPServerStat is one row of the device-fleet MCP aggregation: every DeviceScanMCPServer with the same ConfigHash, observed in any device's latest scan within the requested time window, collapses into a single entity. Identity fields (Name, Transport, Command, URL, Args) are constant within a ConfigHash group by construction. Args is loaded post-hoc because JSONB has no MAX() in Postgres.

type MCPToolCallStats added in v0.8.0

type MCPToolCallStats struct {
	ToolName  string                 `json:"-"`
	CallCount int64                  `json:"callCount"`
	Items     []MCPToolCallStatsItem `json:"items"`
}

MCPToolCallStats represents statistics for individual tool calls

type MCPToolCallStatsItem added in v0.8.0

type MCPToolCallStatsItem struct {
	ToolName         string    `json:"toolName"`
	CreatedAt        time.Time `json:"createdAt"`
	UserID           string    `json:"userID"`
	ProcessingTimeMs int64     `json:"processingTimeMs"`
	ResponseStatus   int       `json:"responseStatus"`
	Error            string    `json:"error"`
}

type MCPUsageStatItem added in v0.8.0

type MCPUsageStatItem struct {
	MCPID                     string                 `json:"mcpID"`
	MCPServerDisplayName      string                 `json:"mcpServerDisplayName"`
	MCPServerCatalogEntryName string                 `json:"mcpServerCatalogEntryName"`
	ToolCalls                 []MCPToolCallStats     `json:"toolCalls,omitempty"`
	ResourceReads             []MCPResourceReadStats `json:"resourceReads,omitempty"`
	PromptReads               []MCPPromptReadStats   `json:"promptReads,omitempty"`
}

MCPUsageStatItem represents usage statistics for MCP servers

type MCPUsageStatsList added in v0.8.0

type MCPUsageStatsList struct {
	TotalCalls  int64              `json:"totalCalls"`
	UniqueUsers int64              `json:"uniqueUsers"`
	TimeStart   time.Time          `json:"timeStart"`
	TimeEnd     time.Time          `json:"timeEnd"`
	Items       []MCPUsageStatItem `json:"items"`
}

type MCPWebhookStatus added in v0.8.0

type MCPWebhookStatus struct {
	Type    string `json:"type,omitempty"`
	URL     string `json:"url,omitempty"`
	Method  string `json:"method,omitempty"`
	Name    string `json:"name,omitempty"`
	Tool    string `json:"tool,omitempty"`
	Status  string `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
}

type MessagePolicyViolation added in v0.19.0

type MessagePolicyViolation struct {
	ID                   uint            `json:"id" gorm:"primaryKey"`
	CreatedAt            time.Time       `json:"createdAt" gorm:"index"`
	UserID               string          `json:"userID" gorm:"index"`
	PolicyID             string          `json:"policyID" gorm:"index"`
	PolicyName           string          `json:"policyName" gorm:"index"`
	PolicyDefinition     string          `json:"policyDefinition"`
	Direction            string          `json:"direction" gorm:"index"`
	ViolationExplanation string          `json:"violationExplanation"`
	BlockedContent       json.RawMessage `json:"blockedContent,omitempty"`
	ProjectID            string          `json:"projectID" gorm:"index"`
	ThreadID             string          `json:"threadID" gorm:"index"`
	Encrypted            bool            `json:"encrypted"`
}

MessagePolicyViolation represents a record of a message policy violation.

type Migration added in v0.12.0

type Migration struct {
	Name string `gorm:"primaryKey"`
}

type Property added in v0.13.0

type Property struct {
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Key       string    `json:"key" gorm:"primaryKey"`
	Value     string    `json:"value"`
}

type RemainingTokenUsage added in v0.8.0

type RemainingTokenUsage struct {
	PromptTokens              int
	CompletionTokens          int
	UnlimitedPromptTokens     bool
	UnlimitedCompletionTokens bool
}

type RunState added in v0.7.0

type RunState struct {
	Name       string    `json:"name" gorm:"primaryKey"`
	Namespace  string    `json:"namespace" gorm:"primaryKey"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
	ThreadName string    `json:"threadName,omitempty"`
	Program    []byte    `json:"program,omitempty"`
	ChatState  []byte    `json:"chatState,omitempty"`
	CallFrame  []byte    `json:"callFrame,omitempty"`
	Output     []byte    `json:"output,omitempty"`
	Done       bool      `json:"done,omitempty"`
	Error      string    `json:"error,omitempty"`
}

type RunTokenActivity added in v0.8.0

type RunTokenActivity struct {
	ID               uint
	CreatedAt        time.Time
	Name             string
	UserID           string
	Model            string
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	PersonalToken    bool
}

type ServiceAccountAPIKey added in v0.21.0

type ServiceAccountAPIKey struct {
	ID                 uint       `gorm:"primaryKey;autoIncrement"`
	ServiceAccountName string     `gorm:"index;not null"`
	HashedSecret       string     `json:"-"`
	Token              string     `gorm:"-" json:"-"`
	CreatedAt          time.Time  `json:"createdAt"`
	ValidAfter         time.Time  `json:"validAfter"`
	RetireAfter        *time.Time `json:"retireAfter,omitempty"`
}

func (*ServiceAccountAPIKey) PlaintextToken added in v0.21.0

func (k *ServiceAccountAPIKey) PlaintextToken() string

type SkillDetail added in v0.22.0

type SkillDetail struct {
	SkillStat
	Description  string
	HasScripts   bool
	GitRemoteURL string
	Files        []string
}

SkillDetail is the per-skill detail payload: an aggregated row plus representative metadata pulled from a single canonical row in the latest-scan-per-device subset. Description / HasScripts / GitRemoteURL / Files come from one observation and are not guaranteed to be stable across observations sharing the same name.

type SkillOccurrence added in v0.22.0

type SkillOccurrence struct {
	DeviceScanID uint      `gorm:"column:device_scan_id"`
	DeviceID     string    `gorm:"column:device_id"`
	Client       string    `gorm:"column:client"`
	Scope        string    `gorm:"column:scope"`
	ProjectPath  string    `gorm:"column:project_path"`
	ScannedAt    time.Time `gorm:"column:scanned_at"`
	ID           uint      `gorm:"column:id"`
}

SkillOccurrence is one device's latest-scan instance of a given skill name.

type SkillStat added in v0.22.0

type SkillStat struct {
	Name             string `gorm:"column:name"`
	DeviceCount      int64  `gorm:"column:device_count"`
	UserCount        int64  `gorm:"column:user_count"`
	ObservationCount int64  `gorm:"column:observation_count"`
}

SkillStat is one row of the per-skill rollup.

type TempSetupUser added in v0.13.0

type TempSetupUser struct {
	ID                    uint        `json:"id" gorm:"primaryKey"`
	UserID                uint        `json:"userID" gorm:"index"`
	Username              string      `json:"username"`
	Email                 string      `json:"email"`
	Role                  types2.Role `json:"role"`
	IconURL               string      `json:"iconURL"`
	AuthProviderName      string      `json:"authProviderName"`
	AuthProviderNamespace string      `json:"authProviderNamespace"`
	CreatedAt             time.Time   `json:"createdAt"`
}

type TokenRequest

type TokenRequest struct {
	ID                    string `gorm:"primaryKey"`
	CreatedAt             time.Time
	UpdatedAt             time.Time
	State                 string `gorm:"index"`
	Nonce                 string
	Token                 string
	NoExpiration          bool
	ExpiresAt             time.Time
	CompletionRedirectURL string
	Error                 string
	TokenRetrieved        bool
}

type User

type User struct {
	ID                       uint        `json:"id" gorm:"primaryKey"`
	CreatedAt                time.Time   `json:"createdAt"`
	DisplayName              string      `json:"displayName"`
	Username                 string      `json:"username"`
	HashedUsername           string      `json:"-" gorm:"unique"`
	Email                    string      `json:"email"`
	HashedEmail              string      `json:"-"`
	VerifiedEmail            *bool       `json:"verifiedEmail,omitempty"`
	Role                     types2.Role `json:"role"`
	IconURL                  string      `json:"iconURL"`
	Timezone                 string      `json:"timezone"`
	AutonomousToolUseEnabled *bool       `json:"autonomousToolUseEnabled"`

	// LastActiveDay is the time of the last request made by this user, currently at the 24 hour granularity.
	LastActiveDay              time.Time `json:"lastActiveDay"`
	Internal                   bool      `json:"internal" gorm:"default:false"`
	DailyPromptTokensLimit     int       `json:"dailyPromptTokensLimit"`
	DailyCompletionTokensLimit int       `json:"dailyCompletionTokensLimit"`
	Encrypted                  bool      `json:"encrypted"`
	// Soft delete fields
	DeletedAt        *time.Time `json:"deletedAt,omitempty"`
	OriginalEmail    string     `json:"-"`
	OriginalUsername string     `json:"-"`
}

type UserQuery

type UserQuery struct {
	Username       string
	Email          string
	Role           types2.Role
	IncludeDeleted bool
}

func NewUserQuery

func NewUserQuery(u url.Values) UserQuery

func (UserQuery) Scope

func (q UserQuery) Scope(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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