mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
refactor: make codex-tools rmcp-optional on wasm
This commit is contained in:
@@ -11,14 +11,16 @@ workspace = true
|
||||
codex-app-server-protocol = { workspace = true }
|
||||
codex-code-mode = { workspace = true }
|
||||
codex-protocol = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
rmcp = { workspace = true, default-features = false, features = [
|
||||
"base64",
|
||||
"macros",
|
||||
"schemars",
|
||||
"server",
|
||||
] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = { workspace = true }
|
||||
|
||||
@@ -54,6 +54,7 @@ pub use mcp_resource_tool::create_list_mcp_resource_templates_tool;
|
||||
pub use mcp_resource_tool::create_list_mcp_resources_tool;
|
||||
pub use mcp_resource_tool::create_read_mcp_resource_tool;
|
||||
pub use mcp_tool::mcp_call_tool_result_output_schema;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use mcp_tool::parse_mcp_tool;
|
||||
pub use request_user_input_tool::create_request_user_input_tool;
|
||||
pub use responses_api::FreeformTool;
|
||||
@@ -63,7 +64,9 @@ pub use responses_api::ResponsesApiNamespaceTool;
|
||||
pub use responses_api::ResponsesApiTool;
|
||||
pub use responses_api::ToolSearchOutputTool;
|
||||
pub use responses_api::dynamic_tool_to_responses_api_tool;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use responses_api::mcp_tool_to_deferred_responses_api_tool;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use responses_api::mcp_tool_to_responses_api_tool;
|
||||
pub use responses_api::tool_definition_to_responses_api_tool;
|
||||
pub use tool_definition::ToolDefinition;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::ToolDefinition;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::parse_tool_input_schema;
|
||||
use serde_json::Value as JsonValue;
|
||||
use serde_json::json;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn parse_mcp_tool(tool: &rmcp::model::Tool) -> Result<ToolDefinition, serde_json::Error> {
|
||||
let mut serialized_input_schema = serde_json::Value::Object(tool.input_schema.as_ref().clone());
|
||||
|
||||
@@ -55,6 +58,6 @@ pub fn mcp_call_tool_result_output_schema(structured_content_schema: JsonValue)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
#[path = "mcp_tool_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::JsonSchema;
|
||||
use crate::ToolDefinition;
|
||||
use crate::parse_dynamic_tool;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::parse_mcp_tool;
|
||||
use codex_protocol::dynamic_tools::DynamicToolSpec;
|
||||
use serde::Deserialize;
|
||||
@@ -68,6 +69,7 @@ pub fn dynamic_tool_to_responses_api_tool(
|
||||
)?))
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn mcp_tool_to_responses_api_tool(
|
||||
name: String,
|
||||
tool: &rmcp::model::Tool,
|
||||
@@ -77,6 +79,7 @@ pub fn mcp_tool_to_responses_api_tool(
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn mcp_tool_to_deferred_responses_api_tool(
|
||||
name: String,
|
||||
tool: &rmcp::model::Tool,
|
||||
@@ -97,6 +100,6 @@ pub fn tool_definition_to_responses_api_tool(tool_definition: ToolDefinition) ->
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
#[path = "responses_api_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user