types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

types 包提供 Leros 的核心数据类型定义

该包定义了数字助手、事件、用户、技能等核心领域模型, 以及相关的常量和数据库表名定义。

Index

Constants

View Source
const (
	SystemUin   uint = 1
	SystemOrgID uint = 1
)
View Source
const (
	// OrgSkillInstallationStatusActive means the org wants this skill available on all workers.
	OrgSkillInstallationStatusActive = "active"
	// OrgSkillInstallationStatusInstalling means the org install is being synchronized.
	OrgSkillInstallationStatusInstalling = "installing"
	// OrgSkillInstallationStatusFailed means the last synchronization attempt failed.
	OrgSkillInstallationStatusFailed = "failed"
)
View Source
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"

	// TableNameSkill 技能表名
	TableNameSkill = tablenamePrefix + "skill"
	// TableNameSkillLog 技能执行日志表名
	TableNameSkillLog = tablenamePrefix + "skill_execution_log"
	// TableNameSkillRegistry 技能注册表名
	TableNameSkillRegistry = tablenamePrefix + "skill_registry"

	// TableNameSession 会话表名
	TableNameSession = tablenamePrefix + "session"
	// TableNameSessionMessage 会话消息表名
	TableNameSessionMessage = tablenamePrefix + "session_message"

	// TableNameLLMModel LLM模型配置表名
	TableNameLLMModel = tablenamePrefix + "llm_model"

	// 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"
	// TableNameBuiltinSkillMarketplaceItem 内置 Skill 市场条目表名
	TableNameBuiltinSkillMarketplaceItem = tablenamePrefix + "builtin_skill_marketplace_item"
	// TableNameSkillMarketplaceItem Skill 市场记录缓存表名
	TableNameSkillMarketplaceItem = tablenamePrefix + "skill_marketplace_item"
	// TableNameOrgSkillInstallation 组织级 Skill 安装记录表名
	TableNameOrgSkillInstallation = tablenamePrefix + "org_skill_installation"

	// TableNameMessageResource 消息资源关联表名
	TableNameMessageResource = tablenamePrefix + "message_resource"

	// TableNameDepartment 组织部门表名
	TableNameDepartment = tablenamePrefix + "department"
	// TableNameMemberDepartment 组织成员部门关联表名
	TableNameMemberDepartment = tablenamePrefix + "rel_user_org_department"
)

数据库表名常量定义

View Source
const (
	DefaultPageSize = 10
	PageMaxCount    = 150
)

分页默认值

Variables

View Source
var ErrBindingIdentityRequired = errors.New("uin and assistant_id cannot both be zero or empty")

ErrBindingIdentityRequired 表示绑定必须指定至少一个主体标识(uin 或 assistant_id)。

View Source
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 链(从根到直接父部门)。

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"`
	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 AuthState

type AuthState int

AuthState 认证状态

const (
	AuthStateNil    AuthState = 0
	AuthStateSucc   AuthState = 1
	AuthStateFailed AuthState = 2
)

type BuiltinSkillMarketplaceItem added in v0.1.1

type BuiltinSkillMarketplaceItem struct {
	gorm.Model

	// SkillID 是内置 Skill 的唯一业务编码。
	SkillID string `gorm:"column:skill_id;type:varchar(100);not null;uniqueIndex:idx_builtin_skill_id_version" json:"skill_id"`

	// Name 是 Skill 在市场页面展示的名称。
	Name string `gorm:"column:name;type:varchar(255);not null" json:"name"`

	// Description 是 Skill 的简短说明。
	Description string `gorm:"column:description;type:text" json:"description"`

	// Version 是当前发布版本。
	Version string `gorm:"column:version;type:varchar(50);not null;uniqueIndex:idx_builtin_skill_id_version" json:"version"`

	// Author 是 Skill 作者或发布方。
	Author string `gorm:"column:author;type:varchar(255);not null;default:Lework" json:"author"`

	// Category 是 Skill 分类。
	Category string `gorm:"column:category;type:varchar(100);not null;index" json:"category"`

	// Tags 是 Skill 标签列表。
	Tags SkillStringList `gorm:"column:tags;type:jsonb" json:"tags"`

	// Icon 是 Skill 图标地址或内置图标标识。
	Icon string `gorm:"column:icon;type:varchar(1000)" json:"icon"`

	// LocalPath 是内置 Skill 在服务端的本地路径或打包路径。
	LocalPath string `gorm:"column:local_path;type:varchar(1000);not null" json:"local_path"`

	// PackageSHA256 是内置 Skill 包的 SHA256 校验值。
	PackageSHA256 string `gorm:"column:package_sha256;type:char(64)" json:"package_sha256"`

	// Verified 表示该 Skill 是否经过官方验证。
	Verified bool `gorm:"column:verified;type:boolean;not null;default:true" json:"verified"`

	// PublishedAt 是该 Skill 发布到市场的时间。
	PublishedAt *time.Time `gorm:"column:published_at" json:"published_at"`

	// Installs 是下载量/安装量计数。
	Installs int64 `gorm:"column:installs;type:bigint;not null;default:0" json:"installs"`
}

BuiltinSkillMarketplaceItem 内置 Skill 市场条目。

func (BuiltinSkillMarketplaceItem) TableName added in v0.1.1

func (BuiltinSkillMarketplaceItem) TableName() string

TableName 返回数据库表名。

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 - 描述信息,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 EventType

type EventType string

EventType 表示事件的类型

const (
	// EventTypeGitHub 表示GitHub类型的事件
	EventTypeGitHub EventType = "github"
	// EventTypeGitLab 表示GitLab类型的事件
	EventTypeGitLab EventType = "gitlab"
	// EventTypeWebhook 表示Webhook类型的事件
	EventTypeWebhook EventType = "webhook"
)

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"`
	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

type IdentityContext struct {
	Caller *Caller `json:"caller"`
	Trace  *Trace  `json:"trace"`
}

IdentityContext 携带执行身份与跟踪信息。

type KnowledgeType

type KnowledgeType string

KnowledgeType 表示知识库类型标识

const (
	// KnowledgeTypeVectorStorage 表示向量存储知识库
	KnowledgeTypeVectorStorage KnowledgeType = "vector_storage"
	// KnowledgeTypeDocument 表示文档知识库
	KnowledgeTypeDocument KnowledgeType = "document"
	// KnowledgeTypeDatabase 表示数据库知识库
	KnowledgeTypeDatabase KnowledgeType = "database"
)

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阶段快速接入多模型配置。

func (LLMModel) TableName

func (LLMModel) TableName() string

TableName 指定LLMModel对应的数据库表名

type LLMModelConfig

type LLMModelConfig map[string]interface{}

LLMModelConfig 表示LLM模型配置的扩展JSON字段

func (*LLMModelConfig) Scan

func (c *LLMModelConfig) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于从数据库中读取 JSON 数据

func (LLMModelConfig) Value

func (c LLMModelConfig) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将扩展配置转换为 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 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

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"`
}

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.

func (MessageArtifactSlice) Value

func (m MessageArtifactSlice) Value() (driver.Value, error)

Value implements driver.Valuer.

type MessageAttachment added in v0.1.2

type MessageAttachment struct {
	FileUploadID string `json:"file_upload_id"`
	Name         string `json:"name"`
	MimeType     string `json:"mime_type"`
	Size         int64  `json:"size"`
	Purpose      string `json:"purpose,omitempty"`
	PublicURL    string `json:"PublicURL"` // resolved at runtime, not exposed to front end
}

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

func (MessageAttachmentSlice) Value added in v0.1.2

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"`
}

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 接口

func (MessageChunkSlice) Value

func (m MessageChunkSlice) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口

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 鎺ュ彛

func (MessageUsage) Value

func (mu MessageUsage) Value() (driver.Value, error)

