vtcode_config/constants/
tools.rs1pub const EXEC_COMMAND: &str = "exec_command";
6pub const WRITE_STDIN: &str = "write_stdin";
8pub const APPLY_PATCH: &str = "apply_patch";
10pub const RECORD_DECISION: &str = "record_decision";
12pub const CODE_SEARCH: &str = "code_search";
14
15pub const UNIFIED_SEARCH: &str = "search_dispatch_internal";
20pub const UNIFIED_EXEC: &str = "command_session_internal";
22pub const UNIFIED_FILE: &str = "file_operation_internal";
24
25pub const THINK: &str = "think";
29pub const SEARCH_TOOLS: &str = "search_tools";
30pub const MCP: &str = "mcp";
36pub const MCP_SEARCH_TOOLS: &str = "mcp_search_tools";
37pub const MCP_GET_TOOL_DETAILS: &str = "mcp_get_tool_details";
38pub const MCP_LIST_SERVERS: &str = "mcp_list_servers";
39pub const MCP_CONNECT_SERVER: &str = "mcp_connect_server";
40pub const MCP_DISCONNECT_SERVER: &str = "mcp_disconnect_server";
41pub const WEB_SEARCH: &str = "web_search";
42pub const WEB_FETCH: &str = "web_fetch";
43pub const FETCH_URL: &str = "fetch_url";
44pub const LIST: &str = "list";
45pub const GREP: &str = "grep";
46pub const FETCH: &str = "fetch";
47pub const EXEC_PTY_CMD: &str = "exec_pty_cmd";
48pub const SHELL: &str = "shell";
49pub const GREP_FILE: &str = "grep_file";
50pub const LIST_FILES: &str = "list_files";
51
52pub const LIST_SKILLS: &str = "list_skills";
57pub const LOAD_SKILL: &str = "load_skill";
59pub const LOAD_SKILL_RESOURCE: &str = "load_skill_resource";
61
62pub const RUN_PTY_CMD: &str = "run_pty_cmd";
66pub const CREATE_PTY_SESSION: &str = "create_pty_session";
67pub const LIST_PTY_SESSIONS: &str = "list_pty_sessions";
68pub const CLOSE_PTY_SESSION: &str = "close_pty_session";
69pub const SEND_PTY_INPUT: &str = "send_pty_input";
70pub const READ_PTY_SESSION: &str = "read_pty_session";
71pub const RESIZE_PTY_SESSION: &str = "resize_pty_session";
72pub const EXECUTE_CODE: &str = "execute_code";
73
74pub const READ_FILE: &str = "read_file";
78pub const WRITE_FILE: &str = "write_file";
79pub const EDIT_FILE: &str = "edit_file";
80pub const DELETE_FILE: &str = "delete_file";
81pub const CREATE_FILE: &str = "create_file";
82pub const SEARCH_REPLACE: &str = "search_replace";
83pub const FILE_OP: &str = "file_op";
84pub const MOVE_FILE: &str = "move_file";
85pub const COPY_FILE: &str = "copy_file";
86
87pub const GET_ERRORS: &str = "get_errors";
91
92pub const REQUEST_USER_INPUT: &str = "request_user_input";
97pub const MEMORY: &str = "memory";
99pub const ASK_QUESTIONS: &str = "ask_questions";
101pub const ASK_USER_QUESTION: &str = "ask_user_question";
103pub const MATRIX: &str = "matrix";
105pub const AGENT: &str = "agent";
112pub const CRON: &str = "cron";
114pub const CRON_CREATE: &str = "cron_create";
116pub const CRON_LIST: &str = "cron_list";
118pub const CRON_DELETE: &str = "cron_delete";
120
121pub const START_PLANNING: &str = "start_planning";
126pub const TASK_TRACKER: &str = "task_tracker";
128
129pub const SPAWN_AGENT: &str = "spawn_agent";
134pub const SPAWN_BACKGROUND_SUBPROCESS: &str = "spawn_background_subprocess";
136pub const SEND_INPUT: &str = "send_input";
138pub const WAIT_AGENT: &str = "wait_agent";
140pub const RESUME_AGENT: &str = "resume_agent";
142pub const CLOSE_AGENT: &str = "close_agent";
144pub const ASK_SESSION: &str = "ask_session";
146pub const ANSWER_SESSION: &str = "answer_session";
148pub const LIST_SESSIONS: &str = "list_sessions";
150
151pub const LIFECYCLE_CLEANUP_TOOLS: &[&str] = &[WAIT_AGENT, CLOSE_AGENT];
155
156pub const ALWAYS_AVAILABLE_WORKFLOW_TOOLS: &[&str] = &[TASK_TRACKER, START_PLANNING, REQUEST_USER_INPUT, MATRIX];
165
166#[inline]
169pub fn is_workflow_coordination_tool(canonical_name: &str) -> bool {
170 ALWAYS_AVAILABLE_WORKFLOW_TOOLS.contains(&canonical_name)
171}
172
173#[inline]
180pub fn canonical_command_session_tool_name(tool_name: &str) -> Option<&'static str> {
181 match tool_name {
182 UNIFIED_EXEC | RUN_PTY_CMD | SEND_PTY_INPUT | CREATE_PTY_SESSION | READ_PTY_SESSION | LIST_PTY_SESSIONS
183 | CLOSE_PTY_SESSION | EXECUTE_CODE | EXEC_PTY_CMD | EXEC_COMMAND | WRITE_STDIN | SHELL | "bash" | "exec"
184 | "container.exec" => Some(UNIFIED_EXEC),
185 _ => None,
186 }
187}
188
189#[must_use]
191#[inline]
192pub fn is_command_session_tool(tool_name: &str) -> bool {
193 canonical_command_session_tool_name(tool_name).is_some()
194}
195
196pub const WILDCARD_ALL: &str = "*";
198
199const _: () = {
209 const fn validate_tool_name(name: &str) {
213 assert!(!name.is_empty(), "tool name must not be empty");
214 let bytes = name.as_bytes();
215 if bytes.len() == 1 && bytes[0] == b'*' {
217 return;
218 }
219 assert!(
220 bytes[0] != b'_' && bytes[bytes.len() - 1] != b'_',
221 "tool name must not have leading/trailing underscores"
222 );
223 let mut i = 0;
224 while i < bytes.len() {
225 let b = bytes[i];
226 assert!(b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_', "tool name must contain only [a-z0-9_]");
227 i += 1;
228 }
229 }
230
231 validate_tool_name(EXEC_COMMAND);
233 validate_tool_name(WRITE_STDIN);
234 validate_tool_name(APPLY_PATCH);
235 validate_tool_name(CODE_SEARCH);
236
237 validate_tool_name(UNIFIED_SEARCH);
239 validate_tool_name(UNIFIED_EXEC);
240 validate_tool_name(UNIFIED_FILE);
241
242 validate_tool_name(THINK);
244 validate_tool_name(SEARCH_TOOLS);
245 validate_tool_name(MCP);
246 validate_tool_name(MCP_SEARCH_TOOLS);
247 validate_tool_name(MCP_GET_TOOL_DETAILS);
248 validate_tool_name(MCP_LIST_SERVERS);
249 validate_tool_name(MCP_CONNECT_SERVER);
250 validate_tool_name(MCP_DISCONNECT_SERVER);
251 validate_tool_name(WEB_SEARCH);
252 validate_tool_name(WEB_FETCH);
253 validate_tool_name(FETCH_URL);
254 validate_tool_name(LIST);
255 validate_tool_name(GREP);
256 validate_tool_name(FETCH);
257 validate_tool_name(EXEC_PTY_CMD);
258 validate_tool_name(SHELL);
259 validate_tool_name(GREP_FILE);
260 validate_tool_name(LIST_FILES);
261
262 validate_tool_name(LIST_SKILLS);
264 validate_tool_name(LOAD_SKILL);
265 validate_tool_name(LOAD_SKILL_RESOURCE);
266
267 validate_tool_name(RUN_PTY_CMD);
269 validate_tool_name(CREATE_PTY_SESSION);
270 validate_tool_name(LIST_PTY_SESSIONS);
271 validate_tool_name(CLOSE_PTY_SESSION);
272 validate_tool_name(SEND_PTY_INPUT);
273 validate_tool_name(READ_PTY_SESSION);
274 validate_tool_name(RESIZE_PTY_SESSION);
275 validate_tool_name(EXECUTE_CODE);
276
277 validate_tool_name(READ_FILE);
279 validate_tool_name(WRITE_FILE);
280 validate_tool_name(EDIT_FILE);
281 validate_tool_name(DELETE_FILE);
282 validate_tool_name(CREATE_FILE);
283 validate_tool_name(SEARCH_REPLACE);
284 validate_tool_name(FILE_OP);
285 validate_tool_name(MOVE_FILE);
286 validate_tool_name(COPY_FILE);
287
288 validate_tool_name(GET_ERRORS);
290
291 validate_tool_name(REQUEST_USER_INPUT);
293 validate_tool_name(MEMORY);
294 validate_tool_name(ASK_QUESTIONS);
295 validate_tool_name(ASK_USER_QUESTION);
296 validate_tool_name(AGENT);
297 validate_tool_name(CRON);
298 validate_tool_name(CRON_CREATE);
299 validate_tool_name(CRON_LIST);
300 validate_tool_name(CRON_DELETE);
301
302 validate_tool_name(START_PLANNING);
304 validate_tool_name(TASK_TRACKER);
305
306 validate_tool_name(SPAWN_AGENT);
308 validate_tool_name(SPAWN_BACKGROUND_SUBPROCESS);
309 validate_tool_name(SEND_INPUT);
310 validate_tool_name(WAIT_AGENT);
311 validate_tool_name(RESUME_AGENT);
312 validate_tool_name(CLOSE_AGENT);
313
314 validate_tool_name(WILDCARD_ALL);
316};
317
318#[cfg(test)]
319mod tests {
320 use super::*;
321
322 #[test]
323 fn workflow_coordination_tools_bypass_the_full_auto_allow_list() {
324 for tool in [TASK_TRACKER, START_PLANNING, REQUEST_USER_INPUT] {
325 assert!(is_workflow_coordination_tool(tool), "{tool} must bypass the allow-list");
326 }
327 }
328
329 #[test]
330 fn execution_tools_do_not_bypass_the_full_auto_allow_list() {
331 for tool in [
332 EXEC_COMMAND,
333 WRITE_STDIN,
334 APPLY_PATCH,
335 CODE_SEARCH,
336 WEB_FETCH,
337 "not_a_tool",
338 ] {
339 assert!(!is_workflow_coordination_tool(tool), "{tool} must stay allow-list gated");
340 }
341 }
342}