Skip to content
Open
42 changes: 29 additions & 13 deletions openhands-tools/openhands/tools/terminal/terminal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
import platform

from openhands.tools.terminal.terminal.factory import create_terminal_session
from openhands.tools.terminal.terminal.interface import (
TerminalInterface,
TerminalSessionBase,
)
from openhands.tools.terminal.terminal.subprocess_terminal import (
SubprocessTerminal,
)
from openhands.tools.terminal.terminal.terminal_session import (
TerminalCommandStatus,
TerminalSession,
)
from openhands.tools.terminal.terminal.tmux_terminal import TmuxTerminal


__all__ = [
"TerminalInterface",
"TerminalSessionBase",
"TmuxTerminal",
"SubprocessTerminal",
"TerminalSession",
"TerminalCommandStatus",
"create_terminal_session",
]
# Conditionally import platform-specific terminals
if platform.system() == "Windows":
from openhands.tools.terminal.terminal.windows_terminal import WindowsTerminal

__all__ = [
"TerminalInterface",
"TerminalSessionBase",
"WindowsTerminal",
"TerminalSession",
"TerminalCommandStatus",
"create_terminal_session",
]
else:
from openhands.tools.terminal.terminal.subprocess_terminal import (
SubprocessTerminal,
)
from openhands.tools.terminal.terminal.tmux_terminal import TmuxTerminal

__all__ = [
"TerminalInterface",
"TerminalSessionBase",
"TmuxTerminal",
"SubprocessTerminal",
"TerminalSession",
"TerminalCommandStatus",
"create_terminal_session",
]
8 changes: 7 additions & 1 deletion openhands-tools/openhands/tools/terminal/terminal/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ def create_terminal_session(
system = platform.system()

if system == "Windows":
raise NotImplementedError("Windows is not supported yet for OpenHands V1.")
from openhands.tools.terminal.terminal.windows_terminal import (
WindowsTerminal,
)

logger.info("Auto-detected: Using WindowsTerminal (Windows system)")
terminal = WindowsTerminal(work_dir, username)
return TerminalSession(terminal, no_change_timeout_seconds)
else:
# On Unix-like systems, prefer tmux if available, otherwise use subprocess
if _is_tmux_available():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def _handle_completed_command(
self._ready_for_next_command()
return ExecuteBashObservation.from_text(
command=command,
exit_code=metadata.exit_code if metadata.exit_code != -1 else None,
text=command_output,
metadata=metadata,
)
Expand Down
Loading
Loading