Value 瀹炵幇 driver.Valuer 鎺ュ彛

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 接口

func (ObjectMetadata) Value

func (pm ObjectMetadata) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口

type OrgSkillInstallation added in v0.1.22

type OrgSkillInstallation struct {
	gorm.Model

	// OrgID scopes the installed skill to one organization.
	OrgID uint `gorm:"column:org_id;type:bigint;not null;uniqueIndex:idx_org_skill_installation_key;index"`
	// Source records where the skill came from, such as Leros, ClawHub, or github.
	Source string `gorm:"column:source;type:varchar(64);not null;uniqueIndex:idx_org_skill_installation_key"`
	// Action records the worker skill command action needed to replay this install.
	Action string `gorm:"column:action;type:varchar(32);not null;default:'install'"`
	// SkillID is the source-specific skill identifier.
	SkillID string `gorm:"column:skill_id;type:varchar(255);not null;uniqueIndex:idx_org_skill_installation_key"`
	// Version records the requested version, using latest when omitted.
	Version string `gorm:"column:version;type:varchar(64);not null;default:'latest';uniqueIndex:idx_org_skill_installation_key"`
	// Name is the user-facing skill name when known.
	Name string `gorm:"column:name;type:varchar(255);not null;default:'';index"`
	// Description is copied from marketplace metadata when available.
	Description string `gorm:"column:description;type:text"`
	// Category supports installed skill filtering.
	Category string `gorm:"column:category;type:varchar(100);not null;default:'';index"`
	// Tags stores marketplace tags.
	Tags SkillStringList `gorm:"column:tags;type:jsonb"`
	// PackageStoragePath points to the cached zip package when available.
	PackageStoragePath string `gorm:"column:package_storage_path;type:varchar(500)"`
	// Status records the org-level desired install status.
	Status string `gorm:"column:status;type:varchar(32);not null;default:'active';index"`
	// LastError stores the last synchronization error.
	LastError string `gorm:"column:last_error;type:text"`
	// InstalledBy records the user who initiated the install.
	InstalledBy uint `gorm:"column:installed_by;type:bigint;not null;default:0;index"`
}

OrgSkillInstallation is the org-level source of truth for installed skills.

func (OrgSkillInstallation) TableName added in v0.1.22

func (OrgSkillInstallation) TableName() string

TableName returns the org skill installation table name.

type Organization

type Organization struct {
	gorm.Model
	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)"`                              // 组织描述
	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 表示系统中的组织/企业信息

组织是系统中的顶级实体,可以代表公司、团队或项目。 多个用户可以关联到同一个组织。

func (Organization) TableName

func (Organization) TableName() string

TableName 重写表名

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

func NewPageQuery(caller Caller, offset, limit int) *PageQuery

NewPageQuery 快速创建 PageQuery,接受 Caller 和分页参数。

func (*PageQuery) AddExactFilter

func (pq *PageQuery) AddExactFilter(field string, values ...string) *PageQuery

AddExactFilter 链式添加精确过滤条件。

func (*PageQuery) AddFilter

func (pq *PageQuery) AddFilter(field string, values ...string) *PageQuery

AddFilter 链式添加过滤条件。

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

func (*Pagination) Fill

func (p *Pagination) Fill()

Fill 设置分页默认值

type PermissionCaller added in v0.2.1

type PermissionCaller struct {
	OrgID       uint
	Uin         uint
	AssistantID uint
}

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 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 表示系统中的项目

项目是长期工作的核心容器,承载会话、任务、AI队友、知识库和项目资产。 项目提供了长期上下文和协作空间。

func (Project) TableName

func (Project) TableName() string

