【用户】任务管理
任务控制流 WebSocket
数据格式约定:当前仅支持文本帧透传。服务端将 Agent 的原始文本数据包装为如下结构返回给前端(对应 domain.TaskStream):
{ "type": "string", "data": "string", "kind": "string", "timestamp": 0 }
独立于 stream 的长生命周期 WebSocket 连接,用于处理 call/call-response(文件浏览、diff 查看等同步请求)。 task 结束后连接不断开,仍可用于文件操作。 支持同一 taskID 多 tab 并发连接。
上行消息
Type=call, Kind=repo_file_diff — 获取文件 diff
请求 Data:
{"request_id":"string","path":"string","unified":true,"context_lines":3}
响应 Data:
{"request_id":"string","path":"string","diff":"string","success":true,"error":"string?"}
Type=call, Kind=repo_file_list — 列出目录文件
请求 Data:
{"request_id":"string","path":"string","glob_pattern":"string?","include_hidden":false}
响应 Data:
{"request_id":"string","path":"string","files":[{"name":"string","path":"string","entry_mode":0,"size":0,"modified_at":0}],"success":true,"error":"string?"}
Type=call, Kind=repo_read_file — 读取文件内容
请求 Data:
{"request_id":"string","path":"string","offset":0,"length":0}
响应 Data:
{"request_id":"string","path":"string","content":"bytes","total_size":0,"offset":0,"length":0,"is_truncated":false,"success":true,"error":"string?"}
Type=call, Kind=repo_file_changes — 查询变更文件列表
请求 Data:
{"request_id":"string"}
响应 Data:
{"request_id":"string","changes":[{"path":"string","status":"string","additions":0,"deletions":0,"old_path":"string?"}],"branch":"string?","commit_hash":"string?","success":true,"error":"string?"}
Type=call, Kind=port_forward_list — 获取端口转发列表
请求 Data:
{"request_id":"string"}
响应 Data:
{"request_id":"string","ports":[{"port":0,"status":"string","process":"string","forward_id":"string?","access_url":"string?","label":"string?","error_message":"string?","whitelist_ips":["string"]}]}
Type=call, Kind=restart — 重启任务
请求 Data:
{"request_id":"string","load_session":true}
响应 Data:
{"id":"uuid","request_id":"string?","success":true,"message":"string","session_id":"string"}
Type=call, Kind=switch_model — 切换运行中任务模型
请求 Data:
{"request_id":"string","model_id":"uuid","load_session":true}
响应 Data:
{"id":"uuid","request_id":"string?","success":true,"message":"string","session_id":"string","model":{}}
Type=call, Kind=switch_agent_resources — 运行中更新任务 skill/plugin 列表
请求 Data (全量声明当前所选,非增量):
{"request_id":"string","skill_ids":["uuid"],"plugin_ids":["uuid"]}
响应 Data:
{"request_id":"string","success":true,"message":"string","session_id":"string"}
Type=sync-my-ip — 同步 Web 客户端真实 IP
请求 Data:
{"client_ip":"string"}
下行消息
- Type=call-response: 同步请求响应(Kind 与请求一致)。失败时 Data 为:
{"request_id":"string","success":false,"error":"string"}
- Type=task-event: 任务事件(从 TaskLive 订阅转发)
- Type=ping: 心跳(无 Data)
get/api/v1/users/tasks/control
Query parameters
idstring required
任务 ID
Response
成功