File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
packages/opencode/src/tool Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ export const TaskTool = Tool.define("task", async (ctx) => {
5656
5757 const agent = await Agent . get ( params . subagent_type )
5858 if ( ! agent ) throw new Error ( `Unknown agent type: ${ params . subagent_type } is not a valid agent type` )
59+
60+ const hasTaskPermission = agent . permission . some ( ( rule ) => rule . permission === "task" )
61+
5962 const session = await iife ( async ( ) => {
6063 if ( params . session_id ) {
6164 const found = await Session . get ( params . session_id ) . catch ( ( ) => { } )
@@ -76,11 +79,15 @@ export const TaskTool = Tool.define("task", async (ctx) => {
7679 pattern : "*" ,
7780 action : "deny" ,
7881 } ,
79- {
80- permission : "task" ,
81- pattern : "*" ,
82- action : "deny" ,
83- } ,
82+ ...( hasTaskPermission
83+ ? [ ]
84+ : [
85+ {
86+ permission : "task" as const ,
87+ pattern : "*" as const ,
88+ action : "deny" as const ,
89+ } ,
90+ ] ) ,
8491 ...( config . experimental ?. primary_tools ?. map ( ( t ) => ( {
8592 pattern : "*" ,
8693 action : "allow" as const ,
@@ -146,7 +153,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
146153 tools : {
147154 todowrite : false ,
148155 todoread : false ,
149- task : false ,
156+ ... ( hasTaskPermission ? { } : { task : false } ) ,
150157 ...Object . fromEntries ( ( config . experimental ?. primary_tools ?? [ ] ) . map ( ( t ) => [ t , false ] ) ) ,
151158 } ,
152159 parts : promptParts ,
You can’t perform that action at this time.
0 commit comments