This PR reworks `assess_command_safety()` so that the combination of `AskForApproval::Never` and `SandboxPolicy::DangerFullAccess` ensures that commands are run without _any_ sandbox and the user should never be prompted. In turn, it adds support for a new `--dangerously-bypass-approvals-and-sandbox` flag (that cannot be used with `--approval-policy` or `--full-auto`) that sets both of those options. Fixes https://github.com/openai/codex/issues/1254
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
use clap::Parser;
|
|
use codex_common::ApprovalModeCliArg;
|
|
use codex_common::CliConfigOverrides;
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version)]
|
|
pub struct Cli {
|
|
/// Optional user prompt to start the session.
|
|
pub prompt: Option<String>,
|
|
|
|
/// Optional image(s) to attach to the initial prompt.
|
|
#[arg(long = "image", short = 'i', value_name = "FILE", value_delimiter = ',', num_args = 1..)]
|
|
pub images: Vec<PathBuf>,
|
|
|
|
/// Model the agent should use.
|
|
#[arg(long, short = 'm')]
|
|
pub model: Option<String>,
|
|
|
|
/// Configuration profile from config.toml to specify default options.
|
|
#[arg(long = "profile", short = 'p')]
|
|
pub config_profile: Option<String>,
|
|
|
|
/// Configure when the model requires human approval before executing a command.
|
|
#[arg(long = "ask-for-approval", short = 'a')]
|
|
pub approval_policy: Option<ApprovalModeCliArg>,
|
|
|
|
/// Convenience alias for low-friction sandboxed automatic execution (-a on-failure, -c sandbox.mode=workspace-write).
|
|
#[arg(long = "full-auto", default_value_t = false)]
|
|
pub full_auto: bool,
|
|
|
|
/// Skip all confirmation prompts and execute commands without sandboxing.
|
|
/// EXTREMELY DANGEROUS. Intended solely for running in environments that are externally sandboxed.
|
|
#[arg(
|
|
long = "dangerously-bypass-approvals-and-sandbox",
|
|
default_value_t = false,
|
|
conflicts_with_all = ["approval_policy", "full_auto"]
|
|
)]
|
|
pub dangerously_bypass_approvals_and_sandbox: bool,
|
|
|
|
/// Tell the agent to use the specified directory as its working root.
|
|
#[clap(long = "cd", short = 'C', value_name = "DIR")]
|
|
pub cwd: Option<PathBuf>,
|
|
|
|
/// Allow running Codex outside a Git repository.
|
|
#[arg(long = "skip-git-repo-check", default_value_t = false)]
|
|
pub skip_git_repo_check: bool,
|
|
|
|
#[clap(skip)]
|
|
pub config_overrides: CliConfigOverrides,
|
|
}
|