@@ -651,7 +651,13 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
651651 const platform = yield * HostProcess . Platform ;
652652 const architecture = yield * HostProcess . Architecture ;
653653 const hostEnvironment = yield * HostProcess . Environment ;
654- const resolveExecutable = yield * SpawnExecutableResolution ;
654+ const executableResolver = yield * SpawnExecutableResolution ;
655+ const resolveExecutable = Effect . fn ( "AcpRegistryCatalog.resolveExecutable" ) ( function * (
656+ command : string ,
657+ environment : NodeJS . ProcessEnv ,
658+ ) {
659+ return yield * Effect . promise ( async ( ) => executableResolver ( command , platform , environment ) ) ;
660+ } ) ;
655661 const platformTarget = resolveAcpRegistryPlatformTarget ( platform , architecture ) ;
656662 const registryUrl = input . registryUrl ?? ACP_REGISTRY_URL ;
657663 const registryDirectory = path . join ( input . cacheDir , "acp-registry" ) ;
@@ -1154,9 +1160,8 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
11541160 const commandName = npmCommandName ( agent , packageIdentity . name , manifest . value ) ;
11551161 if ( commandName === undefined ) return Option . none < AcpRegistryPackageInstallReceipt > ( ) ;
11561162 const binDirectory = platform === "win32" ? globalPrefix : path . join ( globalPrefix , "bin" ) ;
1157- const executablePath = resolveExecutable (
1163+ const executablePath = yield * resolveExecutable (
11581164 commandName ,
1159- platform ,
11601165 withPreferredPath ( environment , binDirectory , platform ) ,
11611166 ) ;
11621167 return executablePath === undefined
@@ -1203,9 +1208,11 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
12031208 truncatedOutputReason : "install_failed" ,
12041209 } ) . pipe ( Effect . flatMap ( ( output ) => parsePackageManagerPath ( managerPath , output ) ) ) ;
12051210 const commandEnvironment = withPreferredPath ( environment , binDirectory , platform ) ;
1206- const executablePath = packageCommandCandidates ( agent , packageIdentity . name )
1207- . map ( ( candidate ) => resolveExecutable ( candidate , platform , commandEnvironment ) )
1208- . find ( ( candidate ) : candidate is string => candidate !== undefined ) ;
1211+ let executablePath : string | undefined ;
1212+ for ( const candidate of packageCommandCandidates ( agent , packageIdentity . name ) ) {
1213+ executablePath = yield * resolveExecutable ( candidate , commandEnvironment ) ;
1214+ if ( executablePath !== undefined ) break ;
1215+ }
12091216 return executablePath === undefined
12101217 ? Option . none < AcpRegistryPackageInstallReceipt > ( )
12111218 : Option . some < AcpRegistryPackageInstallReceipt > ( {
@@ -1228,7 +1235,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
12281235 environment : NodeJS . ProcessEnv ,
12291236 ) {
12301237 const managerName = packageManagerFor ( distribution ) ! ;
1231- const managerPath = resolveExecutable ( managerName , platform , environment ) ;
1238+ const managerPath = yield * resolveExecutable ( managerName , environment ) ;
12321239 if ( managerPath === undefined ) {
12331240 return yield * new AcpRegistryError ( {
12341241 reason : "runner_unavailable" ,
@@ -1629,22 +1636,27 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
16291636 const search : AcpRegistryCatalog [ "Service" ] [ "search" ] = Effect . fn ( "AcpRegistryCatalog.search" ) (
16301637 function * ( input ) {
16311638 const registry = yield * recentRegistry ( ) ;
1632- const ranked = registry . agents . flatMap ( ( agent ) => {
1639+ const ranked = [ ] ;
1640+ const managerAvailability = new Map < string , boolean > ( ) ;
1641+ for ( const agent of registry . agents ) {
16331642 const distribution = resolveAcpRegistryDistribution ( {
16341643 agent,
16351644 preference : "auto" ,
16361645 platformTarget,
16371646 } ) ;
16381647 const rank = searchRank ( agent , input . query ) ;
1639- const packageManager =
1640- distribution === undefined ? undefined : packageManagerFor ( distribution . kind ) ;
1641- const packageManagerAvailable =
1642- packageManager === undefined ||
1643- resolveExecutable ( packageManager , platform , hostEnvironment ) !== undefined ;
1644- return distribution === undefined || rank === undefined || ! packageManagerAvailable
1645- ? [ ]
1646- : [ { agent, distribution, rank } ] ;
1647- } ) ;
1648+ if ( distribution === undefined || rank === undefined ) continue ;
1649+ const packageManager = packageManagerFor ( distribution . kind ) ;
1650+ if ( packageManager !== undefined ) {
1651+ let available = managerAvailability . get ( packageManager ) ;
1652+ if ( available === undefined ) {
1653+ available = ( yield * resolveExecutable ( packageManager , hostEnvironment ) ) !== undefined ;
1654+ managerAvailability . set ( packageManager , available ) ;
1655+ }
1656+ if ( ! available ) continue ;
1657+ }
1658+ ranked . push ( { agent, distribution, rank } ) ;
1659+ }
16481660 ranked . sort (
16491661 ( left , right ) =>
16501662 left . rank - right . rank ||
@@ -1715,7 +1727,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
17151727 if ( settings . source === "local" ) {
17161728 const command = settings . commandPath . trim ( ) ;
17171729 if ( ! command ) return { status : "unconfigured" } as const ;
1718- const executable = resolveExecutable ( command , platform , environment ?? hostEnvironment ) ;
1730+ const executable = yield * resolveExecutable ( command , environment ?? hostEnvironment ) ;
17191731 if ( executable !== undefined ) yield * validateLocalExecutable ( executable ) ;
17201732 return executable === undefined
17211733 ? ( {
@@ -1743,8 +1755,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
17431755 const commandOverride = settings . commandPath . trim ( ) ;
17441756 if ( commandOverride . length > 0 ) {
17451757 const available =
1746- resolveExecutable ( commandOverride , platform , environment ?? hostEnvironment ) !==
1747- undefined ;
1758+ ( yield * resolveExecutable ( commandOverride , environment ?? hostEnvironment ) ) !== undefined ;
17481759 return available
17491760 ? ( {
17501761 status : "ready" ,
@@ -1805,7 +1816,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
18051816
18061817 const runner = packageManagerFor ( distribution . kind ) ! ;
18071818 const available =
1808- resolveExecutable ( runner , platform , environment ?? hostEnvironment ) !== undefined ;
1819+ ( yield * resolveExecutable ( runner , environment ?? hostEnvironment ) ) !== undefined ;
18091820 return available
18101821 ? ( {
18111822 status : "ready" ,
@@ -1835,7 +1846,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
18351846 } ) ;
18361847 }
18371848 const env = environment ?? hostEnvironment ;
1838- const command = resolveExecutable ( executable , platform , env ) ;
1849+ const command = yield * resolveExecutable ( executable , env ) ;
18391850 if ( command === undefined ) {
18401851 return yield * new AcpRegistryError ( {
18411852 reason : "runner_unavailable" ,
@@ -1865,7 +1876,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
18651876 const effectiveEnvironment = environment ?? hostEnvironment ;
18661877 const commandOverride = settings . commandPath . trim ( ) ;
18671878 if ( commandOverride . length > 0 ) {
1868- const resolvedOverride = resolveExecutable ( commandOverride , platform , effectiveEnvironment ) ;
1879+ const resolvedOverride = yield * resolveExecutable ( commandOverride , effectiveEnvironment ) ;
18691880 if ( resolvedOverride === undefined ) {
18701881 return yield * new AcpRegistryError ( {
18711882 reason : "runner_unavailable" ,
0 commit comments