2026-02-08 16:25:25 +09:00
|
|
|
import type { OhMyOpenCodeConfig } from "../config";
|
2026-02-16 20:42:58 +09:00
|
|
|
import { getAgentDisplayName } from "../shared/agent-display-names";
|
2026-02-08 16:25:25 +09:00
|
|
|
|
|
|
|
|
type AgentWithPermission = { permission?: Record<string, unknown> };
|
|
|
|
|
|
2026-02-16 20:42:58 +09:00
|
|
|
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
|
|
|
|
|
return agentResult[getAgentDisplayName(key)] as AgentWithPermission | undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-08 16:25:25 +09:00
|
|
|
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";
|
|
|
|
|
|
2026-02-16 20:42:58 +09:00
|
|
|
const librarian = agentByKey(params.agentResult, "librarian");
|
|
|
|
|
if (librarian) {
|
|
|
|
|
librarian.permission = { ...librarian.permission, "grep_app_*": "allow" };
|
2026-02-08 16:25:25 +09:00
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const looker = agentByKey(params.agentResult, "multimodal-looker");
|
|
|
|
|
if (looker) {
|
|
|
|
|
looker.permission = { ...looker.permission, task: "deny", look_at: "deny" };
|
2026-02-08 16:25:25 +09:00
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const atlas = agentByKey(params.agentResult, "atlas");
|
|
|
|
|
if (atlas) {
|
|
|
|
|
atlas.permission = {
|
|
|
|
|
...atlas.permission,
|
2026-02-08 16:25:25 +09:00
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const sisyphus = agentByKey(params.agentResult, "sisyphus");
|
|
|
|
|
if (sisyphus) {
|
|
|
|
|
sisyphus.permission = {
|
|
|
|
|
...sisyphus.permission,
|
2026-02-08 16:25:25 +09:00
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const hephaestus = agentByKey(params.agentResult, "hephaestus");
|
|
|
|
|
if (hephaestus) {
|
|
|
|
|
hephaestus.permission = {
|
|
|
|
|
...hephaestus.permission,
|
2026-02-08 16:25:25 +09:00
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const prometheus = agentByKey(params.agentResult, "prometheus");
|
|
|
|
|
if (prometheus) {
|
|
|
|
|
prometheus.permission = {
|
|
|
|
|
...prometheus.permission,
|
2026-02-08 16:25:25 +09:00
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|
2026-02-16 20:42:58 +09:00
|
|
|
const junior = agentByKey(params.agentResult, "sisyphus-junior");
|
|
|
|
|
if (junior) {
|
|
|
|
|
junior.permission = {
|
|
|
|
|
...junior.permission,
|
2026-02-08 16:25:25 +09:00
|
|
|
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",
|
|
|
|
|
};
|
|
|
|
|
}
|