@@ -320,7 +320,10 @@ function listedToolNames(out: string): string[] {
320320 return out
321321 . split ( "\n" )
322322 . filter ( ( line ) => line . startsWith ( "- " ) )
323- . map ( ( line ) => line . slice ( 2 ) . split ( ":" ) [ 0 ] ! . trim ( ) ) ;
323+ . flatMap ( ( line ) => {
324+ const name = line . slice ( 2 ) . split ( ":" ) [ 0 ] ;
325+ return name === undefined ? [ ] : [ name . trim ( ) ] ;
326+ } ) ;
324327}
325328
326329async function flushMicrotasks ( rounds = 100 ) : Promise < void > {
@@ -342,9 +345,7 @@ describe("createToolSearchTool", () => {
342345 expect ( out ) . toContain ( "present" ) ;
343346 expect ( out ) . toContain ( "layout" ) ;
344347 expect ( out ) . not . toMatch ( / p r o m o t e d / i) ;
345- expect (
346- advertisedTools ( defs ) . map ( ( d ) => d . name ) ,
347- ) . not . toContain ( "present" ) ;
348+ expect ( advertisedTools ( defs ) . map ( ( d ) => d . name ) ) . not . toContain ( "present" ) ;
348349 } ) ;
349350
350351 test ( "default tool_search returns at most 5 matches and does not promote them" , async ( ) => {
@@ -666,7 +667,11 @@ describe("createToolSearchTool", () => {
666667} ) ;
667668
668669describe ( "promote-on-execute" , ( ) => {
669- const stringTool = ( name : string , reply : string , description : string ) : AgentTool => ( {
670+ const stringTool = (
671+ name : string ,
672+ reply : string ,
673+ description : string ,
674+ ) : AgentTool => ( {
670675 kind : "string" ,
671676 definition : {
672677 name,
@@ -678,7 +683,9 @@ describe("promote-on-execute", () => {
678683
679684 function wirePromoteOnExecute ( ) {
680685 const tools = [
681- ...wideCatalog . map ( ( d ) => stringTool ( d . name , `ran:${ d . name } ` , d . description ) ) ,
686+ ...wideCatalog . map ( ( d ) =>
687+ stringTool ( d . name , `ran:${ d . name } ` , d . description ) ,
688+ ) ,
682689 stringTool (
683690 "mcp__never__searched" ,
684691 "ran:never" ,
@@ -753,7 +760,8 @@ describe("promote-on-execute", () => {
753760 ) ;
754761 expect ( listed ) . toHaveLength ( 3 ) ;
755762 expect ( promoted ) . toEqual ( [ ] ) ;
756- const called = listed [ 0 ] ! ;
763+ const called = listed [ 0 ] ;
764+ if ( called === undefined ) throw new Error ( "expected a listed tool" ) ;
757765 const others = listed . slice ( 1 ) ;
758766 const result = await dispatch ( runner , called ) ;
759767 expect ( result . content ) . toBe ( `ran:${ called } ` ) ;
@@ -772,7 +780,9 @@ describe("promote-on-execute", () => {
772780 expect ( result . content ) . toBe ( "ran:never" ) ;
773781 expect ( result . isError ) . toBeUndefined ( ) ;
774782 expect ( promoted ) . toEqual ( [ "mcp__never__searched" ] ) ;
775- expect ( advertisedNames ( advertised , runner ) ) . toContain ( "mcp__never__searched" ) ;
783+ expect ( advertisedNames ( advertised , runner ) ) . toContain (
784+ "mcp__never__searched" ,
785+ ) ;
776786 } ) ;
777787
778788 test ( "executing list_dir does not join the advertised tail" , async ( ) => {
0 commit comments