






















@@ -1,5 +1,5 @@
11import { beforeEach, describe, expect, it, vi } from "vitest";
2-import type { AcpRuntime } from "../runtime-api.js";
2+import { AcpRuntimeError, type AcpRuntime } from "../runtime-api.js";
33import { AcpxRuntime, __testing } from "./runtime.js";
4455type TestSessionStore = {
@@ -85,6 +85,43 @@ describe("AcpxRuntime fresh reset wrapper", () => {
8585vi.restoreAllMocks();
8686});
878788+it("rejects unsupported runtime session modes with a clear AcpRuntimeError (issue #73071)", async () => {
89+const baseStore: TestSessionStore = {
90+load: vi.fn(async () => undefined),
91+save: vi.fn(async () => {}),
92+};
93+const { runtime, delegate } = makeRuntime(baseStore);
94+const ensureSpy = vi.spyOn(delegate, "ensureSession").mockResolvedValue({
95+sessionKey: "agent:claude:acp:test",
96+backend: "acpx",
97+runtimeSessionName: "claude",
98+});
99+100+for (const badMode of ["run", "session", "", undefined, null, 0]) {
101+await expect(
102+runtime.ensureSession({
103+sessionKey: "agent:claude:acp:test",
104+agent: "claude",
105+mode: badMode as never,
106+}),
107+).rejects.toMatchObject({
108+name: "AcpRuntimeError",
109+code: "ACP_INVALID_RUNTIME_OPTION",
110+message: expect.stringContaining("Unsupported ACP runtime session mode"),
111+});
112+}
113+114+expect(ensureSpy).not.toHaveBeenCalled();
115+});
116+117+it("exposes assertSupportedRuntimeSessionMode as a typed guard", () => {
118+expect(() => __testing.assertSupportedRuntimeSessionMode("persistent")).not.toThrow();
119+expect(() => __testing.assertSupportedRuntimeSessionMode("oneshot")).not.toThrow();
120+expect(() => __testing.assertSupportedRuntimeSessionMode("run" as never)).toThrow(
121+AcpRuntimeError,
122+);
123+});
124+88125it("normalizes OpenClaw Codex model ids for ACP startup", async () => {
89126const baseStore: TestSessionStore = {
90127load: vi.fn(async () => undefined),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。