more detailed desc
This commit is contained in:
@@ -24,7 +24,7 @@ from typing import Dict, Any, List
|
|||||||
|
|
||||||
# Import toolsets
|
# Import toolsets
|
||||||
from web_tools import web_search_tool, web_extract_tool, web_crawl_tool, check_tavily_api_key
|
from web_tools import web_search_tool, web_extract_tool, web_crawl_tool, check_tavily_api_key
|
||||||
from terminal_tool import terminal_tool, check_hecate_requirements
|
from terminal_tool import terminal_tool, check_hecate_requirements, TERMINAL_TOOL_DESCRIPTION
|
||||||
|
|
||||||
def get_web_tool_definitions() -> List[Dict[str, Any]]:
|
def get_web_tool_definitions() -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
@@ -123,7 +123,7 @@ def get_terminal_tool_definitions() -> List[Dict[str, Any]]:
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": "terminal",
|
"name": "terminal",
|
||||||
"description": "Execute commands on a Linux VM with optional interactive session support. Automatically manages VM lifecycle - creates VMs on demand, reuses existing VMs, and cleans up after inactivity. Can handle both simple commands and interactive sessions.",
|
"description": TERMINAL_TOOL_DESCRIPTION,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -25,6 +25,53 @@ from typing import Optional, Dict, Any
|
|||||||
from hecate import run_tool_with_lifecycle_management
|
from hecate import run_tool_with_lifecycle_management
|
||||||
from morphcloud._llm import ToolCall
|
from morphcloud._llm import ToolCall
|
||||||
|
|
||||||
|
# Detailed description for the terminal tool based on Hermes Terminal system prompt
|
||||||
|
TERMINAL_TOOL_DESCRIPTION = """Execute commands on a secure, persistent Linux VM environment with full interactive application support.
|
||||||
|
|
||||||
|
**Environment:**
|
||||||
|
- Minimal Debian-based OS with internet access
|
||||||
|
- Automatic VM lifecycle management (creates on-demand, reuses, cleans up)
|
||||||
|
- **Full state persistence across tool calls**: current directory (pwd), environment variables, activated virtual environments (conda/venv), running processes, and command history all persist between consecutive tool calls
|
||||||
|
- Session state managed automatically via tmux
|
||||||
|
|
||||||
|
**Command Execution:**
|
||||||
|
- Simple commands: Just provide the 'command' parameter
|
||||||
|
- Background processes: Set 'background': True for servers/long-running tasks
|
||||||
|
- Interactive applications automatically detected and handled
|
||||||
|
|
||||||
|
**Interactive Applications (TUIs/Pagers/Prompts):**
|
||||||
|
When commands enter interactive mode (vim, nano, less, git prompts, package managers, etc.), you'll receive screen content with "frozen" status. This is NORMAL - the session is still active and waiting for input.
|
||||||
|
|
||||||
|
**To interact with frozen sessions:**
|
||||||
|
1. Use 'input_keys' parameter with keystrokes to send
|
||||||
|
2. System auto-detects and uses the active session
|
||||||
|
3. Session stays active until application exits
|
||||||
|
|
||||||
|
**Special Key Syntax for input_keys:**
|
||||||
|
- `<ESC>`: Escape key
|
||||||
|
- `<ENTER>`: Enter/Return
|
||||||
|
- `<CTRL+C>`, `<CTRL+D>`, `<CTRL+Z>`: Control combinations
|
||||||
|
- `<UP>`, `<DOWN>`, `<LEFT>`, `<RIGHT>`: Arrow keys
|
||||||
|
- `<TAB>`, `<BACKSPACE>`: Tab and Backspace
|
||||||
|
- `<F1>` through `<F12>`: Function keys
|
||||||
|
- `<SHIFT+TAB>`: Shift+Tab
|
||||||
|
- Uppercase letters for Shift+letter (e.g., 'V' for Shift+V)
|
||||||
|
- Symbols for Shift+number (e.g., '!' for Shift+1, ':' for Shift+;)
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
- Start vim: `{"command": "vim file.txt"}`
|
||||||
|
- Type in vim: `{"input_keys": "iHello World<ESC>"}`
|
||||||
|
- Save and quit: `{"input_keys": ":wq<ENTER>"}`
|
||||||
|
- Navigate in less: `{"input_keys": "j"}`
|
||||||
|
- Quit less: `{"input_keys": "q"}`
|
||||||
|
|
||||||
|
**Best Practices:**
|
||||||
|
- Run servers/long processes in background with separate tool calls
|
||||||
|
- Chain multiple foreground commands in single call if needed
|
||||||
|
- Monitor disk usage for large tasks, clean up to free space
|
||||||
|
- Test components incrementally with mock inputs
|
||||||
|
- Install whatever tools needed - full system access provided"""
|
||||||
|
|
||||||
def terminal_tool(
|
def terminal_tool(
|
||||||
command: Optional[str] = None,
|
command: Optional[str] = None,
|
||||||
input_keys: Optional[str] = None,
|
input_keys: Optional[str] = None,
|
||||||
|
|||||||
Reference in New Issue
Block a user