Skip to main content

vtcode_core/tools/handlers/
mod.rs

1//! Tool handlers module
2//!
3//! The authoritative public tool surface, name resolution, and catalog assembly
4//! live in `crate::tools::registry`. This module holds the handler-side types
5//! and the tool implementations that the registry and runloop build on.
6//!
7//! The Codex-compatible execution scaffolding (`router`, `adapter`, `events`,
8//! `apply_patch_handler`, `shell_handler`, `list_dir_handler`,
9//! `tool_orchestrator`, `orchestrator`, `intercept_apply_patch`) was never
10//! registered as a live path and has been removed. `tools::SHELL` and the other
11//! command-session aliases resolve to `unified_exec` through
12//! `tool_intent::canonical_command_session_tool_name`, and the executor
13//! pipeline in `crate::tools::registry` owns dispatch. Do not reintroduce a
14//! parallel handler path that bypasses it.
15//!
16//! ## Key Components
17//!
18//! - [`tool_handler`]: Handler-side types still used by live code (`ToolCallError`,
19//!   `TurnContext`, `ToolSession`, approval/sandbox policy wrappers)
20//! - [`sandboxing`]: Approval, sandbox, and runtime traits (from Codex)
21//! - [`turn_diff_tracker`]: Aggregates file diffs across patches in a turn
22//!
23//! ## Handlers
24//!
25//! - [`compact`]: Tool description compaction
26//! - [`planning_workflow`]: Plan approval artifacts and workflow state
27//! - [`planning_task_tracker`], [`task_tracker`], [`task_tracking`]: Task trackers
28//! - [`read_file`]: File reading with line ranges
29//! - [`session_tool_catalog`]: Per-session tool catalog projection
30//!
31//! ## Usage
32//!
33//! ```rust,ignore
34//! use vtcode_core::tools::handlers::{ToolHandler, ToolInvocation, ToolOutput};
35//!
36//! struct MyHandler;
37//!
38//! #[async_trait::async_trait]
39//! impl ToolHandler for MyHandler {
40//!     fn kind(&self) -> ToolKind {
41//!         ToolKind::Function
42//!     }
43//!
44//!     async fn handle(&self, invocation: ToolInvocation) -> Result<ToolOutput, ToolCallError> {
45//!         Ok(ToolOutput::simple("Done!"))
46//!     }
47//! }
48//! ```
49
50// Core architecture modules
51pub mod sandboxing;
52pub mod tool_handler;
53pub mod turn_diff_tracker;
54
55// Handler implementations
56pub mod compact;
57pub mod planning_task_tracker;
58pub mod planning_workflow;
59pub mod read_file;
60pub mod session_tool_catalog;
61mod session_tool_projection;
62pub mod task_tracker;
63pub mod task_tracking;
64
65// Re-export main types for convenience
66
67// New Sandboxing module (Codex-compatible)
68pub use sandboxing::{
69    Approvable, ApprovalCtx, ApprovalStore, AskForApproval, BoxFuture, CommandSpec, ExecApprovalRequirement, ExecEnv,
70    ExecPolicyAmendment, ExecToolCallOutput, NetworkAccess, RejectConfig, ReviewDecision, SandboxAttempt,
71    SandboxConfig, SandboxManager, SandboxOverride, SandboxPolicy, SandboxTransformError, SandboxType, Sandboxable,
72    SandboxablePreference, ToolCtx, ToolError, ToolRuntime, default_exec_approval_requirement, execute_env,
73    with_cached_approval,
74};
75
76// Turn Diff Tracker with Agent Trace support
77pub use turn_diff_tracker::{
78    ChangeAttribution, FileChange, FileChangeKind, SharedTurnDiffTracker, TurnDiffTracker, new_shared_tracker,
79};
80
81pub use session_tool_catalog::{
82    CatalogToolKind, DeferredToolPolicy, DeferredToolSearchKind, SessionSurface, SessionToolCatalog,
83    SessionToolsConfig, ToolCatalogEntry, ToolCatalogSource, ToolModelCapabilities, ToolProfile, ToolSchemaEntry,
84    anthropic_native_memory_enabled_for_runtime, deferred_tool_policy_for_runtime,
85};
86// Planning workflow tools
87pub use planning_workflow::{PlanningWorkflowState, StartPlanningTool};
88
89// Task tracker (NL2Repo-Bench)
90pub use planning_task_tracker::PlanningTaskTrackerTool;
91pub use task_tracker::TaskTrackerTool;
92
93// Core tool handler types
94pub use tool_handler::{
95    AdditionalProperties, ApprovalPolicy, ConfiguredToolSpec, Constrained, ContentItem, DiffTracker, FreeformTool,
96    FreeformToolFormat, JsonSchema, McpToolResult, ResponsesApiTool, SandboxPermissions, SharedDiffTracker,
97    ShellEnvironmentPolicy, ShellToolCallParams, ToolCallError, ToolHandler, ToolInvocation, ToolKind, ToolOutput,
98    ToolPayload, ToolSession, ToolSpec, TurnContext,
99};
100
101// Legacy FileChange re-export for backward compatibility
102pub use tool_handler::FileChange as LegacyFileChange;