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 {
55 type AgentEventPayload ,
66 onAgentEvent ,
@@ -10,7 +10,6 @@ import {
1010 emitAcpLifecycleError ,
1111 emitAcpPromptSubmitted ,
1212 emitAcpRuntimeEvent ,
13- formatAcpLifecycleError ,
1413} from "./attempt-execution.js" ;
1514
1615let captured : AgentEventPayload [ ] = [ ] ;
@@ -132,12 +131,12 @@ describe("emitAcpLifecycleError preserves AcpRuntimeError detail (regression: op
132131 } ) ;
133132
134133 it ( "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" ) ;
138137
139138 const token = "sk-abcdefghijklmnopqrstuvwxyz123456" ;
140- const text = formatAcpLifecycleError ( `upstream rejected token=${ token } ` ) ;
139+ const text = formatAcpErrorChain ( `upstream rejected token=${ token } ` ) ;
141140 expect ( text ) . toMatch ( / u p s t r e a m r e j e c t e d / ) ;
142141 expect ( text ) . not . toContain ( token ) ;
143142 } ) ;
@@ -146,7 +145,7 @@ describe("emitAcpLifecycleError preserves AcpRuntimeError detail (regression: op
146145 const e : Error & { cause ?: unknown } = new Error ( "loop" ) ;
147146 e . cause = e ;
148147
149- const text = formatAcpLifecycleError ( e ) ;
148+ const text = formatAcpErrorChain ( e ) ;
150149
151150 // Should produce a finite string with the message, not hang.
152151 expect ( text ) . toMatch ( / l o o p / ) ;
0 commit comments