Skip to content

About

Rust-backed Windows console support for Google Colab CLI, with a reversible uv-tool installer.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

termios-win for Google Colab CLI

Run Google Colab CLI's interactive console from Windows. A small Rust backend handles native console input, and a Python adapter connects it to Colab's existing WebSocket protocol.

Built for google-colab-cli 0.7.4 installed with uv tool install. Tested on x64 Windows with Python 3.12.9. This is a focused compatibility adapter, not a complete OpenBSD/POSIX termios implementation. Independent project; not affiliated with Google or OpenBSD.

Quick start

You need Windows 10/11, Git, uv, and Rust with the MSVC C++ build tools. Start with the Windows setup guide if any of those are missing.

In PowerShell:

git clone https://github.com/mESmaC/termios-win.git
cd termios-win

# Skip this if uv tool list already shows google-colab-cli v0.7.4.
uv tool install --python 3.12 "google-colab-cli==0.7.4"

.\install-colab.ps1
colab --help

Then connect to an existing Colab session:

colab console -s your-session

Replace your-session with your session name. For authentication and runtime creation, follow the upstream Colab CLI guide. If PowerShell blocks the installer, see the execution policy instructions.

What works

Feature Behavior
CLI startup Avoids Windows import errors for Unix-only termios and tty
Raw input Sends keys immediately, without local line buffering or echo
Keys Arrows, navigation keys, F1–F12, modifiers, Ctrl-C and Ctrl-D
Text Unicode, surrogate pairs, key repeats, and AltGr
Output VT/ANSI processing and UTF-8 redirected output
Resize Sends visible terminal columns and rows to the remote session
Cleanup Restores console modes after disconnects and Python exceptions

The installer builds a DLL, adds termios_win to the existing uv tool environment, and patches that environment's colab_cli/console.py. It saves the original file with SHA-256 checksums for rollback. No global Python modules are replaced, and no Python extension SDK is required.

Limitations

  • Supported upstream version: 0.7.4. Installation rejects other versions and unrecognized import layouts. An upstream upgrade or reinstall may remove the patch.
  • colab ssh has separate Windows pipe/quoting issues that this adapter does not fix.
  • No serial ports, baud rates, arbitrary line disciplines, job control, or POSIX C ABI.
  • Mouse reporting, application cursor mode, and bracketed-paste negotiation are not implemented. Full terminal-emulator compatibility is outside the current scope.
  • Forced process termination cannot guarantee terminal restoration.
  • Local native-console and WebSocket tests pass; authenticated Google runtime interaction has not been verified by this project's automated tests.

Restore or update

Close active Colab consoles, then undo the patch from this checkout:

.\install-colab.ps1 -Restore

To update this adapter, restore first, pull the new source, and reinstall. See updates, rollback, and troubleshooting for the full procedure and recovery after an upstream upgrade.

Development

From PowerShell on Windows, after installing the supported Colab CLI version:

cargo test --locked
cargo clippy --all-targets --locked -- -D warnings
cargo build --release --locked
$toolPython = Join-Path ((uv tool dir | Out-String).Trim()) 'google-colab-cli\Scripts\python.exe'
& $toolPython -m unittest discover -s tests -v

The suite covers key translation, piped input, error/disconnect cleanup, native Win32 input in a hidden console, exact mode restoration, and a local WebSocket integration. It needs no Google account and creates no Colab runtime.

Source Purpose
src/console.rs Owned Win32 handles, console modes, restoration
src/keys.rs Windows key events to terminal sequences
src/ffi.rs Private C ABI used by Python ctypes
python/termios_win/ DLL wrapper and Colab console adapter
scripts/install_colab.py Targeted installation and checked rollback
tests/ Python, native-console, and WebSocket integration tests

Bug reports and pull requests are welcome. Include Windows/Python/Rust versions, the terminal app, the Colab CLI version, and a minimal reproduction. Remove tokens and private session URLs from logs before posting. See contributing for the development workflow.

License

Original Rust and support code: MIT. The Colab Python adapter: Apache-2.0. See third-party notices for upstream attribution. Dependencies retain their respective licenses.

Reference interfaces: OpenBSD termios.h, Windows console modes, and Colab's console implementation.

About

Rust-backed Windows console support for Google Colab CLI, with a reversible uv-tool installer.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages