chore: commit workspace updates

This commit is contained in:
ddCat
2026-09-14 01:11:56 +08:00
parent 01a2d171f5
commit 9727656b2b
491 changed files with 12826 additions and 72249 deletions

View File

@@ -0,0 +1,39 @@
package model
import "time"
// CloudAgentExecution checkpoints orchestration independently of billed tasks.
type CloudAgentExecution struct {
ID string `gorm:"primaryKey;size:80"`
UserID string `gorm:"index;size:36"`
Status string `gorm:"index;size:32"`
Revision int64
// Control fields remain writable even when the transcript cannot be decoded or saved.
CanvasID string `gorm:"size:80"`
ActiveTaskID string `gorm:"size:80"`
MediaTaskID string `gorm:"size:80"`
CleanupPending bool `gorm:"not null;default:false;index"`
FailureMessage string `gorm:"size:1000"`
StateJSON string `gorm:"type:text"`
CreatedAt time.Time
UpdatedAt time.Time
}
// CloudAgentCanvasMutation records one atomic canvas change made by an Agent.
// BeforeJSON is intentionally bounded by the application layer; mutations that
// cannot retain a safe snapshot are marked not_undoable instead of truncating it.
type CloudAgentCanvasMutation struct {
ID string `json:"id" gorm:"primaryKey;size:80"`
RunID string `json:"runId" gorm:"index;size:80"`
UserID string `json:"userId" gorm:"index;size:36"`
CanvasID string `json:"canvasId" gorm:"index;size:80"`
StepID string `json:"stepId" gorm:"index;size:160"`
Operation string `json:"operation" gorm:"size:64"`
BeforeSnapshotHash string `json:"beforeSnapshotHash" gorm:"size:64"`
AfterSnapshotHash string `json:"afterSnapshotHash" gorm:"size:64"`
BeforeJSON string `json:"-" gorm:"type:text"`
HasSubmittedTask bool `json:"hasSubmittedTask"`
Status string `json:"status" gorm:"index;size:24"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
UndoneAt *time.Time `json:"undoneAt,omitempty"`
}

View File

@@ -6,7 +6,6 @@ import (
type TaskStatus string
type ProviderCancelStatus string
type SessionStatus string
type UserRole string
type UserStatus string
type ChannelScope string
@@ -50,10 +49,6 @@ const (
// 完成后调用 /tasks/:id/text-replay-complete 归并为最终正文。
TaskStatusTextReplay TaskStatus = "text_replay"
SessionStatusActive SessionStatus = "active"
SessionStatusCompleted SessionStatus = "completed"
SessionStatusFailed SessionStatus = "failed"
UserRoleAdmin UserRole = "admin"
UserRoleUser UserRole = "user"
@@ -86,9 +81,6 @@ const (
ChannelInterfaceRunningHubImage ChannelInterfaceType = "runninghub-workflow-image"
ChannelInterfaceRunningHubVideo ChannelInterfaceType = "runninghub-workflow-video"
ChannelInterfaceRunningHubAudio ChannelInterfaceType = "runninghub-workflow-audio"
ChannelInterfaceComfyBridgeImage ChannelInterfaceType = "comfyui-bridge-image"
ChannelInterfaceComfyBridgeVideo ChannelInterfaceType = "comfyui-bridge-video"
ChannelInterfaceComfyBridgeAudio ChannelInterfaceType = "comfyui-bridge-audio"
ApiCallStatusSucceeded ApiCallStatus = "succeeded"
ApiCallStatusFailed ApiCallStatus = "failed"

View File

@@ -1,36 +0,0 @@
package model
import "time"
// ComfyBridge 是用户电脑上本地 Bridge 的持久化身份。Token 只在创建时返回明文,数据库只保存摘要。
type ComfyBridge struct {
ID string `json:"id" gorm:"primaryKey;size:64"`
UserID string `json:"userId" gorm:"index;size:36"`
Name string `json:"name" gorm:"size:80"`
TokenHash string `json:"-" gorm:"uniqueIndex;size:128"`
Enabled bool `json:"enabled" gorm:"index"`
LastSeenAt *time.Time `json:"lastSeenAt,omitempty"`
LastTaskAt *time.Time `json:"lastTaskAt,omitempty"`
CapabilitiesJSON string `json:"-" gorm:"type:text"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// ComfyBridgeRequest 是云端任务与本地 Bridge 之间的持久化交接记录。
// Payload 和 Result 只保存工作流执行协议,不包含 Bridge Token。
type ComfyBridgeRequest struct {
ID string `json:"id" gorm:"primaryKey;size:64"`
TaskID string `json:"taskId" gorm:"index;size:64"`
UserID string `json:"userId" gorm:"index;size:36"`
BridgeID string `json:"bridgeId" gorm:"index:idx_comfy_bridge_request_queue,priority:1;size:64"`
Kind string `json:"kind" gorm:"size:32"`
Status string `json:"status" gorm:"index:idx_comfy_bridge_request_queue,priority:2;size:24"`
PayloadJSON string `json:"-" gorm:"type:text"`
ResultJSON string `json:"-" gorm:"type:text"`
Error string `json:"error,omitempty" gorm:"type:text"`
ClaimedAt *time.Time `json:"claimedAt,omitempty"`
CompletedAt *time.Time `json:"completedAt,omitempty"`
ExpiresAt time.Time `json:"expiresAt" gorm:"index"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -8,20 +8,19 @@ import (
)
type ModelChannel struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
Scope ChannelScope `json:"scope" gorm:"index;size:24"`
Enabled bool `json:"enabled" gorm:"index"`
Name string `json:"name" gorm:"size:80"`
PublicAlias string `json:"publicAlias" gorm:"size:80;not null;default:''"`
SortOrder int `json:"sortOrder" gorm:"not null;default:0"`
BaseURL string `json:"baseUrl"`
AllowLocalChannel bool `json:"allowLocalChannel" gorm:"default:false"`
APIKey string `json:"-"`
SecretKey string `json:"-"`
APIFormat string `json:"apiFormat" gorm:"size:24"`
ConcurrencyLimit int `json:"concurrencyLimit"`
ModelsJSON string `json:"modelsJson" gorm:"type:text"`
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
Scope ChannelScope `json:"scope" gorm:"index;size:24"`
Enabled bool `json:"enabled" gorm:"index"`
Name string `json:"name" gorm:"size:80"`
PublicAlias string `json:"publicAlias" gorm:"size:80;not null;default:''"`
SortOrder int `json:"sortOrder" gorm:"not null;default:0"`
BaseURL string `json:"baseUrl"`
APIKey string `json:"-"`
SecretKey string `json:"-"`
APIFormat string `json:"apiFormat" gorm:"size:24"`
ConcurrencyLimit int `json:"concurrencyLimit"`
ModelsJSON string `json:"modelsJson" gorm:"type:text"`
// RetiredModelsJSON 记录已被一个模型家族吸收的上游 SKU,防止目录拉取时重新创建重复记录。
RetiredModelsJSON string `json:"-" gorm:"type:text"`
HeadersJSON string `json:"-" gorm:"type:text"`

View File

@@ -40,19 +40,21 @@ type BillingOrder struct {
ChannelID string `json:"channelId" gorm:"index;size:36"`
ChannelModelID string `json:"channelModelId" gorm:"index;size:36"`
// PriceTierID/Version 记录任务实际命中的规格档;金额字段仍是不可变结算快照。
PriceTierID string `json:"priceTierId,omitempty" gorm:"index;size:36"`
PriceTierVersion int64 `json:"priceTierVersion"`
PriceSelectorJSON string `json:"-" gorm:"type:text"`
Model string `json:"model" gorm:"index;size:120"`
Capability string `json:"capability" gorm:"index;size:32"`
Scene string `json:"scene" gorm:"index;size:80"`
BillingMode string `json:"billingMode" gorm:"size:32"`
PriceVersion int64 `json:"priceVersion"`
UnitPriceMicrocredits int64 `json:"unitPriceMicrocredits"`
MultiplierBasisPoints int64 `json:"multiplierBasisPoints"`
Quantity int64 `json:"quantity"`
AmountMicrocredits int64 `json:"amountMicrocredits"`
ReservedAmountMicrocredits int64 `json:"reservedAmountMicrocredits"`
PriceTierID string `json:"priceTierId,omitempty" gorm:"index;size:36"`
PriceTierVersion int64 `json:"priceTierVersion"`
PriceSelectorJSON string `json:"-" gorm:"type:text"`
Model string `json:"model" gorm:"index;size:120"`
Capability string `json:"capability" gorm:"index;size:32"`
Scene string `json:"scene" gorm:"index;size:80"`
BillingMode string `json:"billingMode" gorm:"size:32"`
PriceVersion int64 `json:"priceVersion"`
UnitPriceMicrocredits int64 `json:"unitPriceMicrocredits"`
MultiplierBasisPoints int64 `json:"multiplierBasisPoints"`
Quantity int64 `json:"quantity"`
AmountMicrocredits int64 `json:"amountMicrocredits"`
ReservedAmountMicrocredits int64 `json:"reservedAmountMicrocredits"`
// ChargeLimitMicrocredits 非零时限制最终用户扣费;Agent 的 Token 报价用它把预授权金额固化为本轮硬上限。
ChargeLimitMicrocredits int64 `json:"chargeLimitMicrocredits,omitempty"`
ActualAmountMicrocredits int64 `json:"actualAmountMicrocredits"`
RefundedAmountMicrocredits int64 `json:"refundedAmountMicrocredits"`
InputTokenPriceMicrocredits int64 `json:"inputTokenPriceMicrocredits"`

View File

@@ -8,7 +8,6 @@ type Task struct {
UserID string `json:"userId" gorm:"index;size:36;index:idx_tasks_user_created,priority:1;index:idx_tasks_user_project_created,priority:1"`
TraceID string `json:"-" gorm:"index;size:96"`
RequestID string `json:"-" gorm:"index;size:96"`
SessionID string `json:"sessionId" gorm:"index;size:36"`
ProjectID string `json:"projectId" gorm:"index;size:80;index:idx_tasks_user_project_created,priority:2"`
Type string `json:"type" gorm:"index;size:64"`
Status TaskStatus `json:"status" gorm:"index;size:24;index:idx_tasks_status_created,priority:1;index:idx_tasks_claim,priority:1;index:idx_tasks_provider_cancel,priority:1"`
@@ -59,28 +58,6 @@ type TaskTextDelta struct {
ExpiresAt time.Time `json:"expiresAt" gorm:"index"`
}
type Session struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
ProjectID string `json:"projectId" gorm:"index;size:80"`
Status SessionStatus `json:"status" gorm:"index;size:24"`
Prompt string `json:"prompt"`
CanvasSnapshotJSON string `json:"canvasSnapshotJson" gorm:"type:text"`
CanvasOpsJSON string `json:"canvasOpsJson" gorm:"type:text"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Message struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
SessionID string `json:"sessionId" gorm:"index;size:36"`
Role string `json:"role" gorm:"size:24"`
Content string `json:"content"`
Payload string `json:"payload" gorm:"type:text"`
CreatedAt time.Time `json:"createdAt"`
}
type TaskLog struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
@@ -93,22 +70,10 @@ type TaskLog struct {
CreatedAt time.Time `json:"createdAt"`
}
type SessionFile struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
SessionID string `json:"sessionId" gorm:"index;size:36"`
FileName string `json:"fileName"`
MimeType string `json:"mimeType"`
Path string `json:"-"`
Size int64 `json:"size"`
CreatedAt time.Time `json:"createdAt"`
}
type Result struct {
ID string `json:"id" gorm:"primaryKey;size:36"`
UserID string `json:"userId" gorm:"index;size:36"`
TaskID string `json:"taskId" gorm:"index;size:36"`
SessionID string `json:"sessionId" gorm:"index;size:36"`
Kind string `json:"kind" gorm:"size:64"`
URL string `json:"url"`
Payload string `json:"payload" gorm:"type:text"`