Source: src/cwsandbox/_types.py:768
Handle for an interactive TTY session in a sandbox.
TerminalSession is designed for interactive use cases where a local
terminal is connected to a remote shell. Unlike Process:
- Output is raw bytes (
StreamReader[bytes]), preserving ANSI sequences.
- No output buffering, which makes it safe for long-running sessions.
result() returns TerminalResult (exit code only, no captured output).
Properties
command
The executed command.
returncode
The exit code, or None if the session is still active.
Methods
resize
Send terminal resize. Fire-and-forget.
Parameters
width (int): New terminal width in columns.
height (int): New terminal height in rows.
Raises
SandboxExecutionError: If the session has ended.
result
Block until the terminal session ends and return the result.
Parameters
timeout (float | None): Maximum seconds to wait. None means wait forever.
Returns
TerminalResult: TerminalResult with the exit code.
Raises
concurrent.futures.TimeoutError: If timeout expires.
Exception: Any exception from the session.
wait
Block until the session ends and return exit code.
Parameters
timeout (float | None): Maximum seconds to wait. None means wait forever.
Returns
int: The process exit code.
Raises
concurrent.futures.TimeoutError: If timeout expires.
Exception: Any exception from the session.
Last modified on May 29, 2026