Add dynamic agent discovery tools
All checks were successful
build / test (push) Successful in 20s
publish / npm (push) Successful in 22s

This commit is contained in:
2026-06-05 20:07:37 -03:00
parent 80261e5224
commit 3ebe88708e
9 changed files with 628 additions and 75 deletions

View File

@@ -48,3 +48,46 @@ test("ControlPlaneClient forwards bearer tokens and extracts JSON error detail",
/API 403: keycloak email is not verified/,
);
});
test("ControlPlaneClient searches agents with query filters", async () => {
let seenUrl = "";
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
seenUrl = String(input);
const headers = init?.headers as Record<string, string>;
assert.equal(headers.authorization, "Bearer access-token");
return new Response(
JSON.stringify([
{
name: "soc2-evidence",
description: "SOC2 evidence agent",
status: "running",
public: true,
url: "https://soc2.example.test",
score: 0.9,
match_source: "lexical",
setup_required: false,
skills: [{ name: "collect", description: "", tags: ["security"], input_fields: [] }],
},
]),
{ status: 200, headers: { "content-type": "application/json" } },
);
}) as typeof fetch;
const rows = await new ControlPlaneClient(
"https://api.example.test",
"access-token",
).searchAgents({
query: "soc2",
tags: ["security", "evidence"],
skill: "collect",
limit: 12,
});
const url = new URL(seenUrl);
assert.equal(url.pathname, "/v1/agents/search");
assert.equal(url.searchParams.get("q"), "soc2");
assert.deepEqual(url.searchParams.getAll("tag"), ["security", "evidence"]);
assert.equal(url.searchParams.get("skill"), "collect");
assert.equal(url.searchParams.get("limit"), "12");
assert.equal(rows[0].name, "soc2-evidence");
});