feat(agent): 统一专业拆镜入口与真实镜头生成
This commit is contained in:
@@ -343,10 +343,10 @@ func (s *Service) prepareCreationTask(userID string, req CreateTaskRequest) (*mo
|
||||
if err := validateCreationJSON(req); err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
if req.Type != "canvas_text" && req.Type != "text" && req.Type != "canvas_image" && req.Type != "canvas_video" {
|
||||
if req.Type != "canvas_text" && req.Type != "text" && req.Type != "agent_storyboard_rows" && req.Type != "canvas_image" && req.Type != "canvas_video" {
|
||||
return nil, nil, "", BadAuthRequest("智能创作任务类型不受支持")
|
||||
}
|
||||
expectedMode := map[string]string{"text": "text", "canvas_text": "text", "canvas_image": "image", "canvas_video": "video"}[req.Type]
|
||||
expectedMode := map[string]string{"text": "text", "canvas_text": "text", "agent_storyboard_rows": "text", "canvas_image": "image", "canvas_video": "video"}[req.Type]
|
||||
if stringValue(req.Input["mode"]) != expectedMode || strings.TrimSpace(stringValue(req.Input["prompt"])) != strings.TrimSpace(req.Prompt) {
|
||||
return nil, nil, "", BadAuthRequest("任务类型、模式和实际提示词必须一致")
|
||||
}
|
||||
@@ -478,7 +478,7 @@ func validateCreationSubmissionScope(run *model.CreationRun, version int64, req
|
||||
if run.Status == "paused" || run.Status == "cancelled" || run.Status == "completed" {
|
||||
return creationConflict("请先恢复创作任务")
|
||||
}
|
||||
if req.Type == "canvas_text" || req.Type == "text" {
|
||||
if req.Type == "canvas_text" || req.Type == "text" || req.Type == "agent_storyboard_rows" {
|
||||
if req.ProjectID != "" && req.ProjectID != run.CanvasID {
|
||||
return creationConflict("规划任务的画布关联不匹配")
|
||||
}
|
||||
|
||||
@@ -43,6 +43,30 @@ func creationTestService(t *testing.T) (*Service, *gorm.DB, string, CreationGuar
|
||||
func creationTextRequest() CreateTaskRequest {
|
||||
return CreateTaskRequest{Type: "canvas_text", Prompt: "只输出测试", Model: "text-test", Input: map[string]any{"mode": "text", "prompt": "只输出测试", "config": map[string]any{"channelId": "channel", "model": "text-test"}}}
|
||||
}
|
||||
|
||||
func TestCreationStoryboardRequiresApprovalAndCanvasScope(t *testing.T) {
|
||||
s, _, id, guard := creationTestService(t)
|
||||
req := creationTextRequest()
|
||||
req.Type = "agent_storyboard_rows"
|
||||
req.Operation = "storyboard_rows"
|
||||
item, err := s.PrepareCreationSubmission("user", id, CreationRequest{CreationGuard: guard, ItemKey: "storyboard", Request: req})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = s.ExecuteCreationSubmission("user", id, CreationRequest{CreationGuard: guard, SubmissionID: item.ID}); err == nil {
|
||||
t.Fatal("unapproved storyboard executed")
|
||||
}
|
||||
if _, err = s.ApproveCreationSubmissions("user", id, CreationRequest{CreationGuard: guard, SubmissionIDs: []string{item.ID}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
task, err := s.ExecuteCreationSubmission("user", id, CreationRequest{CreationGuard: guard, SubmissionID: item.ID})
|
||||
if err != nil || task.Type != "agent_storyboard_rows" {
|
||||
t.Fatalf("professional storyboard not submitted: task=%v error=%v", task, err)
|
||||
}
|
||||
if err = validateCreationSubmissionScope(&model.CreationRun{CanvasID: "canvas", Status: "running"}, 0, CreateTaskRequest{Type: "agent_storyboard_rows", ProjectID: "other"}); err == nil {
|
||||
t.Fatal("cross-canvas storyboard accepted")
|
||||
}
|
||||
}
|
||||
func prepareApprovedCreation(t *testing.T, s *Service, id string, guard CreationGuard) *CreationSubmissionOutput {
|
||||
t.Helper()
|
||||
item, err := s.PrepareCreationSubmission("user", id, CreationRequest{CreationGuard: guard, ItemKey: "text-1", Request: creationTextRequest()})
|
||||
|
||||
Reference in New Issue
Block a user