Download codex-rs/cli/src/lib.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 6.15 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/cli/src/lib.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/cli/src/lib.rs
-
curl -L -o lib.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/cli/src/lib.rs
6.15 kB
| pub(crate) mod debug_sandbox; | |
| mod exit_status; | |
| pub(crate) mod login; | |
| use clap::Args; | |
| use clap::Parser; | |
| use codex_utils_absolute_path::AbsolutePathBuf; | |
| use codex_utils_cli::CliConfigOverrides; | |
| use codex_utils_cli::ProfileV2Name; | |
| use std::path::PathBuf; | |
| pub use debug_sandbox::run_command_under_landlock; | |
| pub use debug_sandbox::run_command_under_seatbelt; | |
| pub use debug_sandbox::run_command_under_windows_sandbox; | |
| pub use login::read_access_token_from_stdin; | |
| pub use login::read_api_key_from_stdin; | |
| pub use login::run_login_status; | |
| pub use login::run_login_with_access_token; | |
| pub use login::run_login_with_api_key; | |
| pub use login::run_login_with_chatgpt; | |
| pub use login::run_login_with_device_code; | |
| pub use login::run_login_with_device_code_fallback_to_browser; | |
| pub use login::run_logout; | |
| pub struct SandboxStateArgs { | |
| /// JSON value from `codex/sandbox-state-meta` to apply directly. | |
| )] | |
| pub sandbox_state_json: Option<String>, | |
| /// Add a readable root to the supplied sandbox state. Repeat for multiple roots. | |
| pub sandbox_state_readable_root: Vec<AbsolutePathBuf>, | |
| /// Disable direct network access in the supplied sandbox state. | |
| pub sandbox_state_disable_network: bool, | |
| } | |
| // These command structs share common sandbox options, but remain separate | |
| // because each host backend has a slightly different option surface. | |
| pub struct SeatbeltCommand { | |
| pub sandbox_state: SandboxStateArgs, | |
| /// Named permissions profile to apply from the active configuration stack. | |
| pub permissions_profile: Option<String>, | |
| /// Layer $CODEX_HOME/<name>.config.toml on top of the base user config. | |
| pub config_profile: Option<ProfileV2Name>, | |
| /// Working directory used for profile resolution and command execution. | |
| pub cwd: Option<PathBuf>, | |
| /// Include managed requirements while resolving an explicit permissions profile. | |
| pub include_managed_config: bool, | |
| /// Allow the sandboxed command to bind/connect AF_UNIX sockets rooted at this path. Relative paths are resolved against the current directory. Repeat to allow multiple paths. | |
| pub allow_unix_sockets: Vec<AbsolutePathBuf>, | |
| /// While the command runs, capture macOS sandbox denials via `log stream` and print them after exit | |
| pub log_denials: bool, | |
| pub config_overrides: CliConfigOverrides, | |
| /// Full command args to run under seatbelt. | |
| pub command: Vec<String>, | |
| } | |
| fn parse_absolute_path(raw: &str) -> Result<AbsolutePathBuf, String> { | |
| AbsolutePathBuf::relative_to_current_dir(raw) | |
| .map_err(|err| format!("invalid path {raw}: {err}")) | |
| } | |
| pub struct LandlockCommand { | |
| pub sandbox_state: SandboxStateArgs, | |
| /// Named permissions profile to apply from the active configuration stack. | |
| pub permissions_profile: Option<String>, | |
| /// Layer $CODEX_HOME/<name>.config.toml on top of the base user config. | |
| pub config_profile: Option<ProfileV2Name>, | |
| /// Working directory used for profile resolution and command execution. | |
| pub cwd: Option<PathBuf>, | |
| /// Include managed requirements while resolving an explicit permissions profile. | |
| pub include_managed_config: bool, | |
| pub config_overrides: CliConfigOverrides, | |
| /// Full command args to run under the Linux sandbox. | |
| pub command: Vec<String>, | |
| } | |
| pub struct WindowsCommand { | |
| pub sandbox_state: SandboxStateArgs, | |
| /// Named permissions profile to apply from the active configuration stack. | |
| pub permissions_profile: Option<String>, | |
| /// Layer $CODEX_HOME/<name>.config.toml on top of the base user config. | |
| pub config_profile: Option<ProfileV2Name>, | |
| /// Working directory used for profile resolution and command execution. | |
| pub cwd: Option<PathBuf>, | |
| /// Include managed requirements while resolving an explicit permissions profile. | |
| pub include_managed_config: bool, | |
| pub config_overrides: CliConfigOverrides, | |
| /// Full command args to run under Windows restricted token sandbox. | |
| pub command: Vec<String>, | |
| } | |