完成统一方案 v0.1 剩余客户端要求(#10/#11/#12)+ 对接文档。 - #10 项目文件夹产物(§12):Manager 解析 runtime 的 markdown 多文件 artifact 成项目文件树, 新增 .../artifacts/{id}/manifest、/files/{path}、/archive 三接口(按需解析,zip 打包)。 - #11 本地修改 revision 协议(§12.7):新模型 AgentArtifactRevision + 迁移; .../local-edits、/local-edits/batch、/revisions;base_revision 冲突检测返回 ARTIFACT_REVISION_CONFLICT;Manager 持有 accepted 基线,回调 Runtime(审计事件)。 - #12 云部署控制面(§18):新模型 AgentCloudDeployment + 迁移; GET /api/heicode/deployment-targets;.../tasks/{id}/deployments(创建/列表); 生产环境进 waiting_approval;客户端只传 resource_binding_id(禁 inline secret); 真实云执行留 executor=pending_worker,等 Deploy Worker 接入。 - 文档:新增 docs/integration/heicode-desktop-unified-api.md(取代旧 sub-agile 文档, 覆盖 capabilities/统一任务路由/display_status/项目文件夹/本地修改/云部署/客户端约束/错误码)。 验证:go build ./... + go test(controller/router/model/middleware)全绿。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 lines
2.1 KiB
Go
47 lines
2.1 KiB
Go
package model
|
|
|
|
// AgentCloudDeployment is the Manager-side control-plane record for deploying a
|
|
// project_folder artifact to a cloud target (unified spec §18). Manager owns
|
|
// validation/approval/credential-resolution/audit; actual provisioning is
|
|
// executed by a Deploy Worker (not yet connected — records sit in a requested/
|
|
// waiting state until a worker picks them up).
|
|
type AgentCloudDeployment struct {
|
|
Id int `gorm:"primaryKey" json:"id"`
|
|
DeployRunID string `gorm:"type:varchar(64);uniqueIndex" json:"deployment_run_id"`
|
|
DeploymentID string `gorm:"type:varchar(64);index" json:"deployment_id"`
|
|
UserID string `gorm:"type:varchar(64);index" json:"user_id"`
|
|
ArtifactID string `gorm:"type:varchar(128)" json:"artifact_id"`
|
|
ArtifactRevision int `json:"artifact_revision"`
|
|
Target string `gorm:"type:varchar(32);index" json:"target"`
|
|
Environment string `gorm:"type:varchar(32)" json:"environment"`
|
|
Region string `gorm:"type:varchar(64)" json:"region"`
|
|
ResourceBindingID int `json:"resource_binding_id"`
|
|
Status string `gorm:"type:varchar(32);index" json:"status"`
|
|
URL string `gorm:"type:varchar(512)" json:"url"`
|
|
PayloadJSON string `gorm:"type:text" json:"-"`
|
|
CreatedAtMs int64 `gorm:"bigint;index" json:"created_at"`
|
|
UpdatedAtMs int64 `gorm:"bigint" json:"updated_at"`
|
|
}
|
|
|
|
func (AgentCloudDeployment) TableName() string {
|
|
return "agent_cloud_deployments"
|
|
}
|
|
|
|
func InsertAgentCloudDeployment(r *AgentCloudDeployment) error {
|
|
return DB.Create(r).Error
|
|
}
|
|
|
|
func ListAgentCloudDeploymentsByDeployment(deploymentID string) ([]AgentCloudDeployment, error) {
|
|
var rows []AgentCloudDeployment
|
|
err := DB.Where("deployment_id = ?", deploymentID).Order("id desc").Find(&rows).Error
|
|
return rows, err
|
|
}
|
|
|
|
func GetAgentCloudDeployment(deployRunID string, userID string) (AgentCloudDeployment, bool) {
|
|
var row AgentCloudDeployment
|
|
if err := DB.Where("deploy_run_id = ? AND user_id = ?", deployRunID, userID).First(&row).Error; err != nil {
|
|
return AgentCloudDeployment{}, false
|
|
}
|
|
return row, true
|
|
}
|