Documentation
¶
Overview ¶
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
types 包提供 Leros 的核心数据类型定义
该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。
Index ¶
- Constants
- Variables
- func BuildDepartmentParentIDs(parent *Department) []uint
- func ValidateOwnerScope(scope OwnerScope, orgID uint) bool
- type AITeammateTemplate
- type Action
- type ArtifactSource
- type ArtifactStatus
- type ArtifactType
- type AssistantPromptTrace
- type AuthLoginAttempt
- type AuthPhoneVerificationCode
- type AuthRefreshToken
- type AuthState
- type Automation
- type AutomationCalendarConfig
- type AutomationCalendarPreset
- type AutomationExecution
- type AutomationExecutionStatus
- type AutomationExecutionTriggerType
- type AutomationIntervalConfig
- type AutomationScheduleFormConfig
- type AutomationScheduleMode
- type AutomationSchedulePolicy
- type AutomationScheduleSpec
- type AutomationScheduleSpecItem
- type Caller
- type CallerKind
- type ChannelType
- type Department
- type DepartmentList
- type DigitalAssistant
- type DigitalAssistantMemory
- type DigitalAssistantPromptBlock
- type DigitalAssistantStatus
- type Event
- type EventAction
- type EventType
- type ExecutionMode
- type FileUpload
- type Filter
- type IdentityContext
- type KnowledgeType
- type LLMHistory
- type LLMLimitFields
- type LLMModel
- type LLMModelConfig
- type LLMModelStatus
- type LLMProviderType
- type LLMSamplingParams
- type MCPChannel
- type MCPChannelAuthBindings
- type MCPChannelAuthConfig
- type MCPChannelAuthConfigJSON
- type MCPChannelAuthField
- type MCPChannelHeaders
- type MCPChannelOAuthConfig
- type MemberDepartment
- type MemberDepartmentList
- type MemberInput
- type MemberRole
- type MemberType
- type MemoryType
- type MessageArtifact
- type MessageArtifactSlice
- type MessageAttachment
- type MessageAttachmentSlice
- type MessageChunk
- type MessageChunkSlice
- type MessageResource
- type MessageRole
- type MessageStatus
- type MessageType
- type MessageUsage
- type ObjectMetadata
- type Organization
- type OwnerScope
- type PageQuery
- type Pagination
- type PermissionCaller
- type PermissionDecision
- type PermissionExplainDecision
- type Plugin
- type PluginMarketplaceItem
- type PluginRevision
- type PluginRevisionContent
- type PluginRevisionFile
- type PluginRevisionFileList
- type PluginStringList
- type Project
- type ProjectActivity
- type ProjectActivityAction
- type ProjectActivityPayload
- type ProjectFile
- type ProjectFileResourceType
- type ProjectMember
- type ProjectPluginBinding
- type ProjectStatus
- type ProjectionReceipt
- type ReliableTask
- type ReliableTaskStatus
- type Resource
- type ResourceBinding
- type ResourcePathIDs
- type ResourceRef
- type ResourceRole
- type ResourceType
- type RuntimeType
- type SeedExecStatus
- type SeedRecord
- type Session
- type SessionMessage
- type SessionStatus
- type SessionType
- type SkillStringList
- type Task
- type TaskStatus
- type TaskType
- type Trace
- type User
- type UserOrg
- type WorkbenchRecentContext
- type WorkerDeployment
- type WorkerDeploymentStatus
Constants ¶
const ( SystemUin uint = 1 SystemOrgID uint = 1 )
const ( // MCPChannelStatusActive allows a channel to be displayed and used for new connections. MCPChannelStatusActive = "active" // MCPChannelStatusInactive keeps a channel configuration without allowing new connections. MCPChannelStatusInactive = "inactive" // MCPChannelAuthTypeNone requires no user authorization. MCPChannelAuthTypeNone = "none" // MCPChannelAuthTypeForm collects connector values from a schema-driven form. MCPChannelAuthTypeForm = "form" // MCPChannelAuthTypeOAuth reserves an OAuth authorization flow for channels that support it. MCPChannelAuthTypeOAuth = "oauth" // MCPChannelAuthTypeManaged delegates credential creation to a server-side handler. MCPChannelAuthTypeManaged = "managed" )
const ( // PluginStatusActive means the plugin can be used by future executions. PluginStatusActive = "active" // PluginStatusArchived means the plugin is retained for history but cannot be newly used. PluginStatusArchived = "archived" )
const ( // TableNameUser 用户表名 TableNameUser = tablenamePrefix + "user" // TableNameOrganization 组织表名 TableNameOrganization = tablenamePrefix + "organization" // TableNameUserOrg 用户组织关联表名 TableNameUserOrg = tablenamePrefix + "user_org" // TableNameAuthRefreshToken 登录刷新令牌表名 TableNameAuthRefreshToken = tablenamePrefix + "auth_refresh_token" // TableNameAuthLoginAttempt 登录失败尝试表名 TableNameAuthLoginAttempt = tablenamePrefix + "auth_login_attempt" // TableNameAuthPhoneVerificationCode 手机验证码表名 TableNameAuthPhoneVerificationCode = tablenamePrefix + "auth_phone_verification_code" // TableNameDigitalAssistant 数字助手表名 TableNameDigitalAssistant = tablenamePrefix + "digital_assistant" // TableNameDigitalAssistantPromptBlock AI 队友提示词分层块表名 TableNameDigitalAssistantPromptBlock = tablenamePrefix + "digital_assistant_prompt_block" // TableNameDigitalAssistantMemory AI 队友长期记忆表名 TableNameDigitalAssistantMemory = tablenamePrefix + "digital_assistant_memory" // TableNameAssistantPromptTrace AI 队友提示词注入追踪表名 TableNameAssistantPromptTrace = tablenamePrefix + "assistant_prompt_trace" // TableNameAITeammateTemplate AI 队友模板表名 TableNameAITeammateTemplate = tablenamePrefix + "ai_teammate_template" // TableNameDigitalAssistantInstance 数字助手实例表名 TableNameDigitalAssistantInstance = tablenamePrefix + "digital_assistant_instance" // TableNameWorkerDeployment Worker 部署表名 TableNameWorkerDeployment = tablenamePrefix + "worker_deployment" // TableNameEvent 事件表名 TableNameEvent = tablenamePrefix + "event" // TableNameSession 会话表名 TableNameSession = tablenamePrefix + "session" // TableNameSessionMessage 会话消息表名 TableNameSessionMessage = tablenamePrefix + "session_message" // TableNameReliableTask 通用可靠任务 Outbox 表名。 TableNameReliableTask = tablenamePrefix + "reliable_task" // TableNameProjectionReceipt 通用事件投影回执表名。 TableNameProjectionReceipt = tablenamePrefix + "projection_receipt" // TableNameLLMModel LLM模型配置表名 TableNameLLMModel = tablenamePrefix + "llm_model" // TableNameLLMHistory LLM调用记录表名 TableNameLLMHistory = tablenamePrefix + "llm_history" // TableNameLLMCallRecord 旧LLM调用记录表名(待迁移至 TableNameLLMHistory) TableNameLLMCallRecord = tablenamePrefix + "llm_call_record" // TableNameProject 项目表名 TableNameProject = tablenamePrefix + "project" // TableNameProjectMember 项目成员表名 TableNameProjectMember = tablenamePrefix + "project_member" // TableNameProjectActivity 项目操作动态表名 TableNameProjectActivity = tablenamePrefix + "project_activity" // TableNameResource 统一资源表名 TableNameResource = tablenamePrefix + "resource" // TableNameResourceBinding 统一资源身份绑定表名 TableNameResourceBinding = tablenamePrefix + "resource_binding" // TableNameTask 任务表名 TableNameTask = tablenamePrefix + "task" // TableNameWorkbenchRecentContext 工作台最近使用上下文表名 TableNameWorkbenchRecentContext = tablenamePrefix + "workbench_recent_context" // TableNameFileUpload 文件上传表名 TableNameFileUpload = tablenamePrefix + "file_upload" // TableNameProjectFile 项目文件关联表名 TableNameProjectFile = tablenamePrefix + "project_file" // TableNamePlugin 组织插件表名 TableNamePlugin = tablenamePrefix + "plugin" // TableNamePluginRevision 插件修订表名 TableNamePluginRevision = tablenamePrefix + "plugin_revision" // TableNamePluginRevisionContent 插件修订内容快照表名 TableNamePluginRevisionContent = tablenamePrefix + "plugin_revision_content" // TableNameProjectPluginBinding 项目插件绑定表名 TableNameProjectPluginBinding = tablenamePrefix + "project_plugin_binding" // TableNamePluginMarketplaceItem 系统插件市场目录表名 TableNamePluginMarketplaceItem = tablenamePrefix + "plugin_marketplace_item" // TableNameMCPChannel 系统 MCP 渠道配置表名 TableNameMCPChannel = tablenamePrefix + "mcp_channel" // TableNameMessageResource 消息资源关联表名 TableNameMessageResource = tablenamePrefix + "message_resource" // TableNameDepartment 组织部门表名 TableNameDepartment = tablenamePrefix + "department" // TableNameMemberDepartment 组织成员部门关联表名 TableNameMemberDepartment = tablenamePrefix + "rel_user_org_department" // TableNameSeedRecord SQL 种子执行记录表名 TableNameSeedRecord = tablenamePrefix + "seed_record" // TableNameAutomation 自动化定时任务配置表名 TableNameAutomation = tablenamePrefix + "automation" // TableNameAutomationExecution 自动化执行记录表名 TableNameAutomationExecution = tablenamePrefix + "automation_execution" )
数据库表名常量定义
const ( DefaultPageSize = 10 PageMaxCount = 150 )
分页默认值
const DefaultDigitalAssistantPublicIDPrefix = "assistant_default_"
DefaultDigitalAssistantPublicIDPrefix identifies organization-level system assistants.
const (
// PluginRevisionContentSchemaSkillV1 identifies the first Skill content snapshot shape.
PluginRevisionContentSchemaSkillV1 = "skill-content/v1"
)
Variables ¶
var ErrBindingIdentityRequired = errors.New("uin and assistant_id cannot both be zero or empty")
ErrBindingIdentityRequired 表示绑定必须指定至少一个主体标识(uin 或 assistant_id)。
var ResourceRoleStrength = map[ResourceRole]int{ ResourceRoleOwner: 3, ResourceRoleAdmin: 2, ResourceRoleMember: 1, }
ResourceRoleStrength 定义各资源角色的强度值,用于跨资源层继承时取最高角色。 owner > admin > member;未知角色强度视为 0。
Functions ¶
func BuildDepartmentParentIDs ¶ added in v0.1.23
func BuildDepartmentParentIDs(parent *Department) []uint
BuildDepartmentParentIDs 根据父部门构建祖先 ID 链(从根到直接父部门)。
func ValidateOwnerScope ¶ added in v0.3.7
func ValidateOwnerScope(scope OwnerScope, orgID uint) bool
ValidateOwnerScope checks the scope and organization identity invariant.
Types ¶
type AITeammateTemplate ¶ added in v0.1.22
type AITeammateTemplate struct {
gorm.Model
// Code is the globally unique business identifier for the template.
Code string `gorm:"column:code;type:varchar(128);not null;uniqueIndex" json:"code"`
// Name is the display name shown in the AI teammate template list.
Name string `gorm:"column:name;type:varchar(255);not null" json:"name"`
// Description is the short user-facing summary.
Description string `gorm:"column:description;type:text" json:"description"`
// Avatar stores a URL or built-in avatar resource identifier.
Avatar string `gorm:"column:avatar;type:varchar(500)" json:"avatar"`
// Provider records where the preset teammate profile comes from.
Provider string `gorm:"column:provider;type:varchar(100)" json:"provider"`
// SystemPrompt is copied to DigitalAssistant.SystemPrompt when creating from the template.
SystemPrompt string `gorm:"column:system_prompt;type:text;not null" json:"system_prompt"`
// Expertise stores the template's domain tags.
Expertise SkillStringList `gorm:"column:expertise;type:jsonb" json:"expertise"`
// Category supports filtering in the AI teammate marketplace.
Category string `gorm:"column:category;type:varchar(100);not null;index" json:"category"`
// Tags stores search and display labels.
Tags SkillStringList `gorm:"column:tags;type:jsonb" json:"tags"`
// SortOrder controls default ordering in the marketplace.
SortOrder int `gorm:"column:sort_order;type:integer;not null;default:0;index" json:"sort_order"`
// UseCount records successful teammate creations from this template.
UseCount int64 `gorm:"column:use_count;type:bigint;not null;default:0" json:"use_count"`
// RecommendCount records template recommendation exposure actions.
RecommendCount int64 `gorm:"column:recommend_count;type:bigint;not null;default:0" json:"recommend_count"`
// Status controls whether the template can be listed and used.
Status string `gorm:"column:status;type:varchar(32);not null;default:active;index" json:"status"`
// IsSystem marks templates shipped by the platform.
IsSystem bool `gorm:"column:is_system;type:boolean;not null;default:true" json:"is_system"`
}
AITeammateTemplate stores preset AI teammate profiles for marketplace-style creation.
func (AITeammateTemplate) TableName ¶ added in v0.1.22
func (AITeammateTemplate) TableName() string
TableName returns the AI teammate template table name.
type Action ¶ added in v0.2.1
type Action string
Action 表示对资源的操作类型,由 PermissionPolicy 定义允许的集合。
const ( // ActionProjectView 查看项目。 ActionProjectView Action = "project:view" // ActionProjectUpdate 更新项目元数据。 ActionProjectUpdate Action = "project:update" // ActionProjectDelete 删除项目。 ActionProjectDelete Action = "project:delete" // ActionProjectMemberCreate 添加项目成员。 ActionProjectMemberCreate Action = "project:member.create" // ActionProjectMemberUpdate 更新项目成员角色。 ActionProjectMemberUpdate Action = "project:member.update" // ActionProjectMemberDelete 移除项目成员。 ActionProjectMemberDelete Action = "project:member.delete" // ActionProjectMemberList 查看项目成员列表。 ActionProjectMemberList Action = "project:member.list" // ActionProjectMemberLeave 退出项目(仅允许操作自己)。 ActionProjectMemberLeave Action = "project:member.leave" // ActionFileView 查看文件。 ActionFileView Action = "file:view" // ActionFileDownload 下载文件。 ActionFileDownload Action = "file:download" // ActionArtifactView 查看产物。 ActionArtifactView Action = "artifact:view" // ActionArtifactDownload 下载产物。 ActionArtifactDownload Action = "artifact:download" // ActionTaskCreate 在父项目下创建任务(经项目 effective role 解释)。 ActionTaskCreate Action = "task:create" // ActionTaskView 查看任务。 ActionTaskView Action = "task:view" // ActionTaskUpdate 更新任务。 ActionTaskUpdate Action = "task:update" // ActionTaskDelete 删除任务。 ActionTaskDelete Action = "task:delete" )
type ArtifactSource ¶
type ArtifactSource string
ArtifactSource 表示产出物记录来源。
const ( // ArtifactSourceAgentDeclared 表示 Agent 通过 manifest 显式声明的产物。 ArtifactSourceAgentDeclared ArtifactSource = "agent_declared" // ArtifactSourceDiff 表示通过执行前后文件变更自动检测到的产物。 ArtifactSourceDiff ArtifactSource = "diff" )
type ArtifactStatus ¶
type ArtifactStatus string
ArtifactStatus 表示产出物的状态
const ( // ArtifactStatusCompleted 产出物已完成 ArtifactStatusCompleted ArtifactStatus = "completed" )
type ArtifactType ¶
type ArtifactType string
ArtifactType 表示产出物的类型
const ( // ArtifactTypeFile 文件附件(图片、压缩包、二进制) ArtifactTypeFile ArtifactType = "file" )
type AssistantPromptTrace ¶ added in v0.1.22
type AssistantPromptTrace struct {
gorm.Model
// SessionID references the session where this prompt was assembled.
SessionID uint `gorm:"column:session_id;type:bigint;not null;index"`
// MessageID references the user message that triggered this prompt assembly.
MessageID uint `gorm:"column:message_id;type:bigint;not null;index"`
// AssistantID references the AI teammate whose persona was assembled.
AssistantID uint `gorm:"column:assistant_id;type:bigint;not null;index"`
// CorePromptVersion records the mandatory identity prompt version.
CorePromptVersion int `gorm:"column:core_prompt_version;type:integer;not null;default:1"`
// InjectedBlockIDs records prompt block IDs injected into this request.
InjectedBlockIDs SkillStringList `gorm:"column:injected_block_ids;type:jsonb"`
// InjectedMemoryIDs records memory IDs injected into this request.
InjectedMemoryIDs SkillStringList `gorm:"column:injected_memory_ids;type:jsonb"`
// PromptHash stores a stable hash of the assembled prompt for debugging without duplicating long text.
PromptHash string `gorm:"column:prompt_hash;type:varchar(128);index"`
}
AssistantPromptTrace records which persona layers and memories were injected for an LLM request.
func (AssistantPromptTrace) TableName ¶ added in v0.1.22
func (AssistantPromptTrace) TableName() string
TableName returns the assistant prompt trace table name.
type AuthLoginAttempt ¶
type AuthLoginAttempt struct {
gorm.Model
Identifier string `gorm:"column:identifier;type:varchar(255);uniqueIndex;not null"`
FailureCount int `gorm:"column:failure_count;type:integer;default:0;not null"`
WindowExpiresAt time.Time `gorm:"column:window_expires_at;index;not null"`
}
AuthLoginAttempt stores failed login counters in a rolling window.
func (AuthLoginAttempt) TableName ¶
func (AuthLoginAttempt) TableName() string
TableName 指定AuthLoginAttempt结构体对应的数据库表名。
type AuthPhoneVerificationCode ¶ added in v0.1.12
type AuthPhoneVerificationCode struct {
gorm.Model
Phone string `gorm:"column:phone;type:varchar(32);index;not null"`
CodeHash string `gorm:"column:code_hash;type:varchar(64);not null"`
ExpiresAt time.Time `gorm:"column:expires_at;index;not null"`
UsedAt *time.Time `gorm:"column:used_at;index"`
}
AuthPhoneVerificationCode stores one-time phone login codes.
func (AuthPhoneVerificationCode) TableName ¶ added in v0.1.12
func (AuthPhoneVerificationCode) TableName() string
TableName 指定AuthPhoneVerificationCode结构体对应的数据库表名。
type AuthRefreshToken ¶
type AuthRefreshToken struct {
gorm.Model
TokenHash string `gorm:"column:token_hash;type:varchar(64);uniqueIndex;not null"`
Uin uint `gorm:"column:uin;type:bigint;index;not null;default:0"`
LoginWay int `gorm:"column:login_way;type:int;not null;default:0"`
ExpiresAt time.Time `gorm:"column:expires_at;index;not null"`
RevokedAt *time.Time `gorm:"column:revoked_at;index"`
}
AuthRefreshToken stores a hashed refresh token for local account sessions.
func (AuthRefreshToken) TableName ¶
func (AuthRefreshToken) TableName() string
TableName 指定AuthRefreshToken结构体对应的数据库表名。
type Automation ¶ added in v0.3.9
type Automation struct {
gorm.Model
// automation - 自动化唯一标识,格式如:auto_xxx,VARCHAR(255),NOT NULL,UNIQUE
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
// automation - 所属组织ID,INTEGER,NOT NULL,INDEX
OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
// automation - 创建者用户ID(执行身份),INTEGER,NOT NULL,INDEX
OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
// automation - 自动化名称,VARCHAR(100),NOT NULL
Name string `gorm:"column:name;type:varchar(100);not null"`
// automation - 每轮发送给 Agent 的完整指令,TEXT,允许为空
Instruction string `gorm:"column:instruction;type:text"`
// automation - 是否接受周期触发,BOOLEAN,NOT NULL,DEFAULT TRUE
Enabled bool `gorm:"column:enabled;type:boolean;not null;default:true"`
// automation - 调度模式(calendar/interval),只表示底层计算模式,VARCHAR(16),NOT NULL
ScheduleMode string `gorm:"column:schedule_mode;type:varchar(16);not null"`
// automation - 版本化规范化调度规则,JSONB,NOT NULL,DEFAULT '{}'
ScheduleSpec AutomationScheduleSpec `gorm:"column:schedule_spec;type:jsonb;not null;default:'{}'"`
// automation - IANA 时区,VARCHAR(64),NOT NULL,DEFAULT 'Asia/Shanghai'
Timezone string `gorm:"column:timezone;type:varchar(64);not null;default:'Asia/Shanghai'"`
// automation - 创建时固定的默认 AI 队友 ID,BIGINT,NOT NULL,INDEX
AssistantID uint `gorm:"column:assistant_id;type:bigint;not null;index"`
// automation - 下一次计划执行时间(UTC),TIMESTAMP,可空
NextRunAt *time.Time `gorm:"column:next_run_at;type:timestamp"`
// automation - 最近一次实际生成 execution 的时间(UTC),TIMESTAMP,可空
LastRunAt *time.Time `gorm:"column:last_run_at;type:timestamp"`
// automation - 当前自动化项目主键,BIGINT,可空,INDEX
ProjectID *uint `gorm:"column:project_id;type:bigint;index"`
// automation - 当前项目代数,初始为 0,INTEGER,NOT NULL,DEFAULT 0
ProjectGeneration int `gorm:"column:project_generation;type:integer;not null;default:0"`
}
Automation 表示系统中的自动化定时任务配置
自动化是将一条 Agent 指令按日历规则或固定间隔自动执行的长期调度配置。 自动化本身不是任务(Task),它只在每次触发时生成一次执行记录(AutomationExecution, Phase 2 引入)和对应的 cron 任务。
func (Automation) TableName ¶ added in v0.3.9
func (Automation) TableName() string
TableName 指定Automation结构体对应的数据库表名
type AutomationCalendarConfig ¶ added in v0.3.9
type AutomationCalendarConfig struct {
// Preset 预设类型:daily/weekly/monthly/hourly
Preset string `json:"preset"`
// Hour 小时(0-23)
Hour int `json:"hour"`
// Minute 分钟(0-59)
Minute int `json:"minute"`
// DaysOfWeek 每周预设的星期集合(0=周日,6=周六),0-6
DaysOfWeek []int `json:"days_of_week,omitempty"`
// DaysOfMonth 每月预设的日期集合(1-31)
DaysOfMonth []int `json:"days_of_month,omitempty"`
}
AutomationCalendarConfig 表示日历类预设的表单配置
type AutomationCalendarPreset ¶ added in v0.3.9
type AutomationCalendarPreset string
AutomationCalendarPreset 表示日历类预设类型。
预设只用于前端表单生成/回显配置,不参与后端执行算法选择;执行算法只依赖 calendar/interval 两种规范化规则。
const ( AutomationPresetDaily AutomationCalendarPreset = "daily" AutomationPresetWeekly AutomationCalendarPreset = "weekly" AutomationPresetMonthly AutomationCalendarPreset = "monthly" AutomationPresetHourly AutomationCalendarPreset = "hourly" )
type AutomationExecution ¶ added in v0.3.9
type AutomationExecution struct {
gorm.Model
// autom_auto_exec - 对外 ID,格式如:autoexec_xxx,VARCHAR(255),NOT NULL,UNIQUE
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
// autom_auto_exec - 所属自动化主键,BIGINT,NOT NULL,INDEX(与 occurrence_key 组成唯一防重)
AutomationID uint `gorm:"column:automation_id;type:bigint;not null;index;uniqueIndex:ux_auto_exec_occurrence"`
// autom_auto_exec - 所属组织ID,BIGINT,NOT NULL,INDEX
OrgID uint `gorm:"column:org_id;type:bigint;not null;index"`
// autom_auto_exec - 执行身份(创建者)用户ID,BIGINT,NOT NULL,INDEX
OwnerID uint `gorm:"column:owner_id;type:bigint;not null;index"`
// autom_auto_exec - 触发来源:scheduled/manual,VARCHAR(16),NOT NULL
TriggerType AutomationExecutionTriggerType `gorm:"column:trigger_type;type:varchar(16);not null;index"`
// autom_auto_exec - 周期防重键;周期触发用理论计划时间,手动触发用 execution public ID。
// (automation_id, occurrence_key) 组合唯一,作为周期最终防重边界。
OccurrenceKey string `gorm:"column:occurrence_key;type:varchar(128);not null;uniqueIndex:ux_auto_exec_occurrence"`
// autom_auto_exec - 执行状态:queued/running/succeeded/failed/skipped,VARCHAR(16),NOT NULL,INDEX
Status AutomationExecutionStatus `gorm:"column:status;type:varchar(16);not null;default:'queued';index"`
// autom_auto_exec - 理论触发时间(UTC),TIMESTAMP,NOT NULL
ScheduledAt time.Time `gorm:"column:scheduled_at;not null;index"`
// autom_auto_exec - Worker 最晚允许开始时间(UTC),TIMESTAMP,可空
NotAfter *time.Time `gorm:"column:not_after;type:timestamp"`
// autom_auto_exec - 实际开始时间(UTC),TIMESTAMP,可空
StartedAt *time.Time `gorm:"column:started_at;type:timestamp"`
// autom_auto_exec - 实际完成时间(UTC),TIMESTAMP,可空
FinishedAt *time.Time `gorm:"column:finished_at;type:timestamp"`
// autom_auto_exec - 自动化名称快照,VARCHAR(100),NOT NULL
NameSnapshot string `gorm:"column:name_snapshot;type:varchar(100);not null"`
// autom_auto_exec - 指令快照,TEXT,允许为空
InstructionSnapshot string `gorm:"column:instruction_snapshot;type:text"`
// autom_auto_exec - 固定 AI 队友快照,BIGINT,NOT NULL
AssistantIDSnapshot uint `gorm:"column:assistant_id_snapshot;type:bigint;not null"`
// autom_auto_exec - 被折叠的更早遗漏数量,INTEGER,NOT NULL,DEFAULT 0
MissedCount int `gorm:"column:missed_count;type:integer;not null;default:0"`
// autom_auto_exec - 已创建项目主键,BIGINT,可空,INDEX
ProjectID *uint `gorm:"column:project_id;type:bigint;index"`
// autom_auto_exec - 已创建任务主键,BIGINT,可空,INDEX
TaskID *uint `gorm:"column:task_id;type:bigint;index"`
// autom_auto_exec - 已创建会话主键,BIGINT,可空,INDEX
SessionID *uint `gorm:"column:session_id;type:bigint;index"`
// autom_auto_exec - 已创建首条消息主键,BIGINT,可空,INDEX
MessageID *uint `gorm:"column:message_id;type:bigint;index"`
// autom_auto_exec - Worker Run 标识,VARCHAR(255),可空,INDEX
RunID string `gorm:"column:run_id;type:varchar(255);index"`
// autom_auto_exec - Dispatcher 投递尝试次数,INTEGER,NOT NULL,DEFAULT 0
AttemptCount int `gorm:"column:attempt_count;type:integer;not null;default:0"`
// autom_auto_exec - 多实例执行领取租约持有者,VARCHAR(64),可空
LeaseOwner string `gorm:"column:lease_owner;type:varchar(64)"`
// autom_auto_exec - 领取租约到期时间(UTC),TIMESTAMP,可空
LeaseUntil *time.Time `gorm:"column:lease_until;type:timestamp"`
// autom_auto_exec - 稳定错误码,VARCHAR(64),可空
ErrorCode string `gorm:"column:error_code;type:varchar(64)"`
// autom_auto_exec - 可展示失败信息(入库前截断并清理敏感字段),TEXT,可空
ErrorMsg string `gorm:"column:error_msg;type:text"`
// autom_auto_exec - 命令成功写入 JetStream 的时间(UTC),TIMESTAMP,可空
DispatchedAt *time.Time `gorm:"column:dispatched_at;type:timestamp"`
}
AutomationExecution 表示一次自动化计划触发或手动触发。
每次触发生成一条独立记录,用于追踪执行生命周期、状态、失败原因和 已创建的业务实体(项目/任务/会话/消息/Run)。execution 同时充当 Server 侧的持久化 outbox,保证 NATS 失败时可重试、不重复。
func (AutomationExecution) TableName ¶ added in v0.3.9
func (AutomationExecution) TableName() string
TableName 指定AutomationExecution结构体对应的数据库表名
type AutomationExecutionStatus ¶ added in v0.3.9
type AutomationExecutionStatus string
AutomationExecutionStatus 表示一次自动化执行的生命周期状态
const ( // AutomationExecutionQueued 已生成,等待派发 AutomationExecutionQueued AutomationExecutionStatus = "queued" // AutomationExecutionRunning 已派发并开始执行 AutomationExecutionRunning AutomationExecutionStatus = "running" // AutomationExecutionSucceeded 执行成功 AutomationExecutionSucceeded AutomationExecutionStatus = "succeeded" // AutomationExecutionFailed 执行失败 AutomationExecutionFailed AutomationExecutionStatus = "failed" // AutomationExecutionSkipped 因上一轮仍活跃等原因被跳过 AutomationExecutionSkipped AutomationExecutionStatus = "skipped" )
type AutomationExecutionTriggerType ¶ added in v0.3.9
type AutomationExecutionTriggerType string
AutomationExecutionTriggerType 表示一次执行的触发来源
const ( // AutomationTriggerScheduled 周期触发 AutomationTriggerScheduled AutomationExecutionTriggerType = "scheduled" // AutomationTriggerManual 手动触发(立即运行) AutomationTriggerManual AutomationExecutionTriggerType = "manual" )
type AutomationIntervalConfig ¶ added in v0.3.9
type AutomationIntervalConfig struct {
// IntervalSeconds 间隔秒数
IntervalSeconds int64 `json:"interval_seconds,omitempty"`
// AnchorAt 本地时区锚点时间(ISO8601,不带时区偏移,解释为指定时区)
AnchorAt string `json:"anchor_at,omitempty"`
// IntervalMinutes 间隔分钟数(表单友好字段,服务端换算为秒并生成 interval_seconds)
IntervalMinutes int `json:"interval_minutes,omitempty"`
// IntervalUnit 间隔单位,只用于回显:minute/hour/day
IntervalUnit string `json:"interval_unit,omitempty"`
}
AutomationIntervalConfig 表示固定间隔配置的表单配置
type AutomationScheduleFormConfig ¶ added in v0.3.9
type AutomationScheduleFormConfig struct {
// Mode 调度模式(calendar/interval),与 Automation 的 schedule_mode 保持一致
Mode string `json:"mode"`
// Calendar 日历类预设配置(mode == "calendar" 时有效)
Calendar *AutomationCalendarConfig `json:"calendar,omitempty"`
// Interval 固定间隔配置(mode == "interval" 时有效)
Interval *AutomationIntervalConfig `json:"interval,omitempty"`
// Timezone 表单发起时的 IANA 时区
Timezone string `json:"timezone,omitempty"`
}
AutomationScheduleFormConfig 表示前端表单的编辑模型(用于回显)
其中 mode 仅用于编辑界面展示,最终调度语义由 AutomationScheduleSpec.Spec 决定。
type AutomationScheduleMode ¶ added in v0.3.9
type AutomationScheduleMode string
AutomationScheduleMode 表示自动化的底层调度计算模式
const ( // AutomationScheduleModeCalendar 按本地日历边界执行 AutomationScheduleModeCalendar AutomationScheduleMode = "calendar" // AutomationScheduleModeInterval 从锚点开始按固定时长执行 AutomationScheduleModeInterval AutomationScheduleMode = "interval" )
type AutomationSchedulePolicy ¶ added in v0.3.9
type AutomationSchedulePolicy struct {
// MonthDayOverflow 当日历配置的日期超过目标月份实际天数时的处理方式
// 取值为 last_day(月末回退),默认 last_day
MonthDayOverflow string `json:"month_day_overflow,omitempty"`
}
AutomationSchedulePolicy 表示日历规则的边界策略
type AutomationScheduleSpec ¶ added in v0.3.9
type AutomationScheduleSpec struct {
// FormConfig 前端表单编辑模型,用于编辑回显
FormConfig *AutomationScheduleFormConfig `json:"form_config"`
// Spec 编译后的规范化规则
Spec AutomationScheduleSpecItem `json:"spec"`
}
AutomationScheduleSpec 表示自动化的完整调度配置,jsonb 存储
func (*AutomationScheduleSpec) Scan ¶ added in v0.3.9
func (s *AutomationScheduleSpec) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口,用于从数据库中读取 JSON 数据
type AutomationScheduleSpecItem ¶ added in v0.3.9
type AutomationScheduleSpecItem struct {
// Version 规则版本
Version int `json:"version"`
// Mode 底层计算模式:calendar/interval
Mode string `json:"mode"`
// Expression 日历模式下的 cron 表达式(mode == "calendar" 时有效)
Expression string `json:"expression,omitempty"`
// Policy 边界策略(月末回退等)
Policy *AutomationSchedulePolicy `json:"policy,omitempty"`
// AnchorAt 固定间隔模式的本地锚点时间
AnchorAt string `json:"anchor_at,omitempty"`
// IntervalSeconds 固定间隔模式的间隔秒数
IntervalSeconds int64 `json:"interval_seconds,omitempty"`
// Timezone 规则生效时区
Timezone string `json:"timezone"`
}
AutomationScheduleSpecItem 表示编译后的规范化调度规则(Phase 2 直接使用)
type Caller ¶
type Caller struct {
Uin uint `json:"uin"`
OrgID uint `json:"org_id"`
WorkerID uint `json:"worker_id,omitempty"`
Kind CallerKind `json:"kind,omitempty"`
State AuthState `json:"state"`
}
Caller 定义了一个执行身份,包含用户 ID、租户 ID 和认证状态。
func SystemIdentity ¶
func SystemIdentity() *Caller
SystemIdentity 返回一个预定义的系统身份,通常用于系统内部调用或没有特定用户上下文的场景。
type CallerKind ¶ added in v0.1.12
type CallerKind string
CallerKind identifies the authenticated principal type.
const ( CallerKindUser CallerKind = "user" CallerKindWorker CallerKind = "worker" CallerKindSystem CallerKind = "system" )
type ChannelType ¶
type ChannelType string
ChannelType 表示渠道类型标识
const ( // ChannelTypeGitHub 表示GitHub渠道 ChannelTypeGitHub ChannelType = "github" // ChannelTypeGitLab 表示GitLab渠道 ChannelTypeGitLab ChannelType = "gitlab" // ChannelTypeWeChat 表示微信渠道 ChannelTypeWeChat ChannelType = "wechat" // ChannelTypeWeWork 表示企业微信渠道 ChannelTypeWeWork ChannelType = "wework" // ChannelTypeFeishu 表示飞书渠道 ChannelTypeFeishu ChannelType = "feishu" )
type Department ¶ added in v0.1.23
type Department struct {
gorm.Model
Name string `` /* 134-byte string literal not displayed */
ParentID uint `` /* 133-byte string literal not displayed */
ParentIDs []uint `gorm:"column:parent_ids;type:jsonb;serializer:json;comment:祖先部门ID链,从根到直接父部门"`
Sort uint `gorm:"column:sort;type:bigint;not null;default:0;comment:同级排序"`
OrgID uint `` /* 150-byte string literal not displayed */
}
Department 表示组织部门表。
func (Department) TableName ¶ added in v0.1.23
func (Department) TableName() string
TableName 返回组织部门表名。
type DepartmentList ¶ added in v0.1.23
type DepartmentList []Department
DepartmentList 表示组织部门列表。
func (DepartmentList) ToMap ¶ added in v0.1.23
func (l DepartmentList) ToMap() map[uint]Department
ToMap 按主键索引组织部门列表。
type DigitalAssistant ¶
type DigitalAssistant struct {
gorm.Model
// digital_assistant - 公开标识符,在组织内唯一标识数字助手,VARCHAR(255),NOT NULL
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
// digital_assistant - 所属组织ID,INTEGER,NOT NULL
OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
// digital_assistant - 拥有者ID,INTEGER,NOT NULL
OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
// digital_assistant - 数字助手名称,VARCHAR(255),NOT NULL
Name string `gorm:"column:name;type:varchar(255);not null"`
// digital_assistant - 对外展示的角色名称,VARCHAR(255),允许为空以兼容历史数据
RoleName string `gorm:"column:role_name;type:varchar(255)"`
// digital_assistant - 描述信息,TEXT,允许为空
Description string `gorm:"column:description;type:text"`
// digital_assistant - 头像URL地址,VARCHAR(500),允许为空
Avatar string `gorm:"column:avatar;type:varchar(500)"`
// digital_assistant - 状态,表示数字助手当前运行状态,VARCHAR(50),NOT NULL
Status string `gorm:"column:status;type:varchar(50);not null"`
// digital_assistant - 版本号,跟踪配置变动版本,INTEGER,默认值0
Version int `gorm:"column:version;type:integer;default:0"`
// digital_assistant - 系统提示词,定义数字助手的角色和行为,TEXT,允许为空
SystemPrompt string `gorm:"column:system_prompt;type:text"`
// digital_assistant - 擅长领域列表,JSONB,允许为空
Expertise SkillStringList `gorm:"column:expertise;type:jsonb"`
// digital_assistant - 来源模板ID,INTEGER,允许为空
TemplateID *uint `gorm:"column:template_id;type:integer;index"`
// digital_assistant - 创建来源,VARCHAR(32),NOT NULL
Source string `gorm:"column:source;type:varchar(32);not null;default:custom;index"`
}
DigitalAssistant 数字助手结构体定义了AI数字助手的基本信息与配置
func (DigitalAssistant) TableName ¶
func (DigitalAssistant) TableName() string
TableName 指定DigitalAssistant结构体对应的数据库表名
type DigitalAssistantMemory ¶ added in v0.1.22
type DigitalAssistantMemory struct {
gorm.Model
// AssistantID references the AI teammate that owns this memory.
AssistantID uint `gorm:"column:assistant_id;type:bigint;not null;index:idx_da_memory_assistant_type"`
// MemoryType identifies the memory category, such as preference, experience, template, fact, or rule.
MemoryType string `gorm:"column:memory_type;type:varchar(32);not null;index:idx_da_memory_assistant_type"`
// Content stores the memory text that can be retrieved and injected later.
Content string `gorm:"column:content;type:text;not null"`
// SourceType records where the memory came from, such as user_confirmed, task_summary, or manual.
SourceType string `gorm:"column:source_type;type:varchar(64);not null;default:manual;index"`
// SourceID optionally links the memory to a task, session, message, or external artifact.
SourceID string `gorm:"column:source_id;type:varchar(255);index"`
// Confidence records trust in this memory before it is used for prompt assembly.
Confidence float64 `gorm:"column:confidence;type:double precision;not null;default:0.8;index"`
// EmbeddingID stores the vector-store identifier when retrieval is enabled.
EmbeddingID string `gorm:"column:embedding_id;type:varchar(255);index"`
// Enabled controls whether the memory can participate in retrieval.
Enabled bool `gorm:"column:enabled;type:boolean;not null;default:true;index"`
}
DigitalAssistantMemory stores evolvable teammate memory for future retrieval-augmented persona.
func (DigitalAssistantMemory) TableName ¶ added in v0.1.22
func (DigitalAssistantMemory) TableName() string
TableName returns the digital assistant memory table name.
type DigitalAssistantPromptBlock ¶ added in v0.1.22
type DigitalAssistantPromptBlock struct {
gorm.Model
// AssistantID references the AI teammate that owns this prompt block.
AssistantID uint `gorm:"column:assistant_id;type:bigint;not null;index:idx_da_prompt_block_assistant_type"`
// BlockType identifies the prompt layer, such as identity, capability, boundary, style, or example.
BlockType string `gorm:"column:block_type;type:varchar(32);not null;index:idx_da_prompt_block_assistant_type"`
// Title is a short management label for the block.
Title string `gorm:"column:title;type:varchar(255);not null"`
// Content stores the prompt fragment that can be injected when this layer is selected.
Content string `gorm:"column:content;type:text;not null"`
// Priority controls deterministic ordering when multiple blocks are injected.
Priority int `gorm:"column:priority;type:integer;not null;default:0;index"`
// Enabled controls whether the block can participate in prompt assembly.
Enabled bool `gorm:"column:enabled;type:boolean;not null;default:true;index"`
// Version tracks prompt block edits for traceability.
Version int `gorm:"column:version;type:integer;not null;default:1"`
}
DigitalAssistantPromptBlock stores layered persona prompt blocks for future dynamic injection.
func (DigitalAssistantPromptBlock) TableName ¶ added in v0.1.22
func (DigitalAssistantPromptBlock) TableName() string
TableName returns the digital assistant prompt block table name.
type DigitalAssistantStatus ¶
type DigitalAssistantStatus string
DigitalAssistantStatus 表示数字助手的当前运行状态
const ( // DigitalAssistantStatusActive 表示数字助手处于激活状态 DigitalAssistantStatusActive DigitalAssistantStatus = "active" // DigitalAssistantStatusInactive 表示数字助手处于非激活状态 DigitalAssistantStatusInactive DigitalAssistantStatus = "inactive" // DigitalAssistantStatusPaused 表示数字助手处于暂停状态 DigitalAssistantStatusPaused DigitalAssistantStatus = "paused" // DigitalAssistantStatusError 表示数字助手处于错误状态 DigitalAssistantStatusError DigitalAssistantStatus = "error" )
type Event ¶
type Event struct {
gorm.Model
MessageID string // 消息唯一标识符
TraceID string // 分布式追踪 ID
Source string // 事件来源
Type string // 事件类型(建议使用 types.EventType 定义的常量值)
Action string // 事件动作(建议使用 types.EventAction 定义的常量值)
Actor string // 事件触发者
Target string // 事件目标
Payload map[string]interface{} `gorm:"type:jsonb"` // 事件负载数据
Timestamp int64 // 事件时间戳
}
Event 表示系统中持久化存储的事件记录
该结构用于将事件信息存储到数据库中,包含事件的基本信息、 来源、类型、动作、参与者、目标和负载数据等。
type EventAction ¶
type EventAction string
EventAction 表示事件的动作行为
const ( // EventActionOpened 表示打开或创建事件 EventActionOpened EventAction = "opened" // EventActionClosed 表示关闭或删除事件 EventActionClosed EventAction = "closed" // EventActionUpdated 表示更新事件 EventActionUpdated EventAction = "updated" // EventActionCommented 表示评论事件 EventActionCommented EventAction = "commented" )
type ExecutionMode ¶ added in v0.1.22
type ExecutionMode string
ExecutionMode describes the business/API execution mode requested for a user message.
const ( // ExecutionModeDefault uses the normal runtime behavior. ExecutionModeDefault ExecutionMode = "default" // ExecutionModePlan requests planning behavior from runtimes that support it. ExecutionModePlan ExecutionMode = "plan" )
type FileUpload ¶ added in v0.1.2
type FileUpload struct {
gorm.Model
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
OwnerScope OwnerScope `` /* 237-byte string literal not displayed */
OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
Filename string `gorm:"column:filename;type:varchar(500)"`
OriginalName string `gorm:"column:original_name;type:varchar(500)"`
MimeType string `gorm:"column:mime_type;type:varchar(100)"`
FileSize int64 `gorm:"column:file_size;type:bigint"`
StorageURI string `gorm:"column:storage_uri;type:varchar(500);not null"`
Sha256 string `gorm:"column:sha256;type:varchar(64);index"`
Purpose string `gorm:"column:purpose;type:varchar(50);index"`
Status string `gorm:"column:status;type:varchar(50);not null;default:'active';index"`
Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}
FileUpload 表示用户上传的文件
func (FileUpload) TableName ¶ added in v0.1.2
func (FileUpload) TableName() string
TableName 指定 FileUpload 结构体对应的数据库表名
type Filter ¶
type Filter struct {
Field string `json:"field"`
Value []string `json:"value"`
ExactMatch bool `json:"exact_match"`
}
Filter 过滤条件
type IdentityContext ¶
IdentityContext 携带执行身份与跟踪信息。
type KnowledgeType ¶
type KnowledgeType string
KnowledgeType 表示知识库类型标识
const ( // KnowledgeTypeVectorStorage 表示向量存储知识库 KnowledgeTypeVectorStorage KnowledgeType = "vector_storage" // KnowledgeTypeDocument 表示文档知识库 KnowledgeTypeDocument KnowledgeType = "document" // KnowledgeTypeDatabase 表示数据库知识库 KnowledgeTypeDatabase KnowledgeType = "database" )
type LLMHistory ¶ added in v0.3.0
type LLMHistory struct {
gorm.Model
// 组织ID,用于隔离不同组织的调用记录
OrgID uint `gorm:"column:org_id;type:integer;not null;index:idx_llm_call_org_started;sort:desc"`
// 调用所使用的模型ID,关联LLMModel表
ModelID uint `gorm:"column:model_id;type:integer;index:idx_llm_call_model"`
// 模型供应商标识,例如 openai、anthropic、deepseek
Provider string `gorm:"column:provider;type:varchar(64);not null"`
// 实际调用的模型名称
ModelName string `gorm:"column:model_name;type:varchar(255);not null"`
// 模型供应商(与 provider 一致,单独存储便于检索)
ModelProvider string `gorm:"column:model_provider;type:varchar(50);not null;default:''"`
// 调用入口协议,如 openai_chat、anthropic_messages、openai_responses、gemini
EntryProtocol string `gorm:"column:entry_protocol;type:varchar(32)"`
// 是否为流式调用
IsStream bool `gorm:"column:is_stream;type:boolean;default:false"`
// 输入Token数量
InputTokens int `gorm:"column:input_tokens;type:integer;default:0"`
// 输出Token数量
OutputTokens int `gorm:"column:output_tokens;type:integer;default:0"`
// 总Token数量
TotalTokens int `gorm:"column:total_tokens;type:integer;default:0"`
// 调用耗时,单位毫秒
LatencyMS int64 `gorm:"column:latency_ms;type:bigint;default:0"`
// Prompt Token 用量(大整型)
PromptTokens int64 `gorm:"column:prompt_tokens;type:bigint;default:0"`
// 缓存命中 Token 数
CacheHitTokens int64 `gorm:"column:cache_hit_tokens;type:bigint;default:0"`
// 缓存未命中 Token 数
CacheMissTokens int64 `gorm:"column:cache_miss_tokens;type:bigint;default:0"`
// HTTP状态码或供应商返回的业务状态码
StatusCode int `gorm:"column:status_code;type:integer;default:0"`
// 调用是否成功
Success bool `gorm:"column:success;type:boolean;default:false;index:idx_llm_call_success"`
// 调用状态字符串:success / error
Status string `gorm:"column:status;type:varchar(50);not null;default:''"`
// 失败时的错误信息
Message string `gorm:"column:message;type:text"`
// 调用方类型,如 worker、api、skill
CallerType string `gorm:"column:caller_type;type:varchar(64);not null;index:idx_llm_call_caller"`
// 业务请求标识,用于串联链路上的 LLM 调用与业务事件
ReqID string `gorm:"column:req_id;type:varchar(255);default:''"`
// 追踪ID
TraceID string `gorm:"column:trace_id;type:varchar(255);not null;default:''"`
// 重试次数
RetryTimes int64 `gorm:"column:retry_times;type:bigint;default:1"`
// 输入长度
InputLen int `gorm:"column:input_len;type:integer;default:0"`
// 输出长度
OutputLen int `gorm:"column:output_len;type:integer;default:0"`
// 输入是否被截断
InputTruncated bool `gorm:"column:input_truncated;type:boolean;default:false"`
// 输出是否被截断
OutputTruncated bool `gorm:"column:output_truncated;type:boolean;default:false"`
// 客户端IP
ClientIP string `gorm:"column:client_ip;type:varchar(64);default:''"`
// 项目ID,关联 leros_leros_project 表
ProjectID uint `gorm:"column:project_id;type:integer;not null;default:0;index:idx_llm_call_project"`
// 会话ID,关联 leros_leros_session 表
SessionID uint `gorm:"column:session_id;type:integer;not null;default:0;index:idx_llm_call_session"`
// 消息ID,关联 leros_leros_session_message 表
MessageID uint `gorm:"column:message_id;type:integer;not null;default:0"`
// 数字助理ID,关联 leros_leros_assistant 表
AssistantID uint `gorm:"column:assistant_id;type:integer;not null;default:0;index:idx_llm_call_assistant"`
// 用户ID,关联 leros_leros_user 表
Uin uint `gorm:"column:uin;type:integer;not null;default:0;index:idx_llm_call_uin"`
// 模型调用时的完整输入数据(messages / prompt)
Input string `gorm:"column:input;type:text"`
// 模型调用时的完整输出数据(response body / assistant message)
Output string `gorm:"column:output;type:text"`
// 调用开始时间
StartedAt time.Time `gorm:"column:started_at;type:timestamp;not null;index:idx_llm_call_org_started;sort:desc"`
// 调用结束时间
FinishedAt time.Time `gorm:"column:finished_at;type:timestamp"`
}
LLMHistory 记录一次LLM调用的完整信息。
该表用于持久化每次LLM调用的入参摘要、耗时、Token用量和执行结果, 为后续的用量统计、成本分析和链路追踪提供数据支撑。
func (LLMHistory) TableName ¶ added in v0.3.0
func (LLMHistory) TableName() string
TableName 指定LLMHistory对应的数据库表名
type LLMLimitFields ¶ added in v0.3.10
type LLMLimitFields struct {
Context int `json:"context,omitempty"`
Output int `json:"output,omitempty"`
}
LLMLimitFields 描述模型上下文窗口与单次输出上限(来源 config.yaml/DB config)。
type LLMModel ¶
type LLMModel struct {
gorm.Model
// 模型所属组织ID,用于隔离不同组织的模型配置
OrgID uint `` /* 168-byte string literal not displayed */
// 模型配置编码,在组织内唯一,用于业务配置引用
Code string `gorm:"column:code;type:varchar(128);not null;uniqueIndex:idx_llm_model_org_code"`
// 模型展示名称,用于前端列表和选择器展示
Name string `gorm:"column:name;type:varchar(255);not null"`
// 模型描述,用于记录用途、额度、注意事项等说明
Description string `gorm:"column:description;type:text"`
// 模型供应商标识,例如 openai、anthropic、deepseek、custom
Provider string `gorm:"column:provider;type:varchar(64);not null;index"` // 建议使用 types.LLMProviderType 定义的常量值
// 实际传递给供应商API或CLI的模型名称
ModelName string `gorm:"column:model;type:varchar(255);not null"`
// API基础地址,官方默认地址可为空,自定义网关或兼容接口需填写
BaseURL string `gorm:"column:base_url;type:varchar(500)"`
// 是否已确认基础地址包含 /v1 前缀,记录连通性探测结果。默认 true 以兼容已有数据。
BaseURLHasV1 bool `gorm:"column:base_url_has_v1;type:boolean;default:true"`
// API Key密文,业务读取时需要通过统一密钥服务解密
APIKeyEncrypted string `gorm:"column:api_key_encrypted;type:text"`
// API Key脱敏展示值,仅用于前端展示,禁止用于真实调用
APIKeyMasked string `gorm:"column:api_key_masked;type:varchar(128)"`
// 默认最大输出Token数,运行请求可按需覆盖
MaxTokens int `gorm:"column:max_tokens;type:integer;default:4096"`
// 默认采样温度,运行请求可按需覆盖
Temperature float64 `gorm:"column:temperature;type:decimal(4,3);default:0.7"`
// 默认请求超时时间,单位秒
TimeoutSec int `gorm:"column:timeout_sec;type:integer;default:120"`
// 模型状态,inactive状态下不应被新任务选择
Status string `gorm:"column:status;type:varchar(32);not null;default:active;index"` // 建议使用 types.LLMModelStatus 定义的常量值
// 是否为组织默认模型,业务未显式选择模型时可回退到该模型
IsDefault bool `gorm:"column:is_default;type:boolean;default:false;index"`
// 是否为系统内置配置,内置配置可用于初始化或演示场景
IsSystem bool `gorm:"column:is_system;type:boolean;default:false"`
// 扩展配置,保存能力标记、上下文窗口、价格、额外Header等非核心字段
Config LLMModelConfig `gorm:"column:config;type:jsonb"`
}
LLMModel 定义一个在数据库中持久化的LLM模型配置
该表以“可直接调用的模型配置”为最小管理单元,暂时将供应商、 模型、凭证、默认参数和扩展配置放在同一张表中,便于MVP阶段快速接入多模型配置。
type LLMModelConfig ¶
type LLMModelConfig map[string]interface{}
LLMModelConfig 表示LLM模型配置的扩展JSON字段
func (*LLMModelConfig) Scan ¶
func (c *LLMModelConfig) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口,用于从数据库中读取 JSON 数据
type LLMModelStatus ¶
type LLMModelStatus string
LLMModelStatus 表示LLM模型配置的启用状态
const ( // LLMModelStatusActive 表示模型配置可被业务使用 LLMModelStatusActive LLMModelStatus = "active" // LLMModelStatusInactive 表示模型配置暂不可被业务使用 LLMModelStatusInactive LLMModelStatus = "inactive" )
type LLMProviderType ¶
type LLMProviderType string
LLMProviderType 表示LLM提供商类型标识
const ( // LLMProviderOpenAI 表示OpenAI提供商 LLMProviderOpenAI LLMProviderType = "openai" // LLMProviderAnthropic 表示Anthropic提供商 LLMProviderAnthropic LLMProviderType = "anthropic" // LLMProviderDeepSeek 表示DeepSeek提供商 LLMProviderDeepSeek LLMProviderType = "deepseek" // LLMProviderQwen 表示通义千问提供商 LLMProviderQwen LLMProviderType = "qwen" // LLMProviderGemini 表示Google Gemini提供商 LLMProviderGemini LLMProviderType = "gemini" // LLMProviderArk 表示火山方舟提供商 LLMProviderArk LLMProviderType = "ark" // LLMProviderOpenRouter 表示OpenRouter提供商 LLMProviderOpenRouter LLMProviderType = "openrouter" // LLMProviderCustom 表示自定义提供商 LLMProviderCustom LLMProviderType = "custom" )
type LLMSamplingParams ¶ added in v0.3.10
type LLMSamplingParams struct {
TopP *float64 `json:"top_p,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
Limit *LLMLimitFields `json:"limit,omitempty"`
}
LLMSamplingParams 是按字段名存储的采样参数集合,键对齐 OpenAI 兼容服务的 snake_case 字段。
func SamplingParamsFromConfig ¶ added in v0.3.10
func SamplingParamsFromConfig(c LLMModelConfig) LLMSamplingParams
SamplingParamsFromConfig 从扩展配置 map 中解包采样参数。 缺省(无 config 或未声明对应键)返回零值。仅在此处触碰 map 对应键。
type MCPChannel ¶ added in v0.3.7
type MCPChannel struct {
gorm.Model
Channel string `gorm:"column:channel;type:varchar(64);not null;uniqueIndex:ux_mcp_channel_channel"`
Name string `gorm:"column:name;type:varchar(255);not null"`
Description string `gorm:"column:description;type:text"`
SkillCode string `gorm:"column:skill_code;type:varchar(128);not null;default:''"`
Transport string `gorm:"column:transport;type:varchar(32);not null;default:''"`
URL string `gorm:"column:url;type:varchar(2000);not null;default:''"`
Headers MCPChannelHeaders `gorm:"column:headers;type:jsonb;not null;default:'{}'"`
AuthType string `gorm:"column:auth_type;type:varchar(32);not null;default:'none'"`
AuthConfig MCPChannelAuthConfigJSON `gorm:"column:auth_config;type:jsonb;not null;default:'{}'"`
Status string `gorm:"column:status;type:varchar(32);not null;default:'active';index"`
}
MCPChannel is a system-maintained template for one built-in connector channel.
func (MCPChannel) TableName ¶ added in v0.3.7
func (MCPChannel) TableName() string
TableName returns the MCP channel configuration table name.
type MCPChannelAuthBindings ¶ added in v0.3.7
type MCPChannelAuthBindings struct {
SkillEnv map[string]string `json:"skill_env,omitempty"`
MCPBearerToken string `json:"mcp_bearer_token,omitempty"`
MCPHeaders map[string]string `json:"mcp_headers,omitempty"`
MCPEnv map[string]string `json:"mcp_env,omitempty"`
MCPQuery map[string]string `json:"mcp_query,omitempty"`
}
MCPChannelAuthBindings maps stored value keys into runtime destinations.
type MCPChannelAuthConfig ¶ added in v0.3.7
type MCPChannelAuthConfig struct {
Fields []MCPChannelAuthField `json:"fields,omitempty"`
Bindings MCPChannelAuthBindings `json:"bindings,omitempty"`
Handler string `json:"handler,omitempty"`
OAuth *MCPChannelOAuthConfig `json:"oauth,omitempty"`
}
MCPChannelAuthConfig defines channel-specific authorization without storing user credentials.
type MCPChannelAuthConfigJSON ¶ added in v0.3.7
type MCPChannelAuthConfigJSON MCPChannelAuthConfig
MCPChannelAuthConfigJSON stores one typed channel authorization schema.
func (*MCPChannelAuthConfigJSON) Scan ¶ added in v0.3.7
func (c *MCPChannelAuthConfigJSON) Scan(value interface{}) error
Scan implements sql.Scanner.
type MCPChannelAuthField ¶ added in v0.3.7
type MCPChannelAuthField struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"`
Required bool `json:"required"`
Placeholder string `json:"placeholder,omitempty"`
Description string `json:"description,omitempty"`
}
MCPChannelAuthField describes one user-provided authorization value.
type MCPChannelHeaders ¶ added in v0.3.7
MCPChannelHeaders stores non-sensitive fixed HTTP headers for one MCP channel.
func (*MCPChannelHeaders) Scan ¶ added in v0.3.7
func (h *MCPChannelHeaders) Scan(value interface{}) error
Scan implements sql.Scanner.
type MCPChannelOAuthConfig ¶ added in v0.3.7
type MCPChannelOAuthConfig struct {
AppKey string `json:"app_key,omitempty"`
SecretKey string `json:"secret_key,omitempty"`
RedirectURI string `json:"redirect_uri,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
MCPChannelOAuthConfig stores operations-managed OAuth application settings.
type MemberDepartment ¶ added in v0.1.23
type MemberDepartment struct {
gorm.Model
Uin uint `gorm:"column:uin;type:bigint;not null;index;comment:组织成员Uin"`
OrgID uint `gorm:"column:org_id;type:bigint;not null;comment:组织ID"`
DepartmentID uint `gorm:"column:department_id;type:bigint;not null;index;comment:部门ID"`
IsPrimary bool `gorm:"column:is_primary;type:boolean;not null;default:false;comment:是否为主部门"`
}
MemberDepartment 表示组织成员部门关联表。
func (MemberDepartment) TableName ¶ added in v0.1.23
func (MemberDepartment) TableName() string
TableName 返回组织成员部门关联表名。
type MemberDepartmentList ¶ added in v0.1.23
type MemberDepartmentList []MemberDepartment
MemberDepartmentList 表示组织成员部门关联列表。
func (MemberDepartmentList) ToMap ¶ added in v0.1.23
func (l MemberDepartmentList) ToMap() map[uint]MemberDepartment
ToMap 按主键索引组织成员部门关联列表。
type MemberInput ¶ added in v0.2.1
type MemberInput struct {
// TargetUin 被操作用户的 Uin(与 TargetAssistantID 互斥)。
TargetUin uint
// TargetAssistantID 被操作助手的 ID(与 TargetUin 互斥)。
TargetAssistantID *uint
// RequestedRole 本次操作希望赋予目标的角色。
RequestedRole ResourceRole
}
MemberInput 是成员管理类动作的请求上下文,由调用方传入用于派生 MemberAuthContext。 所有字段均来自请求参数,不得由前端直接控制业务逻辑。
type MemberRole ¶
type MemberRole string
MemberRole 成员角色
const ( MemberRoleOwner MemberRole = "owner" MemberRoleAdmin MemberRole = "admin" MemberRoleMember MemberRole = "member" MemberRoleViewer MemberRole = "viewer" )
type MemberType ¶
type MemberType string
MemberType 成员类型
const ( MemberTypeUser MemberType = "user" MemberTypeAssistant MemberType = "assistant" )
type MemoryType ¶
type MemoryType string
MemoryType 表示记忆存储类型标识
const ( // MemoryTypePostgres 表示基于PostgreSQL的记忆存储 MemoryTypePostgres MemoryType = "postgres" // MemoryTypeInMemory 表示内存记忆存储 MemoryTypeInMemory MemoryType = "in_memory" )
type MessageArtifact ¶
type MessageArtifact struct {
ArtifactID string `json:"artifact_id,omitempty"`
Title string `json:"title,omitempty"`
Filename string `json:"filename,omitempty"`
Description string `json:"description,omitempty"`
MimeType string `json:"mime_type,omitempty"`
ArtifactType string `json:"artifact_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
StorageURI string `json:"storage_uri,omitempty"`
Sha256 string `json:"sha256,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
VersionNo int `json:"version_no,omitempty"`
}
MessageArtifact stores one lightweight artifact reference for a session message.
type MessageArtifactSlice ¶
type MessageArtifactSlice []MessageArtifact
MessageArtifactSlice stores artifact references in JSONB.
func (*MessageArtifactSlice) Scan ¶
func (m *MessageArtifactSlice) Scan(value interface{}) error
Scan implements sql.Scanner.
type MessageAttachment ¶ added in v0.1.2
type MessageAttachmentSlice ¶ added in v0.1.2
type MessageAttachmentSlice []MessageAttachment
func (*MessageAttachmentSlice) Scan ¶ added in v0.1.2
func (m *MessageAttachmentSlice) Scan(value interface{}) error
type MessageChunk ¶
type MessageChunk struct {
Seq int64 `json:"seq,omitempty"`
LastSeq int64 `json:"last_seq,omitempty"`
Type string `json:"type"`
Timestamp int64 `json:"timestamp,omitempty"`
Payload json.RawMessage `json:"payload,omitempty" swaggertype:"object"`
AssistantID string `json:"assistant_id,omitempty"`
}
MessageChunk stores one archived runtime event for a completed session message.
type MessageChunkSlice ¶
type MessageChunkSlice []MessageChunk
MessageChunkSlice stores structured message chunks in JSONB.
func (*MessageChunkSlice) Scan ¶
func (m *MessageChunkSlice) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口
type MessageResource ¶ added in v0.1.15
type MessageResource struct {
gorm.Model
ResourceID string `gorm:"column:resource_id;type:varchar(255);not null;index"` // DB primary key of the resource (empty if not found)
MessageID uint `gorm:"column:message_id;type:bigint;not null;index"` // FK to leros_session_message.id
SessionID uint `gorm:"column:session_id;type:bigint;not null;index"` // FK to leros_session.id
OrgID uint `gorm:"column:org_id;type:integer;not null;default:0;index"` // org isolation
Uin uint `gorm:"column:uin;type:bigint;default:0;index"` // user isolation
ResourceType string `gorm:"column:resource_type;type:varchar(50);not null;index"` // skill / MCP / tool / ...
ResourceKey string `gorm:"column:resource_key;type:varchar(255);not null;index"` // {source}:{skill_id} composite key
ResourceName string `gorm:"column:resource_name;type:varchar(255);not null"` // resource display name
InvokeType string `gorm:"column:invoke_type;type:varchar(50);not null"` // slash_command / mention / auto / ...
Seq int `gorm:"column:seq;type:integer;not null;default:0"` // order within the same message
}
MessageResource records which resource (skill/MCP/tool/etc.) a message used.
func (MessageResource) TableName ¶ added in v0.1.15
func (MessageResource) TableName() string
TableName specifies the database table name for MessageResource.
type MessageRole ¶
type MessageRole string
MessageRole 消息角色常量
const ( MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" MessageRoleSystem MessageRole = "system" MessageRoleTool MessageRole = "tool" )
type MessageStatus ¶
type MessageStatus string
MessageStatus 消息状态常量
const ( MessageStatusPending MessageStatus = "pending" MessageStatusProcessing MessageStatus = "processing" MessageStatusCompleted MessageStatus = "completed" MessageStatusFailed MessageStatus = "failed" MessageStatusCancelled MessageStatus = "cancelled" )
type MessageType ¶
type MessageType string
MessageType 消息类型常量
const ( MessageTypeText MessageType = "text" MessageTypeImage MessageType = "image" MessageTypeCode MessageType = "code" MessageTypeFile MessageType = "file" )
type MessageUsage ¶
type MessageUsage struct {
TotalTokens int `json:"total_tokens"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheInputTokens int `json:"cache_input_tokens"`
CacheOutputTokens int `json:"cache_output_tokens"`
}
MessageUsage stores model token usage for a session message.
func (*MessageUsage) Scan ¶
func (mu *MessageUsage) Scan(value interface{}) error
Scan 瀹炵幇 sql.Scanner 鎺ュ彛
type ObjectMetadata ¶
type ObjectMetadata struct {
// 元数据 - 项目标签
Tags []string `json:"tags,omitempty"`
// 元数据 - 项目类型/模板标识
Type string `json:"type,omitempty"`
// 元数据 - 对象存储桶
Bucket string `json:"bucket,omitempty"`
// 元数据 - 对象存储键
Key string `json:"key,omitempty"`
// 元数据 - 其他扩展字段
Extra map[string]interface{} `json:"extra,omitempty"`
}
ObjectMetadata 项目元数据结构
func (ObjectMetadata) IsZero ¶ added in v0.1.23
func (m ObjectMetadata) IsZero() bool
IsZero 判断 ObjectMetadata 是否所有字段均为零值。
func (*ObjectMetadata) Scan ¶
func (pm *ObjectMetadata) Scan(value interface{}) error
Scan 实现 sql.Scanner 接口
type Organization ¶
type Organization struct {
gorm.Model
ExternalCompanyID uint `gorm:"column:external_company_id;index"` // identity-platform Company.ID
PublicID string `gorm:"column:public_id;type:varchar(64);uniqueIndex;not null;default:''"` // 组织公开ID
Type string `gorm:"column:type;type:varchar(50);default:'company'"` // 组织类型: company/team/project
Code string `gorm:"column:code;type:varchar(255);unique_index;not null"` // 组织代码(唯一)
Name string `gorm:"column:name;type:varchar(255);not null"` // 组织名称
Status string `gorm:"column:status;type:varchar(20);default:'active'"` // 状态: active/inactive
Description string `gorm:"column:description;type:varchar(256)"` // 组织描述
Logo string `gorm:"column:logo;type:varchar(256)"` // 组织 Logo URL
Address string `gorm:"column:address;type:varchar(256)"` // 联系地址
Website string `gorm:"column:website;type:varchar(256)"` // 官网地址
CreatedByUin uint `gorm:"column:created_by_uin;type:bigint;default:0"` // 创建者 Uin
}
Organization 表示系统中的组织/企业信息
组织是系统中的顶级实体,可以代表公司、团队或项目。 多个用户可以关联到同一个组织。
type OwnerScope ¶ added in v0.3.7
type OwnerScope string
OwnerScope identifies whether a resource belongs to one organization or to the Leros system namespace.
const ( OwnerScopeOrganization OwnerScope = "organization" OwnerScopeSystem OwnerScope = "system" )
func NormalizeOwnerScope ¶ added in v0.3.7
func NormalizeOwnerScope(scope OwnerScope) OwnerScope
NormalizeOwnerScope applies the default for organization-owned callers.
type PageQuery ¶
type PageQuery struct {
Filters []Filter `json:"filters,omitempty"`
OrderBy []string `json:"order_by,omitempty"`
ProjectIDs []uint `json:"-"`
Caller `json:"-"`
Pagination `json:",inline"`
}
PageQuery 通用分页查询参数
func NewPageQuery ¶
NewPageQuery 快速创建 PageQuery,接受 Caller 和分页参数。
func (*PageQuery) AddExactFilter ¶
AddExactFilter 链式添加精确过滤条件。
type Pagination ¶
type Pagination struct {
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
ListAll bool `json:"list_all,omitempty"`
}
Pagination pagination request base
type PermissionCaller ¶ added in v0.2.1
PermissionCaller 表示权限判断中的请求主体。 Uin 与 AssistantID 互斥:普通用户登录时 Uin 非 0,助手身份时 AssistantID 非 0。
type PermissionDecision ¶ added in v0.2.1
type PermissionDecision struct {
Allowed bool
Reason string
Role ResourceRole
ResourceID uint
MatchedBindingID uint
MatchedResourceID uint
}
PermissionDecision 是单次权限判断结果。
type PermissionExplainDecision ¶ added in v0.2.1
type PermissionExplainDecision struct {
PermissionDecision
Inherited bool
}
PermissionExplainDecision 在 PermissionDecision 基础上增加继承来源信息。
type Plugin ¶ added in v0.3.7
type Plugin struct {
gorm.Model
PublicID string `gorm:"column:public_id;type:varchar(255);not null"`
OwnerScope OwnerScope `` /* 198-byte string literal not displayed */
OrgID uint `gorm:"column:org_id;type:bigint;not null"`
Code string `gorm:"column:code;type:varchar(128);not null"`
Kind string `gorm:"column:kind;type:varchar(32);not null"`
Name string `gorm:"column:name;type:varchar(255);not null"`
Description string `gorm:"column:description;type:text"`
Status string `gorm:"column:status;type:varchar(32);not null;default:'active'"`
Origin string `gorm:"column:origin;type:varchar(32);not null;default:'org'"`
CurrentRevision int `gorm:"column:current_revision;type:integer;not null;default:0"`
CreatedBy uint `gorm:"column:created_by;type:bigint;not null"`
UpdatedBy uint `gorm:"column:updated_by;type:bigint;not null"`
}
Plugin is a scope-owned plugin identity shared by organizations and the system catalogue.
type PluginMarketplaceItem ¶ added in v0.3.7
type PluginMarketplaceItem struct {
gorm.Model
PublicID string `gorm:"column:public_id;type:varchar(255);not null"`
PluginID uint `gorm:"column:plugin_id;type:bigint;not null;check:chk_marketplace_plugin_id,plugin_id > 0"`
Kind string `gorm:"column:kind;type:varchar(32);not null"`
Code string `gorm:"column:code;type:varchar(128);not null"`
Name string `gorm:"column:name;type:varchar(255);not null"`
Description string `gorm:"column:description;type:text"`
Author string `gorm:"column:author;type:varchar(255);not null;default:''"`
SourceType string `gorm:"column:source_type;type:varchar(32);not null"`
SourceRef string `gorm:"column:source_ref;type:varchar(1000);not null"`
Status string `gorm:"column:status;type:varchar(32);not null;default:'published'"`
Category string `gorm:"column:category;type:varchar(100);not null;default:''"`
Tags PluginStringList `gorm:"column:tags;type:jsonb;not null;default:'[]'"`
Icon string `gorm:"column:icon;type:varchar(1000)"`
Verified bool `gorm:"column:verified;type:boolean;not null;default:false"`
PublishedAt time.Time `gorm:"column:published_at;not null"`
}
PluginMarketplaceItem is a system-maintained public plugin directory item.
func (PluginMarketplaceItem) TableName ¶ added in v0.3.7
func (PluginMarketplaceItem) TableName() string
TableName returns the plugin marketplace item table name.
type PluginRevision ¶ added in v0.3.7
type PluginRevision struct {
gorm.Model
PluginID uint `gorm:"column:plugin_id;type:bigint;not null"`
SourceMarketplaceItemID *uint `gorm:"column:source_marketplace_item_id;type:bigint"`
SourcePluginRevisionID *uint `gorm:"column:source_plugin_revision_id;type:bigint"`
Revision int `gorm:"column:revision;type:integer;not null"`
Status string `gorm:"column:status;type:varchar(32);not null;default:'published'"`
Definition json.RawMessage `gorm:"column:definition;type:jsonb;not null;default:'{}'"`
PublishedByType string `gorm:"column:published_by_type;type:varchar(32);not null"`
PublishedByID uint `gorm:"column:published_by_id;type:bigint;not null"`
PublishedAt time.Time `gorm:"column:published_at;not null"`
}
PluginRevision is an immutable published plugin package record.
func (PluginRevision) TableName ¶ added in v0.3.7
func (PluginRevision) TableName() string
TableName returns the plugin revision table name.
type PluginRevisionContent ¶ added in v0.3.7
type PluginRevisionContent struct {
gorm.Model
PluginRevisionID uint `gorm:"column:plugin_revision_id;type:bigint;not null;uniqueIndex:ux_plugin_revision_content_revision"`
Schema string `gorm:"column:schema;type:varchar(32);not null"`
ArtifactSHA256 string `gorm:"column:artifact_sha256;type:varchar(64);not null"`
EntrypointPath string `gorm:"column:entrypoint_path;type:varchar(1000);not null"`
EntrypointContent string `gorm:"column:entrypoint_content;type:text;not null"`
FileIndex PluginRevisionFileList `gorm:"column:file_index;type:jsonb;not null;default:'[]'"`
}
PluginRevisionContent is the one-to-one immutable content projection of a plugin revision.
func (PluginRevisionContent) TableName ¶ added in v0.3.7
func (PluginRevisionContent) TableName() string
TableName returns the plugin revision content table name.
type PluginRevisionFile ¶ added in v0.3.7
type PluginRevisionFile struct {
Path string `json:"path"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
}
PluginRevisionFile describes one immutable regular file in a plugin package.
type PluginRevisionFileList ¶ added in v0.3.7
type PluginRevisionFileList []PluginRevisionFile
PluginRevisionFileList is the stable, path-sorted file index of a plugin revision.
func (*PluginRevisionFileList) Scan ¶ added in v0.3.7
func (files *PluginRevisionFileList) Scan(value interface{}) error
Scan implements sql.Scanner.
type PluginStringList ¶ added in v0.3.7
type PluginStringList []string
PluginStringList is a non-null JSON array used by plugin marketplace metadata.
func (*PluginStringList) Scan ¶ added in v0.3.7
func (s *PluginStringList) Scan(value interface{}) error
Scan implements sql.Scanner.
type Project ¶
type Project struct {
gorm.Model
// project - 项目唯一标识,格式如:prj_xxx,VARCHAR(255),NOT NULL,UNIQUE
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
// project - 所属组织ID,INTEGER,NOT NULL,INDEX
OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
// project - 创建者用户ID,INTEGER,NOT NULL,INDEX
OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
// project - 项目名称,VARCHAR(255),NOT NULL
Name string `gorm:"column:name;type:varchar(255);not null"`
// project - 项目描述,TEXT,允许为空
Description string `gorm:"column:description;type:text"`
// project - 项目目标,TEXT,允许为空
Objective string `gorm:"column:objective;type:text"`
// project - 项目状态,VARCHAR(50),NOT NULL,DEFAULT 'active'
Status string `gorm:"column:status;type:varchar(50);not null;default:'active';index"`
// project - gitea 仓库全名(格式:org/repo_name),VARCHAR(255)
GiteaRepoFullName string `gorm:"column:gitea_repo_full_name;type:varchar(255)"`
// project - gitea 内部仓库 ID,BIGINT
GiteaRepoID int64 `gorm:"column:gitea_repo_id;type:bigint"`
// project - gitea 仓库默认分支名,VARCHAR(128),DEFAULT 'main'
GiteaDefaultBranch string `gorm:"column:gitea_default_branch;type:varchar(128);default:'main'"`
// project - 元数据(JSON格式存储标签等扩展信息),JSONB,允许为空
Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
// project - 关联的自动化主键(自动化为该自动化创建),BIGINT,可空,INDEX
AutomationID *uint `gorm:"column:automation_id;type:bigint;index"`
// project - 项目代数(该自动化下第几代项目),INTEGER,可空,DEFAULT 0
AutomationGeneration int `gorm:"column:automation_generation;type:integer;default:0"`
}
Project 表示系统中的项目
项目是长期工作的核心容器,承载会话、任务、AI队友、知识库和项目资产。 项目提供了长期上下文和协作空间。
type ProjectActivity ¶ added in v0.2.1
type ProjectActivity struct {
ID uint `gorm:"primaryKey" json:"id"`
ProjectID string `` /* 180-byte string literal not displayed */
OperatorID string `` /* 182-byte string literal not displayed */
ActionType ProjectActivityAction `gorm:"column:action_type;type:varchar(64);not null;index" json:"action_type"`
Payload ProjectActivityPayload `gorm:"column:payload;type:jsonb;serializer:json" json:"payload"`
RequestID *string `` /* 141-byte string literal not displayed */
Version int16 `gorm:"column:version;type:smallint;not null;default:1" json:"version"`
CreatedAt time.Time `` /* 244-byte string literal not displayed */
}
ProjectActivity 记录项目内成员、AI 队友、技能等操作动态。
func (ProjectActivity) TableName ¶ added in v0.2.1
func (ProjectActivity) TableName() string
TableName 返回项目动态表名。
type ProjectActivityAction ¶ added in v0.2.1
type ProjectActivityAction string
ProjectActivityAction 表示项目操作动态类型。
const ( // ProjectActivityActionProjectCreated 记录项目创建。 ProjectActivityActionProjectCreated ProjectActivityAction = "project.created" // ProjectActivityActionSkillsChanged 记录项目技能集合变化。 ProjectActivityActionSkillsChanged ProjectActivityAction = "project.skills.changed" // ProjectActivityActionMCPsChanged 记录项目 MCP 连接器集合变化。 ProjectActivityActionMCPsChanged ProjectActivityAction = "project.mcps.changed" // ProjectActivityActionParticipantsChanged 记录项目成员和 AI 队友集合变化。 ProjectActivityActionParticipantsChanged ProjectActivityAction = "project.participants.changed" )
type ProjectActivityPayload ¶ added in v0.2.1
type ProjectActivityPayload struct {
AddedSkillIDs []string `json:"added_skill_ids"`
RemovedSkillIDs []string `json:"removed_skill_ids"`
AddedMCPIDs []string `json:"added_mcp_ids"`
RemovedMCPIDs []string `json:"removed_mcp_ids"`
AddedMemberIDs []string `json:"added_member_ids"`
RemovedMemberIDs []string `json:"removed_member_ids"`
AddedAITeammateIDs []string `json:"added_ai_teammate_ids"`
RemovedAITeammateIDs []string `json:"removed_ai_teammate_ids"`
}
ProjectActivityPayload 保存不同动态类型的差异明细。
type ProjectFile ¶ added in v0.1.17
type ProjectFile struct {
gorm.Model
FilePublicID string `gorm:"column:file_public_id;type:varchar(255);not null;index"`
OrgID uint `` /* 136-byte string literal not displayed */
ProjectID uint `` /* 139-byte string literal not displayed */
TaskID uint `gorm:"column:task_id;type:bigint;index"`
ResourceID uint `gorm:"column:resource_id;type:bigint;not null;default:0;index"`
ResourceType ProjectFileResourceType `gorm:"column:resource_type;type:varchar(50);not null;index;index:idx_project_file_path,priority:3"`
Uin uint `gorm:"column:uin;type:bigint;index"`
RelativePath string `gorm:"column:relative_path;type:varchar(1000);not null;default:'';index:idx_project_file_path,priority:4"`
InitialFilePublicID string `` /* 129-byte string literal not displayed */
VersionNo int `gorm:"column:version_no;type:integer;not null;default:1;index:idx_project_file_version_lookup,priority:4"`
}
ProjectFile 项目文件关联表,记录项目/任务/资源之间的映射关系
func (ProjectFile) TableName ¶ added in v0.1.17
func (ProjectFile) TableName() string
type ProjectFileResourceType ¶ added in v0.1.17
type ProjectFileResourceType string
ProjectFileResourceType 项目文件关联的资源类型
const ( ProjectFileResourceTypeUserUpload ProjectFileResourceType = "user_upload" // 用户上传 ProjectFileResourceTypeArtifact ProjectFileResourceType = "artifact" // 工作产物 ProjectFileResourceTypePlan ProjectFileResourceType = "plan" // 计划文件 )
type ProjectMember ¶
type ProjectMember struct {
gorm.Model
// project_member - 关联项目ID,BIGINT,NOT NULL,INDEX
ProjectID uint `gorm:"column:project_id;type:bigint;not null;index"`
// project_member - 成员ID(用户ID或数字助手ID),BIGINT,NOT NULL,INDEX
MemberID uint `gorm:"column:member_id;type:bigint;not null;index"`
// project_member - 成员类型(user/assistant),VARCHAR(50),NOT NULL
MemberType MemberType `gorm:"column:member_type;type:varchar(50);not null;default:'user'"`
// project_member - 成员角色(owner/admin/member/viewer),VARCHAR(50),NOT NULL
MemberRole MemberRole `gorm:"column:member_role;type:varchar(50);not null;default:'member'"`
// project_member - 是否为系统默认绑定的 AI 队友(不可被用户移除),BOOLEAN,NOT NULL,DEFAULT FALSE
IsDefault bool `gorm:"column:is_default;type:boolean;not null;default:false"`
// project_member - 加入时间,TIMESTAMP,NOT NULL
JoinedAt time.Time `gorm:"column:joined_at;not null;default:CURRENT_TIMESTAMP"`
}
ProjectMember 项目成员关联表
关联项目与用户或数字助手,定义项目中的成员类型和角色。
func (ProjectMember) TableName ¶
func (ProjectMember) TableName() string
TableName 指定ProjectMember结构体对应的数据库表名
type ProjectPluginBinding ¶ added in v0.3.7
type ProjectPluginBinding struct {
gorm.Model
ProjectID uint `gorm:"column:project_id;type:bigint;not null"`
PluginID uint `gorm:"column:plugin_id;type:bigint;not null"`
Enabled bool `gorm:"column:enabled;type:boolean;not null;default:true"`
Config []byte `gorm:"column:config;type:jsonb;not null;default:'{}'"`
CreatedBy uint `gorm:"column:created_by;type:bigint;not null"`
UpdatedBy uint `gorm:"column:updated_by;type:bigint;not null"`
}
ProjectPluginBinding authorizes a plugin for one project.
func (ProjectPluginBinding) TableName ¶ added in v0.3.7
func (ProjectPluginBinding) TableName() string
TableName returns the project plugin binding table name.
type ProjectStatus ¶
type ProjectStatus string
ProjectStatus 项目生命周期状态
const ( ProjectStatusActive ProjectStatus = "active" ProjectStatusPaused ProjectStatus = "paused" ProjectStatusCompleted ProjectStatus = "completed" ProjectStatusArchived ProjectStatus = "archived" )
type ProjectionReceipt ¶ added in v0.3.9
type ProjectionReceipt struct {
gorm.Model
Consumer string `gorm:"column:consumer;type:varchar(128);not null;uniqueIndex:ux_projection_receipt"`
EventID string `gorm:"column:event_id;type:varchar(255);not null;uniqueIndex:ux_projection_receipt"`
RunID string `gorm:"column:run_id;type:varchar(255);index"`
SessionID string `gorm:"column:session_id;type:varchar(255);not null;index"`
EventType string `gorm:"column:event_type;type:varchar(64);not null"`
}
ProjectionReceipt provides a generic idempotency boundary for durable consumers.
func (ProjectionReceipt) TableName ¶ added in v0.3.9
func (ProjectionReceipt) TableName() string
type ReliableTask ¶ added in v0.3.9
type ReliableTask struct {
gorm.Model
TaskID string `gorm:"column:task_id;type:varchar(255);not null;uniqueIndex"`
Kind string `gorm:"column:kind;type:varchar(64);not null;uniqueIndex:ux_reliable_task_source,priority:1"`
Destination string `gorm:"column:destination;type:varchar(512);not null"`
ContentType string `gorm:"column:content_type;type:varchar(64);not null;default:'application/json'"`
Payload []byte `gorm:"column:payload;type:jsonb;not null"`
SourceType string `` /* 140-byte string literal not displayed */
SourceID string `` /* 139-byte string literal not displayed */
PartitionKey string `gorm:"column:partition_key;type:varchar(255);index"`
Status ReliableTaskStatus `gorm:"column:status;type:varchar(32);not null;index:idx_reliable_task_ready,priority:1"`
AttemptCount int `gorm:"column:attempt_count;not null;default:0"`
NextAttemptAt time.Time `gorm:"column:next_attempt_at;not null;index:idx_reliable_task_ready,priority:2"`
DeadlineAt time.Time `gorm:"column:deadline_at;not null;index"`
LeaseOwner string `gorm:"column:lease_owner;type:varchar(255)"`
LeaseUntil *time.Time `gorm:"column:lease_until;index"`
PublishedAt *time.Time `gorm:"column:published_at"`
LastError string `gorm:"column:last_error;type:text"`
}
ReliableTask is a durable, opaque handoff. Business services provide its destination and payload; the dispatcher must not decode either one.
func (ReliableTask) TableName ¶ added in v0.3.9
func (ReliableTask) TableName() string
type ReliableTaskStatus ¶ added in v0.3.9
type ReliableTaskStatus string
ReliableTaskStatus is transport-independent lifecycle state for a durable task.
const ( // ReliableTaskPending is waiting for the Server relay to obtain a JetStream PubAck. ReliableTaskPending ReliableTaskStatus = "pending" ReliableTaskPublished ReliableTaskStatus = "published" ReliableTaskExpired ReliableTaskStatus = "expired" )
type Resource ¶ added in v0.1.24
type Resource struct {
gorm.Model
// OrgID 将资源限定在特定组织范围内。
OrgID uint `` /* 141-byte string literal not displayed */
// Uin 记录资源创建或归属用户,不作为最终权限来源。
Uin uint `gorm:"column:uin;type:bigint;not null;default:0;index:idx_leros_resource_uin"`
// Type 是资源类型,PermissionService 按资源类型和动作判断权限。
Type ResourceType `` /* 144-byte string literal not displayed */
// BizID 指向业务对象的内部 ID,例如 projects.id、文件 ID、artifact ID。
BizID uint `gorm:"column:biz_id;type:bigint;not null;uniqueIndex:ux_leros_resource_active_biz,where:deleted_at IS NULL"`
// ParentResourceID 指向父资源,用于继承权限。
ParentResourceID *uint `gorm:"column:parent_resource_id;type:bigint;index:idx_leros_resource_parent"`
// ParentResourcePathIDs 从根到父节点存储祖先资源 ID。
ParentResourcePathIDs ResourcePathIDs `gorm:"column:parent_resource_path_ids;type:bigint[];not null;default:'{}'"`
}
Resource 是统一的权限资源记录。
type ResourceBinding ¶ added in v0.1.24
type ResourceBinding struct {
gorm.Model
// OrgID 冗余组织字段,用于快速过滤和防止跨组织误查。
OrgID uint `` /* 151-byte string literal not displayed */
// Uin 是被绑定用户的 Uin,用户主体时非 nil 且非 0。
Uin *uint `` /* 228-byte string literal not displayed */
// ResourceID 是绑定的资源 ID。
ResourceID uint `` /* 311-byte string literal not displayed */
// AssistantID 是被绑定的助手 ID,与 Uin 互斥,助手主体时非 nil 且非 0。
AssistantID *uint `` /* 209-byte string literal not displayed */
// Role 是主体在该资源上的角色。
Role ResourceRole `gorm:"column:resource_role;type:varchar(50);not null"`
}
ResourceBinding 表示用户或助手在资源上的身份绑定。 Uin 和 AssistantID 互斥:同一条绑定只能属于用户或助手之一。
func (ResourceBinding) TableName ¶ added in v0.1.24
func (ResourceBinding) TableName() string
TableName 返回 ResourceBinding 对应的数据库表名。
func (*ResourceBinding) Validate ¶ added in v0.2.1
func (b *ResourceBinding) Validate() error
Validate 校验 ResourceBinding 字段约束。 至少指定 uin 或 assistant_id 之一非 nil 且非 0;角色必须在允许集合内。
type ResourcePathIDs ¶ added in v0.1.24
type ResourcePathIDs []uint
ResourcePathIDs 按资源树顺序存储祖先资源 ID。
func (*ResourcePathIDs) Scan ¶ added in v0.1.24
func (ids *ResourcePathIDs) Scan(value interface{}) error
Scan 实现 sql.Scanner,用于读取 PostgreSQL bigint[] 值。
type ResourceRef ¶ added in v0.2.1
type ResourceRef struct {
Type ResourceType
BizID uint
}
ResourceRef 是前端或业务层传入的资源引用,PermissionService 据此定位 resource 记录。
type ResourceRole ¶ added in v0.1.24
type ResourceRole string
ResourceRole 描述主体与资源之间的关系角色。
const ( // ResourceRoleOwner 授予 owner 级别的策略权限。 ResourceRoleOwner ResourceRole = "owner" // ResourceRoleAdmin 授予 admin 级别的策略权限。 ResourceRoleAdmin ResourceRole = "admin" // ResourceRoleMember 授予 member 级别的策略权限。 ResourceRoleMember ResourceRole = "member" )
type ResourceType ¶ added in v0.1.24
type ResourceType string
ResourceType 标识受权限管理的业务对象类型。
const ( // ResourceTypeProject 表示项目根资源。 ResourceTypeProject ResourceType = "project" // ResourceTypeFile 表示项目下的文件资源。 ResourceTypeFile ResourceType = "file" // ResourceTypeArtifact 表示项目下的产物资源。 ResourceTypeArtifact ResourceType = "artifact" // ResourceTypeTask 表示项目下的任务资源。 ResourceTypeTask ResourceType = "task" )
type RuntimeType ¶
type RuntimeType string
RuntimeType 表示运行时环境类型标识
const ( // RuntimeTypeDocker 表示Docker容器运行时 RuntimeTypeDocker RuntimeType = "docker" // RuntimeTypeProcess 表示进程运行时 RuntimeTypeProcess RuntimeType = "process" )
type SeedExecStatus ¶ added in v0.3.9
type SeedExecStatus string
SeedExecStatus 表示一个 SQL seed 文件的执行结果。
const ( // SeedExecStatusSuccess 表示文件已成功执行完。 SeedExecStatusSuccess SeedExecStatus = "succ" // SeedExecStatusFailed 表示文件执行失败,记录失败行号供断点续跑。 SeedExecStatusFailed SeedExecStatus = "fail" )
type SeedRecord ¶ added in v0.3.9
type SeedRecord struct {
ID uint `gorm:"column:id;primarykey"`
FileName string `gorm:"column:file_name;type:varchar(255);not null;index"`
ExecStatus SeedExecStatus `gorm:"column:exec_status;type:varchar(10);not null;index"`
ErrorMessage string `gorm:"column:error_message;type:text"`
FailLineAt int `gorm:"column:fail_line_at;type:int;not null"`
StartTime time.Time `gorm:"column:start_time"`
EndTime time.Time `gorm:"column:end_time"`
ExecTime float64 `gorm:"column:exec_time"`
}
SeedRecord 记录某个 SQL seed 文件的执行情况,用于跳过已成功文件与失败续跑。
func (SeedRecord) TableName ¶ added in v0.3.9
func (SeedRecord) TableName() string
TableName 返回种子执行记录的表名。
type Session ¶
type Session struct {
gorm.Model
// session - 会话对外唯一标识,格式如:sess_xxx,VARCHAR(255),NOT NULL,UNIQUE
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
// session - 会话类型,VARCHAR(50),NOT NULL
Type SessionType `gorm:"column:type;type:varchar(50);not null"`
// session - 关联用户UIN,0表示不关联,BIGINT,DEFAULT 0
Uin uint `gorm:"column:uin;type:bigint;default:0;index"`
// session - 所属组织ID,0表示未设置,INTEGER,NOT NULL,DEFAULT 0
OrgID uint `gorm:"column:org_id;type:integer;default:0;not null;index"`
// session - 关联数字助手ID,0表示不关联,BIGINT,DEFAULT 0
AssistantID uint `gorm:"column:assistant_id;type:bigint;default:0;index"`
// session - 分配的数字员工ID,0表示未分配,BIGINT,DEFAULT 0
AllocatedAssistantID uint `gorm:"column:allocated_assistant_id;type:bigint;default:0;index"`
// session - 关联任务ID,允许为空,BIGINT,INDEX(scope=task时绑定)
TaskID *uint `gorm:"column:task_id;type:bigint;uniqueIndex:uni_session_project_task"`
// session - 关联项目ID,允许为空,BIGINT,INDEX(scope=project时绑定)
ProjectID *uint `gorm:"column:project_id;type:bigint;uniqueIndex:uni_session_project_task"`
// session - 会话状态,VARCHAR(50),NOT NULL,DEFAULT 'active'
Status string `gorm:"column:status;type:varchar(50);not null;default:'active'"`
// session - 会话标题,VARCHAR(500),允许为空
Title string `gorm:"column:title;type:varchar(500)"`
// session - 用户是否手动修改过标题
TitleManuallySet bool `gorm:"column:title_manually_set;type:boolean;default:false;not null"`
// session - 元数据,JSON格式存储额外信息,JSONB,允许为空
Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
// session - 消息数量,INTEGER,DEFAULT 0
MessageCount int `gorm:"column:message_count;type:integer;default:0"`
// session - 最后消息时间,TIMESTAMP,允许为空
LastMessageAt *time.Time `gorm:"column:last_message_at"`
// session - 过期时间,TIMESTAMP,允许为空
ExpiredAt *time.Time `gorm:"column:expired_at;index"`
}
Session 会话结构体定义了用户与数字助手之间的会话信息
type SessionMessage ¶
type SessionMessage struct {
gorm.Model
// session_message - 关联会话ID(FK -> Session.ID),BIGINT,NOT NULL,INDEX
SessionID uint `gorm:"column:session_id;type:bigint;not null;index"`
// session_message - 消息角色(user/assistant/system/tool),VARCHAR(50),NOT NULL
Role string `gorm:"column:role;type:varchar(50);not null"`
// session_message - 消息内容,TEXT,NOT NULL
Content string `gorm:"column:content;type:text;not null"`
// session_message - 错误详情,TEXT,允许为空
ErrorMsg string `gorm:"column:error_msg;type:text"`
// session_message - 消息类型(text/image/code/file),VARCHAR(50),DEFAULT 'text'
MessageType string `gorm:"column:message_type;type:varchar(50);default:'text'"`
// session_message - 消息状态(sending/streaming/complete/error),VARCHAR(50),DEFAULT 'complete'
Status string `gorm:"column:status;type:varchar(50);default:'complete'"`
// session_message - 流式片段(JSON数组),JSONB,允许为空
Chunks MessageChunkSlice `gorm:"column:chunks;type:jsonb"`
// session_message - assistant message artifact references.
Artifacts MessageArtifactSlice `gorm:"column:artifacts;type:jsonb"`
// session_message - file attachment references.
Attachments MessageAttachmentSlice `gorm:"column:attachments;type:jsonb"`
// session_message - 消息元数据,JSONB,允许为空
Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
Usage MessageUsage `gorm:"column:usage;type:jsonb"`
// session_message - 消息序号(用于排序),BIGINT,NOT NULL
Sequence int64 `gorm:"column:sequence;type:bigint;not null;index"`
// session_message - 时间戳(Unix毫秒),BIGINT,允许为空
Timestamp int64 `gorm:"column:timestamp;type:bigint"`
// session_message - 发送者用户ID(真人发言时有值,AI回复时为nil),BIGINT
SenderUin *uint `gorm:"column:sender_uin;type:bigint;default:0"`
// session_message - 发送者名称(真人=User.Name,AI=DigitalAssistant.Name),VARCHAR(255)
SenderName string `gorm:"column:sender_name;type:varchar(255);default:''"`
// session_message - 关联的 agent run ID(AI 回复消息时填充),VARCHAR(255)
RunID string `gorm:"column:run_id;type:varchar(255);default:''"`
// session_message - 关联的 AI 队友 ID(AI 回复时填充,用户消息为 0),BIGINT,DEFAULT 0,INDEX
AssistantID uint `gorm:"column:assistant_id;type:bigint;default:0;index"`
// session_message - 自动化执行记录主键(首条自动化指令消息),BIGINT,可空,唯一索引
AutomationExecutionID *uint `gorm:"column:automation_execution_id;type:bigint;index"`
}
SessionMessage 会话消息结构体
func (SessionMessage) TableName ¶
func (SessionMessage) TableName() string
TableName 指定SessionMessage结构体对应的数据库表名
type SessionStatus ¶
type SessionStatus string
SessionStatus 会话状态常量
const ( SessionStatusActive SessionStatus = "active" SessionStatusPaused SessionStatus = "paused" SessionStatusEnded SessionStatus = "ended" SessionStatusExpired SessionStatus = "expired" )
type SessionType ¶
type SessionType string
SessionType 会话类型常量
const ( SessionTypeUserChat SessionType = "chat" SessionTypeTask SessionType = "task" SessionTypeProject SessionType = "project" )
type SkillStringList ¶ added in v0.1.1
type SkillStringList []string
SkillStringList stores assistant Skill names as a JSON array.
func (*SkillStringList) Scan ¶ added in v0.1.1
func (s *SkillStringList) Scan(value interface{}) error
Scan implements sql.Scanner.
type Task ¶
type Task struct {
gorm.Model
PublicID string `gorm:"column:public_id;type:varchar(255);not null;uniqueIndex"`
OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
ProjectID uint `gorm:"column:project_id;type:bigint;not null;index"`
SessionID *uint `gorm:"column:session_id;type:bigint;index"`
// TaskType 任务类型(如:general/general、cron/定时任务等),VARCHAR(16),NOT NULL,DEFAULT 'general'
TaskType TaskType `gorm:"column:task_type;type:varchar(16);not null;default:'general';index"`
AssigneeID *uint `gorm:"column:assignee_id;type:bigint;index"`
Title string `gorm:"column:title;type:varchar(500);not null"`
Description string `gorm:"column:description;type:text"`
Status string `gorm:"column:status;type:varchar(50);not null;default:'created';index"`
Deadline *time.Time `gorm:"column:deadline;index"`
// cron 任务的自动化执行记录主键,BIGINT,可空,唯一索引(防止 Dispatcher 重试重复建 Task)
AutomationExecutionID *uint `gorm:"column:automation_execution_id;type:bigint;index"`
Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}
Task 表示系统中的任务
任务是项目中的最小执行单元,由 AI 队友(DigitalAssistant)执行, 支持子任务拆分(通过 ParentTaskID 自引用)和状态生命周期管理。
type TaskStatus ¶
type TaskStatus string
TaskStatus 表示任务的当前状态
const ( TaskStatusCreated TaskStatus = "created" TaskStatusPendingAssignment TaskStatus = "pending_assignment" TaskStatusInProgress TaskStatus = "in_progress" TaskStatusPendingApproval TaskStatus = "pending_approval" TaskStatusCompleted TaskStatus = "completed" TaskStatusFailed TaskStatus = "failed" TaskStatusCancelled TaskStatus = "cancelled" TaskStatusPaused TaskStatus = "paused" )
type Trace ¶
type Trace struct {
RequestID string `json:"request_id"`
TraceID string `json:"trace_id"`
SpanID []string `json:"span_id"`
}
Trace 定义了一个跟踪信息结构体,用于在请求链路中传递跟踪标识符,帮助进行分布式追踪和日志关联。
type User ¶
type User struct {
gorm.Model
ExternalID uint `gorm:"column:external_id;index"` // identity-platform User.ID
PublicID string `gorm:"column:public_id;type:varchar(64);uniqueIndex;not null;default:''"` // 用户公开ID
Password string `gorm:"column:password;type:varchar(255)"` // 密码(本地认证用)
Name string `gorm:"column:name;type:varchar(255)"` // 用户姓名
Email string `gorm:"column:email;type:varchar(255)"` // 用户邮箱
Phone string `gorm:"column:phone;type:varchar(32);uniqueIndex"` // 手机号
AvatarURL string `gorm:"column:avatar_url;type:varchar(500)"` // 头像 URL
}
User 表示系统中的用户信息
type UserOrg ¶
type UserOrg struct {
gorm.Model
ExternalUin uint `gorm:"column:external_uin;index"` // identity-platform UIN.ID
UserID uint `gorm:"column:user_id;type:bigint;index;not null;uniqueIndex:uni_user_org_member"` // 用户ID
OrgID uint `gorm:"column:org_id;type:bigint;index;not null;uniqueIndex:uni_user_org_member"` // 组织ID
IsDefault bool `gorm:"column:is_default;type:boolean;default:false"` // 是否为默认组织
}
UserOrg 表示用户与组织的关联关系
该表是多对多关系的中间表,用于关联用户和组织。 每个用户可以关联多个组织,其中一个可以标记为默认组织。
type WorkbenchRecentContext ¶ added in v0.1.21
type WorkbenchRecentContext struct {
gorm.Model
OrgID uint `gorm:"column:org_id;type:integer;not null;uniqueIndex:uni_workbench_recent_context"`
Uin uint `gorm:"column:uin;type:integer;not null;uniqueIndex:uni_workbench_recent_context"`
ProjectID uint `gorm:"column:project_id;type:bigint;not null;index"`
TaskID *uint `gorm:"column:task_id;type:bigint;index"`
UsedAt time.Time `gorm:"column:used_at;not null;index"`
}
WorkbenchRecentContext 记录用户在首页工作台最近明确使用的项目/任务上下文。
func (WorkbenchRecentContext) TableName ¶ added in v0.1.21
func (WorkbenchRecentContext) TableName() string
TableName 指定 WorkbenchRecentContext 对应的数据库表名。
type WorkerDeployment ¶ added in v0.1.12
type WorkerDeployment struct {
gorm.Model
PublicID string `gorm:"column:public_id;type:varchar(255);not null;default:'';uniqueIndex:idx_worker_deploy_public_id"`
OrgID uint `gorm:"column:org_id;type:bigint;not null;index;uniqueIndex:idx_worker_deploy_org_worker"`
DigitalAssistantID uint `gorm:"column:digital_assistant_id;type:bigint;not null;uniqueIndex;index"`
WorkerID uint `gorm:"column:worker_id;type:bigint;not null;uniqueIndex:idx_worker_deploy_org_worker"`
DeploymentName string `gorm:"column:deployment_name;type:varchar(255);not null;uniqueIndex"`
Namespace string `gorm:"column:namespace;type:varchar(255);not null;default:''"`
Status string `gorm:"column:status;type:varchar(50);not null;default:'pending';index"`
BootstrapTokenHash string `gorm:"column:bootstrap_token_hash;type:varchar(64);not null;default:''"`
WorkspacePath string `gorm:"column:workspace_path;type:varchar(1000);not null;default:''"`
LastError string `gorm:"column:last_error;type:text"`
LastStartedAt *time.Time `gorm:"column:last_started_at;index"`
LastReconciledAt *time.Time `gorm:"column:last_reconciled_at;index"`
}
WorkerDeployment binds an AI teammate to an org-scoped worker runtime.
func (WorkerDeployment) TableName ¶ added in v0.1.12
func (WorkerDeployment) TableName() string
TableName 指定 WorkerDeployment 结构体对应的数据库表名。
type WorkerDeploymentStatus ¶ added in v0.1.12
type WorkerDeploymentStatus string
const ( WorkerDeploymentStatusPending WorkerDeploymentStatus = "pending" WorkerDeploymentStatusProvisioning WorkerDeploymentStatus = "provisioning" WorkerDeploymentStatusReady WorkerDeploymentStatus = "ready" WorkerDeploymentStatusFailed WorkerDeploymentStatus = "failed" WorkerDeploymentStatusStopped WorkerDeploymentStatus = "stopped" )
Source Files
¶
- ai_teammate_template.go
- auth.go
- automation.go
- automation_execution.go
- constants.go
- department.go
- digital_assistant.go
- digital_assistant_evolution.go
- event.go
- file_upload.go
- llm_history.go
- llm_model.go
- mcp_channel.go
- message_resource.go
- organization.go
- owner_scope.go
- permission.go
- plugin.go
- plugin_revision_content.go
- project.go
- project_activity.go
- project_file.go
- rel_user_org_department.go
- resource.go
- resource_binding.go
- run_dispatch.go
- seed_record.go
- session.go
- skill_string_list.go
- tables.go
- task.go
- user.go
- user_org.go
- util.go
- workbench_recent_context.go
- worker_deployment.go