@@ -151,7 +151,7 @@ function createDirectNodeRun(signal?: AbortSignal): DirectNodeRun {
151151 } ;
152152}
153153
154- describe ( "direct node run cancellation " , ( ) => {
154+ describe ( "direct node run" , ( ) => {
155155 beforeEach ( ( ) => {
156156 callGatewayToolMock . mockReset ( ) ;
157157 callGatewayToolMock . mockResolvedValue ( {
@@ -180,6 +180,33 @@ describe("direct node run cancellation", () => {
180180 }
181181 } ) ;
182182
183+ it ( "surfaces capped stderr and the node error when stdout is also present" , async ( ) => {
184+ const stdout = "small stdout" ;
185+ const stderr = `${ "x" . repeat ( 200_000 ) } \n... (truncated)` ;
186+ const errorText = "node command failed" ;
187+ callGatewayToolMock . mockResolvedValueOnce ( {
188+ payload : {
189+ success : false ,
190+ stdout,
191+ stderr,
192+ error : errorText ,
193+ exitCode : 1 ,
194+ } ,
195+ } ) ;
196+
197+ const result = await invokeNodeSystemRunDirect ( createDirectNodeRun ( ) ) ;
198+ const visibleText = result . content [ 0 ] ?. type === "text" ? result . content [ 0 ] . text : "" ;
199+
200+ expect ( visibleText ) . toContain ( "... (truncated)" ) ;
201+ expect ( visibleText ) . toContain ( errorText ) ;
202+ expect ( visibleText ) . toBe ( `${ stdout } \n${ stderr } \n${ errorText } ` ) ;
203+ expect ( result . details ) . toMatchObject ( {
204+ status : "failed" ,
205+ exitCode : 1 ,
206+ aggregated : visibleText ,
207+ } ) ;
208+ } ) ;
209+
183210 it ( "never dispatches a direct node run after cancellation" , async ( ) => {
184211 const controller = new AbortController ( ) ;
185212 const reason = new Error ( "cancelled before direct node dispatch" ) ;
0 commit comments