Report the exec-server release version in environment info (#42270)

## Why

Clients need the executor's release version to make version-based compatibility decisions.

## What changed

- Add `executorVersion` to `EnvironmentInfo` and return it from both `initialize` and `environment/info`.
- Resolve the package release version at process startup so the advertised value remains stable for the server's lifetime.
- Use `0.0.0` when the version is unknown or omitted by a legacy executor.

## Testing

- Cover packaged and source-build initialization, startup caching, protocol serialization, and client-side metadata caching.

GitOrigin-RevId: a0c7f0b701a8e7e50345cd5fb1b5c5d2d38ff3b1
This commit is contained in:
felixxia-oai
2026-09-02 12:07:32 +00:00
committed by copyberry
parent a0dcfe2ada
commit 8d32abcd01
15 changed files with 131 additions and 28 deletions
+13 -2
View File
@@ -94,6 +94,10 @@ pub struct InitializeResponse {
#[serde(rename_all = "camelCase")]
pub struct EnvironmentInfo {
pub shell: ShellInfo,
/// Executor release version for version-based compatibility decisions.
/// `0.0.0` when unknown, including responses from legacy executors.
#[serde(default = "unknown_executor_version")]
pub executor_version: String,
/// Working directory inherited by the exec-server process.
#[serde(default)]
pub cwd: Option<PathUri>,
@@ -115,6 +119,10 @@ pub struct EnvironmentInfo {
pub capabilities: EnvironmentCapabilities,
}
fn unknown_executor_version() -> String {
"0.0.0".to_string()
}
/// Features supported by the selected exec-server environment.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -214,6 +222,7 @@ impl EnvironmentInfo {
Self {
shell: codex_shell_command::shell_detect::default_user_shell().into(),
executor_version: unknown_executor_version(),
cwd: cwd.and_then(|cwd| PathUri::from_host_native_path(cwd).ok()),
user_home_dir: PathUri::from_host_native_path("~").ok(),
platform_os: Some(std::env::consts::OS.to_string()),
@@ -980,6 +989,7 @@ mod tests {
name: "zsh".to_string(),
path: "/bin/zsh".to_string(),
},
executor_version: "0.0.0".to_string(),
cwd: None,
user_home_dir: None,
platform_os: None,
@@ -1012,9 +1022,10 @@ mod tests {
}
#[test]
fn environment_info_preserves_executor_temporary_directories() {
fn environment_info_preserves_executor_metadata() {
let expected = serde_json::json!({
"shell": { "name": "powershell", "path": "powershell.exe" },
"executorVersion": "1.2.3-alpha.4",
"cwd": null,
"userHomeDir": "file:///C:/Users/remote",
"platformOs": "windows",
@@ -1029,7 +1040,7 @@ mod tests {
},
});
let info: EnvironmentInfo = serde_json::from_value(expected.clone())
.expect("environment info with executor temporary directories should deserialize");
.expect("environment info with executor metadata should deserialize");
assert_eq!(
serde_json::to_value(info).expect("environment info should serialize"),