fix(task): respect agent permission config for todowrite tool (#19125)
This commit is contained in:
@@ -64,6 +64,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
|||||||
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent 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 hasTaskPermission = agent.permission.some((rule) => rule.permission === "task")
|
||||||
|
const hasTodoWritePermission = agent.permission.some((rule) => rule.permission === "todowrite")
|
||||||
|
|
||||||
const session = await iife(async () => {
|
const session = await iife(async () => {
|
||||||
if (params.task_id) {
|
if (params.task_id) {
|
||||||
@@ -75,11 +76,15 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
|||||||
parentID: ctx.sessionID,
|
parentID: ctx.sessionID,
|
||||||
title: params.description + ` (@${agent.name} subagent)`,
|
title: params.description + ` (@${agent.name} subagent)`,
|
||||||
permission: [
|
permission: [
|
||||||
{
|
...(hasTodoWritePermission
|
||||||
permission: "todowrite",
|
? []
|
||||||
pattern: "*",
|
: [
|
||||||
action: "deny",
|
{
|
||||||
},
|
permission: "todowrite" as const,
|
||||||
|
pattern: "*" as const,
|
||||||
|
action: "deny" as const,
|
||||||
|
},
|
||||||
|
]),
|
||||||
...(hasTaskPermission
|
...(hasTaskPermission
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
@@ -131,7 +136,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
|
|||||||
},
|
},
|
||||||
agent: agent.name,
|
agent: agent.name,
|
||||||
tools: {
|
tools: {
|
||||||
todowrite: false,
|
...(hasTodoWritePermission ? {} : { todowrite: false }),
|
||||||
...(hasTaskPermission ? {} : { task: false }),
|
...(hasTaskPermission ? {} : { task: false }),
|
||||||
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
|
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user