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.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: termadaptor-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d5b8881e0c84582d32c6b2851d05213f62747f686fc2156773815d5b57b03ed
MD5 9c2fe81337f35467d63d63fcbaca367b
BLAKE2b-256 c96f72019c250d02830165924de8bba187525fd78b3b3ff4ee5796eba36c6371

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