The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 13:00 UTC
fix(providers): fall back to windows-x86_64 ACP binaries on Windows on ARM (#18521)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Max Weinbach committed
Oct 15, 2026 at 13:39 UTC
76cb251da129579d13be333ffe89a8767f7a257a
2 files changed
+176
-17
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+127
@@ -14,6 +14,8 @@ import * as FileSystem from "effect/FileSystem";
14
import * as Path from "effect/Path";
15
import * as Fiber from "effect/Fiber";
16
import * as Layer from "effect/Layer";
17
+import * as Sink from "effect/Sink";
18
+import * as Stream from "effect/Stream";
19
import * as Schema from "effect/Schema";
20
import * as HttpClient from "effect/http/HttpClient";
21
import * as HttpClientResponse from "effect/http/HttpClientResponse";
@@ -209,6 +211,47 @@ describe("AcpRegistrySupport", () => {
211
platformTarget: "darwin-aarch64",
212
}),
213
).toBeUndefined();
214
+ expect(
215
+ AcpRegistrySupport.resolveAcpRegistryDistribution({
216
+ agent: makeAgent({
217
+ binary: {
218
+ "windows-x86_64": {
219
+ archive: archiveUrl,
220
+ cmd: "./bin/example-agent-x64.exe",
221
+ args: ["acp"],
222
+ },
223
+ },
224
+ }),
225
+ preference: "auto",
226
+ platformTarget: "windows-aarch64",
227
+ }),
228
+ ).toMatchObject({
229
+ kind: "binary",
230
+ binaryTarget: { cmd: "./bin/example-agent-x64.exe" },
231
+ });
232
+ expect(
233
+ AcpRegistrySupport.resolveAcpRegistryDistribution({
234
+ agent: makeAgent({
235
+ binary: {
236
+ "windows-aarch64": {
237
+ archive: archiveUrl,
238
+ cmd: "./bin/example-agent-arm64.exe",
239
+ args: ["acp"],
240
+ },
241
+ "windows-x86_64": {
242
+ archive: archiveUrl,
243
+ cmd: "./bin/example-agent-x64.exe",
244
+ args: ["acp"],
245
+ },
246
+ },
247
+ }),
248
+ preference: "auto",
249
+ platformTarget: "windows-aarch64",
250
+ }),
251
+ ).toMatchObject({
252
+ kind: "binary",
253
+ binaryTarget: { cmd: "./bin/example-agent-arm64.exe" },
254
+ });
255
});
256
257
it.effect("resolves a local command on the selected environment without the registry", () => {
@@ -782,6 +825,90 @@ describe("AcpRegistrySupport", () => {
825
);
826
});
827
828
+ it.effect("prepares an x64 ZIP fallback on Windows ARM when PATH tar cannot read ZIP", () => {
829
+ const downloadUrl = "https://registry.test/agent-windows-x64.zip";
830
+ const agent = makeAgent({
831
+ binary: { "windows-x86_64": { archive: downloadUrl, cmd: "./agent.exe" } },
832
+ npx: { package: "@example/acp@1.2.3" },
833
+ });
834
+ return Effect.gen(function* () {
835
+ const fileSystem = yield* FileSystem.FileSystem;
836
+ const path = yield* Path.Path;
837
+ const cacheDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-acp-arm-zip-" });
838
+ const commands: Array<string> = [];
839
+ const spawner = ChildProcessSpawner.make((command) =>
840
+ Effect.gen(function* () {
841
+ if (command._tag !== "StandardCommand") return yield* Effect.die("Unexpected pipeline");
842
+ commands.push(command.command);
843
+ // Simulate Git's GNU tar rejecting ZIP and System32 bsdtar listing/extracting it.
844
+ const supportsZip = command.command === "C:\\Windows\\System32\\tar.exe";
845
+ if (supportsZip && command.args[0] === "-xf") {
846
+ const outputDirectory = command.args[3];
847
+ if (!outputDirectory) return yield* Effect.die("Missing extraction directory");
848
+ yield* fileSystem.writeFileString(path.join(outputDirectory, "agent.exe"), "fixture");
849
+ }
850
+ return ChildProcessSpawner.makeHandle({
851
+ pid: ChildProcessSpawner.ProcessId(1),
852
+ exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(supportsZip ? 0 : 1)),
853
+ isRunning: Effect.succeed(false),
854
+ kill: () => Effect.void,
855
+ unref: Effect.succeed(Effect.void),
856
+ stdin: Sink.drain,
857
+ stdout: Stream.make(new TextEncoder().encode(supportsZip ? "agent.exe\r\n" : "")),
858
+ stderr: Stream.make(
859
+ new TextEncoder().encode(supportsZip ? "" : "GNU tar cannot read ZIP"),
860
+ ),
861
+ all: Stream.empty,
862
+ getInputFd: () => Sink.drain,
863
+ getOutputFd: () => Stream.empty,
864
+ });
865
+ }).pipe(Effect.orDie),
866
+ );
867
+ const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog({
868
+ cacheDir,
869
+ toolsDir: path.join(cacheDir, "tools"),
870
+ registryUrl,
871
+ }).pipe(
872
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
873
+ Effect.provideService(HostProcess.Platform, "win32"),
874
+ Effect.provideService(HostProcess.Architecture, "arm64"),
875
+ Effect.provideService(HostProcess.Environment, {
876
+ SystemRoot: "C:\\Windows",
877
+ PATH: "C:\\Program Files\\Git\\usr\\bin;C:\\Windows\\System32",
878
+ }),
879
+ Effect.provideService(SpawnExecutableResolution, (command) =>
880
+ command === "tar" ? "C:\\Program Files\\Git\\usr\\bin\\tar.exe" : command,
881
+ ),
882
+ );
883
+ yield* resolver.prepare({ agentId: agent.id });
884
+ const resolved = yield* resolver.resolve(settings(), "/workspace", {});
885
+ expect(resolved.spawn.command).toBe(
886
+ yield* fileSystem.realPath(
887
+ path.join(cacheDir, "tools", agent.id, agent.version, "windows-x86_64", "agent.exe"),
888
+ ),
889
+ );
890
+ expect(yield* fileSystem.readFileString(resolved.spawn.command)).toBe("fixture");
891
+ expect(commands).toEqual([
892
+ "C:\\Windows\\System32\\tar.exe",
893
+ "C:\\Windows\\System32\\tar.exe",
894
+ ]);
895
+ }).pipe(
896
+ Effect.scoped,
897
+ Effect.provide(
898
+ layerResolver((request) =>
899
+ Effect.succeed(
900
+ HttpClientResponse.fromWeb(
901
+ request,
902
+ request.url === registryUrl
903
+ ? new Response(makeRegistry(agent))
904
+ : new Response("ZIP fixture"),
905
+ ),
906
+ ),
907
+ ),
908
+ ),
909
+ );
910
+ });
911
+
912
it.effect("searches compatible agents with deterministic ranking and bounded metadata", () => {
913
const exact = {
914
...makeAgent({ npx: { package: "@example/acp@1.2.3" } }),
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+49
-17
@@ -12,6 +12,7 @@ import {
12
} from "@t3tools/contracts";
13
import type { AcpRegistryDistributionPreference } from "../settings.ts";
14
import type { AcpRegistrySettings } from "../settings.ts";
15
+import { cliArchiveTarCommand } from "@t3tools/shared/cliRelease";
16
import * as HostProcess from "@t3tools/shared/HostProcess";
17
import {
18
mergePathEntries,
@@ -238,6 +239,18 @@ export function resolveAcpRegistryPlatformTarget(
239
return os && arch ? (`${os}-${arch}` as AcpRegistryPlatformTarget) : undefined;
240
}
241
242
+function resolveAcpRegistryPlatformTargetCandidates(
243
+ platformTarget: AcpRegistryPlatformTarget | undefined,
244
+): ReadonlyArray<AcpRegistryPlatformTarget> {
245
+ if (platformTarget === undefined) return [];
246
+ // Windows 11 on ARM executes windows-x86_64 binaries under Prism emulation
247
+ // when an agent does not publish a native windows-aarch64 binary.
248
+ if (platformTarget === "windows-aarch64") {
249
+ return ["windows-aarch64", "windows-x86_64"];
250
+ }
251
+ return [platformTarget];
252
+}
253
+
254
interface ExactPackageSpec {
255
readonly name: string;
256
readonly version: string;
@@ -375,18 +388,22 @@ export const acpRegistryManagedBinaryDirectories = Effect.fn("acpRegistryManaged
388
(left, right) => right.localeCompare(left, undefined, { numeric: true }),
389
);
390
for (const version of versions) {
378
- const installRoot = path.join(installsDirectory, agent, version, target);
379
- if (yield* fileSystem.exists(installRoot).pipe(Effect.orElseSucceed(() => false))) {
380
- const binaryTarget = cachedAgentByInstall.get(`${agent}\0${version}`)?.distribution
381
- .binary?.[target];
382
- const commandSegments =
383
- binaryTarget === undefined ? undefined : normalizeRegistryCommandPath(binaryTarget.cmd);
384
- const directory =
385
- commandSegments === undefined
386
- ? installRoot
387
- : path.join(installRoot, ...commandSegments.slice(0, -1));
388
- if (yield* fileSystem.exists(directory).pipe(Effect.orElseSucceed(() => false))) {
389
- directories.push(directory);
391
+ for (const candidateTarget of resolveAcpRegistryPlatformTargetCandidates(target)) {
392
+ const installRoot = path.join(installsDirectory, agent, version, candidateTarget);
393
+ if (yield* fileSystem.exists(installRoot).pipe(Effect.orElseSucceed(() => false))) {
394
+ const binaryTarget = cachedAgentByInstall.get(`${agent}\0${version}`)?.distribution
395
+ .binary?.[candidateTarget];
396
+ const commandSegments =
397
+ binaryTarget === undefined
398
+ ? undefined
399
+ : normalizeRegistryCommandPath(binaryTarget.cmd);
400
+ const directory =
401
+ commandSegments === undefined
402
+ ? installRoot
403
+ : path.join(installRoot, ...commandSegments.slice(0, -1));
404
+ if (yield* fileSystem.exists(directory).pipe(Effect.orElseSucceed(() => false))) {
405
+ directories.push(directory);
406
+ }
407
}
408
}
409
}
@@ -409,7 +426,9 @@ export function resolveAcpRegistryDistribution(input: {
426
readonly platformTarget: AcpRegistryPlatformTarget | undefined;
427
}): ResolvedAcpRegistryDistribution | undefined {
428
const { agent, platformTarget } = input;
412
- const binary = platformTarget ? agent.distribution.binary?.[platformTarget] : undefined;
429
+ const binary = resolveAcpRegistryPlatformTargetCandidates(platformTarget)
430
+ .map((candidate) => agent.distribution.binary?.[candidate])
431
+ .find((entry) => entry !== undefined);
432
const candidates: ReadonlyArray<AcpRegistryDistributionKind> =
433
input.preference === "auto" ? ["binary", "npx", "uvx"] : [input.preference];
434
@@ -1336,11 +1355,16 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1355
1356
const binaryPaths = (agent: AcpRegistryAgent, target: typeof AcpRegistryBinaryTarget.Type) => {
1357
const commandSegments = normalizeRegistryCommandPath(target.cmd);
1339
- if (platformTarget === undefined || commandSegments === undefined) return undefined;
1340
- const installRoot = path.join(agentInstallRoot(agent), platformTarget);
1358
+ const matchedPlatformTarget =
1359
+ resolveAcpRegistryPlatformTargetCandidates(platformTarget).find(
1360
+ (candidate) => agent.distribution.binary?.[candidate] === target,
1361
+ ) ?? platformTarget;
1362
+ if (matchedPlatformTarget === undefined || commandSegments === undefined) return undefined;
1363
+ const installRoot = path.join(agentInstallRoot(agent), matchedPlatformTarget);
1364
return {
1365
commandSegments,
1366
installRoot,
1367
+ platformTarget: matchedPlatformTarget,
1368
executablePath: path.join(installRoot, ...commandSegments),
1369
};
1370
};
@@ -1487,6 +1511,14 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1511
yield* fileSystem.makeDirectory(path.dirname(targetPath), { recursive: true });
1512
yield* fileSystem.rename(archivePath, targetPath);
1513
} else {
1514
+ // The new Windows ARM fallback must extract x64 ZIPs even when Git's GNU tar wins PATH.
1515
+ // Keep archive selection for existing native distributions unchanged in this PR.
1516
+ const tarCommand =
1517
+ platformTarget === "windows-aarch64" &&
1518
+ paths.platformTarget === "windows-x86_64" &&
1519
+ kind === "zip"
1520
+ ? cliArchiveTarCommand(platform, hostEnvironment)
1521
+ : "tar";
1522
const listArgs =
1523
kind === "tar_gz"
1524
? ["-tzf", archivePath]
@@ -1498,7 +1530,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1530
const entries =
1531
listArgs === undefined
1532
? yield* runCommand("unzip", ["-Z1", archivePath])
1501
- : yield* runCommand("tar", listArgs);
1533
+ : yield* runCommand(tarCommand, listArgs);
1534
if (!validateArchiveEntries(entries)) {
1535
return yield* new AcpRegistryError({
1536
reason: "archive_invalid",
@@ -1509,7 +1541,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1541
yield* runCommand("unzip", ["-q", archivePath, "-d", extractionRoot]);
1542
} else {
1543
const extractFlag = kind === "tar_gz" ? "-xzf" : kind === "tar_bz2" ? "-xjf" : "-xf";
1512
- yield* runCommand("tar", [extractFlag, archivePath, "-C", extractionRoot]);
1544
+ yield* runCommand(tarCommand, [extractFlag, archivePath, "-C", extractionRoot]);
1545
}
1546
}
1547