@@ -372,6 +372,45 @@ describe("openshell backend manager", () => {
372372 renameSpy . mockRestore ( ) ;
373373 }
374374 } ) ;
375+
376+ it ( "drops non-directory materialized sandbox skills from mirror downloads" , async ( ) => {
377+ const workspaceDir = await makeTempDir ( "openclaw-openshell-workspace-" ) ;
378+ cliMocks . runOpenShellCli . mockImplementation ( async ( { args } : { args : string [ ] } ) => {
379+ if ( args [ 0 ] === "sandbox" && args [ 1 ] === "download" ) {
380+ const tmpDir = args [ 4 ] ;
381+ await fs . writeFile ( path . join ( tmpDir , "from-remote.txt" ) , "remote" , "utf8" ) ;
382+ await fs . mkdir ( path . join ( tmpDir , ".openclaw" ) , { recursive : true } ) ;
383+ await fs . writeFile ( path . join ( tmpDir , ".openclaw" , "sandbox-skills" ) , "poison" , "utf8" ) ;
384+ }
385+ return { code : 0 , stdout : "" , stderr : "" } ;
386+ } ) ;
387+
388+ const factory = createOpenShellSandboxBackendFactory ( {
389+ pluginConfig : resolveOpenShellPluginConfig ( {
390+ command : "openshell" ,
391+ mode : "mirror" ,
392+ } ) ,
393+ } ) ;
394+ const backend = await factory ( {
395+ sessionKey : "agent:main:turn" ,
396+ scopeKey : "agent:main" ,
397+ workspaceDir,
398+ agentWorkspaceDir : workspaceDir ,
399+ cfg : createOpenShellBackendSandboxConfig ( ) ,
400+ } ) ;
401+
402+ await backend . finalizeExec ?.( {
403+ status : "completed" ,
404+ exitCode : 0 ,
405+ timedOut : false ,
406+ token : undefined ,
407+ } ) ;
408+
409+ await expect ( fs . readFile ( path . join ( workspaceDir , "from-remote.txt" ) , "utf8" ) ) . resolves . toBe (
410+ "remote" ,
411+ ) ;
412+ await expectPathMissing ( path . join ( workspaceDir , ".openclaw" , "sandbox-skills" ) ) ;
413+ } ) ;
375414} ) ;
376415
377416const tempDirs : string [ ] = [ ] ;
0 commit comments