@@ -3,6 +3,13 @@ import { getOutputFormat, outputJsonCollection, outputNoResults, boldBlue, getMa
33import { search } from "@use-agently/sdk/agently" ;
44import { defaultClient } from "../client" ;
55
6+ const SUPPORTED_PROTOCOLS = [ "a2a" , "mcp" ] as const ;
7+
8+ function getHealthyProtocols ( protocol ?: Record < string , { healthy ?: boolean } > ) : string [ ] {
9+ if ( ! protocol ) return [ ] ;
10+ return SUPPORTED_PROTOCOLS . filter ( ( name ) => protocol [ name ] ?. healthy === true ) ;
11+ }
12+
613export const searchCommand = new Command ( "search" )
714 . description ( "Search the Agently marketplace for agents" )
815 . option ( "-q, --query <text>" , "Search query to filter agents by name or description" )
@@ -31,7 +38,12 @@ export const searchCommand = new Command("search")
3138 const format = getOutputFormat ( command ) ;
3239 const protocol = options . protocol ? options . protocol . split ( "," ) . map ( ( p ) => p . trim ( ) . toLowerCase ( ) ) : undefined ;
3340 const result = await search ( defaultClient , { q : options . query , protocol } ) ;
34- const items = result . hits . map ( ( { id, name, description, protocols } ) => ( { id, name, description, protocols } ) ) ;
41+ const items = result . hits
42+ . map ( ( hit ) => {
43+ const protocols = getHealthyProtocols ( hit . protocol ) ;
44+ return { id : hit . id , name : hit . name , description : hit . description , protocols } ;
45+ } )
46+ . filter ( ( item ) => item . protocols . length > 0 ) ;
3547
3648 if ( items . length === 0 ) {
3749 outputNoResults ( format ) ;
0 commit comments