|
|
@@ -125,6 +125,24 @@ export const TaskTool = Tool.define(
|
|
|
const parentAgent = parent.agent
|
|
|
? yield* agent.get(parent.agent).pipe(Effect.catchCause(() => Effect.succeed(undefined)))
|
|
|
: undefined
|
|
|
+ const childPermission = deriveSubagentSessionPermission({
|
|
|
+ parentSessionPermission: parent.permission ?? [],
|
|
|
+ parentAgent,
|
|
|
+ subagent: next,
|
|
|
+ })
|
|
|
+ const childToolDenies = [
|
|
|
+ ...(next.permission.some((rule) => rule.permission === "todowrite")
|
|
|
+ ? []
|
|
|
+ : [{ permission: "todowrite" as const, pattern: "*" as const, action: "deny" as const }]),
|
|
|
+ ...(next.permission.some((rule) => rule.permission === id)
|
|
|
+ ? []
|
|
|
+ : [{ permission: id, pattern: "*" as const, action: "deny" as const }]),
|
|
|
+ ...(cfg.experimental?.primary_tools?.map((permission) => ({
|
|
|
+ permission,
|
|
|
+ pattern: "*" as const,
|
|
|
+ action: "deny" as const,
|
|
|
+ })) ?? []),
|
|
|
+ ]
|
|
|
const nextSession =
|
|
|
session ??
|
|
|
(yield* sessions.create({
|
|
|
@@ -132,16 +150,14 @@ export const TaskTool = Tool.define(
|
|
|
title: params.description + ` (@${next.name} subagent)`,
|
|
|
agent: next.name,
|
|
|
permission: [
|
|
|
- ...deriveSubagentSessionPermission({
|
|
|
- parentSessionPermission: parent.permission ?? [],
|
|
|
- parentAgent,
|
|
|
- subagent: next,
|
|
|
- }),
|
|
|
- ...(cfg.experimental?.primary_tools?.map((item) => ({
|
|
|
- pattern: "*",
|
|
|
- action: "allow" as const,
|
|
|
- permission: item,
|
|
|
- })) ?? []),
|
|
|
+ ...childPermission,
|
|
|
+ ...childToolDenies.filter(
|
|
|
+ (deny) =>
|
|
|
+ !childPermission.some(
|
|
|
+ (rule) =>
|
|
|
+ rule.permission === deny.permission && rule.pattern === deny.pattern && rule.action === deny.action,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
],
|
|
|
}))
|
|
|
|
|
|
@@ -182,11 +198,6 @@ export const TaskTool = Tool.define(
|
|
|
},
|
|
|
variant: next.model ? undefined : variant,
|
|
|
agent: next.name,
|
|
|
- tools: {
|
|
|
- ...(next.permission.some((rule) => rule.permission === "todowrite") ? {} : { todowrite: false }),
|
|
|
- ...(next.permission.some((rule) => rule.permission === id) ? {} : { task: false }),
|
|
|
- ...Object.fromEntries((cfg.experimental?.primary_tools ?? []).map((item) => [item, false])),
|
|
|
- },
|
|
|
parts,
|
|
|
})
|
|
|
return result.parts.findLast((item) => item.type === "text")?.text ?? ""
|