@@ -597,4 +597,80 @@ describe("bash tool", () => {
597597 expect ( result . wall_duration_ms ) . toBe ( 0 ) ;
598598 }
599599 } ) ;
600+
601+ it ( "should fail immediately when timeout_secs is undefined" , async ( ) => {
602+ const tool = createBashTool ( { cwd : process . cwd ( ) } ) ;
603+ const args = {
604+ script : "echo hello" ,
605+ timeout_secs : undefined ,
606+ max_lines : 100 ,
607+ } ;
608+
609+ const result = ( await tool . execute ! ( args , mockToolCallOptions ) ) as BashToolResult ;
610+
611+ expect ( result . success ) . toBe ( false ) ;
612+ if ( ! result . success ) {
613+ expect ( result . error ) . toContain ( "timeout_secs parameter is missing or invalid" ) ;
614+ expect ( result . error ) . toContain ( "malformed tool call" ) ;
615+ expect ( result . exitCode ) . toBe ( - 1 ) ;
616+ expect ( result . wall_duration_ms ) . toBe ( 0 ) ;
617+ }
618+ } ) ;
619+
620+ it ( "should fail immediately when timeout_secs is null" , async ( ) => {
621+ const tool = createBashTool ( { cwd : process . cwd ( ) } ) ;
622+ const args = {
623+ script : "echo hello" ,
624+ timeout_secs : null as unknown as number ,
625+ max_lines : 100 ,
626+ } ;
627+
628+ const result = ( await tool . execute ! ( args , mockToolCallOptions ) ) as BashToolResult ;
629+
630+ expect ( result . success ) . toBe ( false ) ;
631+ if ( ! result . success ) {
632+ expect ( result . error ) . toContain ( "timeout_secs parameter is missing or invalid" ) ;
633+ expect ( result . error ) . toContain ( "malformed tool call" ) ;
634+ expect ( result . exitCode ) . toBe ( - 1 ) ;
635+ expect ( result . wall_duration_ms ) . toBe ( 0 ) ;
636+ }
637+ } ) ;
638+
639+ it ( "should fail immediately when timeout_secs is zero" , async ( ) => {
640+ const tool = createBashTool ( { cwd : process . cwd ( ) } ) ;
641+ const args : BashToolArgs = {
642+ script : "echo hello" ,
643+ timeout_secs : 0 ,
644+ max_lines : 100 ,
645+ } ;
646+
647+ const result = ( await tool . execute ! ( args , mockToolCallOptions ) ) as BashToolResult ;
648+
649+ expect ( result . success ) . toBe ( false ) ;
650+ if ( ! result . success ) {
651+ expect ( result . error ) . toContain ( "timeout_secs parameter is missing or invalid" ) ;
652+ expect ( result . error ) . toContain ( "malformed tool call" ) ;
653+ expect ( result . exitCode ) . toBe ( - 1 ) ;
654+ expect ( result . wall_duration_ms ) . toBe ( 0 ) ;
655+ }
656+ } ) ;
657+
658+ it ( "should fail immediately when timeout_secs is negative" , async ( ) => {
659+ const tool = createBashTool ( { cwd : process . cwd ( ) } ) ;
660+ const args : BashToolArgs = {
661+ script : "echo hello" ,
662+ timeout_secs : - 5 ,
663+ max_lines : 100 ,
664+ } ;
665+
666+ const result = ( await tool . execute ! ( args , mockToolCallOptions ) ) as BashToolResult ;
667+
668+ expect ( result . success ) . toBe ( false ) ;
669+ if ( ! result . success ) {
670+ expect ( result . error ) . toContain ( "timeout_secs parameter is missing or invalid" ) ;
671+ expect ( result . error ) . toContain ( "malformed tool call" ) ;
672+ expect ( result . exitCode ) . toBe ( - 1 ) ;
673+ expect ( result . wall_duration_ms ) . toBe ( 0 ) ;
674+ }
675+ } ) ;
600676} ) ;
0 commit comments