Files
deerflow-code/frontend-web/src/roundtable-planning/lib/dag-flow-state.test.ts
T

51 lines
1.7 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { resolveDagMilestoneStates, resolveLiveDagNodeStates } from "./dag-flow-state.ts";
const roles = {
"seat-01": { displayName: "测试01" },
"seat-02": { displayName: "测试02" },
};
test("a streaming first seat takes the in-progress marker off the coordinator", () => {
const seats = resolveLiveDagNodeStates({
agentNameToRole: roles,
dialogues: [
{ sender: "总控协调", streaming: false, confidence: "派活说明", content: "派给测试01" },
{ sender: "测试01", streaming: true, confidence: "调度中", content: "" },
],
dagNodeStates: { "seat-01": "pending", "seat-02": "pending" },
parallelBatch: [],
});
assert.equal(seats["seat-01"], "active");
assert.equal(seats["seat-02"], "pending");
const milestones = resolveDagMilestoneStates({
seatStates: seats,
dialogues: [
{ sender: "总控协调", streaming: false },
{ sender: "测试01", streaming: true },
],
isOrchestrating: true,
hasConsensus: false,
});
assert.equal(milestones.coordinator, "done");
});
test("the coordinator stays in progress while it is still the one speaking", () => {
const seats = resolveLiveDagNodeStates({
agentNameToRole: roles,
dialogues: [{ sender: "总控协调", streaming: true, confidence: "派活中", content: "" }],
dagNodeStates: { "seat-01": "pending", "seat-02": "pending" },
parallelBatch: [],
});
const milestones = resolveDagMilestoneStates({
seatStates: seats,
dialogues: [{ sender: "总控协调", streaming: true }],
isOrchestrating: true,
hasConsensus: false,
});
assert.equal(milestones.coordinator, "active");
assert.equal(seats["seat-01"], "pending");
});