TableName 指定Project结构体对应的数据库表名

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"
	// 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"`
	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;uniqueIndex"`
	OrgID        uint                    `gorm:"column:org_id;type:integer;not null;index"`
	ProjectID    uint                    `gorm:"column:project_id;type:bigint;not null;index"`
	TaskID       uint                    `gorm:"column:task_id;type:bigint;index"`
	ResourceID   uint                    `gorm:"column:resource_id;type:bigint;not null;index"`
	ResourceType ProjectFileResourceType `gorm:"column:resource_type;type:varchar(50);not null;index"`
	Uin          uint                    `gorm:"column:uin;type:bigint;index"`
}

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 ProjectStatus

type ProjectStatus string

ProjectStatus 项目生命周期状态

const (
	ProjectStatusActive    ProjectStatus = "active"
	ProjectStatusPaused    ProjectStatus = "paused"
	ProjectStatusCompleted ProjectStatus = "completed"
	ProjectStatusArchived  ProjectStatus = "archived"
)

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 是统一的权限资源记录。

func (Resource) TableName added in v0.1.24

func (Resource) TableName() string

TableName 返回 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[] 值。

func (ResourcePathIDs) Value added in v0.1.24

func (ids ResourcePathIDs) Value() (driver.Value, error)

Value 实现 driver.Valuer,用于写入 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 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 会话结构体定义了用户与数字助手之间的会话信息

func (Session) TableName

func (Session) TableName() string

TableName 指定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"`
}

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 Skill

type Skill struct {
	gorm.Model
	// 技能唯一标识符,与技能实现相关联的ID
	Code string `gorm:"column:code;type:varchar(255);not null;uniqueIndex"`
	// 技能所属组织ID
	OrgID uint `gorm:"column:org_id;type:integer;not null;index"`
	// 技能拥有者ID
	OwnerID uint `gorm:"column:owner_id;type:integer;not null;index"`
	// 技能名称
	Name string `gorm:"column:name;type:varchar(255);not null"`
	// 技能描述
	Description string `gorm:"column:description;type:text"`
	// 技能图标URL
	Icon string `gorm:"column:icon;type:varchar(500)"`
	// 技能版本号
	Version string `gorm:"column:version;type:varchar(50);not null"`
	// 技能类别(例如:"integration","tool","workflow","ai"等)
	Category string `gorm:"column:category;type:varchar(100);not null;index"` // 建议使用 types.SkillCategory 定义的常量值
	// 技能类型(本地技能或远程技能)
	SkillType string `gorm:"column:skill_type;type:varchar(50);not null"` // 建议使用 types.SkillType 定义的常量值
	// 技能作者
	Author string `gorm:"column:author;type:varchar(255)"`
	// 输入参数Schema定义
	InputSchema map[string]interface{} `gorm:"column:input_schema;type:jsonb"`
	// 输出参数Schema定义
	OutputSchema map[string]interface{} `gorm:"column:output_schema;type:jsonb"`
	// 技能所需权限
	Permissions []interface{} `gorm:"column:permissions;type:jsonb"`
	// 技能配置
	Config map[string]interface{} `gorm:"column:config;type:jsonb"`
	// 是否为系统内置技能
	IsSystem bool `gorm:"column:is_system;type:boolean;default:false"`
}

Skill 定义一个在数据库中持久化的技能实体

func (Skill) TableName

func (Skill) TableName() string

TableName 指定Skill对应的数据库表名

type SkillCategory

type SkillCategory string

SkillCategory 表示技能的类别(如 integration, tool, workflow, ai 等)

const (
	// SkillCategoryIntegration 表示集成类技能
	SkillCategoryIntegration SkillCategory = "integration"
	// SkillCategoryTool 表示工具类技能
	SkillCategoryTool SkillCategory = "tool"
	// SkillCategoryWorkflow 表示工作流技能
	SkillCategoryWorkflow SkillCategory = "workflow"
	// SkillCategoryAI 表示AI类技能
	SkillCategoryAI SkillCategory = "ai"
)

type SkillExecutionLog

