|
|
@@ -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,
|