@@ -446,3 +446,66 @@ test("legacy tools config maps write/edit/patch/multiedit to edit permission", a
446446 } ,
447447 } )
448448} )
449+
450+ test ( "Truncate.DIR is allowed even when user denies external_directory globally" , async ( ) => {
451+ const { Truncate } = await import ( "../../src/tool/truncation" )
452+ await using tmp = await tmpdir ( {
453+ config : {
454+ permission : {
455+ external_directory : "deny" ,
456+ } ,
457+ } ,
458+ } )
459+ await Instance . provide ( {
460+ directory : tmp . path ,
461+ fn : async ( ) => {
462+ const build = await Agent . get ( "build" )
463+ expect ( PermissionNext . evaluate ( "external_directory" , Truncate . DIR , build ! . permission ) . action ) . toBe ( "allow" )
464+ expect ( PermissionNext . evaluate ( "external_directory" , "/some/other/path" , build ! . permission ) . action ) . toBe ( "deny" )
465+ } ,
466+ } )
467+ } )
468+
469+ test ( "Truncate.DIR is allowed even when user denies external_directory per-agent" , async ( ) => {
470+ const { Truncate } = await import ( "../../src/tool/truncation" )
471+ await using tmp = await tmpdir ( {
472+ config : {
473+ agent : {
474+ build : {
475+ permission : {
476+ external_directory : "deny" ,
477+ } ,
478+ } ,
479+ } ,
480+ } ,
481+ } )
482+ await Instance . provide ( {
483+ directory : tmp . path ,
484+ fn : async ( ) => {
485+ const build = await Agent . get ( "build" )
486+ expect ( PermissionNext . evaluate ( "external_directory" , Truncate . DIR , build ! . permission ) . action ) . toBe ( "allow" )
487+ expect ( PermissionNext . evaluate ( "external_directory" , "/some/other/path" , build ! . permission ) . action ) . toBe ( "deny" )
488+ } ,
489+ } )
490+ } )
491+
492+ test ( "explicit Truncate.DIR deny is respected" , async ( ) => {
493+ const { Truncate } = await import ( "../../src/tool/truncation" )
494+ await using tmp = await tmpdir ( {
495+ config : {
496+ permission : {
497+ external_directory : {
498+ "*" : "deny" ,
499+ [ Truncate . DIR ] : "deny" ,
500+ } ,
501+ } ,
502+ } ,
503+ } )
504+ await Instance . provide ( {
505+ directory : tmp . path ,
506+ fn : async ( ) => {
507+ const build = await Agent . get ( "build" )
508+ expect ( PermissionNext . evaluate ( "external_directory" , Truncate . DIR , build ! . permission ) . action ) . toBe ( "deny" )
509+ } ,
510+ } )
511+ } )
0 commit comments