Skip to content
TypeScript

fix(acp-registry): list every compatible agent in Add provider (#19145)

Craig Davison5188454cd9ef
diff --git a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
index 095ef3864c8..7814e3ce0d8 100644
--- a/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
+++ b/apps/web/src/components/settings/AcpRegistrySearchStep.browser.test.tsx
@@ -1,4 +1,9 @@
-import { EnvironmentId, ProviderDriverKind, type AcpRegistrySearchAgent } from "@t3tools/contracts";
+import {
+ EnvironmentId,
+ ProviderDriverKind,
+ type AcpRegistrySearchAgent,
+ type AcpRegistrySearchInput,
+} from "@t3tools/contracts";
import * as Cause from "effect/Cause";
import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
@@ -127,22 +132,37 @@ afterEach(async () => {
document.body.replaceChildren();
});
-it("loads the catalog immediately and searches only after typing settles", async () => {
+it("shows the full catalog initially and after clearing a debounced search", async () => {
+ const agents = Array.from({ length: 25 }, (_, index) => ({
+ ...gemini,
+ id: `gemini-${index}`,
+ name: `Gemini CLI ${index + 1}`,
+ }));
+ state.search.mockImplementation(({ input }: { input: AcpRegistrySearchInput }) => {
+ state.result = {
+ agents: agents
+ .filter((agent) => agent.name.toLowerCase().includes(input.query.toLowerCase()))
+ .slice(0, input.limit ?? 20),
+ };
+ });
+ const addButtons = () => page.getByRole("button", { name: /^Add Gemini CLI / }).elements();
await render();
- expect(state.search).toHaveBeenLastCalledWith({ environmentId, input: { query: "" } });
+ expect(addButtons()).toHaveLength(25);
+ await expect.element(page.getByRole("button", { name: "Add Gemini CLI 25" })).toBeEnabled();
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
await userEvent.fill(searchBox(), " Gemini ");
await act(async () => vi.advanceTimersByTime(200));
await userEvent.fill(searchBox(), " Gemini CLI ");
await act(async () => vi.advanceTimersByTime(299));
- expect(lastQuery()).toBe("");
+ expect(addButtons()).toHaveLength(25);
await act(async () => vi.advanceTimersByTime(1));
- expect(lastQuery()).toBe("Gemini CLI");
+ expect(addButtons()).toHaveLength(20);
await userEvent.clear(searchBox());
await act(async () => vi.advanceTimersByTime(300));
- expect(lastQuery()).toBe("");
+ expect(addButtons()).toHaveLength(25);
+ await expect.element(page.getByRole("button", { name: "Add Gemini CLI 25" })).toBeEnabled();
});
it("shows the loading, error, and empty states", async () => {
diff --git a/apps/web/src/components/settings/AcpRegistrySearchStep.tsx b/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
index 594f9ac3387..9449ceba627 100644
--- a/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
+++ b/apps/web/src/components/settings/AcpRegistrySearchStep.tsx
@@ -1,4 +1,4 @@
-import { AuthProvidersManageScope } from "@t3tools/contracts";
+import { ACP_REGISTRY_MAX_AGENTS, AuthProvidersManageScope } from "@t3tools/contracts";
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
import {
isAtomCommandInterrupted,
@@ -72,7 +72,9 @@ export function AcpRegistrySearchStep({
const search = useEnvironmentQuery(
serverEnvironment.searchAcpRegistry({
environmentId,
- input: { query: submittedQuery },
+ input: submittedQuery
+ ? { query: submittedQuery }
+ : { query: "", limit: ACP_REGISTRY_MAX_AGENTS },
}),
);
const prepareAgent = useAtomCommand(serverEnvironment.prepareAcpRegistryAgent, {
diff --git a/packages/contracts/src/acpRegistry.test.ts b/packages/contracts/src/acpRegistry.test.ts
index 8f87d41a9b0..3859f53a6b7 100644
--- a/packages/contracts/src/acpRegistry.test.ts
+++ b/packages/contracts/src/acpRegistry.test.ts
@@ -50,6 +50,7 @@ describe("ACP Registry contracts", () => {
expect(decodeSearchInput({ query: " codex " })).toEqual({
query: "codex",
});
+ expect(decodeSearchInput({ query: "", limit: 512 })).toEqual({ query: "", limit: 512 });
expect(
decodePrepareResult({
agentId: "codex-acp",
@@ -62,6 +63,8 @@ describe("ACP Registry contracts", () => {
it("rejects oversized queries and result metadata", () => {
expect(() => decodeSearchInput({ query: "x".repeat(121) })).toThrow();
+ expect(() => decodeSearchInput({ query: "", limit: 0 })).toThrow();
+ expect(() => decodeSearchInput({ query: "", limit: 513 })).toThrow();
expect(() =>
decodeSearchAgent({
id: "agent",
diff --git a/packages/contracts/src/acpRegistry.ts b/packages/contracts/src/acpRegistry.ts
index 559ac6e4776..3962cf4a995 100644
--- a/packages/contracts/src/acpRegistry.ts
+++ b/packages/contracts/src/acpRegistry.ts
@@ -47,8 +47,13 @@ export type AcpRegistryDistribution = typeof AcpRegistryDistribution.Type;
export const AcpRegistryIntegrity = Schema.Literals(["sha256", "registry"]);
export type AcpRegistryIntegrity = typeof AcpRegistryIntegrity.Type;
+export const ACP_REGISTRY_MAX_AGENTS = 512;
+
export const AcpRegistrySearchInput = Schema.Struct({
query: TrimmedString.check(Schema.isMaxLength(120)),
+ limit: Schema.optional(
+ Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: ACP_REGISTRY_MAX_AGENTS })),
+ ),
});
export type AcpRegistrySearchInput = typeof AcpRegistrySearchInput.Type;
@@ -70,7 +75,7 @@ export const AcpRegistrySearchAgent = Schema.Struct({
export type AcpRegistrySearchAgent = typeof AcpRegistrySearchAgent.Type;
export const AcpRegistrySearchResult = Schema.Struct({
- agents: Schema.Array(AcpRegistrySearchAgent).check(Schema.isMaxLength(20)),
+ agents: Schema.Array(AcpRegistrySearchAgent).check(Schema.isMaxLength(ACP_REGISTRY_MAX_AGENTS)),
});
export type AcpRegistrySearchResult = typeof AcpRegistrySearchResult.Type;
diff --git a/packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts b/packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
index dafad5460f1..f362500ab32 100644
--- a/packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+++ b/packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
@@ -1,6 +1,8 @@
import * as NodeServices from "@effect/platform-node/NodeServices";
import { describe, expect, it } from "@effect/vitest";
import {
+ AcpRegistrySearchInput,
+ AcpRegistrySearchResult,
DEFAULT_SERVER_SETTINGS,
ProviderDriverKind,
ProviderInstanceId,
@@ -29,6 +31,8 @@ import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
const registryUrl = "https://registry.test/registry.json";
const archiveUrl = "https://registry.test/example-agent.bin";
const decodeAcpRegistrySettings = Schema.decodeSync(AcpRegistrySettings);
+const decodeSearchInput = Schema.decodeEffect(AcpRegistrySearchInput);
+const decodeSearchResult = Schema.decodeEffect(AcpRegistrySearchResult);
const encodeUnknownJson = Schema.encodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
function makeAgent(
@@ -1050,6 +1054,51 @@ describe("AcpRegistrySupport", () => {
);
});
+ it.effect("keeps default searches at 20 and honors larger catalog limits", () => {
+ const base = makeAgent({
+ binary: {
+ "linux-x86_64": { archive: archiveUrl, cmd: "example-agent" },
+ },
+ });
+ const agents = Array.from({ length: 26 }, (_, index) => {
+ const suffix = String(index).padStart(2, "0");
+ return { ...base, id: `example-agent-${suffix}`, name: `Example Agent ${suffix}` };
+ });
+ return Effect.gen(function* () {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
+ prefix: "t3-acp-registry-limit-",
+ });
+ const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog({
+ cacheDir,
+ toolsDir: `${cacheDir}/tools`,
+ registryUrl,
+ });
+ const input = yield* decodeSearchInput({ query: "", limit: 512 });
+ const catalog = yield* resolver.search(input).pipe(Effect.flatMap(decodeSearchResult));
+ const limited = yield* resolver.search({ query: "", limit: 25 });
+ const defaultCatalog = yield* resolver.search({ query: "" });
+ const matches = yield* resolver.search({ query: "example" });
+
+ expect(catalog.agents).toHaveLength(26);
+ expect(limited.agents).toHaveLength(25);
+ expect(defaultCatalog.agents).toHaveLength(20);
+ expect(matches.agents).toHaveLength(20);
+ }).pipe(
+ Effect.scoped,
+ Effect.provide(
+ layerResolver((request) =>
+ Effect.succeed(
+ HttpClientResponse.fromWeb(
+ request,
+ new Response(JSON.stringify({ version: "1.0.0", agents })),
+ ),
+ ),
+ ),
+ ),
+ );
+ });
+
it.effect("discards registry agents with blank names or unsafe versions", () => {
const distribution = {
binary: {
diff --git a/packages/provider-acp-registry/src/server/AcpRegistrySupport.ts b/packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
index 28e05da3f55..049e0121a59 100644
--- a/packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+++ b/packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
@@ -1,4 +1,5 @@
import {
+ ACP_REGISTRY_MAX_AGENTS,
AcpRegistryOperationError,
AcpRegistryOperationErrorReason,
TrimmedNonEmptyString,
@@ -51,7 +52,8 @@ const ACP_REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest
const MAX_REGISTRY_BYTES = 1024 * 1024;
const MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024;
const MAX_PACKAGE_MANIFEST_BYTES = 1024 * 1024;
-const MAX_SEARCH_RESULTS = 20;
+// Older clients omit the limit and validate responses against a 20-agent cap.
+const DEFAULT_SEARCH_LIMIT = 20;
const REGISTRY_REQUEST_TIMEOUT = "30 seconds";
const ARCHIVE_REQUEST_TIMEOUT = "20 minutes";
const PACKAGE_INSTALL_TIMEOUT = "20 minutes";
@@ -170,7 +172,7 @@ type AcpRegistryPackageInstallReceipt = typeof AcpRegistryPackageInstallReceipt.
const AcpRegistryIndexEnvelope = Schema.Struct({
version: BoundedVersion,
- agents: Schema.Array(Schema.Unknown).check(Schema.isMaxLength(512)),
+ agents: Schema.Array(Schema.Unknown).check(Schema.isMaxLength(ACP_REGISTRY_MAX_AGENTS)),
});
export interface AcpRegistryIndex {
readonly version: string;
@@ -1614,8 +1616,9 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
compareText(left.agent.name.toLowerCase(), right.agent.name.toLowerCase()) ||
compareText(left.agent.id, right.agent.id),
);
+ const limit = input.limit ?? DEFAULT_SEARCH_LIMIT;
return {
- agents: ranked.slice(0, MAX_SEARCH_RESULTS).map(({ agent, distribution }) => ({
+ agents: ranked.slice(0, limit).map(({ agent, distribution }) => ({
id: agent.id,
name: agent.name,
version: agent.version,