Skip to content

Commit 712bfa0

Browse files
authored
chore: move mcp-server/src/wire_format.rs to protocol/src/mcp_protocol.rs (#2423)
The existing `wire_format.rs` should share more types with the `codex-protocol` crate (like `AskForApproval` instead of maintaining a parallel `CodexToolCallApprovalPolicy` enum), so this PR moves `wire_format.rs` into `codex-protocol`, renaming it as `mcp-protocol.rs`. We also de-dupe types, where appropriate. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2423). * #2424 * __->__ #2423
1 parent da69d50 commit 712bfa0

26 files changed

+121
-109
lines changed

codex-rs/Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ codex-core = { path = "../core" }
2525
codex-exec = { path = "../exec" }
2626
codex-login = { path = "../login" }
2727
codex-mcp-server = { path = "../mcp-server" }
28+
codex-protocol = { path = "../protocol" }
2829
codex-tui = { path = "../tui" }
2930
serde_json = "1"
3031
tokio = { version = "1", features = [

codex-rs/cli/src/debug_sandbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use std::path::PathBuf;
33
use codex_common::CliConfigOverrides;
44
use codex_core::config::Config;
55
use codex_core::config::ConfigOverrides;
6-
use codex_core::config_types::SandboxMode;
76
use codex_core::exec_env::create_env;
87
use codex_core::landlock::spawn_command_under_linux_sandbox;
98
use codex_core::seatbelt::spawn_command_under_seatbelt;
109
use codex_core::spawn::StdioPolicy;
10+
use codex_protocol::config_types::SandboxMode;
1111

1212
use crate::LandlockCommand;
1313
use crate::SeatbeltCommand;

codex-rs/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ workspace = true
99
[dependencies]
1010
clap = { version = "4", features = ["derive", "wrap_help"], optional = true }
1111
codex-core = { path = "../core" }
12+
codex-protocol = { path = "../protocol" }
1213
serde = { version = "1", optional = true }
1314
toml = { version = "0.9", optional = true }
1415

codex-rs/common/src/sandbox_mode_cli_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! `config.toml`.
88
99
use clap::ValueEnum;
10-
use codex_core::config_types::SandboxMode;
10+
use codex_protocol::config_types::SandboxMode;
1111

1212
#[derive(Clone, Copy, Debug, ValueEnum)]
1313
#[value(rename_all = "kebab-case")]

codex-rs/core/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::config_types::History;
33
use crate::config_types::McpServerConfig;
44
use crate::config_types::ReasoningEffort;
55
use crate::config_types::ReasoningSummary;
6-
use crate::config_types::SandboxMode;
76
use crate::config_types::SandboxWorkspaceWrite;
87
use crate::config_types::ShellEnvironmentPolicy;
98
use crate::config_types::ShellEnvironmentPolicyToml;
@@ -16,6 +15,7 @@ use crate::model_provider_info::built_in_model_providers;
1615
use crate::openai_model_info::get_model_info;
1716
use crate::protocol::AskForApproval;
1817
use crate::protocol::SandboxPolicy;
18+
use codex_protocol::config_types::SandboxMode;
1919
use dirs::home_dir;
2020
use serde::Deserialize;
2121
use std::collections::HashMap;

codex-rs/core/src/config_types.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,6 @@ pub enum HistoryPersistence {
7878
#[derive(Deserialize, Debug, Clone, PartialEq, Default)]
7979
pub struct Tui {}
8080

81-
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Default, Serialize, Display)]
82-
#[serde(rename_all = "kebab-case")]
83-
#[strum(serialize_all = "kebab-case")]
84-
pub enum SandboxMode {
85-
#[serde(rename = "read-only")]
86-
#[default]
87-
ReadOnly,
88-
89-
#[serde(rename = "workspace-write")]
90-
WorkspaceWrite,
91-
92-
#[serde(rename = "danger-full-access")]
93-
DangerFullAccess,
94-
}
95-
9681
#[derive(Deserialize, Debug, Clone, PartialEq, Default)]
9782
pub struct SandboxWorkspaceWrite {
9883
#[serde(default)]

codex-rs/core/src/environment_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use serde::Deserialize;
22
use serde::Serialize;
33
use strum_macros::Display as DeriveDisplay;
44

5-
use crate::config_types::SandboxMode;
65
use crate::models::ContentItem;
76
use crate::models::ResponseItem;
87
use crate::protocol::AskForApproval;
98
use crate::protocol::SandboxPolicy;
9+
use codex_protocol::config_types::SandboxMode;
1010
use std::fmt::Display;
1111
use std::path::PathBuf;
1212

codex-rs/exec/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ codex-common = { path = "../common", features = [
2626
] }
2727
codex-core = { path = "../core" }
2828
codex-ollama = { path = "../ollama" }
29+
codex-protocol = { path = "../protocol" }
2930
owo-colors = "4.2.0"
3031
serde_json = "1"
3132
shlex = "1.3.0"
@@ -41,8 +42,8 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
4142

4243
[dev-dependencies]
4344
assert_cmd = "2"
45+
core_test_support = { path = "../core/tests/common" }
4446
libc = "0.2"
4547
predicates = "3"
4648
tempfile = "3.13.0"
4749
wiremock = "0.6"
48-
core_test_support = { path = "../core/tests/common" }

codex-rs/exec/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use codex_core::ConversationManager;
1313
use codex_core::NewConversation;
1414
use codex_core::config::Config;
1515
use codex_core::config::ConfigOverrides;
16-
use codex_core::config_types::SandboxMode;
1716
use codex_core::protocol::AskForApproval;
1817
use codex_core::protocol::Event;
1918
use codex_core::protocol::EventMsg;
@@ -22,6 +21,7 @@ use codex_core::protocol::Op;
2221
use codex_core::protocol::TaskCompleteEvent;
2322
use codex_core::util::is_inside_git_repo;
2423
use codex_ollama::DEFAULT_OSS_MODEL;
24+
use codex_protocol::config_types::SandboxMode;
2525
use event_processor_with_human_output::EventProcessorWithHumanOutput;
2626
use event_processor_with_json_output::EventProcessorWithJsonOutput;
2727
use tracing::debug;

0 commit comments

Comments
 (0)