Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

app-server: require absolute cwd for windowsSandbox/setupStart (#13833)

iceweasel-oai4b4f61d37965
diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
index c181b8bcf2..a790874de0 100644
--- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json
+++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
@@ -3041,9 +3041,13 @@
"WindowsSandboxSetupStartParams": {
"properties": {
"cwd": {
- "type": [
- "string",
- "null"
+ "anyOf": [
+ {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ {
+ "type": "null"
+ }
]
},
"mode": {
@@ -4213,4 +4217,4 @@
}
],
"title": "ClientRequest"
-}
\ No newline at end of file
+}
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
index 495339982b..c26cea19a4 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
@@ -17002,9 +17002,13 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cwd": {
- "type": [
- "string",
- "null"
+ "anyOf": [
+ {
+ "$ref": "#/definitions/v2/AbsolutePathBuf"
+ },
+ {
+ "type": "null"
+ }
]
},
"mode": {
@@ -17067,4 +17071,4 @@
},
"title": "CodexAppServerProtocol",
"type": "object"
-}
\ No newline at end of file
+}
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
index cbc28994bc..bbf05bfed0 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
@@ -15258,9 +15258,13 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cwd": {
- "type": [
- "string",
- "null"
+ "anyOf": [
+ {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ {
+ "type": "null"
+ }
]
},
"mode": {
@@ -15322,4 +15326,4 @@
},
"title": "CodexAppServerProtocolV2",
"type": "object"
-}
\ No newline at end of file
+}
diff --git a/codex-rs/app-server-protocol/schema/json/v2/WindowsSandboxSetupStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/WindowsSandboxSetupStartParams.json
index 00edc8b02e..6e2e8baebf 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/WindowsSandboxSetupStartParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/WindowsSandboxSetupStartParams.json
@@ -1,6 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
+ "AbsolutePathBuf": {
+ "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
+ "type": "string"
+ },
"WindowsSandboxSetupMode": {
"enum": [
"elevated",
@@ -11,9 +15,13 @@
},
"properties": {
"cwd": {
- "type": [
- "string",
- "null"
+ "anyOf": [
+ {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ {
+ "type": "null"
+ }
]
},
"mode": {
@@ -25,4 +33,4 @@
],
"title": "WindowsSandboxSetupStartParams",
"type": "object"
-}
\ No newline at end of file
+}
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartParams.ts
index cb342c24cd..596c9f5b8c 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartParams.ts
@@ -1,6 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+import type { AbsolutePathBuf } from "../AbsolutePathBuf";
import type { WindowsSandboxSetupMode } from "./WindowsSandboxSetupMode";
-export type WindowsSandboxSetupStartParams = { mode: WindowsSandboxSetupMode, cwd?: string | null, };
+export type WindowsSandboxSetupStartParams = { mode: WindowsSandboxSetupMode, cwd?: AbsolutePathBuf | null, };
diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs
index 6798b5bb90..e24bc46d24 100644
--- a/codex-rs/app-server-protocol/src/protocol/v2.rs
+++ b/codex-rs/app-server-protocol/src/protocol/v2.rs
@@ -4226,7 +4226,7 @@ pub enum WindowsSandboxSetupMode {
pub struct WindowsSandboxSetupStartParams {
pub mode: WindowsSandboxSetupMode,
#[ts(optional = nullable)]
- pub cwd: Option<PathBuf>,
+ pub cwd: Option<AbsolutePathBuf>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md
index 9329fd026c..2d517d2710 100644
--- a/codex-rs/app-server/README.md
+++ b/codex-rs/app-server/README.md
@@ -163,7 +163,7 @@ Example with notification opt-out:
- `tool/requestUserInput` — prompt the user with 1–3 short questions for a tool call and return their answers (experimental).
- `config/mcpServer/reload` — reload MCP server config from disk and queue a refresh for loaded threads (applied on each thread's next active turn); returns `{}`. Use this after editing `config.toml` without restarting the server.
- `mcpServerStatus/list` — enumerate configured MCP servers with their tools, resources, resource templates, and auth status; supports cursor+limit pagination.
-- `windowsSandbox/setupStart` — start Windows sandbox setup for the selected mode (`elevated` or `unelevated`); accepts an optional `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`.
+- `windowsSandbox/setupStart` — start Windows sandbox setup for the selected mode (`elevated` or `unelevated`); accepts an optional absolute `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`.
- `feedback/upload` — submit a feedback report (classification + optional reason/logs, conversation_id, and optional `extraLogFiles` attachments array); returns the tracking thread id.
- `config/read` — fetch the effective config on disk after resolving config layering.
- `externalAgentConfig/detect` — detect migratable external-agent artifacts with `includeHome` and optional `cwds`; each detected item includes `cwd` (`null` for home).
diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs
index e069f9abb3..bebce0251c 100644
--- a/codex-rs/app-server/src/codex_message_processor.rs
+++ b/codex-rs/app-server/src/codex_message_processor.rs
@@ -6653,7 +6653,10 @@ impl CodexMessageProcessor {
let config = Arc::clone(&self.config);
let cli_overrides = self.cli_overrides.clone();
let cloud_requirements = self.current_cloud_requirements();
- let command_cwd = params.cwd.unwrap_or_else(|| config.cwd.clone());
+ let command_cwd = params
+ .cwd
+ .map(PathBuf::from)
+ .unwrap_or_else(|| config.cwd.clone());
let outgoing = Arc::clone(&self.outgoing);
let connection_id = request_id.connection_id;
diff --git a/codex-rs/app-server/tests/suite/v2/windows_sandbox_setup.rs b/codex-rs/app-server/tests/suite/v2/windows_sandbox_setup.rs
index 4512d9058f..b3cbfdf325 100644
--- a/codex-rs/app-server/tests/suite/v2/windows_sandbox_setup.rs
+++ b/codex-rs/app-server/tests/suite/v2/windows_sandbox_setup.rs
@@ -62,3 +62,30 @@ async fn windows_sandbox_setup_start_emits_completion_notification() -> Result<(
assert_eq!(payload.mode, WindowsSandboxSetupMode::Unelevated);
Ok(())
}
+
+#[tokio::test]
+async fn windows_sandbox_setup_start_rejects_relative_cwd() -> Result<()> {
+ let codex_home = TempDir::new()?;
+ let mut mcp = McpProcess::new(codex_home.path()).await?;
+ timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
+
+ let request_id = mcp
+ .send_raw_request(
+ "windowsSandbox/setupStart",
+ Some(serde_json::json!({
+ "mode": "unelevated",
+ "cwd": "relative-root",
+ })),
+ )
+ .await?;
+
+ let err = timeout(
+ DEFAULT_READ_TIMEOUT,
+ mcp.read_stream_until_error_message(RequestId::Integer(request_id)),
+ )
+ .await??;
+
+ assert_eq!(err.error.code, -32600);
+ assert!(err.error.message.contains("Invalid request"));
+ Ok(())
+}