import type { Plugin } from "@opencode/plugin"; import { TASK_AGENT, TASK_READER_AGENT } from "../src/runtime/task-agent-policy.js"; import { queryMcpToolId } from "../src/runtime/product-mcp-tools.js"; export const AGENT_MESSAGE_TOOLS = [ queryMcpToolId("list_investigation_tasks"), queryMcpToolId("get_investigation_task"), "send_task_message", queryMcpToolId("read_agent_messages"), "reply_agent_message", ] as const; // Catalog filtering complements the static profiles. The authenticated internal // bridge is authoritative for purpose, actor, project, run and thread ownership. export async function registerAgentMessagePolicy(ctx: Parameters[0]) { await ctx.session.hook("context", async (event) => { const denied = event.agent === TASK_READER_AGENT ? AGENT_MESSAGE_TOOLS : event.agent === TASK_AGENT ? AGENT_MESSAGE_TOOLS.slice(0, 3) : []; for (const name of denied) delete event.tools[name]; }); }