445 lines
17 KiB
Python
445 lines
17 KiB
Python
|
|
def get_tools_definition():
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "kill_process",
|
||
|
|
"description": "Terminate a background process by its PID. Use this to stop processes started with run_command that exceeded their timeout.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"pid": {
|
||
|
|
"type": "integer",
|
||
|
|
"description": "The process ID returned by run_command when status is 'running'."
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"required": ["pid"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "tail_process",
|
||
|
|
"description": "Monitor and retrieve output from a background process by its PID. Use this to check on processes started with run_command that exceeded their timeout.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"pid": {
|
||
|
|
"type": "integer",
|
||
|
|
"description": "The process ID returned by run_command when status is 'running'."
|
||
|
|
},
|
||
|
|
"timeout": {
|
||
|
|
"type": "integer",
|
||
|
|
"description": "Maximum seconds to wait for process completion. Returns partial output if still running.",
|
||
|
|
"default": 30
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"required": ["pid"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "http_fetch",
|
||
|
|
"description": "Fetch content from an HTTP URL",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"url": {"type": "string", "description": "The URL to fetch"},
|
||
|
|
"headers": {"type": "object", "description": "Optional HTTP headers"}
|
||
|
|
},
|
||
|
|
"required": ["url"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "run_command",
|
||
|
|
"description": "Execute a shell command and capture output. Returns immediately after timeout with PID if still running. Use tail_process to monitor or kill_process to terminate long-running commands.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"command": {"type": "string", "description": "The shell command to execute"},
|
||
|
|
"timeout": {"type": "integer", "description": "Maximum seconds to wait for completion", "default": 30}
|
||
|
|
},
|
||
|
|
"required": ["command"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "run_command_interactive",
|
||
|
|
"description": "Execute an interactive terminal command that requires user input or displays UI. The command runs in the user's terminal. Returns exit code only.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"command": {"type": "string", "description": "The interactive command to execute (e.g., vim, nano, top)"}
|
||
|
|
},
|
||
|
|
"required": ["command"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "read_file",
|
||
|
|
"description": "Read contents of a file",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"}
|
||
|
|
},
|
||
|
|
"required": ["filepath"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "write_file",
|
||
|
|
"description": "Write content to a file",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"},
|
||
|
|
"content": {"type": "string", "description": "Content to write"}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "content"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "list_directory",
|
||
|
|
"description": "List directory contents",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"path": {"type": "string", "description": "Directory path", "default": "."},
|
||
|
|
"recursive": {"type": "boolean", "description": "List recursively", "default": False}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "mkdir",
|
||
|
|
"description": "Create a new directory",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"path": {"type": "string", "description": "Path of the directory to create"}
|
||
|
|
},
|
||
|
|
"required": ["path"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "chdir",
|
||
|
|
"description": "Change the current working directory",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"path": {"type": "string", "description": "Path to change to"}
|
||
|
|
},
|
||
|
|
"required": ["path"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "getpwd",
|
||
|
|
"description": "Get the current working directory",
|
||
|
|
"parameters": {"type": "object", "properties": {}}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "db_set",
|
||
|
|
"description": "Set a key-value pair in the database",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"key": {"type": "string", "description": "The key"},
|
||
|
|
"value": {"type": "string", "description": "The value"}
|
||
|
|
},
|
||
|
|
"required": ["key", "value"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "db_get",
|
||
|
|
"description": "Get a value from the database",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"key": {"type": "string", "description": "The key"}
|
||
|
|
},
|
||
|
|
"required": ["key"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "db_query",
|
||
|
|
"description": "Execute a database query",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"query": {"type": "string", "description": "SQL query"}
|
||
|
|
},
|
||
|
|
"required": ["query"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "web_search",
|
||
|
|
"description": "Perform a web search",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"query": {"type": "string", "description": "Search query"}
|
||
|
|
},
|
||
|
|
"required": ["query"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "web_search_news",
|
||
|
|
"description": "Perform a web search for news",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"query": {"type": "string", "description": "Search query for news"}
|
||
|
|
},
|
||
|
|
"required": ["query"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "python_exec",
|
||
|
|
"description": "Execute Python code",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"code": {"type": "string", "description": "Python code to execute"}
|
||
|
|
},
|
||
|
|
"required": ["code"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "index_source_directory",
|
||
|
|
"description": "Index directory recursively and read all source files.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"path": {"type": "string", "description": "Path to index"}
|
||
|
|
},
|
||
|
|
"required": ["path"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "search_replace",
|
||
|
|
"description": "Search and replace text in a file",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"},
|
||
|
|
"old_string": {"type": "string", "description": "String to replace"},
|
||
|
|
"new_string": {"type": "string", "description": "Replacement string"}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "old_string", "new_string"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "apply_patch",
|
||
|
|
"description": "Apply a patch to a file, especially for source code",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file to patch"},
|
||
|
|
"patch_content": {"type": "string", "description": "The patch content as a string"}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "patch_content"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "create_diff",
|
||
|
|
"description": "Create a unified diff between two files",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"file1": {"type": "string", "description": "Path to the first file"},
|
||
|
|
"file2": {"type": "string", "description": "Path to the second file"},
|
||
|
|
"fromfile": {"type": "string", "description": "Label for the first file", "default": "file1"},
|
||
|
|
"tofile": {"type": "string", "description": "Label for the second file", "default": "file2"}
|
||
|
|
},
|
||
|
|
"required": ["file1", "file2"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "open_editor",
|
||
|
|
"description": "Open the RPEditor for a file",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"}
|
||
|
|
},
|
||
|
|
"required": ["filepath"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "close_editor",
|
||
|
|
"description": "Close the RPEditor. Always close files when finished editing.",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"}
|
||
|
|
},
|
||
|
|
"required": ["filepath"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "editor_insert_text",
|
||
|
|
"description": "Insert text at cursor position in the editor",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"},
|
||
|
|
"text": {"type": "string", "description": "Text to insert"},
|
||
|
|
"line": {"type": "integer", "description": "Line number (optional)"},
|
||
|
|
"col": {"type": "integer", "description": "Column number (optional)"}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "text"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "editor_replace_text",
|
||
|
|
"description": "Replace text in a range",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"},
|
||
|
|
"start_line": {"type": "integer", "description": "Start line"},
|
||
|
|
"start_col": {"type": "integer", "description": "Start column"},
|
||
|
|
"end_line": {"type": "integer", "description": "End line"},
|
||
|
|
"end_col": {"type": "integer", "description": "End column"},
|
||
|
|
"new_text": {"type": "string", "description": "New text"}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "start_line", "start_col", "end_line", "end_col", "new_text"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "editor_search",
|
||
|
|
"description": "Search for a pattern in the file",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath": {"type": "string", "description": "Path to the file"},
|
||
|
|
"pattern": {"type": "string", "description": "Regex pattern"},
|
||
|
|
"start_line": {"type": "integer", "description": "Start line", "default": 0}
|
||
|
|
},
|
||
|
|
"required": ["filepath", "pattern"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "display_file_diff",
|
||
|
|
"description": "Display a visual colored diff between two files with syntax highlighting and statistics",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"filepath1": {"type": "string", "description": "Path to the original file"},
|
||
|
|
"filepath2": {"type": "string", "description": "Path to the modified file"},
|
||
|
|
"format_type": {"type": "string", "description": "Display format: 'unified' or 'side-by-side'", "default": "unified"}
|
||
|
|
},
|
||
|
|
"required": ["filepath1", "filepath2"]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "display_edit_summary",
|
||
|
|
"description": "Display a summary of all edit operations performed during the session",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "display_edit_timeline",
|
||
|
|
"description": "Display a timeline of all edit operations with details",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"show_content": {"type": "boolean", "description": "Show content previews", "default": False}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "function",
|
||
|
|
"function": {
|
||
|
|
"name": "clear_edit_tracker",
|
||
|
|
"description": "Clear the edit tracker to start fresh",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
|