mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-04 20:41:51 +08:00
feat(proxy,chat): add per-task/schedule/chat proxy pool routing and @task mentions
- Support pool auto-rotation mode alongside inherit/direct/node/custom proxy routes across gateway and MITM proxy
- Add GET /api/proxy/routes/{scope}/{owner_id}, task create/DTO proxy_route, and schedule proxy persistence + propagation
- Add list_proxy_pool and set_task_proxy chat agent tools and @task mention search/context injection
- Wire shared proxy/pool selectors into tasks, schedules, chat sandbox popover, and container routes UI
This commit is contained in:
1 parent
b18cf89b77
commit
778e49317d
28 files changed
+1683
-124
No files matched your search
+39
-1
@@ -83,6 +83,8 @@ func (s *Server) orchestrationTools() []actool.CoreTool {
|
||||
s.toolUpdateFindingReport(),
|
||||
s.toolGetFindingTraffic(),
|
||||
s.toolBindFindingTraffic(),
|
||||
s.toolListProxyPool(),
|
||||
s.toolSetTaskProxy(),
|
||||
}, s.findingCaseTools()...)
|
||||
}
|
||||
|
||||
@@ -275,6 +277,9 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
||||
"plan_heartbeat_seconds": map[string]any{"type": "integer", "description": "可选:planner 心跳触发间隔(秒)。距上轮规划结束/任务开始满该值且期间无触发 → 触发一轮规划(兜底死锁 + 唤醒去监督飞行中的 worker)。留空或 0 = 默认 600(10min);"},
|
||||
"seed_first_intent": map[string]any{"type": "boolean", "description": "可选:对于简单任务可开启,创建时直接下发一条种子意图(内容=描述+目标)让 worker 免等首轮 planner 直接开跑测试;默认 false(走标准先规划再执行)。"},
|
||||
"attachments": map[string]any{"type": "array", "items": map[string]any{"type": "string"}, "description": "可选:要从当前对话工作区附带到新任务工作区(/workspace/uploads/)的文件路径列表,如 [\"uploads/targets.txt\"]。"},
|
||||
"proxy_mode": map[string]any{"type": "string", "enum": []string{"inherit", "direct", "pool", "proxy"}, "description": "可选:任务容器出口代理模式(inherit=继承全局,direct=直连,pool=代理池自动轮换,proxy=指定节点或自定义 URL)"},
|
||||
"proxy_pool_id": strParam("可选(proxy_mode=proxy 时):代理池节点 ID 或名称"),
|
||||
"proxy_url": strParam("可选(proxy_mode=proxy 且未指定 proxy_pool_id 时):自定义代理 URL"),
|
||||
}, "description", "goal"),
|
||||
func(ctx context.Context, in json.RawMessage) (actool.Result, error) {
|
||||
var a struct {
|
||||
@@ -290,6 +295,9 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
||||
PlanHeartbeatSeconds int `json:"plan_heartbeat_seconds"`
|
||||
SeedFirstIntent bool `json:"seed_first_intent"`
|
||||
Attachments []string `json:"attachments"`
|
||||
ProxyMode string `json:"proxy_mode"`
|
||||
ProxyPoolID string `json:"proxy_pool_id"`
|
||||
ProxyURL string `json:"proxy_url"`
|
||||
}
|
||||
if err := json.Unmarshal(in, &a); err != nil {
|
||||
return actool.Errorf("参数无效: " + err.Error()), nil
|
||||
@@ -336,6 +344,28 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
||||
if pin != nil {
|
||||
llmIDs = []int64{*pin}
|
||||
}
|
||||
var validatedProxy *ProxyRouteInput
|
||||
if strings.TrimSpace(a.ProxyMode) != "" || strings.TrimSpace(a.ProxyPoolID) != "" || strings.TrimSpace(a.ProxyURL) != "" {
|
||||
pm := strings.TrimSpace(a.ProxyMode)
|
||||
if pm == "" {
|
||||
pm = "proxy"
|
||||
}
|
||||
norm, perr := s.validateAndNormalizeProxyRoute(ProxyRouteInput{
|
||||
Mode: pm,
|
||||
ProxyPoolID: a.ProxyPoolID,
|
||||
ProxyURL: a.ProxyURL,
|
||||
}, nil)
|
||||
if perr != nil {
|
||||
return actool.Errorf("任务代理配置无效: " + perr.Error()), nil
|
||||
}
|
||||
if norm.Mode != "inherit" {
|
||||
validatedProxy = &ProxyRouteInput{
|
||||
Mode: norm.Mode,
|
||||
ProxyPoolID: norm.ProxyPoolID,
|
||||
ProxyURL: norm.ProxyURL,
|
||||
}
|
||||
}
|
||||
}
|
||||
name := ""
|
||||
autoTitleEnabled := s.m.pg.GetBool(db.SettingTaskAutoTitle, false)
|
||||
if autoTitleEnabled {
|
||||
@@ -395,6 +425,11 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
||||
}
|
||||
}
|
||||
}
|
||||
if validatedProxy != nil {
|
||||
if _, perr := s.setContainerProxyRoute("task", t.ID, *validatedProxy); perr != nil {
|
||||
log.Printf("[spawn_task] 任务 #%s 应用代理路由失败: %v", t.ID, perr)
|
||||
}
|
||||
}
|
||||
// 共享的建后流程,与 HTTP 建任务(server.go createTask)复用同一段 launchTask:
|
||||
// seed + 后台可见地做目标分解(第0轮/LLM步骤/逐条goal) + engine.Run。
|
||||
// seed_first_intent 默认 false(标准先规划再执行);简单任务可开启直接下发一 work 测试。
|
||||
@@ -633,6 +668,8 @@ func defaultOrchestrationToolBindings(name string) json.RawMessage {
|
||||
switch {
|
||||
case name == "resume_task":
|
||||
return json.RawMessage(`["auto","mainagent"]`)
|
||||
case name == "list_proxy_pool" || name == "set_task_proxy":
|
||||
return json.RawMessage(`["auto","mainagent","pentest"]`)
|
||||
case name == "bind_finding_traffic" || strings.Contains(name, "finding_case") || name == "search_finding_duplicates" || name == "get_finding_record" || name == "merge_finding_records":
|
||||
return json.RawMessage(`["reporter"]`)
|
||||
default:
|
||||
@@ -655,6 +692,7 @@ func (s *Server) seedOrchestrationTools() {
|
||||
s.refreshBuiltinToolSchemas()
|
||||
s.seedAutoDefaultBindings()
|
||||
s.seedTaskReopenBindings()
|
||||
s.seedProxyToolBindings()
|
||||
s.seedPlannerDefaultBindings()
|
||||
s.seedPlannerListAssetsBinding()
|
||||
s.seedCompanyScopeRebind()
|
||||
@@ -746,7 +784,7 @@ func (s *Server) migrateReporterWorkflow() {
|
||||
// reaches an old DB otherwise. Preserves each tool's agent binding + enabled flag.
|
||||
// Bump the flag whenever these tools' schemas/descriptions change in code.
|
||||
func (s *Server) refreshBuiltinToolSchemas() {
|
||||
const flag = "tool_schema_refresh_v9_task_reopen_tools"
|
||||
const flag = "tool_schema_refresh_v10_proxy_tools"
|
||||
if v, _, _ := s.m.pg.GetSetting(flag); v == "true" {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user