use crate::types::io::FunctionTool;
use crate::types::io::input::FunctionToolResultMessage;
use crate::types::tools::ResponsesTool;
use super::codex::CodexNamespaceHandler;
use super::handler::{ToolHandler, ToolOutput};
use super::web_search::web_search_function_tool;
impl ResponsesTool {
#[must_use]
pub fn to_function_tools(&self) -> Vec<FunctionTool> {
match self {
Self::Function(p) => vec![FunctionTool::from(p)],
Self::Mcp(p) => {
tracing::debug!(
server_label = %p.server_label,
"MCP tool skipped in normalize - handler not yet registered"
);
vec![]
}
Self::WebSearch(_) => vec![web_search_function_tool()],
Self::FileSearch(_) => {
tracing::debug!("file_search tool skipped in normalize - handler not yet registered");
vec![]
}
Self::CodeInterpreter(_) => {
tracing::debug!("code_interpreter tool skipped in normalize - handler not yet registered");
vec![]
}
Self::Namespace(p) => {
let param = serde_json::to_value(p).expect("serialization of known struct is infallible");
CodexNamespaceHandler.normalize(¶m)
}
Self::Unknown => {
tracing::debug!("unknown tool skipped in normalize");
vec![]
}
}
}
}
impl From<ToolOutput> for FunctionToolResultMessage {
fn from(o: ToolOutput) -> Self {
Self {
call_id: o.call_id,
output: o.output,
}
}
}