permissions: auto mode refuses dangerous calls (rules + cheap-model judge)
This commit is contained in:
1 parent
63b286efaf
commit
02144d4176
11 files changed
+791
-30
No files matched your search
@@ -9,7 +9,7 @@
|
||||
# remember_model = true # reuse the last model picked with /model or /provider
|
||||
# compact_at = 900000 # auto-compact at this many tokens; default: 90% of the context window
|
||||
# max_tokens = 16384
|
||||
# permissions = "ask" # ask | yolo (bash/write/edit run without a prompt)
|
||||
# permissions = "ask" # ask | auto (refuse dangerous calls, run safe ones) | yolo (nothing asks)
|
||||
# mouse = true # wheel scrolling; false keeps terminal text selection
|
||||
# codemode = false # `codemode` tool: JS scripts that call other tools in a sandbox
|
||||
# system_prompt = "..." # replaces the built-in prompt; AGENTS.md is still appended
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user