fix: remove mcp-types from app server protocol (#4537)
We continue the separation between `codex app-server` and `codex
mcp-server`.
In particular, we introduce a new crate, `codex-app-server-protocol`,
and migrate `codex-rs/protocol/src/mcp_protocol.rs` into it, renaming it
`codex-rs/app-server-protocol/src/protocol.rs`.
Because `ConversationId` was defined in `mcp_protocol.rs`, we move it
into its own file, `codex-rs/protocol/src/conversation_id.rs`, and
because it is referenced in a ton of places, we have to touch a lot of
files as part of this PR.
We also decide to get away from proper JSON-RPC 2.0 semantics, so we
also introduce `codex-rs/app-server-protocol/src/jsonrpc_lite.rs`, which
is basically the same `JSONRPCMessage` type defined in `mcp-types`
except with all of the `"jsonrpc": "2.0"` removed.
Getting rid of `"jsonrpc": "2.0"` makes our serialization logic
considerably simpler, as we can lean heavier on serde to serialize
directly into the wire format that we use now.
2025-09-30 19:16:26 -07:00
|
|
|
use codex_app_server_protocol::AuthMode;
|
2025-08-19 10:55:07 -07:00
|
|
|
use codex_core::protocol_config_types::ReasoningEffort;
|
|
|
|
|
|
|
|
|
|
/// A simple preset pairing a model slug with a reasoning effort.
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct ModelPreset {
|
|
|
|
|
/// Stable identifier for the preset.
|
|
|
|
|
pub id: &'static str,
|
|
|
|
|
/// Display label shown in UIs.
|
|
|
|
|
pub label: &'static str,
|
|
|
|
|
/// Short human description shown next to the label in UIs.
|
|
|
|
|
pub description: &'static str,
|
|
|
|
|
/// Model slug (e.g., "gpt-5").
|
|
|
|
|
pub model: &'static str,
|
|
|
|
|
/// Reasoning effort to apply for this preset.
|
2025-09-12 12:06:33 -07:00
|
|
|
pub effort: Option<ReasoningEffort>,
|
2025-08-19 10:55:07 -07:00
|
|
|
}
|
|
|
|
|
|
2025-09-14 21:32:18 -04:00
|
|
|
const PRESETS: &[ModelPreset] = &[
|
|
|
|
|
ModelPreset {
|
2025-09-15 08:17:13 -07:00
|
|
|
id: "gpt-5-codex-low",
|
|
|
|
|
label: "gpt-5-codex low",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Fastest responses with limited reasoning",
|
2025-09-15 08:17:13 -07:00
|
|
|
model: "gpt-5-codex",
|
2025-09-14 21:32:18 -04:00
|
|
|
effort: Some(ReasoningEffort::Low),
|
|
|
|
|
},
|
|
|
|
|
ModelPreset {
|
2025-09-15 08:17:13 -07:00
|
|
|
id: "gpt-5-codex-medium",
|
|
|
|
|
label: "gpt-5-codex medium",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Dynamically adjusts reasoning based on the task",
|
2025-09-15 08:17:13 -07:00
|
|
|
model: "gpt-5-codex",
|
2025-09-26 22:31:39 -07:00
|
|
|
effort: Some(ReasoningEffort::Medium),
|
2025-09-14 21:32:18 -04:00
|
|
|
},
|
|
|
|
|
ModelPreset {
|
2025-09-15 08:17:13 -07:00
|
|
|
id: "gpt-5-codex-high",
|
|
|
|
|
label: "gpt-5-codex high",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Maximizes reasoning depth for complex or ambiguous problems",
|
2025-09-15 08:17:13 -07:00
|
|
|
model: "gpt-5-codex",
|
2025-09-14 21:32:18 -04:00
|
|
|
effort: Some(ReasoningEffort::High),
|
|
|
|
|
},
|
|
|
|
|
ModelPreset {
|
|
|
|
|
id: "gpt-5-minimal",
|
|
|
|
|
label: "gpt-5 minimal",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Fastest responses with little reasoning",
|
2025-09-14 21:32:18 -04:00
|
|
|
model: "gpt-5",
|
|
|
|
|
effort: Some(ReasoningEffort::Minimal),
|
|
|
|
|
},
|
|
|
|
|
ModelPreset {
|
|
|
|
|
id: "gpt-5-low",
|
|
|
|
|
label: "gpt-5 low",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Balances speed with some reasoning; useful for straightforward queries and short explanations",
|
2025-09-14 21:32:18 -04:00
|
|
|
model: "gpt-5",
|
|
|
|
|
effort: Some(ReasoningEffort::Low),
|
|
|
|
|
},
|
|
|
|
|
ModelPreset {
|
|
|
|
|
id: "gpt-5-medium",
|
|
|
|
|
label: "gpt-5 medium",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Provides a solid balance of reasoning depth and latency for general-purpose tasks",
|
2025-09-14 21:32:18 -04:00
|
|
|
model: "gpt-5",
|
|
|
|
|
effort: Some(ReasoningEffort::Medium),
|
|
|
|
|
},
|
|
|
|
|
ModelPreset {
|
|
|
|
|
id: "gpt-5-high",
|
|
|
|
|
label: "gpt-5 high",
|
2025-10-02 12:38:24 -07:00
|
|
|
description: "Maximizes reasoning depth for complex or ambiguous problems",
|
2025-09-14 21:32:18 -04:00
|
|
|
model: "gpt-5",
|
|
|
|
|
effort: Some(ReasoningEffort::High),
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2025-09-22 20:10:52 -07:00
|
|
|
pub fn builtin_model_presets(_auth_mode: Option<AuthMode>) -> Vec<ModelPreset> {
|
|
|
|
|
PRESETS.to_vec()
|
2025-08-19 10:55:07 -07:00
|
|
|
}
|