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 22, 10:45 UTC
fix(acp-registry): installing one agent no longer blocks other agents (#23684)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 30, 2026 at 20:33 UTC
5b0cf58f682d8887397bab2a184578c99705e631
2 files changed
+83
-7
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+70
@@ -1547,6 +1547,76 @@ describe("AcpRegistrySupport", () => {
1547
});
1548
});
1549
1550
+ it.effect("resolves an installed agent while another agent's download is still running", () => {
1551
+ const slowArchiveUrl = "https://registry.test/slow-agent.bin";
1552
+ const agent = makeAgent({
1553
+ binary: { "linux-x86_64": { archive: archiveUrl, cmd: "./bin/example-agent" } },
1554
+ });
1555
+ const slowAgent = {
1556
+ ...agent,
1557
+ distribution: {
1558
+ binary: { "linux-x86_64": { archive: slowArchiveUrl, cmd: "./bin/slow-agent" } },
1559
+ },
1560
+ id: "slow-agent",
1561
+ name: "Slow Agent",
1562
+ };
1563
+ const binaryBytes = new TextEncoder().encode("#!/bin/sh\necho example\n");
1564
+ return Effect.gen(function* () {
1565
+ const downloadStarted = yield* Deferred.make<void>();
1566
+ const releaseDownload = yield* Deferred.make<void>();
1567
+ return yield* Effect.gen(function* () {
1568
+ const fileSystem = yield* FileSystem.FileSystem;
1569
+ const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
1570
+ prefix: "t3-acp-registry-parallel-install-",
1571
+ });
1572
+ const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog({
1573
+ cacheDir,
1574
+ toolsDir: `${cacheDir}/tools`,
1575
+ registryUrl,
1576
+ });
1577
+
1578
+ yield* resolver.resolve(settings(), "/workspace");
1579
+
1580
+ const prepareFiber = yield* resolver
1581
+ .prepare({ agentId: slowAgent.id })
1582
+ .pipe(Effect.forkChild({ startImmediately: true }));
1583
+ yield* Deferred.await(downloadStarted);
1584
+
1585
+ const resolved = yield* resolver.resolve(settings(), "/workspace");
1586
+ expect(resolved.spawn.command).toContain(
1587
+ "/tools/example-agent/1.2.3/linux-x86_64/bin/example-agent",
1588
+ );
1589
+ expect(prepareFiber.pollUnsafe()).toBeUndefined();
1590
+
1591
+ yield* Deferred.succeed(releaseDownload, undefined);
1592
+ expect(yield* Fiber.join(prepareFiber)).toMatchObject({ prepared: true });
1593
+ }).pipe(
1594
+ Effect.scoped,
1595
+ Effect.provide(
1596
+ layerResolver((request) => {
1597
+ if (request.url === registryUrl) {
1598
+ return Effect.succeed(
1599
+ HttpClientResponse.fromWeb(
1600
+ request,
1601
+ new Response(JSON.stringify({ version: "1.0.0", agents: [slowAgent, agent] })),
1602
+ ),
1603
+ );
1604
+ }
1605
+ const response = HttpClientResponse.fromWeb(
1606
+ request,
1607
+ new Response(binaryBytes.buffer as ArrayBuffer),
1608
+ );
1609
+ if (request.url !== slowArchiveUrl) return Effect.succeed(response);
1610
+ return Deferred.succeed(downloadStarted, undefined).pipe(
1611
+ Effect.andThen(Deferred.await(releaseDownload)),
1612
+ Effect.as(response),
1613
+ );
1614
+ }),
1615
+ ),
1616
+ );
1617
+ });
1618
+ });
1619
+
1620
it.effect("reserves a prepared binary until a configured instance inspects it", () => {
1621
const agent = makeAgent({
1622
binary: {
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+13
-7
@@ -668,7 +668,13 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
668
const registryFetchedAtMs = yield* Ref.make<number | undefined>(undefined);
669
const registryRevision = yield* Ref.make(0);
670
const registrySemaphore = yield* Semaphore.make(1);
671
- const installSemaphore = yield* Semaphore.make(1);
671
+ // Long installs must only block operations on the same agent.
672
+ const installPermits = new Map<string, Semaphore.Semaphore>();
673
+ const withInstallPermit = (agentId: string) => {
674
+ const permit = installPermits.get(agentId) ?? Semaphore.makeUnsafe(1);
675
+ installPermits.set(agentId, permit);
676
+ return permit.withPermits(1);
677
+ };
678
const preparedBinaryReservations = yield* Ref.make<ReadonlyMap<string, number>>(new Map());
679
680
const managerBinDirectory = Effect.fn("AcpRegistryCatalog.managerBinDirectory")(function* (
@@ -1671,13 +1677,13 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1677
const distribution = yield* compatibleDistribution(agent, "auto");
1678
if (distribution.kind === "binary") {
1679
// Only explicit command overrides may use PATH copies with different ACP capabilities.
1674
- yield* installSemaphore.withPermits(1)(
1680
+ yield* withInstallPermit(agent.id)(
1681
installBinary(agent, distribution.binaryTarget!).pipe(
1682
Effect.tap(() => reservePreparedBinary(agent.id)),
1683
),
1684
);
1685
} else {
1680
- yield* installSemaphore.withPermits(1)(
1686
+ yield* withInstallPermit(agent.id)(
1687
ensureGlobalPackage(agent, distribution.kind, distribution.packageName!, hostEnvironment),
1688
);
1689
}
@@ -1754,7 +1760,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1760
}
1761
1762
if (distribution.kind === "binary") {
1757
- return yield* installSemaphore.withPermits(1)(
1763
+ return yield* withInstallPermit(agent.id)(
1764
Effect.gen(function* () {
1765
const paths = binaryPaths(agent, distribution.binaryTarget!);
1766
if (paths === undefined) {
@@ -1866,7 +1872,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1872
command = resolvedOverride;
1873
args = distribution.args;
1874
} else if (distribution.kind === "npx" || distribution.kind === "uvx") {
1869
- const installed = yield* installSemaphore.withPermits(1)(
1875
+ const installed = yield* withInstallPermit(agent.id)(
1876
ensureGlobalPackage(
1877
agent,
1878
distribution.kind,
@@ -1879,7 +1885,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1885
commandBinDirectory = installed.binDirectory;
1886
} else {
1887
const target = distribution.binaryTarget!;
1882
- command = yield* installSemaphore.withPermits(1)(
1888
+ command = yield* withInstallPermit(agent.id)(
1889
installBinary(agent, target).pipe(
1890
Effect.tap(() => consumePreparedBinaryReservation(agent.id)),
1891
),
@@ -1912,7 +1918,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1918
const uninstallManagedBinary: AcpRegistryCatalog["Service"]["uninstallManagedBinary"] = (input) =>
1919
hostSettings
1920
.withSnapshot((settings) =>
1915
- installSemaphore.withPermits(1)(
1921
+ withInstallPermit(input.agentId)(
1922
Effect.gen(function* () {
1923
const safeAgentId = yield* decodeBoundedAgentId(input.agentId).pipe(
1924
Effect.mapError(