mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
## Why Added support for UDS connections in `codex --remote`. TUI also now connects to local app-server using UDS by default if it is running and set to listen to UDS connection. ## What Changed - Introduced `RemoteAppServerEndpoint` with `WebSocket` and `UnixSocket` variants. - Reused the existing JSON-RPC-over-WebSocket protocol over either a TCP WebSocket stream or a UDS stream. - Updated `codex --remote` to accept `ws://host:port`, `wss://host:port`, `unix://`, and `unix://PATH`. - Kept `--remote-auth-token-env` restricted to `wss://` and loopback `ws://` remotes. - Added a fast TUI startup probe for the default daemon socket, falling back to the embedded app server when the daemon is absent or unresponsive. ## Verification - Manually verified that the updated remote flow works. - Added coverage for UDS remote round trips, WebSocket auth headers, auth-token transport policy, remote address parsing, and missing-daemon fallback. - Ran focused remote test coverage locally.
78 lines
2.0 KiB
Rust
78 lines
2.0 KiB
Rust
use clap::Parser;
|
|
use codex_app_server_client::legacy_core;
|
|
use codex_arg0::Arg0DispatchPaths;
|
|
use codex_arg0::arg0_dispatch_or_else;
|
|
use codex_config::LoaderOverrides;
|
|
use codex_tui::AppExitInfo;
|
|
use codex_tui::Cli;
|
|
use codex_tui::ExitReason;
|
|
use codex_tui::run_main;
|
|
use codex_utils_cli::CliConfigOverrides;
|
|
use supports_color::Stream;
|
|
|
|
fn format_exit_messages(exit_info: AppExitInfo, color_enabled: bool) -> Vec<String> {
|
|
let AppExitInfo {
|
|
token_usage,
|
|
thread_id,
|
|
..
|
|
} = exit_info;
|
|
|
|
let mut lines = Vec::new();
|
|
if !token_usage.is_zero() {
|
|
lines.push(token_usage.to_string());
|
|
}
|
|
|
|
if let Some(resume_cmd) =
|
|
legacy_core::util::resume_command(/*thread_name*/ None, thread_id)
|
|
{
|
|
let command = if color_enabled {
|
|
format!("\u{1b}[36m{resume_cmd}\u{1b}[39m")
|
|
} else {
|
|
resume_cmd
|
|
};
|
|
lines.push(format!("To continue this session, run {command}"));
|
|
}
|
|
|
|
lines
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
struct TopCli {
|
|
#[clap(flatten)]
|
|
config_overrides: CliConfigOverrides,
|
|
|
|
#[clap(flatten)]
|
|
inner: Cli,
|
|
}
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
arg0_dispatch_or_else(|arg0_paths: Arg0DispatchPaths| async move {
|
|
let top_cli = TopCli::parse();
|
|
let mut inner = top_cli.inner;
|
|
inner
|
|
.config_overrides
|
|
.raw_overrides
|
|
.splice(0..0, top_cli.config_overrides.raw_overrides);
|
|
let exit_info = run_main(
|
|
inner,
|
|
arg0_paths,
|
|
LoaderOverrides::default(),
|
|
/*explicit_remote_endpoint*/ None,
|
|
)
|
|
.await?;
|
|
match exit_info.exit_reason {
|
|
ExitReason::Fatal(message) => {
|
|
eprintln!("ERROR: {message}");
|
|
std::process::exit(1);
|
|
}
|
|
ExitReason::UserRequested => {}
|
|
}
|
|
|
|
let color_enabled = supports_color::on(Stream::Stdout).is_some();
|
|
for line in format_exit_messages(exit_info, color_enabled) {
|
|
println!("{line}");
|
|
}
|
|
Ok(())
|
|
})
|
|
}
|