permissions: auto mode refuses dangerous calls (rules + cheap-model judge)

This commit is contained in:
hermes committed 2026-11-12 13:44:25 +00:00
1 parent 63b286efaf
commit 02144d4176
11 files changed
+791 -30

No files matched your search

+19 -1
View File
@@ -44,6 +44,10 @@ struct Cli {
/// Skip permission prompts for bash/write/edit (also `permissions = "yolo"` in config.toml).
#[arg(long)]
yolo: bool,
/// Auto permissions: dangerous bash/write/edit calls are refused, routine ones run without a
/// prompt (also `permissions = "auto"`).
#[arg(long, conflicts_with = "yolo")]
auto: bool,
/// Run bash, LSP servers and lens runners in a sandbox (bwrap / seatbelt).
#[arg(long, conflicts_with = "no_sandbox")]
sandbox: bool,
@@ -151,7 +155,7 @@ struct Config {
remember_model: Option<bool>,
/// `/model auto`: tier pins (`fast`, `balanced`, `deep` = model ids) and `down_after`.
auto: Option<hx_core::route::Cfg>,
/// "ask" (default) or "yolo": whether bash/write/edit prompt in the TUI.
/// "ask" (default), "auto" or "yolo": whether bash/write/edit prompt in the TUI.
permissions: Option<String>,
/// Replaces the built-in system prompt (AGENTS.md etc. are still appended).
system_prompt: Option<String>,
@@ -1029,6 +1033,19 @@ async fn main() -> Result<()> {
}
agent.tools.add(task);
}
if CLAUDE_CLI.get().is_none()
&& let (Ok(p), Some(model)) = (
provider(kind),
hx_ai::models::cheap_for(kind, &models).or_else(|| Some(agent.model().to_string())),
)
{
// auto permissions: a cheap model judges the commands the rules cannot classify
let _ = agent
.cx
.state
.judge
.set(hx_core::danger::Judge { provider: p, model });
}
if cfg.codemode.unwrap_or(false) {
// snapshot after every other tool (MCP, lens, task); codemode itself is not callable inside
let cm = hx_tools::codemode::Codemode::new(&agent.tools);
@@ -1083,6 +1100,7 @@ async fn main() -> Result<()> {
specs,
open_sessions,
yolo: cli.yolo || cfg.permissions.as_deref() == Some("yolo"),
auto: cli.auto || cfg.permissions.as_deref() == Some("auto"),
mcp: mcp
.servers
.iter()