mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:00:44 +00:00
* refactor: consume acpx runtime library * refactor: remove duplicated acpx runtime files * fix: update acpx runtime dependency * fix: preserve acp runtime error codes * fix: migrate legacy acpx session files * fix: update acpx runtime dependency * fix: import Dirent from node fs * ACPX: repin shared runtime engine * ACPX: repin runtime semantics fixes * ACPX: repin runtime contract cleanup * Extensions: repin ACPX after layout refactor * ACPX: drop legacy session migration * ACPX: drop direct ACP SDK dependency * Discord ACP: stop duplicate direct fallback replies * ACP: rename delivered text visibility hook * ACPX: pin extension to 0.5.0 * Deps: drop stale ACPX build-script allowlist * ACPX: add local development guidance * ACPX: document temporary pnpm exception flow * SDK: preserve legacy ACP visibility hook * ACP: keep reset commands on local path * ACP: make in-place reset start fresh session * ACP: recover broken bindings on fresh reset * ACP: defer fresh reset marker until close succeeds * ACP: reset bound sessions fresh again * Discord: ensure ACP bindings before /new * ACP: recover missing persistent sessions
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { AcpRuntimeError, isAcpRuntimeError, withAcpRuntimeErrorBoundary } from "./errors.js";
|
|
|
|
describe("withAcpRuntimeErrorBoundary", () => {
|
|
it("wraps generic errors with fallback code and source message", async () => {
|
|
await expect(
|
|
withAcpRuntimeErrorBoundary({
|
|
run: async () => {
|
|
throw new Error("boom");
|
|
},
|
|
fallbackCode: "ACP_TURN_FAILED",
|
|
fallbackMessage: "fallback",
|
|
}),
|
|
).rejects.toMatchObject({
|
|
name: "AcpRuntimeError",
|
|
code: "ACP_TURN_FAILED",
|
|
message: "boom",
|
|
});
|
|
});
|
|
|
|
it("passes through existing ACP runtime errors", async () => {
|
|
const existing = new AcpRuntimeError("ACP_BACKEND_MISSING", "backend missing");
|
|
await expect(
|
|
withAcpRuntimeErrorBoundary({
|
|
run: async () => {
|
|
throw existing;
|
|
},
|
|
fallbackCode: "ACP_TURN_FAILED",
|
|
fallbackMessage: "fallback",
|
|
}),
|
|
).rejects.toBe(existing);
|
|
});
|
|
|
|
it("preserves ACP runtime codes from foreign package errors", async () => {
|
|
class ForeignAcpRuntimeError extends Error {
|
|
readonly code = "ACP_BACKEND_MISSING" as const;
|
|
}
|
|
|
|
const foreignError = new ForeignAcpRuntimeError("backend missing");
|
|
|
|
await expect(
|
|
withAcpRuntimeErrorBoundary({
|
|
run: async () => {
|
|
throw foreignError;
|
|
},
|
|
fallbackCode: "ACP_TURN_FAILED",
|
|
fallbackMessage: "fallback",
|
|
}),
|
|
).rejects.toMatchObject({
|
|
name: "AcpRuntimeError",
|
|
code: "ACP_BACKEND_MISSING",
|
|
message: "backend missing",
|
|
cause: foreignError,
|
|
});
|
|
|
|
expect(isAcpRuntimeError(foreignError)).toBe(true);
|
|
});
|
|
});
|