feat: 任务附件上传(图片/文件随任务提交)

B-① 附件上传(⑧ ★ POST /api/tasks/:id/attachments):

后端:
- 加 @fastify/multipart;schema/db.ts tasks.attachments 列(幂等迁移)
- types.Attachment{name,type,path} + Task.attachments;mappers 映射
- store.addAttachments(追加元数据 + 广播 task.updated)
- POST /api/tasks/:id/attachments:multipart files[](单文件≤25MB/单次≤10),
  落盘 <data>/tasks/<id>/attachments/,文件名消毒,返回全部附件

前端:
- api.uploadAttachments(FormData multipart)
- 新建任务表单加文件选择 + 已选列表;创建任务后自动上传附件

验证:typecheck 干净;206 测试通过;前端 build 通过。
(端到端需重启 daemon 加载新端点——与后续 SSE/takeover 一并重启。)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-24 16:58:14 +08:00
parent 6c9b05e575
commit 9b17d3e24f
11 changed files with 157 additions and 6 deletions
+8
View File
@@ -83,10 +83,18 @@ export interface Task {
retryBaseline: number; // 上次手动重投时已有的失败 run 数(重置重试计数用)
nextEligibleAt: string | null; // 持久化退避:早于此时间不被领取(重试退避,重启不丢);null=即刻可领
lastRunError?: string | null; // needs_attention 时:最近一次失败 run 的错误信息(供审核区展示)
attachments?: Attachment[]; // 随任务提交的图片/文件(存 <data>/tasks/<id>/attachments/
createdAt: string;
updatedAt: string;
}
/** 任务附件:图片/文件随任务提交,落盘于 <MAESTRO_DATA_DIR>/tasks/<taskId>/attachments/ */
export interface Attachment {
name: string; // 原始文件名
type: string; // MIME 类型(如 image/png
path: string; // 相对 data 根的存储路径(tasks/<taskId>/attachments/<name>
}
export type RunKind = 'planner' | 'executor' | 'reviewer' | 'security';
export type RunStatus = 'started' | 'succeeded' | 'failed' | 'cancelled';