type SkillExecutionLog struct {
	gorm.Model
	// 关联的技能ID
	SkillID uint `gorm:"column:skill_id;type:integer;not null;index"`
	// 执行会话ID
	SessionID string `gorm:"column:session_id;type:varchar(255);index"`
	// 用户UIN
	Uin string `gorm:"column:uin;type:varchar(255);index"`
	// 数字助手ID
	AssistantID string `gorm:"column:assistant_id;type:varchar(255);index"`
	// 输入参数
	Input map[string]interface{} `gorm:"column:input;type:jsonb"`
	// 输出结果
	Output map[string]interface{} `gorm:"column:output;type:jsonb"`
	// 是否成功
	Success bool `gorm:"column:success;type:boolean"`
	// 错误信息
	ErrorMsg string `gorm:"column:error_msg;type:text"`
	// 执行耗时(毫秒)
	Duration int64 `gorm:"column:duration;type:bigint"`
}

SkillExecutionLog 记录技能执行日志

func (SkillExecutionLog) TableName

func (SkillExecutionLog) TableName() string

TableName 指定SkillExecutionLog对应的数据库表名

type SkillMarketplaceItem added in v0.1.13

type SkillMarketplaceItem struct {
	gorm.Model

	// SkillID 是 Skill 的唯一业务编码。
	SkillID string `gorm:"column:skill_id;type:varchar(100);not null;uniqueIndex:idx_marketplace_item_source_skill_version" json:"skill_id"`

	// Name 是 Skill 在市场页面展示的名称。
	Name string `gorm:"column:name;type:varchar(255);not null" json:"name"`

	// TranslatedName 是模型根据名称和描述生成的中文展示名。
	TranslatedName string `gorm:"column:translated_name;type:varchar(255)" json:"translated_name"`

	// Source 是数据来源,例如 Leros、ClawHub。
	Source string `gorm:"column:source;type:varchar(50);not null;uniqueIndex:idx_marketplace_item_source_skill_version" json:"source"`

	// Description 是原始描述(通常是英文)。
	Description string `gorm:"column:description;type:text" json:"description"`

	// TranslatedDescription 是模型翻译后的中文描述。
	TranslatedDescription string `gorm:"column:translated_description;type:text" json:"translated_description"`

	// Author 是 Skill 作者或发布方。
	Author string `gorm:"column:author;type:varchar(255);not null" json:"author"`

	// Installs 是下载量/安装量计数。
	Installs int64 `gorm:"column:installs;type:bigint;not null;default:0" json:"installs"`

	// Version 是当前版本。
	Version string `gorm:"column:version;type:varchar(50);not null;uniqueIndex:idx_marketplace_item_source_skill_version" json:"version"`

	// Category 是 Skill 分类。
	Category string `gorm:"column:category;type:varchar(100);not null;index" json:"category"`

	// Tags 是 Skill 标签列表。
	Tags SkillStringList `gorm:"column:tags;type:jsonb" json:"tags"`

	// PackageStoragePath 是缓存到 storage-go 的标准化 zip 包 URI,由 server 在获取详情后异步写入。
	// 格式为 storage-go URI,例如 "s3://bucket/skills/marketplace/{source}/{skill_id}/{version}/skill/package.zip"。
	// 空表示尚未缓存。Worker 安装时优先从此路径读取。
	PackageStoragePath string `gorm:"column:package_storage_path;type:varchar(500)" json:"package_storage_path"`
}

SkillMarketplaceItem 市场搜索结果缓存表,用于缓存 Skill 元数据和中文翻译描述。

func (SkillMarketplaceItem) TableName added in v0.1.13

func (SkillMarketplaceItem) TableName() string

TableName 返回数据库表名。

type SkillRegistry

