@@ -668,7 +668,13 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
668668 const registryFetchedAtMs = yield * Ref . make < number | undefined > ( undefined ) ;
669669 const registryRevision = yield * Ref . make ( 0 ) ;
670670 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+ } ;
672678 const preparedBinaryReservations = yield * Ref . make < ReadonlyMap < string , number > > ( new Map ( ) ) ;
673679
674680 const managerBinDirectory = Effect . fn ( "AcpRegistryCatalog.managerBinDirectory" ) ( function * (
@@ -1671,13 +1677,13 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
16711677 const distribution = yield * compatibleDistribution ( agent , "auto" ) ;
16721678 if ( distribution . kind === "binary" ) {
16731679 // Only explicit command overrides may use PATH copies with different ACP capabilities.
1674- yield * installSemaphore . withPermits ( 1 ) (
1680+ yield * withInstallPermit ( agent . id ) (
16751681 installBinary ( agent , distribution . binaryTarget ! ) . pipe (
16761682 Effect . tap ( ( ) => reservePreparedBinary ( agent . id ) ) ,
16771683 ) ,
16781684 ) ;
16791685 } else {
1680- yield * installSemaphore . withPermits ( 1 ) (
1686+ yield * withInstallPermit ( agent . id ) (
16811687 ensureGlobalPackage ( agent , distribution . kind , distribution . packageName ! , hostEnvironment ) ,
16821688 ) ;
16831689 }
@@ -1754,7 +1760,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
17541760 }
17551761
17561762 if ( distribution . kind === "binary" ) {
1757- return yield * installSemaphore . withPermits ( 1 ) (
1763+ return yield * withInstallPermit ( agent . id ) (
17581764 Effect . gen ( function * ( ) {
17591765 const paths = binaryPaths ( agent , distribution . binaryTarget ! ) ;
17601766 if ( paths === undefined ) {
@@ -1866,7 +1872,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
18661872 command = resolvedOverride ;
18671873 args = distribution . args ;
18681874 } else if ( distribution . kind === "npx" || distribution . kind === "uvx" ) {
1869- const installed = yield * installSemaphore . withPermits ( 1 ) (
1875+ const installed = yield * withInstallPermit ( agent . id ) (
18701876 ensureGlobalPackage (
18711877 agent ,
18721878 distribution . kind ,
@@ -1879,7 +1885,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
18791885 commandBinDirectory = installed . binDirectory ;
18801886 } else {
18811887 const target = distribution . binaryTarget ! ;
1882- command = yield * installSemaphore . withPermits ( 1 ) (
1888+ command = yield * withInstallPermit ( agent . id ) (
18831889 installBinary ( agent , target ) . pipe (
18841890 Effect . tap ( ( ) => consumePreparedBinaryReservation ( agent . id ) ) ,
18851891 ) ,
@@ -1912,7 +1918,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
19121918 const uninstallManagedBinary : AcpRegistryCatalog [ "Service" ] [ "uninstallManagedBinary" ] = ( input ) =>
19131919 hostSettings
19141920 . withSnapshot ( ( settings ) =>
1915- installSemaphore . withPermits ( 1 ) (
1921+ withInstallPermit ( input . agentId ) (
19161922 Effect . gen ( function * ( ) {
19171923 const safeAgentId = yield * decodeBoundedAgentId ( input . agentId ) . pipe (
19181924 Effect . mapError (
0 commit comments