read and write tools, moved schemas to tool/__init__
This commit is contained in:
+8
-19
@@ -1,27 +1,16 @@
|
||||
from tools.bash import bash
|
||||
|
||||
TOOL_SCHEMAS = [
|
||||
{
|
||||
"name": "bash",
|
||||
"description": "Execute a bash command in the isolated sandbox environment. Use this to run shell commands, install packages, run scripts, etc.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"command": {
|
||||
"type": "string",
|
||||
"description": "The bash command to execute (e.g., 'ls -la', 'python script.py', 'pip install requests')",
|
||||
}
|
||||
},
|
||||
"required": ["command"],
|
||||
},
|
||||
}
|
||||
]
|
||||
from tools import TOOL_SCHEMAS, bash, read_file, write_file
|
||||
|
||||
|
||||
async def dispatch_tool(tool_name: str, tool_input: dict, sandbox) -> str:
|
||||
async def dispatch_tool(tool_name: str, tool_input: dict, sandbox):
|
||||
"""Route tool calls to implementations."""
|
||||
|
||||
if tool_name == "bash":
|
||||
return await bash(command=tool_input["command"], sandbox=sandbox)
|
||||
elif tool_name == "read_file":
|
||||
return await read_file(tool_input["filepath"], sandbox=sandbox)
|
||||
elif tool_name == "write_file":
|
||||
return await write_file(
|
||||
tool_input["filepath"], tool_input["content"], sandbox=sandbox
|
||||
)
|
||||
|
||||
return f"Unknown tool: {tool_name}"
|
||||
|
||||
Reference in New Issue
Block a user