File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ describe("toolOutputIndicatesFailure", () => {
156156 "<exited with exit code 2>" ,
157157 "Exited with exit code 1" ,
158158 "exit code: 127" ,
159+ "clean exit first, then ExIt CoDe: 3" ,
159160 ] )
160161 expect ( toolOutputIndicatesFailure ( text ) ) . toBe ( true ) ;
161162 } ) ;
@@ -167,6 +168,9 @@ describe("toolOutputIndicatesFailure", () => {
167168 "Exited with exit code 0" ,
168169 "cannot find path" ,
169170 "is not recognized" ,
171+ "exit" ,
172+ "not found" ,
173+ "the path cannot be found" ,
170174 ] ) {
171175 expect ( toolOutputIndicatesFailure ( text ) ) . toBe ( false ) ;
172176 }
Original file line number Diff line number Diff line change @@ -232,17 +232,21 @@ export function mcpAppFromToolItem(item: {
232232 : undefined ;
233233}
234234
235+ // A superset of every needle below, so most outputs are rejected by this single scan.
236+ const FAILURE_HINT =
237+ / e n o e n t | n o s u c h | n o f i l e s f o u n d | n o t f o u n d | c o m m a n d n o t f o u n d | n o t r e c o g n i z e d | c a n n o t (?: f i n d p a t h | b e f o u n d ) | e x i t / i;
238+
235239/** Some providers report completion even when command output describes a failure. */
236240export function toolOutputIndicatesFailure ( text : string ) : boolean {
237241 return (
238- / f i l e n o t f o u n d | n o f i l e s f o u n d | e n o e n t | n o s u c h f i l e | c o m m a n d n o t f o u n d e x c e p t i o n | c o m m a n d n o t f o u n d | i s n o t r e c o g n i z e d a s t h e n a m e o f a c m d l e t | a p a r a m e t e r c a n n o t b e f o u n d t h a t m a t c h e s p a r a m e t e r n a m e / i. test (
242+ FAILURE_HINT . test ( text ) &&
243+ ( / f i l e n o t f o u n d | n o f i l e s f o u n d | e n o e n t | n o s u c h f i l e | c o m m a n d n o t f o u n d e x c e p t i o n | c o m m a n d n o t f o u n d | i s n o t r e c o g n i z e d a s t h e n a m e o f a c m d l e t | a p a r a m e t e r c a n n o t b e f o u n d t h a t m a t c h e s p a r a m e t e r n a m e / i. test (
239244 text ,
240245 ) ||
241- ( / c a n n o t f i n d p a t h / i. test ( text ) && / b e c a u s e i t d o e s n o t e x i s t / i. test ( text ) ) ||
242- ( / i s n o t r e c o g n i z e d / i. test ( text ) && / t h e t e r m ' / i. test ( text ) ) ||
243- / < e x i t e d w i t h e x i t c o d e \s + [ 1 - 9 ] \d * \s * > / i. test ( text ) ||
244- / e x i t (?: e d ) ? w i t h e x i t c o d e \s + [ 1 - 9 ] \d * / i. test ( text ) ||
245- / e x i t c o d e \s * [: \s] \s * [ 1 - 9 ] \d * \b / i. test ( text )
246+ ( / c a n n o t f i n d p a t h / i. test ( text ) && / b e c a u s e i t d o e s n o t e x i s t / i. test ( text ) ) ||
247+ ( / i s n o t r e c o g n i z e d / i. test ( text ) && / t h e t e r m ' / i. test ( text ) ) ||
248+ / e x i t (?: e d ) ? w i t h e x i t c o d e \s + [ 1 - 9 ] \d * / i. test ( text ) ||
249+ / e x i t c o d e \s * [: \s] \s * [ 1 - 9 ] \d * \b / i. test ( text ) )
246250 ) ;
247251}
248252
You can’t perform that action at this time.
0 commit comments