任务 API

当前 API 是可运行的 Rust/Axum 内存实现,适合本地联调与工作台原型。

Base URL

生产环境 API 地址由部署配置提供;本地默认监听 http://127.0.0.1:8080

完整的机器可读契约位于项目中的 api/openapi.yaml

创建任务

POST /api/v1/tasks

{
  "title": "整理六月销售表",
  "description": "按区域汇总并生成摘要",
  "kind": "spreadsheet",
  "input": {"file_id": "sales-june.xlsx"}
}

成功返回 201 Created 和任务对象。kind 可选 spreadsheetreportresumeocrcustom

读取任务

  • GET /api/v1/tasks:按创建时间倒序列出任务;
  • GET /api/v1/tasks/{id}:读取单个任务;
  • POST /api/v1/tasks/{id}/cancel:取消排队或运行中的任务;
  • PUT /api/v1/tasks/{id}:更新任务(原型阶段逐步扩展);
  • DELETE /api/v1/tasks/{id}:删除任务。

健康检查

GET /healthz 返回:

{"status":"ok","service":"xaiworker-api"}

当前存储为内存 map,重启服务会丢失任务。接入持久化仓库和 Agent 队列后,API 合约会继续保持向后兼容。