Download tests/codex-threads.test.ts from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/codex-threads.test.ts
- Command line
-
hf download hf://datasets/hongcoding/agentlens/tests/codex-threads.test.ts
-
curl -L -o codex-threads.test.ts https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/codex-threads.test.ts
2.04 kB
| import { describe, it, expect } from "vitest"; | |
| import { buildRollout } from "../src/import/codex-threads.js"; | |
| import type { SessionTranscript } from "../src/export/sessions.js"; | |
| const transcript: SessionTranscript = { | |
| id: "dsh-123", | |
| title: "测试导入会话", | |
| cwd: "/Users/x/project", | |
| createdAt: 1700000000000, | |
| entries: [ | |
| { who: "用户", time: 1700000001000, text: "你好" }, | |
| { who: "助手", time: 1700000002000, text: "你好,有什么可以帮你?" }, | |
| { who: "工具", time: 1700000003000, text: "bash ls" }, | |
| { who: "用户", time: 1700000004000, text: "谢谢" }, | |
| ], | |
| }; | |
| describe("buildRollout", () => { | |
| it("emits a session_meta line with a UUID and cwd", () => { | |
| const { id, content } = buildRollout(transcript); | |
| const lines = content.trim().split("\n").map((l) => JSON.parse(l)); | |
| expect(lines[0].type).toBe("session_meta"); | |
| expect(lines[0].payload.session_id).toBe(id); | |
| expect(lines[0].payload.cwd).toBe("/Users/x/project"); | |
| expect(lines[0].payload.imported_from).toBe("dsh"); | |
| expect(lines[0].payload.dsh_session_id).toBe("dsh-123"); | |
| }); | |
| it("emits user/assistant message items and skips tool entries", () => { | |
| const { content } = buildRollout(transcript); | |
| const lines = content.trim().split("\n").map((l) => JSON.parse(l)); | |
| const messages = lines.filter((l) => l.type === "response_item"); | |
| expect(messages.length).toBe(3); | |
| expect(messages[0].payload.role).toBe("user"); | |
| expect(messages[0].payload.content[0].type).toBe("input_text"); | |
| expect(messages[1].payload.role).toBe("assistant"); | |
| expect(messages[1].payload.content[0].type).toBe("output_text"); | |
| expect(messages[2].payload.content[0].text).toBe("谢谢"); | |
| }); | |
| it("assigns increasing ordinals", () => { | |
| const { content } = buildRollout(transcript); | |
| const ordinals = content.trim().split("\n").map((l) => JSON.parse(l).ordinal); | |
| expect(ordinals).toEqual([...ordinals].sort((a, b) => a - b)); | |
| expect(new Set(ordinals).size).toBe(ordinals.length); | |
| }); | |
| }); | |