mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Add experimental Windows sandbox service provisioning (#42353)
## What changed - Add the default-off `windows_sandbox_service` feature and expose it through app-server experimental feature enablement. - When enabled, attempt service provisioning during elevated Windows sandbox setup, using the effective network proxy ports and listener roles. Continue through the existing setup path when the service is unavailable or the configuration is unsupported. - Report unsupported Codex home drives as service unavailability so the client can fall back to the elevated helper. ## Testing - Add a Windows-only unit test covering HTTP and SOCKS listener derivation from the effective proxy configuration. GitOrigin-RevId: 40b119cf51f84e5d0e94d6a0a8d5b506d1123526
This commit is contained in:
1 parent
7e45bdb5fd
commit
830363bd7c
10 files changed
+188
-13
No files matched your search
@@ -71,6 +71,7 @@ const SUPPORTED_EXPERIMENTAL_FEATURE_ENABLEMENT: &[&str] = &[
|
||||
"remote_control",
|
||||
"remote_plugin",
|
||||
"tool_suggest",
|
||||
"windows_sandbox_service",
|
||||
];
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -83,8 +83,82 @@ impl WindowsSandboxRequestProcessor {
|
||||
env_map: std::env::vars().collect(),
|
||||
codex_home: config.codex_home.to_path_buf(),
|
||||
};
|
||||
let setup_result =
|
||||
codex_core::windows_sandbox::run_windows_sandbox_setup(setup_request).await;
|
||||
let setup_result = async {
|
||||
// Workload identity is process-local, so use the existing helper path with
|
||||
// the caller's resolved configuration instead of loading auth in the service.
|
||||
#[cfg(target_os = "windows")]
|
||||
if setup_mode == CoreWindowsSandboxSetupMode::Elevated
|
||||
&& config.features.enabled(Feature::WindowsSandboxService)
|
||||
&& !codex_login::is_workload_identity_selected()
|
||||
{
|
||||
let provisioning = match config
|
||||
.permissions
|
||||
.network
|
||||
.as_ref()
|
||||
.map_or_else(
|
||||
|| {
|
||||
Ok((
|
||||
codex_windows_sandbox::WindowsSandboxProvisioningSettings::from_environment(
|
||||
&setup_request.permission_profile,
|
||||
&setup_request.env_map,
|
||||
),
|
||||
codex_windows_sandbox::WindowsSandboxProxyListeners::from_environment(
|
||||
&setup_request.permission_profile,
|
||||
&setup_request.env_map,
|
||||
),
|
||||
))
|
||||
},
|
||||
codex_core::config::NetworkProxySpec::windows_sandbox_proxy_listeners,
|
||||
)
|
||||
{
|
||||
Ok(provisioning) => Some(provisioning),
|
||||
Err(error) => {
|
||||
warn!(
|
||||
"Windows sandbox service does not support the configured proxy listeners; falling back to elevated setup: {error}"
|
||||
);
|
||||
None
|
||||
}
|
||||
};
|
||||
if let Some((settings, listeners)) = provisioning {
|
||||
let service_setup_request = setup_request.clone();
|
||||
let service_setup_start = Instant::now();
|
||||
tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
|
||||
if codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
|
||||
&service_setup_request.permission_profile,
|
||||
&service_setup_request.workspace_roots,
|
||||
).is_err() {
|
||||
// The existing setup path can still succeed for completed
|
||||
// provisioning without resolving the current profile.
|
||||
return Ok(());
|
||||
}
|
||||
// The shared setup path below handles helper fallback and
|
||||
// refreshes workspace ACLs after provisioning.
|
||||
codex_windows_sandbox::provision_windows_sandbox_via_service(
|
||||
&service_setup_request.codex_home,
|
||||
settings,
|
||||
listeners,
|
||||
)?;
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
.map_err(|error| {
|
||||
anyhow::anyhow!(
|
||||
"Windows sandbox service provisioning task failed: {error}"
|
||||
)
|
||||
})
|
||||
.and_then(std::convert::identity)
|
||||
.inspect_err(|error| {
|
||||
codex_core::windows_sandbox::emit_windows_sandbox_setup_failure_metrics(
|
||||
setup_mode,
|
||||
service_setup_start.elapsed(),
|
||||
error,
|
||||
);
|
||||
})?;
|
||||
}
|
||||
}
|
||||
codex_core::windows_sandbox::run_windows_sandbox_setup(setup_request).await
|
||||
}
|
||||
.await;
|
||||
let notification = WindowsSandboxSetupCompletedNotification {
|
||||
mode: match setup_mode {
|
||||
CoreWindowsSandboxSetupMode::Elevated => WindowsSandboxSetupMode::Elevated,
|
||||
|
||||
Reference in new issue
Block a user