Skip to main content

vtcode_core/tools/registry/
history_facade.rs

1//! Tool execution history accessors for ToolRegistry.
2
3use serde_json::Value;
4use std::time::Duration;
5
6use super::{ToolExecutionRecord, ToolRegistry};
7
8impl ToolRegistry {
9    /// Get recent tool executions (successes and failures).
10    pub fn get_recent_tool_records(&self, count: usize) -> Vec<ToolExecutionRecord> {
11        self.execution_history.get_recent_records(count)
12    }
13
14    /// Get recent tool execution failures.
15    pub fn get_recent_tool_failures(&self, count: usize) -> Vec<ToolExecutionRecord> {
16        self.execution_history.get_recent_failures(count)
17    }
18
19    /// Find a recent spooled output for a tool call with identical args.
20    pub fn find_recent_spooled_output(
21        &self,
22        tool_name: &str,
23        args: &Value,
24        max_age: Duration,
25    ) -> Option<Value> {
26        self.execution_history
27            .find_recent_spooled_result(tool_name, args, max_age)
28    }
29
30    /// Find a recent successful output for a tool call with identical args.
31    pub fn find_recent_successful_output(
32        &self,
33        tool_name: &str,
34        args: &Value,
35        max_age: Duration,
36    ) -> Option<Value> {
37        self.execution_history
38            .find_recent_successful_result(tool_name, args, max_age)
39    }
40
41    /// Find continuation metadata from a recent chunked file-read result for the same path.
42    ///
43    /// Supports both `read_file` and `unified_file` (read action) history records.
44    pub fn find_recent_read_file_spool_progress(
45        &self,
46        path: &str,
47        max_age: Duration,
48    ) -> Option<(usize, usize)> {
49        self.execution_history
50            .find_recent_read_file_spool_progress(path, max_age)
51    }
52
53    /// Clear the execution history.
54    pub fn clear_execution_history(&self) {
55        self.execution_history.clear();
56    }
57
58    /// Get the current number of stored execution records.
59    pub fn execution_history_len(&self) -> usize {
60        self.execution_history.len()
61    }
62}