Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/opencode/src/tool/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { iife } from "@/util/iife"
import { defer } from "@/util/defer"
import { Config } from "../config/config"
import { PermissionNext } from "@/permission/next"
import { MCP } from "../mcp"

const parameters = z.object({
description: z.string().describe("A short (3-5 words) description of the task"),
Expand Down Expand Up @@ -69,6 +70,8 @@ export const TaskTool = Tool.define("task", async (ctx) => {
if (found) return found
}

const mcpTools = Object.keys(await MCP.tools())

return await Session.create({
parentID: ctx.sessionID,
title: params.description + ` (@${agent.name} subagent)`,
Expand Down Expand Up @@ -97,6 +100,11 @@ export const TaskTool = Tool.define("task", async (ctx) => {
action: "allow" as const,
permission: t,
})) ?? []),
...mcpTools.map((t) => ({
pattern: "*",
action: "allow" as const,
permission: t,
})),
],
})
})
Expand Down Expand Up @@ -124,6 +132,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
ctx.abort.addEventListener("abort", cancel)
using _ = defer(() => ctx.abort.removeEventListener("abort", cancel))
const promptParts = await SessionPrompt.resolvePromptParts(params.prompt)
const mcpTools = Object.keys(await MCP.tools())

const result = await SessionPrompt.prompt({
messageID,
Expand All @@ -138,6 +147,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
todoread: false,
...(hasTaskPermission ? {} : { task: false }),
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
...Object.fromEntries(mcpTools.map((t) => [t, false])),
},
parts: promptParts,
})
Expand Down
Loading