Skip to content

Commit 8e1858f

Browse files
fix(provider-acp-registry): prepared binary agents stay ready when the registry advances
Inspect only looked for the current registry version's executable, so a binary agent turned unprepared as soon as the registry index published a new version. Any install of the agent for a compatible platform target now keeps it ready; resolve already installs and launches the current version on demand, matching how npx and uvx agents upgrade. Never-prepared and uninstalled agents still report unprepared. Fixes #26531 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 31eabfe commit 8e1858f

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,11 @@ describe("AcpRegistrySupport", () => {
654654
expect(yield* fileSystem.readFileString(resolved.spawn.command)).toBe(
655655
"#!/bin/sh\necho 1.2.4\n",
656656
);
657+
658+
expect(yield* resolver.uninstallManagedBinary({ agentId: agent.id })).toMatchObject({
659+
removed: true,
660+
});
661+
expect(yield* resolver.inspect(settings())).toMatchObject({ status: "unprepared" });
657662
}).pipe(
658663
Effect.scoped,
659664
Effect.provide(

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

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,27 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
13771377
};
13781378
};
13791379

1380+
const hasInstalledBinaryVersion = Effect.fn("AcpRegistryCatalog.hasInstalledBinaryVersion")(
1381+
function* (agentId: string) {
1382+
const agentRoot = path.join(installsDirectory, agentId);
1383+
const versions = yield* fileSystem
1384+
.readDirectory(agentRoot)
1385+
.pipe(Effect.orElseSucceed((): Array<string> => []));
1386+
for (const version of versions) {
1387+
for (const candidateTarget of resolveAcpRegistryPlatformTargetCandidates(platformTarget)) {
1388+
if (
1389+
yield* fileSystem
1390+
.exists(path.join(agentRoot, version, candidateTarget))
1391+
.pipe(Effect.orElseSucceed(() => false))
1392+
) {
1393+
return true;
1394+
}
1395+
}
1396+
}
1397+
return false;
1398+
},
1399+
);
1400+
13801401
const installBinary = Effect.fn("AcpRegistryCatalog.installBinary")(function* (
13811402
agent: AcpRegistryAgent,
13821403
target: typeof AcpRegistryBinaryTarget.Type,
@@ -1756,25 +1777,28 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
17561777
const exists = yield* fileSystem
17571778
.exists(paths.executablePath)
17581779
.pipe(Effect.orElseSucceed(() => false));
1759-
if (!exists) {
1780+
// Any prepared version keeps the agent ready; resolve installs the current one on demand.
1781+
if (!exists && !(yield* hasInstalledBinaryVersion(agent.id))) {
17601782
return {
17611783
status: "unprepared",
17621784
agentId,
17631785
version: agent.version,
17641786
distribution: "binary",
17651787
} as const;
17661788
}
1767-
yield* assertExecutableInRoot(paths.installRoot, paths.executablePath).pipe(
1768-
Effect.mapError((cause) =>
1769-
isAcpRegistryError(cause)
1770-
? cause
1771-
: new AcpRegistryError({
1772-
reason: "install_failed",
1773-
detail: `Could not validate cached ACP Registry agent ${agent.id}.`,
1774-
cause,
1775-
}),
1776-
),
1777-
);
1789+
if (exists) {
1790+
yield* assertExecutableInRoot(paths.installRoot, paths.executablePath).pipe(
1791+
Effect.mapError((cause) =>
1792+
isAcpRegistryError(cause)
1793+
? cause
1794+
: new AcpRegistryError({
1795+
reason: "install_failed",
1796+
detail: `Could not validate cached ACP Registry agent ${agent.id}.`,
1797+
cause,
1798+
}),
1799+
),
1800+
);
1801+
}
17781802
return {
17791803
status: "ready",
17801804
agentId,

0 commit comments

Comments
 (0)