@@ -839,6 +839,72 @@ describe("AcpRegistrySupport", () => {
839839 ) ;
840840 } ) ;
841841
842+ it . effect . skipIf ( HostProcess . Platform . defaultValue ( ) === "win32" ) (
843+ "leaves the mode of a file outside the install root when the command links to it" ,
844+ ( ) => {
845+ const downloadUrl = "https://registry.test/agent.tar.gz" ;
846+ const agent = makeAgent ( {
847+ binary : { "linux-x86_64" : { archive : downloadUrl , cmd : "./agent" } } ,
848+ } ) ;
849+ return Effect . gen ( function * ( ) {
850+ const fileSystem = yield * FileSystem . FileSystem ;
851+ const cacheDir = yield * fileSystem . makeTempDirectoryScoped ( {
852+ prefix : "t3-acp-outside-link-" ,
853+ } ) ;
854+ const outsideFile = `${ cacheDir } /outside` ;
855+ yield * fileSystem . writeFileString ( outsideFile , "private\n" ) ;
856+ yield * fileSystem . chmod ( outsideFile , 0o600 ) ;
857+ const source = `${ cacheDir } /source` ;
858+ yield * fileSystem . makeDirectory ( source ) ;
859+ yield * fileSystem . symlink ( outsideFile , `${ source } /agent` ) ;
860+ const archivePath = `${ cacheDir } /agent.tar.gz` ;
861+ const spawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
862+ const tar = yield * spawner . spawn (
863+ ChildProcess . make ( "tar" , [ "-czf" , archivePath , "-C" , source , "agent" ] ) ,
864+ ) ;
865+ expect ( yield * tar . exitCode ) . toBe ( 0 ) ;
866+ const archive = yield * fileSystem . readFile ( archivePath ) ;
867+ const resolver = yield * AcpRegistrySupport . makeAcpRegistryCatalog ( {
868+ cacheDir,
869+ toolsDir : `${ cacheDir } /tools` ,
870+ registryUrl,
871+ } ) . pipe (
872+ Effect . provideService (
873+ HttpClient . HttpClient ,
874+ HttpClient . make ( ( request ) =>
875+ Effect . succeed (
876+ HttpClientResponse . fromWeb (
877+ request ,
878+ request . url === registryUrl
879+ ? new Response ( makeRegistry ( agent ) )
880+ : new Response ( archive ) ,
881+ ) ,
882+ ) ,
883+ ) ,
884+ ) ,
885+ ) ;
886+
887+ const error = yield * resolver . prepare ( { agentId : agent . id } ) . pipe ( Effect . flip ) ;
888+
889+ expect ( error . reason ) . toBe ( "archive_invalid" ) ;
890+ expect ( ( yield * fileSystem . stat ( outsideFile ) ) . mode & 0o777 ) . toBe ( 0o600 ) ;
891+ } ) . pipe (
892+ Effect . scoped ,
893+ Effect . provide (
894+ Layer . mergeAll (
895+ NodeServices . layer ,
896+ NodeCrypto . layer ,
897+ TestProviderHost . layer ( ) . pipe (
898+ Layer . provide ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ,
899+ ) ,
900+ ) ,
901+ ) ,
902+ Effect . provideService ( HostProcess . Platform , "linux" ) ,
903+ Effect . provideService ( HostProcess . Architecture , "x64" ) ,
904+ ) ;
905+ } ,
906+ ) ;
907+
842908 it . effect ( "searches compatible agents with deterministic ranking and bounded metadata" , ( ) => {
843909 const exact = {
844910 ...
makeAgent ( { npx :
{ package :
"@example/[email protected] " } } ) ,
0 commit comments