mirror of
https://github.com/usestrix/strix.git
synced 2026-08-16 01:16:40 +02:00
36 lines
888 B
Python
36 lines
888 B
Python
from typing import Any
|
|
|
|
from strix.tools.registry import register_tool
|
|
|
|
from .terminal_manager import get_terminal_manager
|
|
|
|
|
|
@register_tool
|
|
def terminal_execute(
|
|
command: str,
|
|
is_input: bool = False,
|
|
timeout: float | None = None,
|
|
terminal_id: str | None = None,
|
|
no_enter: bool = False,
|
|
) -> dict[str, Any]:
|
|
manager = get_terminal_manager()
|
|
|
|
try:
|
|
return manager.execute_command(
|
|
command=command,
|
|
is_input=is_input,
|
|
timeout=timeout,
|
|
terminal_id=terminal_id,
|
|
no_enter=no_enter,
|
|
)
|
|
except (ValueError, RuntimeError) as e:
|
|
return {
|
|
"error": str(e),
|
|
"command": command,
|
|
"terminal_id": terminal_id or "default",
|
|
"content": "",
|
|
"status": "error",
|
|
"exit_code": None,
|
|
"working_dir": None,
|
|
}
|