Skip to main content

A real terminal adaptor for AI agents

Project description

TermAdaptor logo

TermAdaptor

License: WTFPL PyPI Downloads Code style: black

Demo

Built on top of tmux and many other libraries, Cybergod is capable of understanding and interacting terminal interface with both text-only and multimodal modes. With the help of wcwidth, cursor is placed precisely at the right position even if there are multi-width unicode chars (CJK characters for example).

Code can be found here.

To interact with the environment programmatically, check out here

# env: TmuxEnvironment
env.send_key("vim")
env.send_key("Enter")

Terminal parsing (colorless):

Cybergod demo

Terminal parsing (colorful):

Cybergod demo

Terminal screenshot converted from HTML (cursor in red):

Vim screenshot

Terminal with dark theme and grayscale effects except for the cursor:

Cursor highlight

You can also have a block-styled cursor:

Block cursor

Change the cursor character to underline:

Underline cursor char

Override the cursor block style:

Custom block style

Usage

Terminal environment integration

First, install required binaries:

sudo apt install -y tmux tmuxp aha

Next, install the following dependencies:

pip install parse playwright beautifulsoup4

# setup playwright if you want to take terminal screenshots
playwright install chromium

Finally copy the lib.py, then run test_lib.py next to the lib.py.

The SESSION_COMMAND in test_lib.py is the initial terminal environment command to be executed. Change it according to your need.

To view the environment:

preview = session.preview_html(show_cursor=True,wrap_html=True, dark_mode=True, grayscale=True)

To interact with the environment:

# note that both special key and literal strings can be sent.
env.send_key("date")
env.send_key("Enter") # special key

A full mapping from conventional special keys to standard Tmux special keys can be generated by running generate_funckey_alias.py

You can read the test file for further integration.

Star History

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

termadaptor-0.0.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file termadaptor-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: termadaptor-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for termadaptor-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 563a1c1e0d1bcb0b1dfab64f3197e319b49eb8752e7b65775ba9db5f35ce72d3
MD5 8994cf2e496dda566b9fe1c371284548
BLAKE2b-256 272f75b144969344dc430bac1080e46f4c7663d0826ee59035e870c824be6ad1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page