mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
fmt
This commit is contained in:
@@ -3,17 +3,39 @@ use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_code_mode::ToolDefinition as CodeModeToolDefinition;
|
||||
use codex_tools::ToolName;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::ExecContext;
|
||||
use super::PUBLIC_TOOL_NAME;
|
||||
use super::build_enabled_tools;
|
||||
use super::execute_spec::create_code_mode_tool;
|
||||
use super::handle_runtime_response;
|
||||
use super::is_exec_tool_name;
|
||||
|
||||
pub struct CodeModeExecuteHandler;
|
||||
|
||||
impl CodeModeExecuteHandler {
|
||||
pub(crate) fn definition(
|
||||
enabled_tools: &[CodeModeToolDefinition],
|
||||
namespace_descriptions: &BTreeMap<String, codex_code_mode::ToolNamespaceDescription>,
|
||||
code_mode_only: bool,
|
||||
deferred_tools_available: bool,
|
||||
) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self,
|
||||
create_code_mode_tool(
|
||||
enabled_tools,
|
||||
namespace_descriptions,
|
||||
code_mode_only,
|
||||
deferred_tools_available,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
async fn execute(
|
||||
&self,
|
||||
session: std::sync::Arc<crate::session::session::Session>,
|
||||
|
||||
@@ -5,15 +5,24 @@ use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
use super::DEFAULT_WAIT_YIELD_TIME_MS;
|
||||
use super::ExecContext;
|
||||
use super::WAIT_TOOL_NAME;
|
||||
use super::wait_spec::create_wait_tool;
|
||||
use super::handle_runtime_response;
|
||||
|
||||
pub struct CodeModeWaitHandler;
|
||||
|
||||
impl CodeModeWaitHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_wait_tool())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ExecWaitArgs {
|
||||
cell_id: String,
|
||||
|
||||
@@ -2,13 +2,22 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::agent_jobs_spec::create_report_agent_job_result_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct ReportAgentJobResultHandler;
|
||||
|
||||
impl ReportAgentJobResultHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_report_agent_job_result_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ReportAgentJobResultHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -2,13 +2,22 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::agent_jobs_spec::create_spawn_agents_on_csv_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct SpawnAgentsOnCsvHandler;
|
||||
|
||||
impl SpawnAgentsOnCsvHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_spawn_agents_on_csv_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for SpawnAgentsOnCsvHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ use crate::tools::context::ToolPayload;
|
||||
use crate::tools::events::ToolEmitter;
|
||||
use crate::tools::events::ToolEventCtx;
|
||||
use crate::tools::handlers::apply_granted_turn_permissions;
|
||||
use crate::tools::handlers::apply_patch_spec::create_apply_patch_freeform_tool;
|
||||
use crate::tools::handlers::resolve_tool_environment;
|
||||
use crate::tools::handlers::updated_hook_command;
|
||||
use crate::tools::hook_names::HookToolName;
|
||||
@@ -30,6 +31,8 @@ use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolArgumentDiffConsumer;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::tools::runtimes::apply_patch::ApplyPatchRequest;
|
||||
use crate::tools::runtimes::apply_patch::ApplyPatchRuntime;
|
||||
use crate::tools::sandboxing::ToolCtx;
|
||||
@@ -62,6 +65,13 @@ impl ApplyPatchHandler {
|
||||
pub(crate) fn new(multi_environment: bool) -> Self {
|
||||
Self { multi_environment }
|
||||
}
|
||||
|
||||
pub(crate) fn definition(multi_environment: bool) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self::new(multi_environment),
|
||||
create_apply_patch_freeform_tool(multi_environment),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -3,9 +3,12 @@ use crate::goals::CreateGoalRequest;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::goal_spec::create_create_goal_tool;
|
||||
use crate::tools::handlers::goal_spec::CREATE_GOAL_TOOL_NAME;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
use super::CompletionBudgetReport;
|
||||
@@ -15,6 +18,12 @@ use super::goal_response;
|
||||
|
||||
pub struct CreateGoalHandler;
|
||||
|
||||
impl CreateGoalHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_create_goal_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for CreateGoalHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::goal_spec::create_get_goal_tool;
|
||||
use crate::tools::handlers::goal_spec::GET_GOAL_TOOL_NAME;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
use super::CompletionBudgetReport;
|
||||
@@ -12,6 +15,12 @@ use super::goal_response;
|
||||
|
||||
pub struct GetGoalHandler;
|
||||
|
||||
impl GetGoalHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_get_goal_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for GetGoalHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@ use crate::goals::SetGoalRequest;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::goal_spec::create_update_goal_tool;
|
||||
use crate::tools::handlers::goal_spec::UPDATE_GOAL_TOOL_NAME;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::protocol::ThreadGoalStatus;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
@@ -17,6 +20,12 @@ use super::goal_response;
|
||||
|
||||
pub struct UpdateGoalHandler;
|
||||
|
||||
impl UpdateGoalHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_update_goal_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for UpdateGoalHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_list_mcp_resource_templates_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::models::function_call_output_content_items_to_text;
|
||||
use codex_protocol::protocol::McpInvocation;
|
||||
use codex_tools::ToolName;
|
||||
@@ -23,6 +26,12 @@ use super::serialize_function_output;
|
||||
|
||||
pub struct ListMcpResourceTemplatesHandler;
|
||||
|
||||
impl ListMcpResourceTemplatesHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_list_mcp_resource_templates_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ListMcpResourceTemplatesHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_list_mcp_resources_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::models::function_call_output_content_items_to_text;
|
||||
use codex_protocol::protocol::McpInvocation;
|
||||
use codex_tools::ToolName;
|
||||
@@ -23,6 +26,12 @@ use super::serialize_function_output;
|
||||
|
||||
pub struct ListMcpResourcesHandler;
|
||||
|
||||
impl ListMcpResourcesHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_list_mcp_resources_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ListMcpResourcesHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_read_mcp_resource_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::models::function_call_output_content_items_to_text;
|
||||
use codex_protocol::protocol::McpInvocation;
|
||||
use codex_tools::ToolName;
|
||||
@@ -23,6 +26,12 @@ use super::serialize_function_output;
|
||||
|
||||
pub struct ReadMcpResourceHandler;
|
||||
|
||||
impl ReadMcpResourceHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_read_mcp_resource_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ReadMcpResourceHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -14,8 +14,17 @@ use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolOutput;
|
||||
use crate::tools::context::ToolPayload;
|
||||
pub(crate) use crate::tools::handlers::multi_agents_common::*;
|
||||
use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::WaitAgentTimeoutOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::create_close_agent_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_resume_agent_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_send_input_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_wait_agent_tool_v1;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
|
||||
@@ -3,6 +3,12 @@ use crate::turn_timing::now_unix_timestamp_ms;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_close_agent_tool_v1())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = CloseAgentResult;
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@ use std::sync::Arc;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_resume_agent_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = ResumeAgentResult;
|
||||
|
||||
|
||||
@@ -4,6 +4,12 @@ use crate::turn_timing::now_unix_timestamp_ms;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_send_input_tool_v1())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = SendInputResult;
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ use crate::turn_timing::now_unix_timestamp_ms;
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition(options: SpawnAgentToolOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_spawn_agent_tool_v1(options))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = SpawnAgentResult;
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ use tokio::time::timeout_at;
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition(options: WaitAgentTimeoutOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_wait_agent_tool_v1(options))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = WaitAgentResult;
|
||||
|
||||
|
||||
@@ -7,8 +7,18 @@ use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolOutput;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::multi_agents_common::*;
|
||||
use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::WaitAgentTimeoutOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::create_close_agent_tool_v2;
|
||||
use crate::tools::handlers::multi_agents_spec::create_followup_task_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_list_agents_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_send_message_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v2;
|
||||
use crate::tools::handlers::multi_agents_spec::create_wait_agent_tool_v2;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::AgentPath;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
|
||||
@@ -3,6 +3,12 @@ use crate::turn_timing::now_unix_timestamp_ms;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_close_agent_tool_v2())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = CloseAgentResult;
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ use crate::tools::context::FunctionToolOutput;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_followup_task_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ use crate::agent::control::ListedAgent;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_list_agents_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = ListAgentsResult;
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ use crate::tools::context::FunctionToolOutput;
|
||||
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_send_message_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ use codex_protocol::protocol::Op;
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition(options: SpawnAgentToolOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_spawn_agent_tool_v2(options))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = SpawnAgentResult;
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@ use tokio::time::timeout_at;
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Handler;
|
||||
|
||||
impl Handler {
|
||||
pub(crate) fn definition(options: WaitAgentTimeoutOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_wait_agent_tool_v2(options))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for Handler {
|
||||
type Output = WaitAgentResult;
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ use crate::function_tool::FunctionCallError;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolOutput;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::plan_spec::create_update_plan_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::config_types::ModeKind;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
@@ -13,6 +16,12 @@ use serde_json::Value as JsonValue;
|
||||
|
||||
pub struct PlanHandler;
|
||||
|
||||
impl PlanHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_update_plan_tool())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PlanToolOutput;
|
||||
|
||||
const PLAN_UPDATED_MESSAGE: &str = "Plan updated";
|
||||
|
||||
@@ -6,11 +6,24 @@ use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments_with_base_path;
|
||||
use crate::tools::handlers::shell_spec::create_request_permissions_tool;
|
||||
use crate::tools::handlers::shell_spec::request_permissions_tool_description;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
pub struct RequestPermissionsHandler;
|
||||
|
||||
impl RequestPermissionsHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self,
|
||||
create_request_permissions_tool(request_permissions_tool_description()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for RequestPermissionsHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use codex_tools::DiscoverableToolType;
|
||||
use codex_tools::REQUEST_PLUGIN_INSTALL_PERSIST_ALWAYS_VALUE;
|
||||
use codex_tools::REQUEST_PLUGIN_INSTALL_PERSIST_KEY;
|
||||
use codex_tools::REQUEST_PLUGIN_INSTALL_TOOL_NAME;
|
||||
use codex_tools::RequestPluginInstallEntry;
|
||||
use codex_tools::RequestPluginInstallArgs;
|
||||
use codex_tools::RequestPluginInstallResult;
|
||||
use codex_tools::ToolName;
|
||||
@@ -30,11 +31,25 @@ use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::handlers::request_plugin_install_spec::create_request_plugin_install_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RequestPluginInstallHandler;
|
||||
|
||||
impl RequestPluginInstallHandler {
|
||||
pub(crate) fn definition(
|
||||
discoverable_tools: &[RequestPluginInstallEntry],
|
||||
) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self,
|
||||
create_request_plugin_install_tool(discoverable_tools),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for RequestPluginInstallHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -4,9 +4,13 @@ use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::handlers::request_user_input_spec::REQUEST_USER_INPUT_TOOL_NAME;
|
||||
use crate::tools::handlers::request_user_input_spec::create_request_user_input_tool;
|
||||
use crate::tools::handlers::request_user_input_spec::normalize_request_user_input_args;
|
||||
use crate::tools::handlers::request_user_input_spec::request_user_input_tool_description;
|
||||
use crate::tools::handlers::request_user_input_spec::request_user_input_unavailable_message;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_protocol::config_types::ModeKind;
|
||||
use codex_protocol::request_user_input::RequestUserInputArgs;
|
||||
use codex_tools::ToolName;
|
||||
@@ -15,6 +19,16 @@ pub struct RequestUserInputHandler {
|
||||
pub available_modes: Vec<ModeKind>,
|
||||
}
|
||||
|
||||
impl RequestUserInputHandler {
|
||||
pub(crate) fn definition(available_modes: Vec<ModeKind>) -> RuntimeToolDefinition {
|
||||
let description = request_user_input_tool_description(&available_modes);
|
||||
runtime_tool_definition(
|
||||
Self { available_modes },
|
||||
create_request_user_input_tool(description),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for RequestUserInputHandler {
|
||||
type Output = FunctionToolOutput;
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ use crate::tools::hook_names::HookToolName;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::tools::runtimes::shell::ShellRuntimeBackend;
|
||||
use crate::tools::handlers::shell_spec::create_local_shell_tool;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct LocalShellHandler {
|
||||
@@ -28,6 +31,10 @@ impl LocalShellHandler {
|
||||
supports_parallel_tool_calls: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self::new(), create_local_shell_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for LocalShellHandler {
|
||||
|
||||
@@ -26,7 +26,11 @@ use crate::tools::hook_names::HookToolName;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::tools::runtimes::shell::ShellRuntimeBackend;
|
||||
use crate::tools::handlers::shell_spec::CommandToolOptions;
|
||||
use crate::tools::handlers::shell_spec::create_shell_command_tool;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
enum ShellCommandBackend {
|
||||
@@ -47,6 +51,13 @@ impl ShellCommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn definition(
|
||||
backend_config: ShellCommandBackendConfig,
|
||||
options: CommandToolOptions,
|
||||
) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self::new(backend_config), create_shell_command_tool(options))
|
||||
}
|
||||
|
||||
fn shell_runtime_backend(&self) -> ShellRuntimeBackend {
|
||||
match self.backend {
|
||||
ShellCommandBackend::Classic => ShellRuntimeBackend::ShellCommandClassic,
|
||||
|
||||
@@ -21,7 +21,11 @@ use crate::tools::handlers::resolve_workdir_base_path;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::tools::runtimes::shell::ShellRuntimeBackend;
|
||||
use crate::tools::handlers::shell_spec::ShellToolOptions;
|
||||
use crate::tools::handlers::shell_spec::create_shell_tool;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ShellHandler {
|
||||
@@ -35,6 +39,10 @@ impl ShellHandler {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn definition(options: ShellToolOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self::new(), create_shell_tool(options))
|
||||
}
|
||||
|
||||
pub(super) fn to_exec_params(
|
||||
params: &ShellToolCallParams,
|
||||
turn_context: &TurnContext,
|
||||
|
||||
@@ -13,11 +13,20 @@ use crate::tools::context::FunctionToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::handlers::test_sync_spec::create_test_sync_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
pub struct TestSyncHandler;
|
||||
|
||||
impl TestSyncHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_test_sync_tool())
|
||||
}
|
||||
}
|
||||
|
||||
const DEFAULT_TIMEOUT_MS: u64 = 1_000;
|
||||
|
||||
static BARRIERS: OnceLock<tokio::sync::Mutex<HashMap<String, BarrierState>>> = OnceLock::new();
|
||||
|
||||
@@ -3,7 +3,10 @@ use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::context::ToolSearchOutput;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::tools::tool_search_entry::ToolSearchEntry;
|
||||
use crate::tools::handlers::tool_search_spec::create_tool_search_tool;
|
||||
use bm25::Document;
|
||||
use bm25::Language;
|
||||
use bm25::SearchEngine;
|
||||
@@ -39,6 +42,16 @@ impl ToolSearchHandler {
|
||||
search_engine,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn definition(
|
||||
entries: Vec<ToolSearchEntry>,
|
||||
source_infos: Vec<codex_tools::ToolSearchSourceInfo>,
|
||||
) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self::new(entries),
|
||||
create_tool_search_tool(&source_infos, TOOL_SEARCH_DEFAULT_LIMIT),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ToolSearchHandler {
|
||||
|
||||
@@ -18,6 +18,8 @@ use crate::tools::hook_names::HookToolName;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::unified_exec::ExecCommandRequest;
|
||||
use crate::unified_exec::UnifiedExecContext;
|
||||
use crate::unified_exec::UnifiedExecError;
|
||||
@@ -35,10 +37,24 @@ use super::ExecCommandEnvironmentArgs;
|
||||
use super::effective_max_output_tokens;
|
||||
use super::get_command;
|
||||
use super::post_unified_exec_tool_use_payload;
|
||||
use crate::tools::handlers::shell_spec::CommandToolOptions;
|
||||
use crate::tools::handlers::shell_spec::create_exec_command_tool_with_environment_id;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ExecCommandHandler;
|
||||
|
||||
impl ExecCommandHandler {
|
||||
pub(crate) fn definition(
|
||||
options: CommandToolOptions,
|
||||
include_environment_id: bool,
|
||||
) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(
|
||||
Self,
|
||||
create_exec_command_tool_with_environment_id(options, include_environment_id),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for ExecCommandHandler {
|
||||
type Output = ExecCommandToolOutput;
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ use crate::tools::context::ExecCommandToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::handlers::shell_spec::create_write_stdin_tool;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use crate::unified_exec::WriteStdinRequest;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::TerminalInteractionEvent;
|
||||
@@ -28,6 +31,12 @@ struct WriteStdinArgs {
|
||||
|
||||
pub struct WriteStdinHandler;
|
||||
|
||||
impl WriteStdinHandler {
|
||||
pub(crate) fn definition() -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_write_stdin_tool())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolHandler for WriteStdinHandler {
|
||||
type Output = ExecCommandToolOutput;
|
||||
|
||||
|
||||
@@ -18,12 +18,22 @@ use crate::tools::context::ToolOutput;
|
||||
use crate::tools::context::ToolPayload;
|
||||
use crate::tools::handlers::parse_arguments;
|
||||
use crate::tools::handlers::resolve_tool_environment;
|
||||
use crate::tools::handlers::view_image_spec::ViewImageToolOptions;
|
||||
use crate::tools::handlers::view_image_spec::create_view_image_tool;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::runtime_definition::runtime_tool_definition;
|
||||
use codex_tools::ToolName;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ViewImageHandler;
|
||||
|
||||
impl ViewImageHandler {
|
||||
pub(crate) fn definition(options: ViewImageToolOptions) -> RuntimeToolDefinition {
|
||||
runtime_tool_definition(Self, create_view_image_tool(options))
|
||||
}
|
||||
}
|
||||
|
||||
const VIEW_IMAGE_UNSUPPORTED_MESSAGE: &str =
|
||||
"view_image is not allowed because you do not support image inputs";
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ pub(crate) mod orchestrator;
|
||||
pub(crate) mod parallel;
|
||||
pub(crate) mod registry;
|
||||
pub(crate) mod router;
|
||||
pub(crate) mod runtime_definition;
|
||||
pub(crate) mod runtimes;
|
||||
pub(crate) mod sandboxing;
|
||||
pub(crate) mod spec;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_tool_api::ToolDefinition;
|
||||
use codex_tools::ToolSpec;
|
||||
|
||||
use crate::tools::registry::AnyToolHandler;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
|
||||
pub(crate) type RuntimeToolDefinition = ToolDefinition<Arc<dyn AnyToolHandler>, ToolSpec>;
|
||||
|
||||
pub(crate) fn runtime_tool_definition<H>(
|
||||
handler: H,
|
||||
spec: ToolSpec,
|
||||
) -> RuntimeToolDefinition
|
||||
where
|
||||
H: ToolHandler + 'static,
|
||||
{
|
||||
let handler = Arc::new(handler);
|
||||
let tool_name = handler.tool_name();
|
||||
let runtime: Arc<dyn AnyToolHandler> = handler;
|
||||
ToolDefinition::new(tool_name, spec, runtime)
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
use crate::tools::code_mode::execute_spec::create_code_mode_tool;
|
||||
use crate::tools::code_mode::wait_spec::create_wait_tool;
|
||||
use crate::tools::handlers::ApplyPatchHandler;
|
||||
use crate::tools::handlers::CodeModeExecuteHandler;
|
||||
use crate::tools::handlers::CodeModeWaitHandler;
|
||||
@@ -26,62 +24,28 @@ use crate::tools::handlers::ViewImageHandler;
|
||||
use crate::tools::handlers::WriteStdinHandler;
|
||||
use crate::tools::handlers::agent_jobs::ReportAgentJobResultHandler;
|
||||
use crate::tools::handlers::agent_jobs::SpawnAgentsOnCsvHandler;
|
||||
use crate::tools::handlers::agent_jobs_spec::create_report_agent_job_result_tool;
|
||||
use crate::tools::handlers::agent_jobs_spec::create_spawn_agents_on_csv_tool;
|
||||
use crate::tools::handlers::apply_patch_spec::create_apply_patch_freeform_tool;
|
||||
use crate::tools::handlers::extension_tools::ExtensionToolHandler;
|
||||
use crate::tools::handlers::goal_spec::create_create_goal_tool;
|
||||
use crate::tools::handlers::goal_spec::create_get_goal_tool;
|
||||
use crate::tools::handlers::goal_spec::create_update_goal_tool;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_list_mcp_resource_templates_tool;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_list_mcp_resources_tool;
|
||||
use crate::tools::handlers::mcp_resource_spec::create_read_mcp_resource_tool;
|
||||
use crate::tools::handlers::multi_agents::CloseAgentHandler;
|
||||
use crate::tools::handlers::multi_agents::ResumeAgentHandler;
|
||||
use crate::tools::handlers::multi_agents::SendInputHandler;
|
||||
use crate::tools::handlers::multi_agents::SpawnAgentHandler;
|
||||
use crate::tools::handlers::multi_agents::WaitAgentHandler;
|
||||
use crate::tools::handlers::multi_agents_spec::SpawnAgentToolOptions;
|
||||
use crate::tools::handlers::multi_agents_spec::create_close_agent_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_close_agent_tool_v2;
|
||||
use crate::tools::handlers::multi_agents_spec::create_followup_task_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_list_agents_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_resume_agent_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_send_input_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_send_message_tool;
|
||||
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_spawn_agent_tool_v2;
|
||||
use crate::tools::handlers::multi_agents_spec::create_wait_agent_tool_v1;
|
||||
use crate::tools::handlers::multi_agents_spec::create_wait_agent_tool_v2;
|
||||
use crate::tools::handlers::multi_agents_v2::CloseAgentHandler as CloseAgentHandlerV2;
|
||||
use crate::tools::handlers::multi_agents_v2::FollowupTaskHandler as FollowupTaskHandlerV2;
|
||||
use crate::tools::handlers::multi_agents_v2::ListAgentsHandler as ListAgentsHandlerV2;
|
||||
use crate::tools::handlers::multi_agents_v2::SendMessageHandler as SendMessageHandlerV2;
|
||||
use crate::tools::handlers::multi_agents_v2::SpawnAgentHandler as SpawnAgentHandlerV2;
|
||||
use crate::tools::handlers::multi_agents_v2::WaitAgentHandler as WaitAgentHandlerV2;
|
||||
use crate::tools::handlers::plan_spec::create_update_plan_tool;
|
||||
use crate::tools::handlers::request_plugin_install_spec::create_request_plugin_install_tool;
|
||||
use crate::tools::handlers::request_user_input_spec::create_request_user_input_tool;
|
||||
use crate::tools::handlers::request_user_input_spec::request_user_input_tool_description;
|
||||
use crate::tools::handlers::shell_spec::CommandToolOptions;
|
||||
use crate::tools::handlers::shell_spec::ShellToolOptions;
|
||||
use crate::tools::handlers::shell_spec::create_exec_command_tool_with_environment_id;
|
||||
use crate::tools::handlers::shell_spec::create_local_shell_tool;
|
||||
use crate::tools::handlers::shell_spec::create_request_permissions_tool;
|
||||
use crate::tools::handlers::shell_spec::create_shell_command_tool;
|
||||
use crate::tools::handlers::shell_spec::create_shell_tool;
|
||||
use crate::tools::handlers::shell_spec::create_write_stdin_tool;
|
||||
use crate::tools::handlers::shell_spec::request_permissions_tool_description;
|
||||
use crate::tools::handlers::test_sync_spec::create_test_sync_tool;
|
||||
use crate::tools::handlers::tool_search_spec::create_tool_search_tool;
|
||||
use crate::tools::handlers::view_image_spec::ViewImageToolOptions;
|
||||
use crate::tools::handlers::view_image_spec::create_view_image_tool;
|
||||
use crate::tools::hosted_spec::WebSearchToolOptions;
|
||||
use crate::tools::hosted_spec::create_image_generation_tool;
|
||||
use crate::tools::hosted_spec::create_web_search_tool;
|
||||
use crate::tools::registry::AnyToolHandler;
|
||||
use crate::tools::registry::ToolHandler;
|
||||
use crate::tools::registry::ToolRegistryBuilder;
|
||||
use crate::tools::runtime_definition::RuntimeToolDefinition;
|
||||
use crate::tools::spec_plan_types::ToolNamespace;
|
||||
use crate::tools::spec_plan_types::ToolRegistryBuildParams;
|
||||
use crate::tools::spec_plan_types::agent_type_description;
|
||||
@@ -157,20 +121,17 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
CodeModeExecuteHandler,
|
||||
create_code_mode_tool(
|
||||
&enabled_tools,
|
||||
&namespace_descriptions,
|
||||
config.code_mode_only_enabled,
|
||||
tool_search_plan.deferred_tools_available(),
|
||||
),
|
||||
CodeModeExecuteHandler::definition(
|
||||
&enabled_tools,
|
||||
&namespace_descriptions,
|
||||
config.code_mode_only_enabled,
|
||||
tool_search_plan.deferred_tools_available(),
|
||||
),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(CodeModeWaitHandler, create_wait_tool()),
|
||||
CodeModeWaitHandler::definition(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,35 +146,32 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ShellHandler::new(), create_shell_tool(shell_options)),
|
||||
ShellHandler::definition(shell_options),
|
||||
);
|
||||
}
|
||||
ConfigShellToolType::Local => {
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(LocalShellHandler::new(), create_local_shell_tool()),
|
||||
LocalShellHandler::definition(),
|
||||
);
|
||||
}
|
||||
ConfigShellToolType::UnifiedExec => {
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ExecCommandHandler,
|
||||
create_exec_command_tool_with_environment_id(
|
||||
CommandToolOptions {
|
||||
allow_login_shell: config.allow_login_shell,
|
||||
exec_permission_approvals_enabled,
|
||||
},
|
||||
include_environment_id,
|
||||
),
|
||||
ExecCommandHandler::definition(
|
||||
CommandToolOptions {
|
||||
allow_login_shell: config.allow_login_shell,
|
||||
exec_permission_approvals_enabled,
|
||||
},
|
||||
include_environment_id,
|
||||
),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(WriteStdinHandler, create_write_stdin_tool()),
|
||||
WriteStdinHandler::definition(),
|
||||
);
|
||||
}
|
||||
ConfigShellToolType::Disabled => {}
|
||||
@@ -225,9 +183,9 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ShellCommandHandler::new(config.shell_command_backend),
|
||||
create_shell_command_tool(shell_command_options),
|
||||
ShellCommandHandler::definition(
|
||||
config.shell_command_backend,
|
||||
shell_command_options,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -273,43 +231,40 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ListMcpResourcesHandler, create_list_mcp_resources_tool()),
|
||||
ListMcpResourcesHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ListMcpResourceTemplatesHandler,
|
||||
create_list_mcp_resource_templates_tool(),
|
||||
),
|
||||
ListMcpResourceTemplatesHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ReadMcpResourceHandler, create_read_mcp_resource_tool()),
|
||||
ReadMcpResourceHandler::definition(),
|
||||
);
|
||||
}
|
||||
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(PlanHandler, create_update_plan_tool()),
|
||||
PlanHandler::definition(),
|
||||
);
|
||||
if config.goal_tools {
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(GetGoalHandler, create_get_goal_tool()),
|
||||
GetGoalHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(CreateGoalHandler, create_create_goal_tool()),
|
||||
CreateGoalHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(UpdateGoalHandler, create_update_goal_tool()),
|
||||
UpdateGoalHandler::definition(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -317,22 +272,14 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
RequestUserInputHandler {
|
||||
available_modes: available_modes.clone(),
|
||||
},
|
||||
create_request_user_input_tool(request_user_input_tool_description(&available_modes)),
|
||||
),
|
||||
RequestUserInputHandler::definition(available_modes),
|
||||
);
|
||||
|
||||
if config.request_permissions_tool_enabled {
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
RequestPermissionsHandler,
|
||||
create_request_permissions_tool(request_permissions_tool_description()),
|
||||
),
|
||||
RequestPermissionsHandler::definition(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -345,10 +292,7 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ToolSearchHandler::new(entries),
|
||||
create_tool_search_tool(&source_infos, codex_tools::TOOL_SEARCH_DEFAULT_LIMIT),
|
||||
),
|
||||
ToolSearchHandler::definition(entries, source_infos),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -360,10 +304,7 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
RequestPluginInstallHandler,
|
||||
create_request_plugin_install_tool(&discoverable_tool_entries),
|
||||
),
|
||||
RequestPluginInstallHandler::definition(&discoverable_tool_entries),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -373,10 +314,7 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ApplyPatchHandler::new(include_environment_id),
|
||||
create_apply_patch_freeform_tool(include_environment_id),
|
||||
),
|
||||
ApplyPatchHandler::definition(include_environment_id),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -388,7 +326,7 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(TestSyncHandler, create_test_sync_tool()),
|
||||
TestSyncHandler::definition(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -414,7 +352,7 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ViewImageHandler, create_view_image_tool(view_image_options)),
|
||||
ViewImageHandler::definition(view_image_options),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -433,38 +371,32 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
SpawnAgentHandlerV2,
|
||||
create_spawn_agent_tool_v2(spawn_agent_options),
|
||||
),
|
||||
SpawnAgentHandlerV2::definition(spawn_agent_options),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(SendMessageHandlerV2, create_send_message_tool()),
|
||||
SendMessageHandlerV2::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(FollowupTaskHandlerV2, create_followup_task_tool()),
|
||||
FollowupTaskHandlerV2::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
WaitAgentHandlerV2,
|
||||
create_wait_agent_tool_v2(params.wait_agent_timeouts),
|
||||
),
|
||||
WaitAgentHandlerV2::definition(params.wait_agent_timeouts),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(CloseAgentHandlerV2, create_close_agent_tool_v2()),
|
||||
CloseAgentHandlerV2::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ListAgentsHandlerV2, create_list_agents_tool()),
|
||||
ListAgentsHandlerV2::definition(),
|
||||
);
|
||||
} else {
|
||||
let agent_type_description =
|
||||
@@ -480,33 +412,27 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
SpawnAgentHandler,
|
||||
create_spawn_agent_tool_v1(spawn_agent_options),
|
||||
),
|
||||
SpawnAgentHandler::definition(spawn_agent_options),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(SendInputHandler, create_send_input_tool_v1()),
|
||||
SendInputHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(ResumeAgentHandler, create_resume_agent_tool()),
|
||||
ResumeAgentHandler::definition(),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
WaitAgentHandler,
|
||||
create_wait_agent_tool_v1(params.wait_agent_timeouts),
|
||||
),
|
||||
WaitAgentHandler::definition(params.wait_agent_timeouts),
|
||||
);
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(CloseAgentHandler, create_close_agent_tool_v1()),
|
||||
CloseAgentHandler::definition(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -515,16 +441,13 @@ pub fn build_tool_registry_builder(
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(SpawnAgentsOnCsvHandler, create_spawn_agents_on_csv_tool()),
|
||||
SpawnAgentsOnCsvHandler::definition(),
|
||||
);
|
||||
if config.agent_jobs_worker_tools {
|
||||
register_and_publish_tool_definition(
|
||||
&mut builder,
|
||||
config,
|
||||
runtime_tool_definition(
|
||||
ReportAgentJobResultHandler,
|
||||
create_report_agent_job_result_tool(),
|
||||
),
|
||||
ReportAgentJobResultHandler::definition(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -559,7 +482,6 @@ pub fn build_tool_registry_builder(
|
||||
}
|
||||
|
||||
type FunctionRuntimeToolDefinition = ToolDefinition<Arc<dyn AnyToolHandler>>;
|
||||
type RuntimeToolDefinition = ToolDefinition<Arc<dyn AnyToolHandler>, ToolSpec>;
|
||||
|
||||
struct ToolSearchPlan {
|
||||
register: bool,
|
||||
@@ -661,16 +583,6 @@ fn build_tool_search_plan(
|
||||
}
|
||||
}
|
||||
|
||||
fn runtime_tool_definition<H>(handler: H, spec: ToolSpec) -> RuntimeToolDefinition
|
||||
where
|
||||
H: ToolHandler + 'static,
|
||||
{
|
||||
let handler = Arc::new(handler);
|
||||
let tool_name = handler.tool_name();
|
||||
let runtime: Arc<dyn AnyToolHandler> = handler;
|
||||
ToolDefinition::new(tool_name, spec, runtime)
|
||||
}
|
||||
|
||||
fn register_and_publish_tool_definition(
|
||||
builder: &mut ToolRegistryBuilder,
|
||||
config: &ToolsConfig,
|
||||
|
||||
Reference in New Issue
Block a user