Lightweight coding agent that runs in your terminal
Rust
Restore executor tool paths after login shell startup (#49467)
Adam Perry @ OpenAI76a6e55d5ac6
diff --git a/codex-rs/core/src/shell.rs b/codex-rs/core/src/shell.rsindex c253383610..da0fbbea1f 100644--- a/codex-rs/core/src/shell.rs+++ b/codex-rs/core/src/shell.rs@@ -1,5 +1,7 @@use codex_exec_server::ShellInfo;use codex_shell_command::shell_detect::DetectedShell;+use codex_utils_path_uri::PathConvention;+use codex_utils_path_uri::PathUri;use serde::Deserialize;use serde::Serialize;use std::path::PathBuf;@@ -91,6 +93,61 @@ impl ShellInvocation {ShellType::Bash | ShellType::Zsh | ShellType::Sh)}++ /// Builds launch arguments that try to restore the executor's directories to `PATH`+ /// after login startup, so `command` and its children can find them.+ ///+ /// Call this for the POSIX login shell started by Codex when the executor reports+ /// directories and the user has not explicitly configured `PATH`. The request's login+ /// mode is unchanged, even if startup makes `PATH` read-only. Returns `None` if no+ /// directories are reported or the shell or any path cannot use this setup; keep the+ /// original arguments in that case.+ pub(crate) fn derive_exec_args_with_path_prepends(+ &self,+ command: &str,+ paths: &[PathUri],+ ) -> Option<Vec<String>> {+ if !self.is_posix_login() || paths.is_empty() {+ return None;+ }+ let mut setup = Vec::with_capacity(paths.len());+ // Prepend backwards so newly added directories retain the executor's order.+ for path in paths.iter().rev() {+ if path.infer_path_convention() != Some(PathConvention::Posix) {+ return None;+ }+ let path = path.inferred_native_path_string();+ // POSIX PATH has no way to escape a colon inside a single directory.+ if path.contains(':') {+ return None;+ }+ let path = shlex::try_quote(&path).ok()?;+ // Padding `${PATH-}` with colons makes `case` match whole entries, even at the ends;+ // `-` also handles an unset PATH. Re-export a match so child commands inherit it;+ // otherwise probe in a subshell: assigning a read-only PATH can exit the login shell+ // before the user's command runs. `${PATH:+...}` adds `:` only when PATH is nonempty,+ // so we don't make the shell search the current directory.+ setup.push(format!(+ "case \":${{PATH-}}:\" in *:{path}:*) export PATH ;; \+ *) if (export PATH=) 2>/dev/null; then \+ export PATH={path}${{PATH:+:\"$PATH\"}}; fi ;; esac"+ ));+ }+ let setup = setup.join("; ");+ // Keep setup on the first input line so shell diagnostics and $LINENO still refer to+ // the original script. If the quoted path contains literal newlines, decode only the+ // setup with eval in the current shell; the trailing `esac` keeps command substitution+ // from trimming any newlines in the path.+ let setup = if setup.contains('\n') {+ let escaped = setup.replace('\\', "\\\\").replace('\n', "\\n");+ let escaped = shlex::try_quote(&escaped).ok()?;+ format!("eval \"$(command -p printf '%b' {escaped})\"")+ } else {+ setup+ };+ let command = format!("{setup}; {command}");+ Some(self.shell.derive_exec_args(&command, self.use_login_shell))+ }}#[cfg(all(test, unix))]diff --git a/codex-rs/core/src/shell_tests.rs b/codex-rs/core/src/shell_tests.rsindex 0963ef8364..1077aba2b6 100644--- a/codex-rs/core/src/shell_tests.rs+++ b/codex-rs/core/src/shell_tests.rs@@ -1,4 +1,5 @@use super::*;+use pretty_assertions::assert_eq;use std::path::PathBuf;use std::process::Command;@@ -143,6 +144,68 @@ fn derive_exec_args() {);}+/// Diagnostics and `$LINENO` must refer to the original script, even with newlines in the package path.+#[test]+fn codex_path_setup_preserves_shell_script_line_numbers() -> anyhow::Result<()> {+ let temp_dir = tempfile::tempdir()?;+ let run = |argv: &[String]| {+ Command::new(&argv[0])+ .args(&argv[1..])+ .env("ZDOTDIR", temp_dir.path())+ .env("HOME", temp_dir.path())+ .env_remove("BASH_ENV")+ .output()+ };+ for shell_type in [ShellType::Bash, ShellType::Zsh, ShellType::Sh] {+ let Some(shell) = get_shell(shell_type) else {+ assert_eq!(shell_type, ShellType::Zsh, "only zsh may be unavailable");+ continue;+ };+ let invocation = ShellInvocation {+ shell,+ use_login_shell: true,+ };+ for directory in [+ "codex-path",+ "codex '\\c[*]$(printf bad)`printf bad`\npath\n",+ ] {+ let directory = temp_dir.path().join(directory);+ let path = PathUri::from_host_native_path(&directory)?;+ let commands = [+ ":\nif then",+ "printf '%s\\n' \"$LINENO\"\nprintf '%s\\n' \"$LINENO\"",+ ];+ for command in commands {+ if command.contains("LINENO") && shell_type == ShellType::Sh {+ continue; // dash does not implement LINENO.+ }+ let original = invocation+ .shell+ .derive_exec_args(command, /*use_login_shell*/ true);+ let wrapped = invocation+ .derive_exec_args_with_path_prepends(command, std::slice::from_ref(&path))+ .expect("a POSIX package path should be usable");+ assert_eq!(+ run(&wrapped)?,+ run(&original)?,+ "{shell_type:?}: {directory:?}"+ );+ assert_eq!(wrapped[2].lines().count(), command.lines().count());+ }++ let command = "printf '%s' \"$PATH\"";+ let wrapped = invocation+ .derive_exec_args_with_path_prepends(command, std::slice::from_ref(&path))+ .expect("a POSIX package path should be usable");+ let output = run(&wrapped)?;+ assert!(output.status.success());+ let actual_path = String::from_utf8(output.stdout)?;+ assert_eq!(actual_path.split(':').next(), directory.to_str());+ }+ }+ Ok(())+}+#[tokio::test]async fn test_current_shell_detects_zsh() {let shell = Command::new("sh")diff --git a/codex-rs/core/src/tools/handlers/unified_exec_tests.rs b/codex-rs/core/src/tools/handlers/unified_exec_tests.rsindex 4657b64fbc..98b8795839 100644--- a/codex-rs/core/src/tools/handlers/unified_exec_tests.rs+++ b/codex-rs/core/src/tools/handlers/unified_exec_tests.rs@@ -7,6 +7,7 @@ use codex_tools::UnifiedExecShellMode;use codex_tools::ZshForkConfig;use codex_utils_absolute_path::AbsolutePathBuf;use codex_utils_output_truncation::TruncationPolicy;+use codex_utils_path_uri::PathUri;use pretty_assertions::assert_eq;use std::sync::Arc;@@ -95,6 +96,182 @@ fn test_get_command_respects_explicit_bash_shell() -> anyhow::Result<()> {Ok(())}+/// Nested commands must find the first reported tool directory after login startup without duplicating existing entries.+#[cfg(unix)]+#[test]+fn test_get_command_keeps_path_prepends_after_login_startup() -> anyhow::Result<()> {+ use std::os::unix::fs::PermissionsExt;++ let temp_dir = tempfile::tempdir()?;+ let path_dir = temp_dir.path().join("codex '[*] path");+ let extra_path_dir = temp_dir.path().join("extra tools");+ for directory in [&path_dir, &extra_path_dir] {+ std::fs::create_dir(directory)?;+ let rg = directory.join("rg");+ std::fs::write(&rg, "#!/bin/sh\n")?;+ std::fs::set_permissions(&rg, std::fs::Permissions::from_mode(0o755))?;+ }+ let rg = path_dir.join("rg");+ let startup = temp_dir.path().join("startup");+ std::fs::write(+ &startup,+ "export PATH=\"$CODEX_TEST_LOGIN_PATH\" CODEX_TEST_LOGIN_PATH_RESET=1\n",+ )?;+ let path_dirs = [+ PathUri::from_host_native_path(&path_dir)?,+ PathUri::from_host_native_path(&extra_path_dir)?,+ ];+ let args: ExecCommandArgs = parse_arguments(+ r#"{"cmd":"sh -c 'test \"$CODEX_TEST_LOGIN_PATH_RESET\" = 1 && printf \"%s\\n\" \"$PATH\" && command -v rg'"}"#,+ )?;+ let shell = Arc::new(get_shell(ShellType::Bash).expect("bash should be available"));+ let resolved = get_command(+ &args,+ Arc::clone(&shell),+ &UnifiedExecShellMode::Direct,+ /*allow_login_shell*/ true,+ )+ .map_err(anyhow::Error::msg)?;+ assert_eq!(+ resolved.command,+ shell.derive_exec_args(&args.cmd, /*use_login_shell*/ true)+ );++ let execution_command = resolved+ .shell+ .derive_exec_args_with_path_prepends(&args.cmd, &path_dirs)+ .expect("login shell should restore PATH");+ let path_dir = path_dirs[0].inferred_native_path_string();+ let extra_path_dir = path_dirs[1].inferred_native_path_string();+ let already_present = format!(+ "{}:{path_dir}:{extra_path_dir}:/usr/bin:/bin",+ temp_dir.path().display()+ );+ for (login_path, expected_path) in [+ (+ "/usr/bin:/bin".to_string(),+ format!("{path_dir}:{extra_path_dir}:/usr/bin:/bin"),+ ),+ (already_present.clone(), already_present),+ ] {+ let output = std::process::Command::new(&execution_command[0])+ .args(&execution_command[1..])+ .env("BASH_ENV", &startup)+ .env("CODEX_TEST_LOGIN_PATH", login_path)+ .env_remove("CODEX_TEST_LOGIN_PATH_RESET")+ .env("PATH", &path_dir)+ .output()?;+ assert!(+ output.status.success(),+ "{}",+ String::from_utf8_lossy(&output.stderr)+ );+ assert_eq!(+ String::from_utf8(output.stdout)?,+ format!("{expected_path}\n{}\n", rg.display())+ );+ }+ Ok(())+}++/// The requested login shell and its command still run when startup forbids changing PATH.+#[cfg(unix)]+#[test]+fn test_get_command_runs_login_shell_when_path_is_readonly() -> anyhow::Result<()> {+ let temp_dir = tempfile::tempdir()?;+ let startup = temp_dir.path().join("startup");+ // An explicit exit from a login Bash runs ~/.bash_logout; keep the runner's file out of the test.+ std::fs::write(temp_dir.path().join(".bash_logout"), ":\n")?;+ std::fs::write(+ &startup,+ "if shopt -q login_shell; then\n export HOME=\"$CODEX_TEST_LOGIN_HOME\"\n export PATH=/usr/bin:/bin\n readonly PATH\n set -e\nfi\n",+ )?;+ let path_dir = PathUri::from_host_native_path(temp_dir.path().join("codex-path"))?;+ let args: ExecCommandArgs = parse_arguments(+ r#"{"cmd":"shopt -q login_shell || exit 90; case $- in *e*) ;; *) exit 91 ;; esac; /bin/sh -c 'printf \"%s\\n\" \"$PATH\"'; exit 23","login":true}"#,+ )?;+ let shell = Arc::new(get_shell(ShellType::Bash).expect("bash should be available"));+ let resolved = get_command(+ &args,+ shell,+ &UnifiedExecShellMode::Direct,+ /*allow_login_shell*/ true,+ )+ .map_err(anyhow::Error::msg)?;+ let command = resolved+ .shell+ .derive_exec_args_with_path_prepends(&args.cmd, &[path_dir])+ .expect("the reported directory can be put on PATH");+ let output = std::process::Command::new(&command[0])+ .args(&command[1..])+ .env("BASH_ENV", startup)+ .env("CODEX_TEST_LOGIN_HOME", temp_dir.path())+ .env_remove("SHLVL")+ .output()?;++ assert_eq!(+ (+ output.status.code(),+ String::from_utf8(output.stdout)?,+ String::from_utf8(output.stderr)?+ ),+ (Some(23), "/usr/bin:/bin\n".to_string(), String::new())+ );+ Ok(())+}++/// The package path only affects Codex's own POSIX login shells when the executor reports a POSIX path.+#[test]+fn test_get_command_does_not_change_nested_login_or_powershell() -> anyhow::Result<()> {+ for (shell_type, shell_path, arguments, use_login_shell, path) in [+ (+ ShellType::Bash,+ "/bin/bash",+ r#"{"cmd":"bash -lc 'command -v rg'","login":false}"#,+ false,+ "file:///executor/codex-path",+ ),+ (+ ShellType::PowerShell,+ "pwsh",+ r#"{"cmd":"Get-Command rg"}"#,+ true,+ "file:///executor/codex-path",+ ),+ (+ ShellType::Bash,+ "/bin/bash",+ r#"{"cmd":"command -v rg"}"#,+ true,+ "file:///C:/executor/codex-path",+ ),+ ] {+ let args: ExecCommandArgs = parse_arguments(arguments)?;+ let path_dir = PathUri::parse(path)?;+ let shell = Arc::new(Shell {+ shell_type,+ shell_path: PathBuf::from(shell_path),+ });+ let resolved = get_command(+ &args,+ Arc::clone(&shell),+ &UnifiedExecShellMode::Direct,+ /*allow_login_shell*/ true,+ )+ .map_err(anyhow::Error::msg)?;+ assert_eq!(+ (+ resolved.command,+ resolved+ .shell+ .derive_exec_args_with_path_prepends(&args.cmd, &[path_dir])+ ),+ (shell.derive_exec_args(&args.cmd, use_login_shell), None)+ );+ }+ Ok(())+}+#[test]fn test_get_command_resolves_powershell_by_type() -> anyhow::Result<()> {let temp_dir = tempfile::tempdir()?;diff --git a/codex-rs/core/src/tools/runtimes/unified_exec.rs b/codex-rs/core/src/tools/runtimes/unified_exec.rsindex c6ef29c606..82a76ded4c 100644--- a/codex-rs/core/src/tools/runtimes/unified_exec.rs+++ b/codex-rs/core/src/tools/runtimes/unified_exec.rs@@ -45,6 +45,7 @@ use crate::unified_exec::UnifiedExecError;use crate::unified_exec::UnifiedExecProcess;use crate::unified_exec::UnifiedExecProcessManager;use codex_core_plugins::PluginMetricsSidecar;+use codex_features::Feature;use codex_network_proxy::CREDENTIAL_BROKER_ACTIVE_ENV_KEY;use codex_network_proxy::ManagedNetworkSandboxContext;use codex_network_proxy::NetworkProxy;@@ -511,18 +512,31 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt};#[cfg(not(unix))]let runtime_path_prepends = RuntimePathPrepends::default();- let mut command = if environment_is_remote {- base_command.to_vec()- } else {- maybe_wrap_shell_lc_with_snapshot(- base_command,+ // Restore the executor's PATH directories inside the shell so nested commands can+ // still find bundled tools even if login startup clears the inherited PATH.+ // `base_command` already carries the requested login mode; keep it if setup is unavailable.+ // `hook_command` is the raw script the helper needs to prepend setup inside that same shell.+ let mut command = base_command.to_vec();+ if ctx.session.enabled(Feature::LoginShellPackagePath)+ && req.shell.is_posix_login()+ && !explicit_env_overrides.contains_key("PATH")+ && let Ok(info) = req.turn_environment.environment.info().await+ && let Some(command_with_path_prepends) = req+ .shell+ .derive_exec_args_with_path_prepends(&req.hook_command, &info.prepend_path_dirs)+ {+ command = command_with_path_prepends;+ }+ if !environment_is_remote {+ command = maybe_wrap_shell_lc_with_snapshot(+ &command,shell,shell_snapshot_location.as_ref(),&explicit_env_overrides,&env,&runtime_path_prepends,- )- };+ );+ }let brokered_shell_snapshot_missing = !environment_is_remote&& managed_network.is_some()&& envdiff --git a/codex-rs/core/tests/suite/unified_exec_process_events.rs b/codex-rs/core/tests/suite/unified_exec_process_events.rsindex 39d8db4190..983fc2ded3 100644--- a/codex-rs/core/tests/suite/unified_exec_process_events.rs+++ b/codex-rs/core/tests/suite/unified_exec_process_events.rs@@ -5,6 +5,7 @@ use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;use codex_config::test_support::CloudConfigBundleFixture;use codex_core::TurnInputRequest;use codex_exec_server::ExecParams;+use codex_features::Feature;use codex_protocol::config_types::ApprovalsReviewer;use codex_protocol::config_types::CollaborationMode;use codex_protocol::config_types::ModeKind;@@ -71,6 +72,11 @@ const REPLAY_RETAINED_OUTPUT_SEQ: u64 = 800;#[cfg_attr(windows, allow(dead_code))]enum PushedExecScenario {Complete,+ CodexPath,+ CodexPathDefaultFeature,+ CodexPathDisabledFeature,+ CodexPathWithExplicitOverride,+ UnusableCodexPath,DirectDenied,DenyWin,DenyWinUnchanged,@@ -196,18 +202,29 @@ async fn respond_environment_info(if matches!(scenario, PushedExecScenario::DenyLinux) {capabilities["linuxApprovedRootWritePreservesRestrictions"] = json!(true);}- send_exec_server_json(- websocket,- json!({- "id": id,- "result": {- "shell": shell,- "platformOs": platform_os,- "capabilities": capabilities,- }- }),- )- .await;+ let mut response = json!({+ "id": id,+ "result": {+ "shell": shell,+ "platformOs": platform_os,+ "capabilities": capabilities,+ }+ });+ if matches!(+ scenario,+ PushedExecScenario::CodexPath+ | PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature+ | PushedExecScenario::CodexPathWithExplicitOverride+ ) {+ response["result"]["prependPathDirs"] = json!([+ "file:///executor/codex-path",+ "file:///executor/extra-tools",+ ]);+ } else if matches!(scenario, PushedExecScenario::UnusableCodexPath) {+ response["result"]["prependPathDirs"] = json!(["file:///executor/codex%3Apath"]);+ }+ send_exec_server_json(websocket, response).await;}async fn serve_exec_with_pushed_events(@@ -410,6 +427,11 @@ async fn serve_exec_with_pushed_events(| PushedExecScenario::DenyOldLinux| PushedExecScenario::DenyOldLinuxWithRoot(_)| PushedExecScenario::DenyLinux+ | PushedExecScenario::CodexPath+ | PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature+ | PushedExecScenario::CodexPathWithExplicitOverride+ | PushedExecScenario::UnusableCodexPath| PushedExecScenario::ElevatedPowerShell => {let encoded_output = BASE64_STANDARD.encode(COMPLETE_OUTPUT);for message in [@@ -491,7 +513,12 @@ async fn serve_exec_with_pushed_events(Some("process/read") => {process_read_requests += 1;let result = match scenario {- PushedExecScenario::Complete => json!({+ PushedExecScenario::Complete+ | PushedExecScenario::CodexPath+ | PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature+ | PushedExecScenario::CodexPathWithExplicitOverride+ | PushedExecScenario::UnusableCodexPath => json!({"chunks": [{"seq": 1,"stream": "stdout",@@ -606,6 +633,11 @@ async fn serve_exec_with_pushed_events(}#[test_case(PushedExecScenario::Complete, ManagedNetworkScenario::None, false ; "complete_event_stream")]+#[test_case(PushedExecScenario::CodexPath, ManagedNetworkScenario::None, false ; "codex_path_is_exported_before_nested_command")]+#[test_case(PushedExecScenario::CodexPathDefaultFeature, ManagedNetworkScenario::None, false ; "codex_path_is_not_exported_by_default")]+#[test_case(PushedExecScenario::CodexPathDisabledFeature, ManagedNetworkScenario::None, false ; "disabled_codex_path_preserves_original_login_command")]+#[test_case(PushedExecScenario::CodexPathWithExplicitOverride, ManagedNetworkScenario::None, false ; "explicit_path_override_preserves_original_login_command")]+#[test_case(PushedExecScenario::UnusableCodexPath, ManagedNetworkScenario::None, false ; "unusable_codex_path_preserves_requested_login_shell")]#[test_case(PushedExecScenario::DirectDenied, ManagedNetworkScenario::None, false ; "direct_sandbox_denial")]#[test_case(PushedExecScenario::LegacyExit, ManagedNetworkScenario::None, false ; "legacy_exit_metadata")]#[test_case(PushedExecScenario::ReplayGap, ManagedNetworkScenario::None, false ; "truncated_event_replay")]@@ -634,6 +666,7 @@ async fn exec_command_consumes_pushed_remote_process_events(managed_network: ManagedNetworkScenario,foreign_cwd: bool,) -> Result<()> {+ let explicit_path = "/user/configured/bin:/user/other/bin";let managed_network_configured = !matches!(managed_network, ManagedNetworkScenario::None);let managed_network_enabled = matches!(managed_network, ManagedNetworkScenario::Enabled { .. });let policy_callbacks = matches!(@@ -669,6 +702,16 @@ async fn exec_command_consumes_pushed_remote_process_events(CALL_ID,"*** Begin Patch\n*** Update File: secret.txt\n@@\n-old\n+new\n*** End Patch",),+ PushedExecScenario::CodexPathWithExplicitOverride | PushedExecScenario::UnusableCodexPath => ev_function_call(+ CALL_ID,+ "exec_command",+ &json!({+ "cmd": "sh -c 'command -v rg'",+ "login": true,+ "yield_time_ms": 1_000,+ })+ .to_string(),+ ),_ => ev_function_call(CALL_ID,"exec_command",@@ -685,6 +728,9 @@ async fn exec_command_consumes_pushed_remote_process_events("Remove-Item test -Force; {}","Write-Output filler; ".repeat(2_000)),+ PushedExecScenario::CodexPath+ | PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature => "sh -c 'command -v rg'".to_string(),_ => "pwd".to_string(),},"yield_time_ms": 1_000,@@ -777,6 +823,24 @@ timeout = 900}let mut builder = builder.with_config(move |config| {config.project_doc_max_bytes = 0;+ if matches!(scenario, PushedExecScenario::CodexPathDisabledFeature) {+ config+ .features+ .disable(Feature::LoginShellPackagePath)+ .expect("disable login shell package PATH");+ } else if !matches!(scenario, PushedExecScenario::CodexPathDefaultFeature) {+ config+ .features+ .enable(Feature::LoginShellPackagePath)+ .expect("enable login shell package PATH");+ }+ if matches!(scenario, PushedExecScenario::CodexPathWithExplicitOverride) {+ config+ .permissions+ .shell_environment_policy+ .r#set+ .insert("PATH".to_string(), explicit_path.to_string());+ }if matches!(scenario, PushedExecScenario::ElevatedPowerShell) || (foreign_cwd && deny_read){config.set_windows_elevated_sandbox_enabled(/*value*/ true);@@ -930,6 +994,7 @@ timeout = 900).await?;let mut saw_exec_command_begin = false;+ let mut exec_command_begin_command = None;let mut saw_patch_denial_approval = false;if !managed_network_enabled {loop {@@ -940,6 +1005,7 @@ timeout = 900match event {EventMsg::ExecCommandBegin(event) if event.call_id == CALL_ID => {saw_exec_command_begin = true;+ exec_command_begin_command = Some(event.command);}EventMsg::ExecApprovalRequest(approval) if deny_read => {assert_eq!(approval.call_id, CALL_ID);@@ -1169,6 +1235,51 @@ timeout = 900"#);}}+ if matches!(scenario, PushedExecScenario::CodexPath) {+ let argv = &exec_server_result.process_start["params"]["argv"];+ assert_eq!(argv[0], "/bin/zsh");+ assert_eq!(argv[1], "-lc");+ let script = argv[2]+ .as_str()+ .context("shell command should contain a script")?;+ assert!(script.contains("export PATH=/executor/codex-path"));+ assert!(script.contains("export PATH=/executor/extra-tools"));+ assert!(script.ends_with("; sh -c 'command -v rg'"));+ assert_eq!(script.lines().count(), 1);+ assert_eq!(+ exec_command_begin_command,+ Some(vec![+ "/bin/zsh".to_string(),+ "-lc".to_string(),+ "sh -c 'command -v rg'".to_string()+ ])+ );+ } else if matches!(+ scenario,+ PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature+ | PushedExecScenario::CodexPathWithExplicitOverride+ | PushedExecScenario::UnusableCodexPath+ ) {+ let params = &exec_server_result.process_start["params"];+ let expected = vec!["/bin/zsh", "-lc", "sh -c 'command -v rg'"];+ assert_eq!(params["argv"], json!(expected));+ assert_eq!(+ exec_command_begin_command,+ Some(expected.into_iter().map(str::to_string).collect())+ );+ if matches!(scenario, PushedExecScenario::CodexPathWithExplicitOverride) {+ assert_eq!(params["envPolicy"]["set"]["PATH"], explicit_path);+ }+ } else if matches!(scenario, PushedExecScenario::Complete)+ && !foreign_cwd+ && !managed_network_configured+ {+ assert_eq!(+ exec_server_result.process_start["params"]["argv"],+ json!(["/bin/zsh", "-lc", "pwd"])+ );+ }if foreign_cwd {let params = &exec_server_result.process_start["params"];assert_eq!(params["cwd"], "file:///C:/workspace");@@ -1263,6 +1374,11 @@ timeout = 900| PushedExecScenario::DenyOldLinux| PushedExecScenario::DenyOldLinuxWithRoot(_)| PushedExecScenario::DenyLinux+ | PushedExecScenario::CodexPath+ | PushedExecScenario::CodexPathDefaultFeature+ | PushedExecScenario::CodexPathDisabledFeature+ | PushedExecScenario::CodexPathWithExplicitOverride+ | PushedExecScenario::UnusableCodexPath| PushedExecScenario::ElevatedPowerShell => {assert_ne!(success, Some(false));assert!(saw_exec_command_begin);