mirror of
https://github.com/openai/codex.git
synced 2026-10-19 16:17:49 +00:00
Use dedicated parameters for sandboxed file opens (#49818)
## What changed Add `FsHelperOpenParams` with only a `path` field and use it for the exec-server filesystem helper's `fs/open` requests. Replace reuse of `FsReadFileParams`, removing unused read-file options from the open request type. GitOrigin-RevId: ca84447d06fbf391cc5ad189ac6c46e6aeaa1f63
This commit is contained in:
committed by
copyberry
parent
a5eac80150
commit
a73898c249
@@ -1,6 +1,7 @@
|
||||
use base64::Engine as _;
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use codex_exec_server_protocol::JSONRPCErrorError;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use tokio::io;
|
||||
@@ -66,7 +67,7 @@ pub(crate) enum FsHelperRequest {
|
||||
#[serde(rename = "capabilityRoots/discoverV1")]
|
||||
DiscoverCapabilityRoots(CapabilityRootsDiscoverParams),
|
||||
#[serde(rename = "fs/open")]
|
||||
Open(FsReadFileParams),
|
||||
Open(FsHelperOpenParams),
|
||||
#[serde(rename = "fs/readFile")]
|
||||
ReadFile(FsReadFileParams),
|
||||
#[serde(rename = "fs/writeFile")]
|
||||
@@ -87,6 +88,12 @@ pub(crate) enum FsHelperRequest {
|
||||
Copy(FsCopyParams),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct FsHelperOpenParams {
|
||||
pub(crate) path: PathUri,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "status", content = "payload", rename_all = "camelCase")]
|
||||
pub(crate) enum FsHelperResponse {
|
||||
|
||||
@@ -3,6 +3,7 @@ use codex_sandboxing::SandboxExecRequest;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use tokio::io;
|
||||
|
||||
use crate::fs_helper::FsHelperOpenParams;
|
||||
use crate::fs_helper::FsHelperOpenResponse;
|
||||
use crate::fs_helper::FsHelperPayload;
|
||||
use crate::fs_helper::FsHelperRequest;
|
||||
@@ -17,7 +18,6 @@ use crate::fs_sandbox::reap_helper_after_response;
|
||||
use crate::fs_sandbox::spawn_command;
|
||||
#[cfg(unix)]
|
||||
use crate::fs_sandbox::wait_for_helper_output;
|
||||
use crate::protocol::FsReadFileParams;
|
||||
use crate::rpc::internal_error;
|
||||
use crate::rpc::invalid_request;
|
||||
|
||||
@@ -25,12 +25,8 @@ pub(crate) async fn open(
|
||||
command: SandboxExecRequest,
|
||||
path: PathUri,
|
||||
) -> Result<tokio::fs::File, JSONRPCErrorError> {
|
||||
let request = serde_json::to_vec(&FsHelperRequest::Open(FsReadFileParams {
|
||||
path,
|
||||
follow_symlinks: None,
|
||||
sandbox: None,
|
||||
}))
|
||||
.map_err(|error| internal_error(format!("invalid fs sandbox helper request: {error}")))?;
|
||||
let request = serde_json::to_vec(&FsHelperRequest::Open(FsHelperOpenParams { path }))
|
||||
.map_err(|error| internal_error(format!("invalid fs sandbox helper request: {error}")))?;
|
||||
open_platform(command, request).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user