diff --git a/codex-rs/app-server/src/request_processors/fs_processor.rs b/codex-rs/app-server/src/request_processors/fs_processor.rs index e45b3f419e..b16209a5ac 100644 --- a/codex-rs/app-server/src/request_processors/fs_processor.rs +++ b/codex-rs/app-server/src/request_processors/fs_processor.rs @@ -97,9 +97,10 @@ impl FsRequestProcessor { &self, params: FsCreateDirectoryParams, ) -> Result { + let path = PathUri::from_abs_path(¶ms.path).map_err(map_fs_error)?; self.file_system()? .create_directory( - ¶ms.path, + &path, CreateDirectoryOptions { recursive: params.recursive.unwrap_or(true), }, diff --git a/codex-rs/apply-patch/src/lib.rs b/codex-rs/apply-patch/src/lib.rs index 1f767a40e5..705774ca17 100644 --- a/codex-rs/apply-patch/src/lib.rs +++ b/codex-rs/apply-patch/src/lib.rs @@ -633,8 +633,9 @@ async fn write_file_with_missing_parent_retry( Ok(()) => Ok(()), Err(err) if err.kind() == io::ErrorKind::NotFound => { if let Some(parent_abs) = path_abs.parent() { + let parent_uri = PathUri::from_abs_path(&parent_abs)?; fs.create_directory( - &parent_abs, + &parent_uri, CreateDirectoryOptions { recursive: true }, sandbox, ) diff --git a/codex-rs/config/src/loader/tests.rs b/codex-rs/config/src/loader/tests.rs index c51ae98371..e1f91074bf 100644 --- a/codex-rs/config/src/loader/tests.rs +++ b/codex-rs/config/src/loader/tests.rs @@ -45,7 +45,7 @@ impl ExecutorFileSystem for TestFileSystem { async fn create_directory( &self, - _path: &AbsolutePathBuf, + _path: &PathUri, _create_directory_options: CreateDirectoryOptions, _sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { diff --git a/codex-rs/core/tests/common/test_codex.rs b/codex-rs/core/tests/common/test_codex.rs index 90d11359fa..a06ef88998 100644 --- a/codex-rs/core/tests/common/test_codex.rs +++ b/codex-rs/core/tests/common/test_codex.rs @@ -136,10 +136,11 @@ pub async fn test_env() -> Result { let environment = codex_exec_server::Environment::create_for_tests(Some(websocket_url.clone()))?; let cwd = remote_aware_cwd_path(); + let cwd_uri = PathUri::from_path(&cwd)?; environment .get_filesystem() .create_directory( - &cwd, + &cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -908,10 +909,11 @@ impl TestCodexHarness { ) -> Result<()> { let abs_path = self.path_abs(rel); if let Some(parent) = abs_path.parent() { + let parent_uri = PathUri::from_path(&parent)?; self.test .fs() .create_directory( - &parent, + &parent_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -940,10 +942,12 @@ impl TestCodexHarness { } pub async fn create_dir_all(&self, rel: impl AsRef) -> Result<()> { + let path = self.path_abs(rel); + let path_uri = PathUri::from_path(&path)?; self.test .fs() .create_directory( - &self.path_abs(rel), + &path_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/agents_md.rs b/codex-rs/core/tests/suite/agents_md.rs index 1c23033f54..810f73398a 100644 --- a/codex-rs/core/tests/suite/agents_md.rs +++ b/codex-rs/core/tests/suite/agents_md.rs @@ -149,9 +149,10 @@ async fn configured_fallback_is_used_when_agents_candidate_is_directory() -> Res .with_workspace_setup(|cwd, fs| async move { let agents_dir = cwd.join("AGENTS.md"); let fallback = cwd.join("WORKFLOW.md"); + let agents_dir_uri = PathUri::from_path(&agents_dir)?; let fallback_uri = PathUri::from_path(&fallback)?; fs.create_directory( - &agents_dir, + &agents_dir_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -191,12 +192,13 @@ async fn agents_docs_are_concatenated_from_project_root_to_cwd() -> Result<()> { let root_agents = root.join("AGENTS.md"); let git_marker = root.join(".git"); let nested_agents = nested.join("AGENTS.md"); + let nested_uri = PathUri::from_path(&nested)?; let root_agents_uri = PathUri::from_path(&root_agents)?; let git_marker_uri = PathUri::from_path(&git_marker)?; let nested_agents_uri = PathUri::from_path(&nested_agents)?; fs.create_directory( - &nested, + &nested_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/apply_patch_cli.rs b/codex-rs/core/tests/suite/apply_patch_cli.rs index a71730f446..e2945c72da 100644 --- a/codex-rs/core/tests/suite/apply_patch_cli.rs +++ b/codex-rs/core/tests/suite/apply_patch_cli.rs @@ -1330,8 +1330,9 @@ async fn apply_patch_turn_diff_paths_stay_repo_relative_when_session_cwd_is_nest config.cwd = config.cwd.join("subdir"); }) .with_workspace_setup(|cwd, fs| async move { + let cwd_uri = PathUri::from_path(&cwd)?; fs.create_directory( - &cwd, + &cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -1581,6 +1582,7 @@ async fn apply_patch_turn_diff_tracks_local_and_remote_environment_paths() -> Re SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() )) .abs(); + let shared_cwd_uri = PathUri::from_path(&shared_cwd)?; let _ = fs::remove_dir_all(shared_cwd.as_path()); test.fs() .remove( @@ -1595,7 +1597,7 @@ async fn apply_patch_turn_diff_tracks_local_and_remote_environment_paths() -> Re fs::create_dir_all(shared_cwd.as_path())?; test.fs() .create_directory( - &shared_cwd, + &shared_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/remote_env.rs b/codex-rs/core/tests/suite/remote_env.rs index b3544339bb..8e64c0fa57 100644 --- a/codex-rs/core/tests/suite/remote_env.rs +++ b/codex-rs/core/tests/suite/remote_env.rs @@ -297,10 +297,11 @@ async fn exec_command_routes_to_selected_remote_environment() -> Result<()> { )) .abs(); let remote_marker_name = "marker.txt"; + let remote_cwd_uri = PathUri::from_path(&remote_cwd)?; let remote_marker_uri = PathUri::from_path(remote_cwd.join(remote_marker_name))?; test.fs() .create_directory( - &remote_cwd, + &remote_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -393,9 +394,10 @@ async fn remote_request_permissions_grant_unblocks_later_remote_exec() -> Result let local_write_root = local_cwd.path().join(relative_write_root); let local_target_path = local_cwd.path().join(relative_target_path); fs::create_dir(&local_write_root)?; + let remote_write_root_uri = PathUri::from_path(&remote_write_root)?; test.fs() .create_directory( - &remote_write_root, + &remote_write_root_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -573,9 +575,10 @@ async fn apply_patch_freeform_routes_to_selected_remote_environment() -> Result< SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() )) .abs(); + let remote_cwd_uri = PathUri::from_path(&remote_cwd)?; test.fs() .create_directory( - &remote_cwd, + &remote_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -660,9 +663,10 @@ async fn apply_patch_approvals_are_remembered_per_environment() -> Result<()> { SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() )) .abs(); + let remote_cwd_uri = PathUri::from_path(&remote_cwd)?; test.fs() .create_directory( - &remote_cwd, + &remote_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -842,9 +846,10 @@ async fn apply_patch_intercepted_exec_command_routes_to_selected_remote_environm SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() )) .abs(); + let remote_cwd_uri = PathUri::from_path(&remote_cwd)?; test.fs() .create_directory( - &remote_cwd, + &remote_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -932,10 +937,11 @@ async fn remote_test_env_sandboxed_read_allows_readable_root() -> Result<()> { let allowed_dir = PathBuf::from(format!("/tmp/codex-remote-readable-{}", std::process::id())); let file_path = allowed_dir.join("note.txt"); + let allowed_dir_uri = PathUri::from_path(&allowed_dir)?; let file_path_uri = PathUri::from_path(&file_path)?; file_system .create_directory( - &absolute_path(allowed_dir.clone()), + &allowed_dir_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/rmcp_client.rs b/codex-rs/core/tests/suite/rmcp_client.rs index c47aa0970a..88c5722957 100644 --- a/codex-rs/core/tests/suite/rmcp_client.rs +++ b/codex-rs/core/tests/suite/rmcp_client.rs @@ -45,6 +45,7 @@ use codex_protocol::protocol::McpToolCallBeginEvent; use codex_protocol::protocol::Op; use codex_protocol::user_input::UserInput; use codex_utils_cargo_bin::cargo_bin; +use codex_utils_path_uri::PathUri; use core_test_support::assert_regex_match; use core_test_support::remote_env_env_var; use core_test_support::responses; @@ -617,8 +618,10 @@ async fn stdio_server_uses_configured_cwd_before_runtime_fallback() -> anyhow::R let fixture = test_codex() .with_workspace_setup(|cwd, fs| async move { + let configured_cwd = cwd.join("mcp-configured-cwd"); + let configured_cwd_uri = PathUri::from_path(&configured_cwd)?; fs.create_directory( - &cwd.join("mcp-configured-cwd"), + &configured_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/skills.rs b/codex-rs/core/tests/suite/skills.rs index b3f124ac6e..55c75016d9 100644 --- a/codex-rs/core/tests/suite/skills.rs +++ b/codex-rs/core/tests/suite/skills.rs @@ -30,8 +30,9 @@ async fn write_repo_skill( body: &str, ) -> Result<()> { let skill_dir = cwd.join(".agents").join("skills").join(name); + let skill_dir_uri = PathUri::from_path(&skill_dir)?; fs.create_directory( - &skill_dir, + &skill_dir_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/unified_exec.rs b/codex-rs/core/tests/suite/unified_exec.rs index eb8bf29551..06b5288cdc 100644 --- a/codex-rs/core/tests/suite/unified_exec.rs +++ b/codex-rs/core/tests/suite/unified_exec.rs @@ -17,6 +17,7 @@ use codex_protocol::protocol::ExecCommandSource; use codex_protocol::protocol::ExecCommandStatus; use codex_protocol::protocol::Op; use codex_protocol::user_input::UserInput; +use codex_utils_path_uri::PathUri; use core_test_support::TempDirExt; use core_test_support::assert_regex_match; use core_test_support::managed_network_requirements_loader; @@ -228,9 +229,10 @@ async fn create_workspace_directory( rel_path: impl AsRef, ) -> Result { let abs_path = test.config.cwd.join(rel_path.as_ref()); + let abs_path_uri = PathUri::from_path(&abs_path)?; test.fs() .create_directory( - &abs_path, + &abs_path_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/core/tests/suite/view_image.rs b/codex-rs/core/tests/suite/view_image.rs index a20c3d9f00..fbbe078ea0 100644 --- a/codex-rs/core/tests/suite/view_image.rs +++ b/codex-rs/core/tests/suite/view_image.rs @@ -134,9 +134,10 @@ fn png_bytes(width: u32, height: u32, rgba: [u8; 4]) -> anyhow::Result> async fn create_workspace_directory(test: &TestCodex, rel_path: &str) -> anyhow::Result { let abs_path = test.config.cwd.join(rel_path); + let abs_path_uri = PathUri::from_path(&abs_path)?; test.fs() .create_directory( - &abs_path, + &abs_path_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -151,9 +152,10 @@ async fn write_workspace_file( ) -> anyhow::Result { let abs_path = test.config.cwd.join(rel_path); if let Some(parent) = abs_path.parent() { + let parent_uri = PathUri::from_path(&parent)?; test.fs() .create_directory( - &parent, + &parent_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) @@ -579,9 +581,10 @@ async fn view_image_routes_to_selected_remote_environment() -> anyhow::Result<() )) .abs(); let image_path = remote_cwd.join("remote.png"); + let remote_cwd_uri = PathUri::from_path(&remote_cwd)?; test.fs() .create_directory( - &remote_cwd, + &remote_cwd_uri, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/exec-server/src/fs_helper.rs b/codex-rs/exec-server/src/fs_helper.rs index 9da1f21e72..8cfd89237d 100644 --- a/codex-rs/exec-server/src/fs_helper.rs +++ b/codex-rs/exec-server/src/fs_helper.rs @@ -214,9 +214,11 @@ pub(crate) async fn run_direct_request( Ok(FsHelperPayload::WriteFile(FsWriteFileResponse {})) } FsHelperRequest::CreateDirectory(params) => { + let path = + codex_utils_path_uri::PathUri::from_abs_path(¶ms.path).map_err(map_fs_error)?; file_system .create_directory( - ¶ms.path, + &path, CreateDirectoryOptions { recursive: params.recursive.unwrap_or(true), }, diff --git a/codex-rs/exec-server/src/local_file_system.rs b/codex-rs/exec-server/src/local_file_system.rs index 8419cc0fe9..a88bb670dc 100644 --- a/codex-rs/exec-server/src/local_file_system.rs +++ b/codex-rs/exec-server/src/local_file_system.rs @@ -110,7 +110,7 @@ impl ExecutorFileSystem for LocalFileSystem { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { @@ -194,7 +194,7 @@ impl ExecutorFileSystem for UnsandboxedFileSystem { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { @@ -299,11 +299,12 @@ impl ExecutorFileSystem for DirectFileSystem { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { reject_sandbox_context(sandbox)?; + let path = path.to_abs_path()?; if options.recursive { tokio::fs::create_dir_all(path.as_path()).await?; } else { diff --git a/codex-rs/exec-server/src/remote_file_system.rs b/codex-rs/exec-server/src/remote_file_system.rs index 6bb588a990..943555ad97 100644 --- a/codex-rs/exec-server/src/remote_file_system.rs +++ b/codex-rs/exec-server/src/remote_file_system.rs @@ -104,15 +104,16 @@ impl ExecutorFileSystem for RemoteFileSystem { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { trace!("remote fs create_directory"); + let path = path.to_abs_path()?; let client = self.client.get().await.map_err(map_remote_error)?; client .fs_create_directory(FsCreateDirectoryParams { - path: path.clone(), + path, recursive: Some(options.recursive), sandbox: remote_sandbox_context(sandbox), }) diff --git a/codex-rs/exec-server/src/sandboxed_file_system.rs b/codex-rs/exec-server/src/sandboxed_file_system.rs index 0da66dc1a2..e38361547e 100644 --- a/codex-rs/exec-server/src/sandboxed_file_system.rs +++ b/codex-rs/exec-server/src/sandboxed_file_system.rs @@ -121,7 +121,7 @@ impl ExecutorFileSystem for SandboxedFileSystem { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { @@ -129,7 +129,7 @@ impl ExecutorFileSystem for SandboxedFileSystem { self.run_sandboxed( sandbox, FsHelperRequest::CreateDirectory(FsCreateDirectoryParams { - path: path.clone(), + path: path.to_abs_path()?, recursive: Some(options.recursive), sandbox: None, }), diff --git a/codex-rs/exec-server/src/server/file_system_handler.rs b/codex-rs/exec-server/src/server/file_system_handler.rs index ebbc8b7fd4..c1f5f46530 100644 --- a/codex-rs/exec-server/src/server/file_system_handler.rs +++ b/codex-rs/exec-server/src/server/file_system_handler.rs @@ -86,9 +86,10 @@ impl FileSystemHandler { params: FsCreateDirectoryParams, ) -> Result { let recursive = params.recursive.unwrap_or(true); + let path = PathUri::from_abs_path(¶ms.path).map_err(map_fs_error)?; self.file_system .create_directory( - ¶ms.path, + &path, CreateDirectoryOptions { recursive }, params.sandbox.as_ref(), ) diff --git a/codex-rs/exec-server/tests/file_system/shared.rs b/codex-rs/exec-server/tests/file_system/shared.rs index faa40bc421..24aa1f4f54 100644 --- a/codex-rs/exec-server/tests/file_system/shared.rs +++ b/codex-rs/exec-server/tests/file_system/shared.rs @@ -96,7 +96,7 @@ async fn file_system_create_directory_creates_nested_directories( file_system .create_directory( - &absolute_path(&nested_dir), + &PathUri::from_path(&nested_dir)?, CreateDirectoryOptions { recursive: true }, /*sandbox*/ None, ) diff --git a/codex-rs/exec-server/tests/file_system_unix.rs b/codex-rs/exec-server/tests/file_system_unix.rs index 1e626fdff6..d7d1397e94 100644 --- a/codex-rs/exec-server/tests/file_system_unix.rs +++ b/codex-rs/exec-server/tests/file_system_unix.rs @@ -475,7 +475,7 @@ async fn file_system_create_directory_rejects_symlink_escape( let sandbox = workspace_write_sandbox(allowed_dir); let error = match file_system .create_directory( - &absolute_path(&requested_path), + &PathUri::from_path(&requested_path)?, CreateDirectoryOptions { recursive: false }, Some(&sandbox), ) diff --git a/codex-rs/ext/skills/tests/executor_file_system_authority.rs b/codex-rs/ext/skills/tests/executor_file_system_authority.rs index 0017e01cf4..2808b724fa 100644 --- a/codex-rs/ext/skills/tests/executor_file_system_authority.rs +++ b/codex-rs/ext/skills/tests/executor_file_system_authority.rs @@ -94,7 +94,7 @@ impl ExecutorFileSystem for SyntheticFileSystem { async fn create_directory( &self, - _path: &AbsolutePathBuf, + _path: &PathUri, _options: CreateDirectoryOptions, _sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()> { diff --git a/codex-rs/file-system/src/lib.rs b/codex-rs/file-system/src/lib.rs index 3808b24073..a83f055c34 100644 --- a/codex-rs/file-system/src/lib.rs +++ b/codex-rs/file-system/src/lib.rs @@ -166,7 +166,7 @@ pub trait ExecutorFileSystem: Send + Sync { async fn create_directory( &self, - path: &AbsolutePathBuf, + path: &PathUri, create_directory_options: CreateDirectoryOptions, sandbox: Option<&FileSystemSandboxContext>, ) -> FileSystemResult<()>;