mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-17 01:56:18 +00:00
* feat(artifacts): download run files as zip * fix(artifacts): address archive review feedback * fix(artifacts): gate unavailable archive downloads * fix(artifacts): verify archive availability * fix(artifacts): harden archive consistency * fix(artifacts): reject archive path aliases
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import type { Message } from "@langchain/langgraph-sdk";
|
|
import { describe, expect, test } from "@rstest/core";
|
|
|
|
import { getArtifactArchiveCandidatesByGroupIndex } from "@/core/messages/artifact-archive";
|
|
import { getMessageGroups } from "@/core/messages/utils";
|
|
|
|
function presentFiles(id: string, runId: string, filepaths: string[]): Message {
|
|
return {
|
|
id,
|
|
type: "ai",
|
|
content: "",
|
|
run_id: runId,
|
|
tool_calls: [
|
|
{
|
|
id: `call-${id}`,
|
|
name: "present_files",
|
|
args: { filepaths },
|
|
},
|
|
],
|
|
} as Message;
|
|
}
|
|
|
|
describe("artifact archive display placement", () => {
|
|
test("anchors one archive action after a run's final file presentation", () => {
|
|
const groups = getMessageGroups([
|
|
presentFiles("first", "run-1", ["/mnt/user-data/outputs/a.txt"]),
|
|
presentFiles("second", "run-1", [
|
|
"/mnt/user-data/outputs/a.txt",
|
|
"/mnt/user-data/outputs/b.txt",
|
|
]),
|
|
]);
|
|
|
|
expect(getArtifactArchiveCandidatesByGroupIndex(groups)).toEqual([
|
|
undefined,
|
|
{ runId: "run-1" },
|
|
]);
|
|
});
|
|
|
|
test("verifies even a single attempted path against the terminal receipt", () => {
|
|
const groups = getMessageGroups([
|
|
presentFiles("only", "run-1", ["/mnt/user-data/outputs/a.txt"]),
|
|
]);
|
|
|
|
expect(getArtifactArchiveCandidatesByGroupIndex(groups)).toEqual([
|
|
{ runId: "run-1" },
|
|
]);
|
|
});
|
|
|
|
test("keeps archive actions independent across runs", () => {
|
|
const groups = getMessageGroups([
|
|
presentFiles("run-1-first", "run-1", ["/mnt/user-data/outputs/a.txt"]),
|
|
presentFiles("run-2", "run-2", [
|
|
"/mnt/user-data/outputs/c.txt",
|
|
"/mnt/user-data/outputs/d.txt",
|
|
]),
|
|
presentFiles("run-1-last", "run-1", ["/mnt/user-data/outputs/b.txt"]),
|
|
]);
|
|
|
|
expect(getArtifactArchiveCandidatesByGroupIndex(groups)).toEqual([
|
|
undefined,
|
|
{ runId: "run-2" },
|
|
{ runId: "run-1" },
|
|
]);
|
|
});
|
|
});
|