Skip to content

Commit f69dc8e

Browse files
committed
feat: search to only show healthy protocols
1 parent b3d5927 commit f69dc8e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/use-agently-sdk/agently.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface ERC8004Agent {
3333
name: string;
3434
description: string;
3535
protocols: string[];
36+
protocol?: Record<string, { healthy?: boolean }>;
3637
created_at: string;
3738
}
3839

packages/use-agently/src/commands/search.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const TEST_HITS = [
1414
owner: "0xabc",
1515
name: "Echo Agent",
1616
description: "An echo agent",
17+
protocols: ["a2a", "mcp"],
18+
protocol: { a2a: { healthy: true }, mcp: { healthy: true } },
1719
created_at: "2025-01-01T00:00:00.000Z",
1820
},
1921
];

packages/use-agently/src/commands/search.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { getOutputFormat, outputJsonCollection, outputNoResults, boldBlue, getMa
33
import { search } from "@use-agently/sdk/agently";
44
import { 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+
613
export 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

Comments
 (0)