

















11// Covers ACP diagnostic event propagation and sanitized error formatting.
22import { afterEach, beforeEach, describe, expect, it } from "vitest";
3-import { AcpRuntimeError } from "../../acp/runtime/errors.js";
3+import { AcpRuntimeError, formatAcpErrorChain } from "../../acp/runtime/errors.js";
44import {
55type AgentEventPayload,
66onAgentEvent,
@@ -10,7 +10,6 @@ import {
1010emitAcpLifecycleError,
1111emitAcpPromptSubmitted,
1212emitAcpRuntimeEvent,
13-formatAcpLifecycleError,
1413} from "./attempt-execution.js";
15141615let captured: AgentEventPayload[] = [];
@@ -132,12 +131,12 @@ describe("emitAcpLifecycleError preserves AcpRuntimeError detail (regression: op
132131});
133132134133it("formats non-Error values without crashing", () => {
135-expect(formatAcpLifecycleError("just a string")).toBe("just a string");
136-expect(formatAcpLifecycleError(42)).toBe("42");
137-expect(formatAcpLifecycleError(undefined)).toBe("undefined");
134+expect(formatAcpErrorChain("just a string")).toBe("just a string");
135+expect(formatAcpErrorChain(42)).toBe("42");
136+expect(formatAcpErrorChain(undefined)).toBe("undefined");
138137139138const token = "sk-abcdefghijklmnopqrstuvwxyz123456";
140-const text = formatAcpLifecycleError(`upstream rejected token=${token}`);
139+const text = formatAcpErrorChain(`upstream rejected token=${token}`);
141140expect(text).toMatch(/upstream rejected/);
142141expect(text).not.toContain(token);
143142});
@@ -146,7 +145,7 @@ describe("emitAcpLifecycleError preserves AcpRuntimeError detail (regression: op
146145const e: Error & { cause?: unknown } = new Error("loop");
147146e.cause = e;
148147149-const text = formatAcpLifecycleError(e);
148+const text = formatAcpErrorChain(e);
150149151150// Should produce a finite string with the message, not hang.
152151expect(text).toMatch(/loop/);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。