diff --git a/db/schema.sql b/db/schema.sql index 4a35aab..1fe2311 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -524,7 +524,6 @@ CREATE TABLE IF NOT EXISTS tasks ( timeout_seconds INTEGER NOT NULL DEFAULT 0, plan_heartbeat_seconds INTEGER NOT NULL DEFAULT 300, coverage_enabled BOOLEAN NOT NULL DEFAULT true, - worker_count INTEGER NOT NULL DEFAULT 0, -- 0=用全局默认 workers pinned_at TIMESTAMPTZ, first_run_at TIMESTAMPTZ, deadline_at TIMESTAMPTZ, @@ -547,8 +546,6 @@ ALTER TABLE tasks ADD COLUMN IF NOT EXISTS queued BOOLEAN NOT NULL DEFAULT false -- 给 agent 开放 add_task_scope/list_untested_assets;false=全部关闭(见 task_scope.go)。 -- 存量任务默认 true 保持原行为;company 关联(task_scope kind=company)不受此开关影响。 ALTER TABLE tasks ADD COLUMN IF NOT EXISTS coverage_enabled BOOLEAN NOT NULL DEFAULT true; --- 任务级 Worker 运行数量;0=用全局默认(settings.workers)。补旧库。 -ALTER TABLE tasks ADD COLUMN IF NOT EXISTS worker_count INTEGER NOT NULL DEFAULT 0; -- queued_at makes admission FIFO reflect the actual enqueue order rather than the -- task creation order. queue_mode distinguishes first bootstrap from resuming an -- exploration that already owns goals/history. @@ -620,21 +617,16 @@ CREATE TABLE IF NOT EXISTS task_templates ( nkey TEXT NOT NULL UNIQUE, description TEXT NOT NULL, goal TEXT NOT NULL, - remark TEXT NOT NULL DEFAULT '', -- 预设的任务分类;分类删除时置空(与 tasks.category_id 一致,不阻断)。 category_id BIGINT REFERENCES task_categories(id) ON DELETE SET NULL, -- 预设的任务级拦截/允许规则快照(AssetInterceptRuleInput 数组);应用模板时灌进新任务。 intercept_rules JSONB NOT NULL DEFAULT '[]', - -- 预设的任务级 Worker 运行数量;0=用全局默认。 - worker_count INTEGER NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now() ); -- 补旧库(已发版,加列带 IF NOT EXISTS)。 ALTER TABLE task_templates ADD COLUMN IF NOT EXISTS category_id BIGINT REFERENCES task_categories(id) ON DELETE SET NULL; ALTER TABLE task_templates ADD COLUMN IF NOT EXISTS intercept_rules JSONB NOT NULL DEFAULT '[]'; -ALTER TABLE task_templates ADD COLUMN IF NOT EXISTS remark TEXT NOT NULL DEFAULT ''; -ALTER TABLE task_templates ADD COLUMN IF NOT EXISTS worker_count INTEGER NOT NULL DEFAULT 0; CREATE INDEX IF NOT EXISTS idx_task_templates_updated ON task_templates(updated_at DESC, id DESC); DROP TRIGGER IF EXISTS trg_task_templates_upd ON task_templates; CREATE TRIGGER trg_task_templates_upd BEFORE UPDATE ON task_templates diff --git a/db/task_archives_restore.go b/db/task_archives_restore.go index 56f102b..01094ca 100644 --- a/db/task_archives_restore.go +++ b/db/task_archives_restore.go @@ -122,7 +122,7 @@ AND NOT EXISTS ( if _, err := tx.Exec(`UPDATE tasks SET name='',remark='',category_id=NULL,description='',goal='',paused=true,queued=false,queued_at=NULL,queue_mode='', llm_profile_id=NULL,active_llm_profile_id=NULL,llm_chain_revision=llm_chain_revision+1, - company_id=NULL,parent_ref=NULL,timeout_seconds=0,coverage_enabled=true,worker_count=0,pinned_at=NULL, + company_id=NULL,parent_ref=NULL,timeout_seconds=0,coverage_enabled=true,pinned_at=NULL, first_run_at=NULL,deadline_at=NULL,archived_at=now(),deleted_at=now() WHERE id=$1`, taskID); err != nil { return err @@ -322,7 +322,7 @@ func restoreTaskStub(tx *sql.Tx, row map[string]any, taskID, remaining int64) er llm_profile_id=archived.llm_profile_id,active_llm_profile_id=archived.active_llm_profile_id, llm_chain_revision=archived.llm_chain_revision,company_id=archived.company_id,parent_ref=archived.parent_ref, timeout_seconds=archived.timeout_seconds,plan_heartbeat_seconds=archived.plan_heartbeat_seconds, - coverage_enabled=archived.coverage_enabled,worker_count=COALESCE(archived.worker_count,0),pinned_at=archived.pinned_at,first_run_at=archived.first_run_at, + coverage_enabled=archived.coverage_enabled,pinned_at=archived.pinned_at,first_run_at=archived.first_run_at, deadline_at=CASE WHEN archived.paused AND $3>0 THEN now()+make_interval(secs=>$3::double precision) ELSE archived.deadline_at END, deleted_at=NULL,archived_at=NULL,completed_at=archived.completed_at, diff --git a/db/task_templates.go b/db/task_templates.go index 2f42387..80e3116 100644 --- a/db/task_templates.go +++ b/db/task_templates.go @@ -31,10 +31,8 @@ type TaskTemplate struct { NKey string `json:"-"` Description string `json:"description"` Goal string `json:"goal"` - Remark string `json:"remark"` CategoryID *int64 `json:"category_id"` InterceptRules []TaskInterceptRuleInput `json:"intercept_rules"` - WorkerCount int `json:"worker_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } @@ -44,10 +42,8 @@ type TaskTemplateInput struct { Name string Description string Goal string - Remark string CategoryID *int64 InterceptRules []TaskInterceptRuleInput - WorkerCount int } // TaskTemplatePatch changes only fields flagged as set. Name/Description/Goal use @@ -57,20 +53,18 @@ type TaskTemplatePatch struct { Name *string Description *string Goal *string - Remark *string CategoryID *int64 SetCategoryID bool InterceptRules []TaskInterceptRuleInput SetInterceptRules bool - WorkerCount *int } -const taskTemplateCols = `id, name, nkey, description, goal, COALESCE(remark,''), category_id, intercept_rules, COALESCE(worker_count,0), created_at, updated_at` +const taskTemplateCols = `id, name, nkey, description, goal, category_id, intercept_rules, created_at, updated_at` func scanTaskTemplate(row interface{ Scan(...any) error }) (TaskTemplate, error) { var t TaskTemplate var rulesRaw []byte - if err := row.Scan(&t.ID, &t.Name, &t.NKey, &t.Description, &t.Goal, &t.Remark, &t.CategoryID, &rulesRaw, &t.WorkerCount, &t.CreatedAt, &t.UpdatedAt); err != nil { + if err := row.Scan(&t.ID, &t.Name, &t.NKey, &t.Description, &t.Goal, &t.CategoryID, &rulesRaw, &t.CreatedAt, &t.UpdatedAt); err != nil { return t, err } t.InterceptRules = []TaskInterceptRuleInput{} @@ -118,19 +112,11 @@ func normalizeTaskTemplateInput(in TaskTemplateInput) (TaskTemplateInput, string case utf8.RuneCountInString(in.Goal) > MaxTaskTemplateTextRunes: return in, "", fmt.Errorf("%w: goal exceeds %d characters", ErrTaskTemplateInvalid, MaxTaskTemplateTextRunes) } - in.Remark = strings.TrimSpace(in.Remark) - // Align with task remarks (server/remarks.go maxRemarkRunes=2000) so applying a - // template cannot produce a create-task payload that the task API rejects. - const maxTemplateRemarkRunes = 2000 - if utf8.RuneCountInString(in.Remark) > maxTemplateRemarkRunes { - return in, "", fmt.Errorf("%w: remark exceeds %d characters", ErrTaskTemplateInvalid, maxTemplateRemarkRunes) - } - in.WorkerCount = normalizeWorkerCount(in.WorkerCount) return in, taskTemplateNKey(in.Name), nil } func normalizeTaskTemplatePatch(patch TaskTemplatePatch) (TaskTemplatePatch, *string, error) { - if patch.Name == nil && patch.Description == nil && patch.Goal == nil && patch.Remark == nil && !patch.SetCategoryID && !patch.SetInterceptRules && patch.WorkerCount == nil { + if patch.Name == nil && patch.Description == nil && patch.Goal == nil && !patch.SetCategoryID && !patch.SetInterceptRules { return patch, nil, fmt.Errorf("%w: no fields supplied", ErrTaskTemplateInvalid) } var nkey *string @@ -166,18 +152,6 @@ func normalizeTaskTemplatePatch(patch TaskTemplatePatch) (TaskTemplatePatch, *st } patch.Goal = &goal } - if patch.Remark != nil { - remark := strings.TrimSpace(*patch.Remark) - const maxTemplateRemarkRunes = 2000 - if utf8.RuneCountInString(remark) > maxTemplateRemarkRunes { - return patch, nil, fmt.Errorf("%w: remark exceeds %d characters", ErrTaskTemplateInvalid, maxTemplateRemarkRunes) - } - patch.Remark = &remark - } - if patch.WorkerCount != nil { - n := normalizeWorkerCount(*patch.WorkerCount) - patch.WorkerCount = &n - } return patch, nkey, nil } @@ -197,10 +171,10 @@ func (d *DB) CreateTaskTemplate(in TaskTemplateInput) (*TaskTemplate, error) { return nil, err } t, err := scanTaskTemplate(d.QueryRow(` -INSERT INTO task_templates(name, nkey, description, goal, remark, category_id, intercept_rules, worker_count) -VALUES ($1,$2,$3,$4,$5,$6,$7,$8) +INSERT INTO task_templates(name, nkey, description, goal, category_id, intercept_rules) +VALUES ($1,$2,$3,$4,$5,$6) ON CONFLICT (nkey) DO NOTHING -RETURNING `+taskTemplateCols, in.Name, nkey, in.Description, in.Goal, in.Remark, in.CategoryID, rulesJSON, in.WorkerCount)) +RETURNING `+taskTemplateCols, in.Name, nkey, in.Description, in.Goal, in.CategoryID, rulesJSON)) if err == sql.ErrNoRows { return nil, ErrTaskTemplateNameConflict } @@ -247,8 +221,7 @@ func (d *DB) UpdateTaskTemplate(id int64, in TaskTemplateInput) (*TaskTemplate, return nil, err } return d.PatchTaskTemplate(id, TaskTemplatePatch{ - Name: &in.Name, Description: &in.Description, Goal: &in.Goal, Remark: &in.Remark, - WorkerCount: &in.WorkerCount, + Name: &in.Name, Description: &in.Description, Goal: &in.Goal, }) } @@ -269,20 +242,16 @@ SET name=CASE WHEN $2 THEN $3::text ELSE name END, nkey=CASE WHEN $2 THEN $4::text ELSE nkey END, description=CASE WHEN $5 THEN $6::text ELSE description END, goal=CASE WHEN $7 THEN $8::text ELSE goal END, - remark=CASE WHEN $9 THEN $10::text ELSE remark END, - category_id=CASE WHEN $11 THEN $12::bigint ELSE category_id END, - intercept_rules=CASE WHEN $13 THEN $14::jsonb ELSE intercept_rules END, - worker_count=CASE WHEN $15 THEN $16::integer ELSE worker_count END + category_id=CASE WHEN $9 THEN $10::bigint ELSE category_id END, + intercept_rules=CASE WHEN $11 THEN $12::jsonb ELSE intercept_rules END WHERE id=$1 RETURNING `+taskTemplateCols, id, patch.Name != nil, patch.Name, nkey, patch.Description != nil, patch.Description, patch.Goal != nil, patch.Goal, - patch.Remark != nil, patch.Remark, patch.SetCategoryID, patch.CategoryID, patch.SetInterceptRules, rulesJSON, - patch.WorkerCount != nil, patch.WorkerCount, )) if err == sql.ErrNoRows { return nil, ErrTaskTemplateNotFound diff --git a/db/tasks.go b/db/tasks.go index 0a69d60..b675bea 100644 --- a/db/tasks.go +++ b/db/tasks.go @@ -6,9 +6,7 @@ import ( "errors" "fmt" "strconv" - "strings" "time" - "unicode/utf8" ) // Task is a row in the task registry (1:1 with an exploration). @@ -53,9 +51,6 @@ type Task struct { // list_untested_assets、态势里不注入 coverage 块(scope 字段仍保留)。company 关联 // (task_scope kind=company)与此开关无关,永不受影响。见 db/task_scope.go。 CoverageEnabled bool `json:"coverage_enabled"` - // WorkerCount is the per-task concurrent work-agent count. 0 means use the - // global settings.workers default when the engine starts this task. - WorkerCount int `json:"worker_count"` } // TaskDeleteResult reports optional related-data cleanup performed in the same @@ -137,21 +132,6 @@ func normalizeHeartbeat(sec int) int { return sec } -// MaxTaskWorkerCount is the hard upper bound for a per-task worker override. -const MaxTaskWorkerCount = 50 - -// normalizeWorkerCount clamps a per-task worker override into [0, MaxTaskWorkerCount]. -// 0 means "use the global settings.workers default". -func normalizeWorkerCount(n int) int { - if n < 0 { - return 0 - } - if n > MaxTaskWorkerCount { - return MaxTaskWorkerCount - } - return n -} - func (d *DB) CreateTask(description, goal string, llmProfileID *int64, timeoutSeconds, planHeartbeatSeconds int) (*Task, error) { var ids []int64 if llmProfileID != nil { @@ -176,10 +156,6 @@ type TaskCreateOptions struct { // CoverageEnabled 是「资产覆盖度功能」开关;nil=默认开(true),让不关心该开关的创建 // 路径(编排 spawn、老 API)沿用原行为。仅 web 创建任务时可显式传 false 关闭。 CoverageEnabled *bool - // WorkerCount 是本任务并发运行的工作 Agent 数;0/省略=用全局默认。上限 50。 - WorkerCount int - // Remark 是创建时可带的任务备注(最多 2000 字);空=无备注。 - Remark string // InterceptRules 是任务级资产拦截规则,创建时随任务在同一事务内写入 task_intercept_rules。 InterceptRules []TaskInterceptRuleInput } @@ -224,11 +200,6 @@ VALUES ($1, 'fact', $2, 0, 'origin', 'system')`, expID, string(originPayload)); } opts.PlanHeartbeatSeconds = normalizeHeartbeat(opts.PlanHeartbeatSeconds) coverageEnabled := opts.CoverageEnabled == nil || *opts.CoverageEnabled - opts.WorkerCount = normalizeWorkerCount(opts.WorkerCount) - opts.Remark = strings.TrimSpace(opts.Remark) - if utf8.RuneCountInString(opts.Remark) > 2000 { - return nil, fmt.Errorf("备注最多 2000 个字符") - } var categoryName string if opts.CategoryID != nil { if *opts.CategoryID <= 0 { @@ -254,12 +225,12 @@ VALUES ($1, 'fact', $2, 0, 'origin', 'system')`, expID, string(originPayload)); SourceTaskIDs: append([]int64(nil), opts.SourceTaskIDs...), CompanyIDs: append([]int64(nil), opts.CompanyIDs...), TimeoutSeconds: opts.TimeoutSeconds, PlanHeartbeatSeconds: opts.PlanHeartbeatSeconds, - CoverageEnabled: coverageEnabled, WorkerCount: opts.WorkerCount, Remark: opts.Remark, + CoverageEnabled: coverageEnabled, } if err := tx.QueryRow(` -INSERT INTO tasks(name, remark, category_id, description, goal, exploration_id, llm_profile_id, active_llm_profile_id, timeout_seconds, plan_heartbeat_seconds, coverage_enabled, worker_count) -VALUES ($1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$10,$11) -RETURNING id, status, paused, created_at`, opts.Name, opts.Remark, opts.CategoryID, description, goal, expID, active, opts.TimeoutSeconds, opts.PlanHeartbeatSeconds, coverageEnabled, opts.WorkerCount).Scan(&t.ID, &t.Status, &t.Paused, &t.CreatedAt); err != nil { +INSERT INTO tasks(name, category_id, description, goal, exploration_id, llm_profile_id, active_llm_profile_id, timeout_seconds, plan_heartbeat_seconds, coverage_enabled) +VALUES ($1,$2,$3,$4,$5,$6,$6,$7,$8,$9) +RETURNING id, status, paused, created_at`, opts.Name, opts.CategoryID, description, goal, expID, active, opts.TimeoutSeconds, opts.PlanHeartbeatSeconds, coverageEnabled).Scan(&t.ID, &t.Status, &t.Paused, &t.CreatedAt); err != nil { return nil, err } if err := insertTaskRelations(tx, t.ID, opts.SourceTaskIDs); err != nil { @@ -392,11 +363,11 @@ func insertTaskLLMProfiles(tx *sql.Tx, taskID int64, profileIDs []int64) error { const taskCols = `id, COALESCE(name,''), remark, category_id, COALESCE((SELECT category.name FROM task_categories category WHERE category.id=tasks.category_id),''), -description, goal, exploration_id, status, paused, queued, queued_at, COALESCE(queue_mode,''), llm_profile_id, active_llm_profile_id, COALESCE(parent_ref,''), pinned_at, created_at, completed_at, COALESCE(timeout_seconds,0), COALESCE(plan_heartbeat_seconds,300), COALESCE(coverage_enabled,true), COALESCE(worker_count,0), first_run_at, deadline_at` +description, goal, exploration_id, status, paused, queued, queued_at, COALESCE(queue_mode,''), llm_profile_id, active_llm_profile_id, COALESCE(parent_ref,''), pinned_at, created_at, completed_at, COALESCE(timeout_seconds,0), COALESCE(plan_heartbeat_seconds,300), COALESCE(coverage_enabled,true), first_run_at, deadline_at` func scanTask(sc interface{ Scan(...any) error }) (*Task, error) { var t Task - if err := sc.Scan(&t.ID, &t.Name, &t.Remark, &t.CategoryID, &t.CategoryName, &t.Description, &t.Goal, &t.ExplorationID, &t.Status, &t.Paused, &t.Queued, &t.QueuedAt, &t.QueueMode, &t.LLMProfileID, &t.ActiveLLMProfileID, &t.ParentRef, &t.PinnedAt, &t.CreatedAt, &t.CompletedAt, &t.TimeoutSeconds, &t.PlanHeartbeatSeconds, &t.CoverageEnabled, &t.WorkerCount, &t.FirstRunAt, &t.DeadlineAt); err != nil { + if err := sc.Scan(&t.ID, &t.Name, &t.Remark, &t.CategoryID, &t.CategoryName, &t.Description, &t.Goal, &t.ExplorationID, &t.Status, &t.Paused, &t.Queued, &t.QueuedAt, &t.QueueMode, &t.LLMProfileID, &t.ActiveLLMProfileID, &t.ParentRef, &t.PinnedAt, &t.CreatedAt, &t.CompletedAt, &t.TimeoutSeconds, &t.PlanHeartbeatSeconds, &t.CoverageEnabled, &t.FirstRunAt, &t.DeadlineAt); err != nil { return nil, err } t.Pinned = t.PinnedAt != nil diff --git a/server/dto.go b/server/dto.go index 339c1f2..60785a5 100644 --- a/server/dto.go +++ b/server/dto.go @@ -64,7 +64,6 @@ type TaskDTO struct { ArchiveBlockedBy string `json:"archive_blocked_by_task_id,omitempty"` CompanyIDs []int64 `json:"company_ids"` CoverageEnabled bool `json:"coverage_enabled"` // 资产覆盖度功能开关(创建时定) - WorkerCount int `json:"worker_count"` // 本任务 Worker 数;0=用全局默认 } // FindingSeverityDTO 是任务列表里按严重度分档的漏洞计数(严重/高/中/低)。 @@ -139,7 +138,6 @@ func taskDTO(t *Task, status string) TaskDTO { SourceTaskIDs: sourceIDs, CompanyIDs: lifecycle.CompanyIDs, CoverageEnabled: t.CoverageEnabled, - WorkerCount: t.WorkerCount, } } diff --git a/server/engine.go b/server/engine.go index 5a25d9a..b5643b2 100644 --- a/server/engine.go +++ b/server/engine.go @@ -746,10 +746,7 @@ func (e *Engine) ReadyFor(t *Task) bool { // but no-op until an LLM is configured (so a task created while idle picks up // automatically once LLM is set from the UI). func (e *Engine) Run(ctx context.Context, t *Task) { - workers := t.WorkerCount - if workers <= 0 { - workers = e.m.Workers() - } + workers := e.m.Workers() e.deleteMu.RLock() if e.IsDeleting(t.ID) { e.deleteMu.RUnlock() diff --git a/server/manager.go b/server/manager.go index 2457bf3..09fdcd3 100644 --- a/server/manager.go +++ b/server/manager.go @@ -59,7 +59,6 @@ type Task struct { TimeoutSeconds int `json:"timeout_seconds"` PlanHeartbeatSeconds int `json:"plan_heartbeat_seconds"` // planner 心跳触发间隔(秒) CoverageEnabled bool `json:"coverage_enabled"` // 资产覆盖度功能开关(创建时定,默认开) - WorkerCount int `json:"worker_count"` // 本任务 Worker 数;0=用全局默认 FirstRunAt int64 `json:"first_run_at,omitempty"` DeadlineAt int64 `json:"deadline_at,omitempty"` Store *pgdb.ExplorationStore `json:"-"` @@ -850,7 +849,7 @@ func taskFromPG(pt *pgdb.Task, store *pgdb.ExplorationStore, ic *intercept.Inter SourceTaskIDs: append([]int64(nil), pt.SourceTaskIDs...), CompanyIDs: append([]int64(nil), pt.CompanyIDs...), TimeoutSeconds: pt.TimeoutSeconds, PlanHeartbeatSeconds: pt.PlanHeartbeatSeconds, - CoverageEnabled: pt.CoverageEnabled, WorkerCount: pt.WorkerCount, + CoverageEnabled: pt.CoverageEnabled, FirstRunAt: unixOrZero(pt.FirstRunAt), DeadlineAt: unixOrZero(pt.DeadlineAt), Store: store, Guard: guard.NewWithInterceptor(ic), notify: make(chan struct{}, 1), } diff --git a/server/server.go b/server/server.go index 71eee0f..969216c 100644 --- a/server/server.go +++ b/server/server.go @@ -1540,8 +1540,6 @@ type createTaskReq struct { PlanHeartbeatSeconds int `json:"plan_heartbeat_seconds"` // planner 心跳触发间隔(秒);0/省略=默认600(10min);下限=默认=600,低于自动抬到600 SeedFirstIntent *bool `json:"seed_first_intent,omitempty"` // 创建时直接下发一条种子意图(内容=描述+目标),让 worker 免等首轮 planner 直接开跑;省略/null=默认关闭,走标准先规划再执行。显式传 true 才开(CTF 常一 work 解决时可省掉开跑前的 planner 轮)。 CoverageEnabled *bool `json:"coverage_enabled,omitempty"` // 资产覆盖度功能;省略/null=默认开(true)。false=关闭覆盖度计算/展示/自动累积范围+隐藏 add_task_scope/list_untested_assets。company 关联不受影响。 - Remark string `json:"remark,omitempty"` // 任务备注(最多2000字);空=无 - WorkerCount int `json:"worker_count,omitempty"` // 本任务 Worker 数;0/省略=用全局默认;上限50 // InterceptRules 任务级资产拦截/允许规则(创建时录入,存 task_intercept_rules,不进全局表)。 InterceptRules []taskInterceptRuleReq `json:"intercept_rules,omitempty"` } @@ -1605,27 +1603,12 @@ func (s *Server) createTask(w http.ResponseWriter, r *http.Request) { } schedule = &input } - remark, err := normalizeRemark(req.Remark) - if err != nil { - writeErr(w, 400, err.Error()) - return - } - if req.WorkerCount < 0 { - writeErr(w, 400, "Worker 运行数量不能为负数") - return - } - if req.WorkerCount > db.MaxTaskWorkerCount { - writeErr(w, 400, fmt.Sprintf("Worker 运行数量最多 %d", db.MaxTaskWorkerCount)) - return - } t, err := s.m.CreateTaskWithOptions(req.Description, req.Goal, db.TaskCreateOptions{ Schedule: schedule, Name: strings.TrimSpace(req.Name), CategoryID: req.CategoryID, SourceTaskIDs: sourceIDs, CompanyIDs: req.CompanyIDs, LLMProfileIDs: req.LLMProfileIDs, TimeoutSeconds: req.TimeoutSeconds, PlanHeartbeatSeconds: req.PlanHeartbeatSeconds, CoverageEnabled: req.CoverageEnabled, - Remark: remark, - WorkerCount: req.WorkerCount, InterceptRules: interceptRules, }) if err != nil { diff --git a/server/task_templates.go b/server/task_templates.go index ce5f1aa..7125177 100644 --- a/server/task_templates.go +++ b/server/task_templates.go @@ -22,10 +22,8 @@ type taskTemplateRequest struct { Name *string `json:"name"` Description *string `json:"description"` Goal *string `json:"goal"` - Remark *string `json:"remark"` CategoryID *int64 `json:"category_id"` InterceptRules []taskInterceptRuleReq `json:"intercept_rules"` - WorkerCount *int `json:"worker_count"` } // decodeTaskTemplateRequest decodes the body into req and returns the set of @@ -67,7 +65,6 @@ func validateTaskTemplateRequest(req taskTemplateRequest) error { {name: "name", value: req.Name, limit: db.MaxTaskTemplateNameRunes}, {name: "description", value: req.Description, limit: db.MaxTaskTemplateTextRunes}, {name: "goal", value: req.Goal, limit: db.MaxTaskTemplateTextRunes}, - {name: "remark", value: req.Remark, limit: 2000}, // 与任务备注 normalizeRemark 上限一致 } for _, check := range checks { if check.value == nil { @@ -81,14 +78,6 @@ func validateTaskTemplateRequest(req taskTemplateRequest) error { return fmt.Errorf("%s 最多 %d 个字符", check.name, check.limit) } } - if req.WorkerCount != nil { - if *req.WorkerCount < 0 { - return fmt.Errorf("Worker 运行数量不能为负数") - } - if *req.WorkerCount > db.MaxTaskWorkerCount { - return fmt.Errorf("Worker 运行数量最多 %d", db.MaxTaskWorkerCount) - } - } return nil } @@ -136,18 +125,12 @@ func (s *Server) pgCreateTaskTemplate(w http.ResponseWriter, r *http.Request) { writeErr(w, http.StatusBadRequest, "拦截/允许规则无效:"+err.Error()) return } - workerCount := 0 - if req.WorkerCount != nil { - workerCount = *req.WorkerCount - } template, err := pg.CreateTaskTemplate(db.TaskTemplateInput{ Name: stringValue(req.Name), Description: stringValue(req.Description), Goal: stringValue(req.Goal), - Remark: stringValue(req.Remark), CategoryID: req.CategoryID, InterceptRules: rules, - WorkerCount: workerCount, }) if err != nil { writeTaskTemplateErr(w, err) @@ -177,21 +160,11 @@ func (s *Server) pgUpdateTaskTemplate(w http.ResponseWriter, r *http.Request) { } _, catPresent := present["category_id"] _, rulesPresent := present["intercept_rules"] - _, remarkPresent := present["remark"] - _, workerPresent := present["worker_count"] - if req.Name == nil && req.Description == nil && req.Goal == nil && !catPresent && !rulesPresent && !remarkPresent && !workerPresent { - writeErr(w, http.StatusBadRequest, "至少需要提供 name、description、goal、remark、category_id、intercept_rules 或 worker_count") + if req.Name == nil && req.Description == nil && req.Goal == nil && !catPresent && !rulesPresent { + writeErr(w, http.StatusBadRequest, "至少需要提供 name、description、goal、category_id 或 intercept_rules") return } patch := db.TaskTemplatePatch{Name: req.Name, Description: req.Description, Goal: req.Goal} - if remarkPresent { - if req.Remark == nil { - empty := "" - patch.Remark = &empty - } else { - patch.Remark = req.Remark - } - } if catPresent { patch.SetCategoryID = true patch.CategoryID = req.CategoryID @@ -205,13 +178,6 @@ func (s *Server) pgUpdateTaskTemplate(w http.ResponseWriter, r *http.Request) { patch.SetInterceptRules = true patch.InterceptRules = rules } - if workerPresent { - n := 0 - if req.WorkerCount != nil { - n = *req.WorkerCount - } - patch.WorkerCount = &n - } template, err := pg.PatchTaskTemplate(id, patch) if err != nil { writeTaskTemplateErr(w, err) diff --git a/web/src/app/(main)/function/tasks/detail/page.tsx b/web/src/app/(main)/function/tasks/detail/page.tsx index 31772c7..3c23d3e 100644 --- a/web/src/app/(main)/function/tasks/detail/page.tsx +++ b/web/src/app/(main)/function/tasks/detail/page.tsx @@ -404,11 +404,6 @@ function TaskDetailInner() {
{task.goal}
- {task.remark ? ( -- 备注:{task.remark} -
- ) : null} {/* Tabs */}- 单独设置本任务并发运行的工作 Agent 数量;留空或 0 = 用全局默认(系统设置里的工作并发,默认 - 3)。上限 50。 -
-