@@ -10,6 +10,7 @@ import { Instance } from "../project/instance"
1010import { Provider } from "../provider/provider"
1111import { Identifier } from "../id/id"
1212import { Permission } from "../permission"
13+ import { Agent } from "@/agent/agent"
1314
1415const DEFAULT_READ_LIMIT = 2000
1516const MAX_LINE_LENGTH = 2000
@@ -27,21 +28,24 @@ export const ReadTool = Tool.define("read", {
2728 filepath = path . join ( process . cwd ( ) , filepath )
2829 }
2930 const title = path . relative ( Instance . worktree , filepath )
31+ const agent = await Agent . get ( ctx . agent )
3032
3133 if ( ! ctx . extra ?. [ "bypassCwdCheck" ] && ! Filesystem . contains ( Instance . directory , filepath ) ) {
3234 const parentDir = path . dirname ( filepath )
33- await Permission . ask ( {
34- type : "external-directory" ,
35- pattern : parentDir ,
36- sessionID : ctx . sessionID ,
37- messageID : ctx . messageID ,
38- callID : ctx . callID ,
39- title : `Access file outside working directory: ${ filepath } ` ,
40- metadata : {
41- filepath,
42- parentDir,
43- } ,
44- } )
35+ if ( agent . permission . external_directory === "ask" ) {
36+ await Permission . ask ( {
37+ type : "external_directory" ,
38+ pattern : parentDir ,
39+ sessionID : ctx . sessionID ,
40+ messageID : ctx . messageID ,
41+ callID : ctx . callID ,
42+ title : `Access file outside working directory: ${ filepath } ` ,
43+ metadata : {
44+ filepath,
45+ parentDir,
46+ } ,
47+ } )
48+ }
4549 }
4650
4751 const file = Bun . file ( filepath )
0 commit comments