引入游玩回合与开场收口,抽出可替换 agent 司机并支持运行中止;完善预设洞位、世界书拼装与试跑,并打磨会话运行时与 Web 交互。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { MockLlmProvider } from "../src/llm/client.js";
|
||||
import {
|
||||
isAbortError,
|
||||
runWithAbortSignal,
|
||||
throwIfAborted,
|
||||
} from "../src/llm/run-abort.js";
|
||||
|
||||
describe("run abort", () => {
|
||||
it("isAbortError detects AbortError name", () => {
|
||||
const err = new Error("This operation was aborted");
|
||||
err.name = "AbortError";
|
||||
expect(isAbortError(err)).toBe(true);
|
||||
expect(isAbortError(new Error("LLM request failed"))).toBe(false);
|
||||
});
|
||||
|
||||
it("throwIfAborted raises AbortError when the signal is aborted", () => {
|
||||
const ac = new AbortController();
|
||||
ac.abort();
|
||||
expect(() => throwIfAborted(ac.signal)).toThrowError(/aborted/i);
|
||||
});
|
||||
|
||||
it("mock LLM respects the active abort signal", async () => {
|
||||
const llm = new MockLlmProvider(["ok"]);
|
||||
const ac = new AbortController();
|
||||
ac.abort();
|
||||
await expect(
|
||||
runWithAbortSignal(ac.signal, () => llm.complete([{ role: "user", content: "x" }])),
|
||||
).rejects.toMatchObject({ name: "AbortError" });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user