mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
6a6a5f925e
## Why
Shell detection needs to be available through the `Environment`
abstraction so callers can ask the selected local or remote environment
for shell metadata without adding a separate HTTP endpoint or parallel
info-source path. This keeps shell metadata shaped like the existing
environment-owned filesystem capability and lets remote environments
answer through exec-server JSON-RPC.
## What changed
- Added `environment/info` to the exec-server protocol/client/server and
exposed `Environment::info()`.
- Added local and remote environment info providers on `Environment`,
following the existing capability-provider pattern used for filesystem
access.
- Moved the shared shell detection logic into `codex-shell-command` and
kept core shell APIs as wrappers around that implementation.
- Returned shell metadata as `EnvironmentInfo { shell: ShellInfo }`
using the existing shell detection path.
- Added a remote environment test that calls `Environment::info()`
through an exec-server-backed environment.
## Validation
- `git diff --check`
- `just test -p codex-shell-command`
- `just test -p codex-core -E 'test(/shell::tests::/)'`\n- `just test -p
codex-exec-server environment`
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
#![cfg(unix)]
|
|
|
|
mod common;
|
|
|
|
use codex_exec_server::Environment;
|
|
use common::exec_server::exec_server;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn exec_server_serves_readyz_alongside_websocket_endpoint() -> anyhow::Result<()> {
|
|
let mut server = exec_server().await?;
|
|
let http_base_url = server
|
|
.websocket_url()
|
|
.strip_prefix("ws://")
|
|
.expect("websocket URL should use ws://");
|
|
|
|
let response = reqwest::get(format!("http://{http_base_url}/readyz")).await?;
|
|
assert_eq!(response.status(), reqwest::StatusCode::OK);
|
|
|
|
server.shutdown().await?;
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
async fn remote_environment_fetches_info_from_exec_server() -> anyhow::Result<()> {
|
|
let mut server = exec_server().await?;
|
|
let environment = Environment::create_for_tests(Some(server.websocket_url().to_string()))?;
|
|
assert!(environment.is_remote());
|
|
|
|
let remote_info = environment.info().await?;
|
|
let local_info = Environment::default_for_tests().info().await?;
|
|
assert_eq!(remote_info, local_info);
|
|
|
|
server.shutdown().await?;
|
|
Ok(())
|
|
}
|