mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
fix(task): respect agent task permission for nested sub-agents (#8111)
This commit is contained in:
committed by
GitHub
parent
20088a87b0
commit
5d37e58d34
@@ -56,6 +56,9 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
||||
|
||||
const agent = await Agent.get(params.subagent_type)
|
||||
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
|
||||
|
||||
const hasTaskPermission = agent.permission.some((rule) => rule.permission === "task")
|
||||
|
||||
const session = await iife(async () => {
|
||||
if (params.session_id) {
|
||||
const found = await Session.get(params.session_id).catch(() => {})
|
||||
@@ -76,11 +79,15 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
||||
pattern: "*",
|
||||
action: "deny",
|
||||
},
|
||||
{
|
||||
permission: "task",
|
||||
pattern: "*",
|
||||
action: "deny",
|
||||
},
|
||||
...(hasTaskPermission
|
||||
? []
|
||||
: [
|
||||
{
|
||||
permission: "task" as const,
|
||||
pattern: "*" as const,
|
||||
action: "deny" as const,
|
||||
},
|
||||
]),
|
||||
...(config.experimental?.primary_tools?.map((t) => ({
|
||||
pattern: "*",
|
||||
action: "allow" as const,
|
||||
@@ -146,7 +153,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
||||
tools: {
|
||||
todowrite: false,
|
||||
todoread: false,
|
||||
task: false,
|
||||
...(hasTaskPermission ? {} : { task: false }),
|
||||
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
|
||||
},
|
||||
parts: promptParts,
|
||||
|
||||
Reference in New Issue
Block a user