- Provider: rimossi openai, Bedrock e GCP integrati e ogni fallback a OpenAI;
restano ollama, lmstudio e i provider personalizzati. Senza provider, exec e
TUI mostrano come configurarlo.
- Chiave per provider: api_key = "keyring", provider_api_key_store =
auto|keyring|file (fallback su file 0600 / ACL Windows); `codex login
--provider <id> --with-api-key`, `logout --provider`; login status e doctor
mostrano dove sta la chiave senza rivelarla.
- Modelli letti da GET {base_url}/models; contesto da config, poi dal server
(/props, meta.n_ctx), poi 32768; apply_patch come tool function; niente tool
ospitati; niente piu' avviso "metadata not found".
- Unione dei soli messaggi system/developer iniziali in un unico system;
quelli successivi restano al loro posto come user (cache del server
preservata: turno N prefisso esatto del turno N+1).
- Modelli ausiliari (memorie, guardian-v2) = modello di sessione se il
preferito gpt-* non e' nel catalogo.
- Ricerca web: crate web-tools, backend SearXNG con web_search e web_fetch
(protezione SSRF); senza backend nessuno strumento web.
- Skill: rimossa openai-docs; skill-installer punta a git.difonzo.net.
- apply_patch accetta gli header @@ -a,b +c,d @@ dei diff unificati.
- Rimossi resti: request_plugin_install, AppsInstructions, --cyber-access-program,
URL updater/realtime predefiniti.
- Fix: importazione sessioni con provider vuoto.
- Istruzioni di sistema invariate. Test: cancellati solo quelli del codice
rimosso, test di sicurezza adattati; restano solo fallimenti d'ambiente.
- Prova reale su imeAI + SearXNG: risposta, modifica file, web_search,
cache riusata, connessioni solo verso .25 e .57.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
189 lines
5.9 KiB
Rust
189 lines
5.9 KiB
Rust
pub(crate) mod debug_sandbox;
|
|
mod exit_status;
|
|
pub mod local_config;
|
|
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_api_key_from_stdin;
|
|
pub use login::run_login_provider_api_key;
|
|
pub use login::run_login_status;
|
|
pub use login::run_login_with_api_key;
|
|
pub use login::run_logout;
|
|
pub use login::run_logout_provider;
|
|
|
|
#[derive(Debug, Default, Args)]
|
|
pub struct SandboxStateArgs {
|
|
/// Opaque JSON value from `codex/sandbox-state` to apply directly.
|
|
#[arg(
|
|
long = "sandbox-state-json",
|
|
value_name = "JSON",
|
|
conflicts_with_all = ["permissions_profile", "cwd", "include_managed_config"]
|
|
)]
|
|
pub sandbox_state_json: Option<String>,
|
|
|
|
/// Add a readable root to the supplied sandbox state. Repeat for multiple roots.
|
|
#[arg(
|
|
long,
|
|
requires = "sandbox_state_json",
|
|
value_parser = parse_absolute_path
|
|
)]
|
|
pub sandbox_state_readable_root: Vec<AbsolutePathBuf>,
|
|
|
|
/// Disable direct network access in the supplied sandbox state.
|
|
#[arg(long, requires = "sandbox_state_json", default_value_t = false)]
|
|
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.
|
|
#[derive(Debug, Parser)]
|
|
pub struct SeatbeltCommand {
|
|
#[command(flatten)]
|
|
pub sandbox_state: SandboxStateArgs,
|
|
|
|
/// Named permissions profile to apply from the active configuration stack.
|
|
#[arg(
|
|
long = "permission-profile",
|
|
alias = "permissions-profile",
|
|
short = 'P',
|
|
value_name = "NAME"
|
|
)]
|
|
pub permissions_profile: Option<String>,
|
|
|
|
/// Layer $CODEX_HOME/<name>.config.toml on top of the base user config.
|
|
#[arg(long = "profile", short = 'p')]
|
|
pub config_profile: Option<ProfileV2Name>,
|
|
|
|
/// Working directory used for profile resolution and command execution.
|
|
#[arg(
|
|
short = 'C',
|
|
long = "cd",
|
|
value_name = "DIR",
|
|
requires = "permissions_profile"
|
|
)]
|
|
pub cwd: Option<PathBuf>,
|
|
|
|
/// Include managed requirements while resolving an explicit permissions profile.
|
|
#[arg(
|
|
long = "include-managed-config",
|
|
default_value_t = false,
|
|
requires = "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.
|
|
#[arg(long = "allow-unix-socket", value_parser = parse_absolute_path)]
|
|
pub allow_unix_sockets: Vec<AbsolutePathBuf>,
|
|
|
|
/// While the command runs, capture macOS sandbox denials via `log stream` and print them after exit
|
|
#[arg(long = "log-denials", default_value_t = false)]
|
|
pub log_denials: bool,
|
|
|
|
#[clap(skip)]
|
|
pub config_overrides: CliConfigOverrides,
|
|
|
|
/// Full command args to run under seatbelt.
|
|
#[arg(trailing_var_arg = true)]
|
|
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}"))
|
|
}
|
|
|
|
#[derive(Debug, Parser)]
|
|
pub struct LandlockCommand {
|
|
#[command(flatten)]
|
|
pub sandbox_state: SandboxStateArgs,
|
|
|
|
/// Named permissions profile to apply from the active configuration stack.
|
|
#[arg(
|
|
long = "permission-profile",
|
|
alias = "permissions-profile",
|
|
short = 'P',
|
|
value_name = "NAME"
|
|
)]
|
|
pub permissions_profile: Option<String>,
|
|
|
|
/// Layer $CODEX_HOME/<name>.config.toml on top of the base user config.
|
|
#[arg(long = "profile", short = 'p')]
|
|
pub config_profile: Option<ProfileV2Name>,
|
|
|
|
/// Working directory used for profile resolution and command execution.
|
|
#[arg(
|
|
short = 'C',
|
|
long = "cd",
|
|
value_name = "DIR",
|
|
requires = "permissions_profile"
|
|
)]
|
|
pub cwd: Option<PathBuf>,
|
|
|
|
/// Include managed requirements while resolving an explicit permissions profile.
|
|
#[arg(
|
|
long = "include-managed-config",
|
|
default_value_t = false,
|
|
requires = "permissions_profile"
|
|
)]
|
|
pub include_managed_config: bool,
|
|
|
|
#[clap(skip)]
|
|
pub config_overrides: CliConfigOverrides,
|
|
|
|
/// Full command args to run under the Linux sandbox.
|
|
#[arg(trailing_var_arg = true)]
|
|
pub command: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug, Parser)]
|
|
pub struct WindowsCommand {
|
|
#[command(flatten)]
|
|
pub sandbox_state: SandboxStateArgs,
|
|
|
|
/// Named permissions profile to apply from the active configuration stack.
|
|
#[arg(
|
|
long = "permission-profile",
|
|
alias = "permissions-profile",
|
|
short = 'P',
|
|
value_name = "NAME"
|
|
)]
|
|
pub permissions_profile: Option<String>,
|
|
|
|
/// Layer $CODEX_HOME/<name>.config.toml on top of the base user config.
|
|
#[arg(long = "profile", short = 'p')]
|
|
pub config_profile: Option<ProfileV2Name>,
|
|
|
|
/// Working directory used for profile resolution and command execution.
|
|
#[arg(
|
|
short = 'C',
|
|
long = "cd",
|
|
value_name = "DIR",
|
|
requires = "permissions_profile"
|
|
)]
|
|
pub cwd: Option<PathBuf>,
|
|
|
|
/// Include managed requirements while resolving an explicit permissions profile.
|
|
#[arg(
|
|
long = "include-managed-config",
|
|
default_value_t = false,
|
|
requires = "permissions_profile"
|
|
)]
|
|
pub include_managed_config: bool,
|
|
|
|
#[clap(skip)]
|
|
pub config_overrides: CliConfigOverrides,
|
|
|
|
/// Full command args to run under Windows restricted token sandbox.
|
|
#[arg(trailing_var_arg = true)]
|
|
pub command: Vec<String>,
|
|
}
|