Files
codex/codex-rs/windows-sandbox-service/src/lib.rs
T
johnl-oai 501931b399 Add Windows sandbox service lifecycle scaffolding (#42341)
## What changed

- Add the `codex-windows-sandbox-service` workspace crate and Windows-only build target.
- Integrate `CodexSandboxService` with the Windows Service Control Manager, including start, stop, shutdown, status reporting, and event-log handling.
- Support service mode by default and a debug-only `--foreground` mode. Keep provisioning IPC disabled until authenticated request handling is available.

## Testing

- Add argument-parsing tests for service, foreground, unknown, and multiple arguments.

GitOrigin-RevId: 1c84f0a593b65e5cf97ab7606cde03675542b0b0
2026-09-02 19:49:58 +00:00

31 lines
595 B
Rust

use anyhow::Result;
#[cfg(windows)]
mod ipc;
#[cfg(windows)]
mod service;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RunMode {
Service,
#[cfg(debug_assertions)]
Foreground,
}
pub fn run(mode: RunMode) -> Result<()> {
#[cfg(windows)]
{
match mode {
RunMode::Service => service::run(),
#[cfg(debug_assertions)]
RunMode::Foreground => service::run_foreground(),
}
}
#[cfg(not(windows))]
{
let _ = mode;
anyhow::bail!("the Codex sandbox service is only available on Windows")
}
}