2026-02-08 16:25:25 +09:00
|
|
|
import type { OhMyOpenCodeConfig } from "../config";
|
|
|
|
|
|
|
|
|
|
type AgentWithPermission = { permission?: Record<string, unknown> };
|
|
|
|
|
|
|
|
|
|
export function applyToolConfig(params: {
|
|
|
|
|
config: Record<string, unknown>;
|
|
|
|
|
pluginConfig: OhMyOpenCodeConfig;
|
|
|
|
|
agentResult: Record<string, unknown>;
|
|
|
|
|
}): void {
|
2026-02-08 17:34:47 +09:00
|
|
|
const denyTodoTools = params.pluginConfig.experimental?.task_system
|
|
|
|
|
? { todowrite: "deny", todoread: "deny" }
|
|
|
|
|
: {}
|
|
|
|
|
|
2026-02-08 16:25:25 +09:00
|
|
|
params.config.tools = {
|
|
|
|
|
...(params.config.tools as Record<string, unknown>),
|
|
|
|
|
"grep_app_*": false,
|
|
|
|
|
LspHover: false,
|
|
|
|
|
LspCodeActions: false,
|
|
|
|
|
LspCodeActionResolve: false,
|
|
|
|
|
"task_*": false,
|
|
|
|
|
teammate: false,
|
|
|
|
|
...(params.pluginConfig.experimental?.task_system
|
|
|
|
|
? { todowrite: false, todoread: false }
|
|
|
|
|
: {}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const isCliRunMode = process.env.OPENCODE_CLI_RUN_MODE === "true";
|
|
|
|
|
const questionPermission = isCliRunMode ? "deny" : "allow";
|
|
|
|
|
|
|
|
|
|
if (params.agentResult.librarian) {
|
|
|
|
|
const agent = params.agentResult.librarian as AgentWithPermission;
|
|
|
|
|
agent.permission = { ...agent.permission, "grep_app_*": "allow" };
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult["multimodal-looker"]) {
|
|
|
|
|
const agent = params.agentResult["multimodal-looker"] as AgentWithPermission;
|
|
|
|
|
agent.permission = { ...agent.permission, task: "deny", look_at: "deny" };
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult["atlas"]) {
|
|
|
|
|
const agent = params.agentResult["atlas"] as AgentWithPermission;
|
|
|
|
|
agent.permission = {
|
|
|
|
|
...agent.permission,
|
|
|
|
|
task: "allow",
|
|
|
|
|
call_omo_agent: "deny",
|
|
|
|
|
"task_*": "allow",
|
|
|
|
|
teammate: "allow",
|
2026-02-08 17:34:47 +09:00
|
|
|
...denyTodoTools,
|
2026-02-08 16:25:25 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult.sisyphus) {
|
|
|
|
|
const agent = params.agentResult.sisyphus as AgentWithPermission;
|
|
|
|
|
agent.permission = {
|
|
|
|
|
...agent.permission,
|
|
|
|
|
call_omo_agent: "deny",
|
|
|
|
|
task: "allow",
|
|
|
|
|
question: questionPermission,
|
|
|
|
|
"task_*": "allow",
|
|
|
|
|
teammate: "allow",
|
2026-02-08 17:34:47 +09:00
|
|
|
...denyTodoTools,
|
2026-02-08 16:25:25 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult.hephaestus) {
|
|
|
|
|
const agent = params.agentResult.hephaestus as AgentWithPermission;
|
|
|
|
|
agent.permission = {
|
|
|
|
|
...agent.permission,
|
|
|
|
|
call_omo_agent: "deny",
|
|
|
|
|
task: "allow",
|
|
|
|
|
question: questionPermission,
|
2026-02-08 17:34:47 +09:00
|
|
|
...denyTodoTools,
|
2026-02-08 16:25:25 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult["prometheus"]) {
|
|
|
|
|
const agent = params.agentResult["prometheus"] as AgentWithPermission;
|
|
|
|
|
agent.permission = {
|
|
|
|
|
...agent.permission,
|
|
|
|
|
call_omo_agent: "deny",
|
|
|
|
|
task: "allow",
|
|
|
|
|
question: questionPermission,
|
|
|
|
|
"task_*": "allow",
|
|
|
|
|
teammate: "allow",
|
2026-02-08 17:34:47 +09:00
|
|
|
...denyTodoTools,
|
2026-02-08 16:25:25 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (params.agentResult["sisyphus-junior"]) {
|
|
|
|
|
const agent = params.agentResult["sisyphus-junior"] as AgentWithPermission;
|
|
|
|
|
agent.permission = {
|
|
|
|
|
...agent.permission,
|
|
|
|
|
task: "allow",
|
|
|
|
|
"task_*": "allow",
|
|
|
|
|
teammate: "allow",
|
2026-02-08 17:34:47 +09:00
|
|
|
...denyTodoTools,
|
2026-02-08 16:25:25 +09:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
params.config.permission = {
|
|
|
|
|
...(params.config.permission as Record<string, unknown>),
|
|
|
|
|
webfetch: "allow",
|
|
|
|
|
external_directory: "allow",
|
|
|
|
|
task: "deny",
|
|
|
|
|
};
|
|
|
|
|
}
|