mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Make sandbox settings environment-owned
This commit is contained in:
@@ -591,6 +591,15 @@ fn resolve_turn_environment_selections(
|
||||
let mut selections = Vec::with_capacity(environments.len());
|
||||
for environment in environments {
|
||||
let environment_id = environment.environment_id;
|
||||
let sandbox = environment
|
||||
.sandbox
|
||||
.map(TryInto::try_into)
|
||||
.transpose()
|
||||
.map_err(|err| {
|
||||
invalid_request(format!(
|
||||
"invalid sandbox for environment `{environment_id}`: {err}"
|
||||
))
|
||||
})?;
|
||||
let cwd = environment
|
||||
.cwd
|
||||
.to_inferred_path_uri()
|
||||
@@ -622,6 +631,7 @@ fn resolve_turn_environment_selections(
|
||||
environment_id,
|
||||
cwd,
|
||||
workspace_roots,
|
||||
sandbox,
|
||||
});
|
||||
}
|
||||
thread_manager
|
||||
|
||||
@@ -198,6 +198,15 @@ impl TestAppServer {
|
||||
environment_id: selection.environment_id.clone(),
|
||||
cwd: selection.cwd.clone().into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: selection.sandbox.clone().map(|sandbox| {
|
||||
codex_app_server_protocol::TurnEnvironmentSandboxParams {
|
||||
permission_profile: sandbox.permission_profile.into(),
|
||||
active_permission_profile: sandbox.active_permission_profile.map(Into::into),
|
||||
windows_sandbox_level: sandbox.windows_sandbox_level,
|
||||
windows_sandbox_private_desktop: sandbox.windows_sandbox_private_desktop,
|
||||
use_legacy_landlock: sandbox.use_legacy_landlock,
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ async fn selected_environment_emits_connection_lifecycle_notifications() -> Resu
|
||||
cwd: codex_utils_absolute_path::AbsolutePathBuf::try_from(codex_home.path().to_path_buf())?
|
||||
.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
};
|
||||
let request_id = app_server
|
||||
.send_thread_start_request(ThreadStartParams {
|
||||
|
||||
@@ -382,6 +382,7 @@ url = "{mcp_server_url}/mcp"
|
||||
)?
|
||||
.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
selected_capability_roots: Some(vec![SelectedCapabilityRoot {
|
||||
id: "late-plugin@1".to_string(),
|
||||
|
||||
@@ -367,6 +367,7 @@ async fn selected_capabilities_become_available_between_samples_in_one_turn() ->
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: fixture.environment_cwd.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
collaboration_mode: Some(CollaborationMode {
|
||||
mode: ModeKind::Plan,
|
||||
@@ -646,6 +647,7 @@ async fn start_thread(
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: environment_cwd.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
selected_capability_roots: Some(vec![selected_root]),
|
||||
..Default::default()
|
||||
@@ -677,6 +679,7 @@ async fn run_turn(
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: environment_cwd.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -674,6 +674,7 @@ async fn thread_start_rejects_unknown_environment_as_invalid_request() -> Result
|
||||
environment_id: "missing".to_string(),
|
||||
cwd: workspace.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -712,6 +713,7 @@ async fn thread_start_rejects_relative_environment_cwd_as_invalid_request() -> R
|
||||
environment_id: environment_id.clone(),
|
||||
cwd: serde_json::from_value(json!("relative"))?,
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -1478,6 +1478,7 @@ async fn turn_start_rejects_unknown_environment_before_starting_turn() -> Result
|
||||
)?
|
||||
.into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
..Default::default()
|
||||
})
|
||||
@@ -2649,6 +2650,7 @@ async fn turn_start_explicit_local_environment_updates_legacy_cwd_between_turns(
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: second_cwd.abs().into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
}]),
|
||||
thread_id: thread.id.clone(),
|
||||
client_user_message_id: None,
|
||||
@@ -3033,6 +3035,7 @@ fn environment_params(ids: Option<&[&str]>, cwd: &Path) -> Option<Vec<TurnEnviro
|
||||
environment_id: (*id).to_string(),
|
||||
cwd: cwd.abs().into(),
|
||||
runtime_workspace_roots: None,
|
||||
sandbox: None,
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user