Skip to content

Commit 812cb68

Browse files
fix(provider-acp-registry): install agents with large archive listings (#25545)
Co-authored-by: maria-rcks <[email protected]>
1 parent 3121c19 commit 812cb68

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ describe("AcpRegistrySupport", () => {
698698
},
699699
);
700700

701-
it.effect("installs a tar archive containing a root directory entry", () => {
701+
it.effect("installs a tar archive with a root entry and a listing larger than 1 MiB", () => {
702702
const downloadUrl = "https://registry.test/agent.tar.gz";
703703
const agent = makeAgent({
704704
binary: { "linux-x86_64": { archive: downloadUrl, cmd: "./agent" } },
@@ -709,6 +709,14 @@ describe("AcpRegistrySupport", () => {
709709
const source = `${cacheDir}/source`;
710710
yield* fileSystem.makeDirectory(source);
711711
yield* fileSystem.writeFileString(`${source}/agent`, "#!/bin/sh\necho managed\n");
712+
// 5,000 long names list past the generic 1 MiB command output cap.
713+
const entries = `${source}/entries`;
714+
yield* fileSystem.makeDirectory(entries);
715+
yield* Effect.forEach(
716+
Array.from({ length: 5_000 }, (_, index) => index),
717+
(index) => fileSystem.writeFileString(`${entries}/${index}-${"e".repeat(240)}`, ""),
718+
{ concurrency: 16 },
719+
);
712720
const archivePath = `${cacheDir}/agent.tar.gz`;
713721
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
714722
const tar = yield* spawner.spawn(

‎packages/provider-acp-registry/src/server/AcpRegistrySupport.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const ACP_REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest
5151

5252
const MAX_REGISTRY_BYTES = 1024 * 1024;
5353
const MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024;
54+
const MAX_COMMAND_OUTPUT_BYTES = 1024 * 1024;
55+
// Archive listings can exceed the output of package-manager commands.
56+
const MAX_ARCHIVE_LISTING_BYTES = 64 * 1024 * 1024;
5457
const MAX_PACKAGE_MANIFEST_BYTES = 1024 * 1024;
5558
// Older clients omit the limit and validate responses against a 20-agent cap.
5659
const DEFAULT_SEARCH_LIMIT = 20;
@@ -916,6 +919,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
916919
readonly env?: NodeJS.ProcessEnv;
917920
readonly timeout?: Duration.Input;
918921
readonly truncatedOutputReason?: AcpRegistryErrorReason;
922+
readonly maxStdoutBytes?: number;
919923
} = {},
920924
) {
921925
const collect = Effect.gen(function* () {
@@ -934,8 +938,11 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
934938
yield* Effect.addFinalizer(() => child.kill().pipe(Effect.ignore));
935939
const [stdout, stderr, exitCode] = yield* Effect.all(
936940
[
937-
collectUint8StreamText({ stream: child.stdout, maxBytes: 1024 * 1024 }),
938-
collectUint8StreamText({ stream: child.stderr, maxBytes: 1024 * 1024 }),
941+
collectUint8StreamText({
942+
stream: child.stdout,
943+
maxBytes: options.maxStdoutBytes ?? MAX_COMMAND_OUTPUT_BYTES,
944+
}),
945+
collectUint8StreamText({ stream: child.stderr, maxBytes: MAX_COMMAND_OUTPUT_BYTES }),
939946
child.exitCode,
940947
],
941948
{ concurrency: "unbounded" },
@@ -1532,10 +1539,11 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
15321539
: platform === "win32"
15331540
? ["-tf", archivePath]
15341541
: undefined;
1542+
const listingOptions = { maxStdoutBytes: MAX_ARCHIVE_LISTING_BYTES };
15351543
const entries =
15361544
listArgs === undefined
1537-
? yield* runCommand("unzip", ["-Z1", archivePath])
1538-
: yield* runCommand(tarCommand, listArgs);
1545+
? yield* runCommand("unzip", ["-Z1", archivePath], listingOptions)
1546+
: yield* runCommand(tarCommand, listArgs, listingOptions);
15391547
if (!validateArchiveEntries(entries)) {
15401548
return yield* new AcpRegistryError({
15411549
reason: "archive_invalid",

0 commit comments

Comments
 (0)