File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ describe("toolOutputIndicatesFailure", () => {
150150 "<exited with exit code 2>" ,
151151 "Exited with exit code 1" ,
152152 "exit code: 127" ,
153+ "clean exit first, then ExIt CoDe: 3" ,
153154 ] )
154155 expect ( toolOutputIndicatesFailure ( text ) ) . toBe ( true ) ;
155156 } ) ;
@@ -161,6 +162,9 @@ describe("toolOutputIndicatesFailure", () => {
161162 "Exited with exit code 0" ,
162163 "cannot find path" ,
163164 "is not recognized" ,
165+ "exit" ,
166+ "not found" ,
167+ "the path cannot be found" ,
164168 ] ) {
165169 expect ( toolOutputIndicatesFailure ( text ) ) . toBe ( false ) ;
166170 }
Original file line number Diff line number Diff line change @@ -194,17 +194,21 @@ export function mcpAppFromToolItem(item: {
194194 return app !== undefined && item . toolName === `${ app . server } .${ app . tool } ` ? app : undefined ;
195195}
196196
197+ // A superset of every needle below, so most outputs are rejected by this single scan.
198+ const FAILURE_HINT =
199+ / 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;
200+
197201/** Some providers report completion even when command output describes a failure. */
198202export function toolOutputIndicatesFailure ( text : string ) : boolean {
199203 return (
200- / 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 (
204+ FAILURE_HINT . test ( text ) &&
205+ ( / 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 (
201206 text ,
202207 ) ||
203- ( / 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 ) ) ||
204- ( / 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 ) ) ||
205- / < 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 ) ||
206- / 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 ) ||
207- / e x i t c o d e \s * [: \s] \s * [ 1 - 9 ] \d * \b / i. test ( text )
208+ ( / 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 ) ) ||
209+ ( / 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 ) ) ||
210+ / 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 ) ||
211+ / e x i t c o d e \s * [: \s] \s * [ 1 - 9 ] \d * \b / i. test ( text ) )
208212 ) ;
209213}
210214
You can’t perform that action at this time.
0 commit comments