type SkillRegistry struct {
	gorm.Model
	// 关联的技能ID
	SkillID uint `gorm:"column:skill_id;type:integer;not null;uniqueIndex"`
	// 技能服务地址(如果是远程技能)
	ServiceEndpoint string `gorm:"column:service_endpoint;type:varchar(500)"`
	// 技能执行路径
	ExecutionPath string `gorm:"column:execution_path;type:varchar(500)"`
	// 技能认证令牌
	Token string `gorm:"column:token;type:varchar(255)"`
	// 注册状态(registered, unregistered, unhealthy等)
	Status string `gorm:"column:status;type:varchar(50);not null;default:registered"` // 建议使用 types.SkillRegistryStatus 定义的常量值
	// 最后心跳时间
	LastHeartbeat string `gorm:"column:last_heartbeat;type:timestamp"`
	// 健康状态
	IsHealthy bool `gorm:"column:is_healthy;type:boolean;default:true"`
}

SkillRegistry 记录技能在系统中的注册信息

func (SkillRegistry) TableName

func (SkillRegistry) TableName() string

TableName 指定SkillRegistry对应的数据库表名

type SkillRegistryStatus

type SkillRegistryStatus string

SkillRegistryStatus 表示技能注册状态

const (
	// SkillRegistryStatusRegistered 表示已注册
	SkillRegistryStatusRegistered SkillRegistryStatus = "registered"
	// SkillRegistryStatusUnregistered 表示未注册
	SkillRegistryStatusUnregistered SkillRegistryStatus = "unregistered"
	// SkillRegistryStatusUnhealthy 表示不健康
	SkillRegistryStatusUnhealthy SkillRegistryStatus = "unhealthy"
)

type SkillStringList added in v0.1.1

type SkillStringList []string

SkillStringList 是 []string 的 JSONB 存储类型。

func (*SkillStringList) Scan added in v0.1.1

func (s *SkillStringList) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口。

func (SkillStringList) Value added in v0.1.1

func (s SkillStringList) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口。

type SkillType

type SkillType string

SkillType 表示技能类型(本地技能或远程技能)

const (
	// SkillTypeLocal 表示本地技能
	SkillTypeLocal SkillType = "local"
	// SkillTypeRemote 表示远程技能
	SkillTypeRemote SkillType = "remote"
)

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"`

	Metadata ObjectMetadata `gorm:"column:metadata;type:jsonb"`
}

Task 表示系统中的任务

任务是项目中的最小执行单元,由 AI 队友(DigitalAssistant)执行, 支持子任务拆分(通过 ParentTaskID 自引用)和状态生命周期管理。

func (Task) TableName

func (Task) TableName() string

TableName 指定Task结构体对应的数据库表名

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 TaskType

type TaskType string
const (
	TaskTypeGeneral TaskType = "general"
	TaskTypeCron    TaskType = "cron"
)

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
	PublicID    string `gorm:"column:public_id;type:varchar(64);uniqueIndex;not null;default:''"` // 用户公开ID
	GithubID    int64  `gorm:"column:github_id;type:bigint;unique_index"`                         // GitHub 用户 ID
	GithubLogin string `gorm:"column:github_login;type:varchar(255);not null;unique_index"`       // GitHub 登录名
	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
	Bio         string `gorm:"column:bio;type:text"`                                              // 个人简介
	Company     string `gorm:"column:company;type:varchar(255)"`                                  // 公司信息
	Location    string `gorm:"column:location;type:varchar(255)"`                                 // 地理位置
	PublicRepos int    `gorm:"column:public_repos;type:integer"`                                  // 公开仓库数量
	Followers   int    `gorm:"column:followers;type:integer"`                                     // 关注者数量
}

User 表示系统中的用户信息

该结构存储用户的基本信息,包括 GitHub 关联信息、 个人资料、头像等。

func (User) TableName

func (User) TableName() string

TableName 重写表名

type UserOrg

type UserOrg struct {
	gorm.Model
	Uin       uint `gorm:"column:uin;type:bigint;uniqueIndex;not null"`                               // 关联ID,JWT中的Uin
	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 表示用户与组织的关联关系

该表是多对多关系的中间表,用于关联用户和组织。 每个用户可以关联多个组织,其中一个可以标记为默认组织。

func (UserOrg) TableName

func (UserOrg) TableName() string

TableName 重写表名

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"
)

Jump to

Keyboard shortcuts

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