sandbox: runtime /sandbox toggle, sandbox.claude config, --no-claude-sandbox

This commit is contained in:
hermes committed 2026-11-02 12:28:52 +00:00
1 parent d1bfa22580
commit a0cd7946c3
5 files changed
+102 -12

No files matched your search

+13 -1
View File
@@ -45,6 +45,9 @@ struct Cli {
/// Force the sandbox off (overrides config).
#[arg(long)]
no_sandbox: bool,
/// Run `claude` unconfined even when the sandbox is on (overrides config).
#[arg(long)]
no_claude_sandbox: bool,
/// Output mode: text (default for -p), json (NDJSON events on stdout; needs -p), rpc (JSON-RPC on stdio).
#[arg(long, value_enum, default_value_t = Mode::Text)]
mode: Mode,
@@ -317,7 +320,10 @@ fn claude_extra(bin: &str) -> hx_core::sandbox::Extra {
/// The `claude` command: sandboxed when the sandbox is on, unless the user let it out.
async fn claude_command(bin: String) -> tokio::process::Command {
if hx_core::sandbox::active().is_none() || claude_outside().await {
if hx_core::sandbox::active().is_none()
|| !hx_core::sandbox::claude_sandboxed()
|| claude_outside().await
{
return tokio::process::Command::new(bin);
}
hx_core::sandbox::command_with(&bin, &claude_extra(&bin))
@@ -771,7 +777,13 @@ async fn main() -> Result<()> {
if cli.no_sandbox {
sb.mode = hx_core::sandbox::Mode::Off;
}
if cli.no_claude_sandbox {
sb.claude = false;
}
hx_core::sandbox::init(&sb, &cwd).map_err(anyhow::Error::msg)?;
if sb.mode == hx_core::sandbox::Mode::On && !sb.claude {
eprintln!("hx: sandbox on, but claude runs unconfined (sandbox.claude = false)");
}
if let Some(oc) = cfg.openai_compat.clone() {
let _ = COMPAT.set(oc);
}