feat: AI writing history, Word export, roundtable dispatch chain

This commit is contained in:
fengxiangdebaozi committed 2026-06-04 15:40:15 +08:00
1 parent c0e3c5d692
commit 10334ddfe1
21 files changed
+1888 -143

No files matched your search

@@ -0,0 +1,56 @@
/**
* 圆桌后台作业(roundtable job)共享类型。
*
* 对应 `docs/multi-agent-background-run-dev.md` §2「数据契约」。本文件只放纯类型,
* 不含请求逻辑(后续 Phase 4 的 `api/roundtable-jobs.ts` 会引用这些类型)。
*
* Phase 7(派活链路流程图弹窗)只用到其中的 `JobStatus` / `JobPhase` /
* `DispatchChainNode`,其余类型为后续阶段预留,先一并定义好避免反复改动。
*/
/** 作业状态机(§2.1)。 */
export type JobStatus =
| "queued" // 已创建,等待 worker 拉起
| "running" // 编排进行中(Step2 派活循环 / Step3 绘制)
| "awaiting_input" // 命中 clarification,等用户回答(interrupt 挂起)
| "done" // 已跑到 Step3 绘制完成
| "error" // 出错终止
| "cancelled"; // 用户取消
/** 作业阶段(§2.2)——给流程图 / 进度条用。 */
export type JobPhase =
| "initializing" // 建 thread / 总控就绪
| "leader_thinking" // 总控在决策派活
| "dispatching" // 正在顺序派活给席位(配合 activeAgentId)
| "consensus" // 共识达成(dispatched=[])
| "report_drawing" // Step3 报告绘制中
| "report_done"; // 绘制完成
/** 派活链路单节点状态(驱动颜色 / 动画)。 */
export type ChainNodeState = "pending" | "active" | "done";
/** 派活链路节点(§2.3)——流程图核心数据。 */
export interface DispatchChainNode {
/** 席位 agent_id(小写)。 */
agentId: string;
/** 显示名。 */
name: string;
/** 复用 getAvatarTypeFor(agentId, order) → 决定颜色 / 头像。 */
avatarType: string;
/** 横向排列次序(chain 模式=链条顺序;recommend 模式=席位/发言顺序)。 */
order: number;
/** 节点状态。 */
state: ChainNodeState;
/** 最近发言轮次(可选,做 tooltip)。 */
lastSpokeCycle?: number;
}
/** 归一化进度事件(§2.4)——SSE 推送。Phase 7 暂未用到,先占位。 */
export type JobProgressEvent =
| { type: "status"; status: JobStatus }
| { type: "phase"; phase: JobPhase; cycle: number }
| { type: "chain"; nodes: DispatchChainNode[] }
| { type: "active"; agentId: string | null }
| { type: "consensus"; percentage: number }
| { type: "clarification"; question: string }
| { type: "error"; detail: string };