@devries-cameron20 / t3code-1 / commits / 8df455c09b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(acp-registry): ACP Registry installs only change the mode of a contained command (#34531)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

maria committed Nov 12, 2026 at 00:26 UTC 8df455c09bf153433f65e45eb548a478c39655f8
2 files changed +72 -2
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+66
@@ -839,6 +839,72 @@ describe("AcpRegistrySupport", () => {
839 );
840 });
841
842 + it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
843 + "leaves the mode of a file outside the install root when the command links to it",
844 + () => {
845 + const downloadUrl = "https://registry.test/agent.tar.gz";
846 + const agent = makeAgent({
847 + binary: { "linux-x86_64": { archive: downloadUrl, cmd: "./agent" } },
848 + });
849 + return Effect.gen(function* () {
850 + const fileSystem = yield* FileSystem.FileSystem;
851 + const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
852 + prefix: "t3-acp-outside-link-",
853 + });
854 + const outsideFile = `${cacheDir}/outside`;
855 + yield* fileSystem.writeFileString(outsideFile, "private\n");
856 + yield* fileSystem.chmod(outsideFile, 0o600);
857 + const source = `${cacheDir}/source`;
858 + yield* fileSystem.makeDirectory(source);
859 + yield* fileSystem.symlink(outsideFile, `${source}/agent`);
860 + const archivePath = `${cacheDir}/agent.tar.gz`;
861 + const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
862 + const tar = yield* spawner.spawn(
863 + ChildProcess.make("tar", ["-czf", archivePath, "-C", source, "agent"]),
864 + );
865 + expect(yield* tar.exitCode).toBe(0);
866 + const archive = yield* fileSystem.readFile(archivePath);
867 + const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog({
868 + cacheDir,
869 + toolsDir: `${cacheDir}/tools`,
870 + registryUrl,
871 + }).pipe(
872 + Effect.provideService(
873 + HttpClient.HttpClient,
874 + HttpClient.make((request) =>
875 + Effect.succeed(
876 + HttpClientResponse.fromWeb(
877 + request,
878 + request.url === registryUrl
879 + ? new Response(makeRegistry(agent))
880 + : new Response(archive),
881 + ),
882 + ),
883 + ),
884 + ),
885 + );
886 +
887 + const error = yield* resolver.prepare({ agentId: agent.id }).pipe(Effect.flip);
888 +
889 + expect(error.reason).toBe("archive_invalid");
890 + expect((yield* fileSystem.stat(outsideFile)).mode & 0o777).toBe(0o600);
891 + }).pipe(
892 + Effect.scoped,
893 + Effect.provide(
894 + Layer.mergeAll(
895 + NodeServices.layer,
896 + NodeCrypto.layer,
897 + TestProviderHost.layer().pipe(
898 + Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
899 + ),
900 + ),
901 + ),
902 + Effect.provideService(HostProcess.Platform, "linux"),
903 + Effect.provideService(HostProcess.Architecture, "x64"),
904 + );
905 + },
906 + );
907 +
908 it.effect("searches compatible agents with deterministic ranking and bounded metadata", () => {
909 const exact = {
910 ...makeAgent({ npx: { package: "@example/acp@1.2.3" } }),
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+6 -2
@@ -1356,6 +1356,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1356 const assertExecutableInRoot = Effect.fn("AcpRegistryCatalog.assertExecutableInRoot")(function* (
1357 root: string,
1358 executablePath: string,
1359 + options?: { readonly makeExecutable?: boolean },
1360 ) {
1361 const rootRealPath = yield* fileSystem.realPath(root);
1362 const executableRealPath = yield* fileSystem.realPath(executablePath);
@@ -1366,6 +1367,10 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1367 detail: "ACP Registry archive command resolves outside its installation directory.",
1368 });
1369 }
1370 + // chmod follows symlinks, so only change the mode once the real path is known to be inside.
1371 + if (options?.makeExecutable && platform !== "win32") {
1372 + yield* fileSystem.chmod(executableRealPath, 0o755);
1373 + }
1374 const info = yield* fileSystem.stat(executableRealPath);
1375 const hasExecutableMode = platform === "win32" || (info.mode & 0o111) !== 0;
1376 if (info.type !== "File" || !hasExecutableMode) {
@@ -1595,8 +1600,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1600 detail: `ACP Registry archive for ${agent.id} did not contain '${target.cmd}'.`,
1601 });
1602 }
1598 - if (platform !== "win32") yield* fileSystem.chmod(stagedExecutable, 0o755);
1599 - yield* assertExecutableInRoot(extractionRoot, stagedExecutable);
1603 + yield* assertExecutableInRoot(extractionRoot, stagedExecutable, { makeExecutable: true });
1604 yield* fileSystem.remove(installRoot, { recursive: true, force: true });
1605 yield* fileSystem.rename(extractionRoot, installRoot);
1606 return yield* assertExecutableInRoot(installRoot, executablePath);