feat(cli): deny Question tool in CLI run mode
In CLI run mode there is no TUI to answer questions, so the Question tool would hang forever. This sets OPENCODE_CLI_RUN_MODE env var in runner.ts and config-handler uses it to set question permission to deny for sisyphus, hephaestus, and prometheus agents.
This commit is contained in:
parent
b71fe66a7e
commit
961ce19415
@ -77,6 +77,10 @@ export const resolveRunAgent = (
|
||||
}
|
||||
|
||||
export async function run(options: RunOptions): Promise<number> {
|
||||
// Set CLI run mode environment variable before any config loading
|
||||
// This signals to config-handler to deny Question tool (no TUI to answer)
|
||||
process.env.OPENCODE_CLI_RUN_MODE = "true"
|
||||
|
||||
const {
|
||||
message,
|
||||
directory = process.cwd(),
|
||||
|
||||
@ -409,6 +409,10 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
||||
};
|
||||
|
||||
type AgentWithPermission = { permission?: Record<string, unknown> };
|
||||
|
||||
// In CLI run mode, deny Question tool for all agents (no TUI to answer questions)
|
||||
const isCliRunMode = process.env.OPENCODE_CLI_RUN_MODE === "true";
|
||||
const questionPermission = isCliRunMode ? "deny" : "allow";
|
||||
|
||||
if (agentResult.librarian) {
|
||||
const agent = agentResult.librarian as AgentWithPermission;
|
||||
@ -424,15 +428,15 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
||||
}
|
||||
if (agentResult.sisyphus) {
|
||||
const agent = agentResult.sisyphus as AgentWithPermission;
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow", "task_*": "allow", teammate: "allow" };
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission, "task_*": "allow", teammate: "allow" };
|
||||
}
|
||||
if (agentResult.hephaestus) {
|
||||
const agent = agentResult.hephaestus as AgentWithPermission;
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow" };
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission };
|
||||
}
|
||||
if (agentResult["prometheus"]) {
|
||||
const agent = agentResult["prometheus"] as AgentWithPermission;
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow", "task_*": "allow", teammate: "allow" };
|
||||
agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission, "task_*": "allow", teammate: "allow" };
|
||||
}
|
||||
if (agentResult["sisyphus-junior"]) {
|
||||
const agent = agentResult["sisyphus-junior"] as AgentWithPermission;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user