Metadata-Version: 2.1
Name: termadaptor
Version: 0.0.2
Summary: A real terminal adaptor for AI agents
Home-page: https://github.com/james4ever0/agent-terminal-adaptor
License: This is free and unencumbered software released into the public domain.
        
        Anyone is free to copy, modify, publish, use, compile, sell, or
        distribute this software, either in source code form or as a compiled
        binary, for any purpose, commercial or non-commercial, and by any
        means.
        
        In jurisdictions that recognize copyright laws, the author or authors
        of this software dedicate any and all copyright interest in the
        software to the public domain. We make this dedication for the benefit
        of the public at large and to the detriment of our heirs and
        successors. We intend this dedication to be an overt act of
        relinquishment in perpetuity of all present and future rights to this
        software under copyright law.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
        IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
        OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
        ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
        OTHER DEALINGS IN THE SOFTWARE.
        
        For more information, please refer to <https://unlicense.org>
        
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: parse
Requires-Dist: playwright
Requires-Dist: beautifulsoup4

<div align="center"><img src="https://github.com/james4ever0/agent-terminal-adaptor/blob/main/assets/termadaptor_logo.webp?v=1&type=image" alt="TermAdaptor logo"></div>

<h1 align="center">TermAdaptor</h1>

<p align="center">
<a href="https://github.com/james4ever0/agent-terminal-adaptor/blob/master/LICENSE"><img alt="License: WTFPL" src="https://img.shields.io/badge/license-UNLICENSE-green.svg?style=flat"></a>
<a href="https://pypi.org/project/termadaptor/"><img alt="PyPI" src="https://img.shields.io/pypi/v/termadaptor"></a>
<a href="https://pepy.tech/project/termadaptor"><img alt="Downloads" src="https://static.pepy.tech/badge/termadaptor"></a>
<a href="https://github.com/james4ever0/agent-terminal-adaptor"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>

## Demo

Built on top of [`tmux`](https://github.com/tmux/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`](https://github.com/jquast/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](tmux_trials/lib.py).

To interact with the environment programmatically, check out [here](tmux_trials/test_lib.py)

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

Terminal parsing (colorless):

![Cybergod demo](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/tmux_show_0.gif?v=1&type=image)

Terminal parsing (colorful):

![Cybergod demo](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/tmux_show_1.gif?v=1&type=image)

Terminal screenshot converted from HTML (cursor in red):

![Vim screenshot](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/vim_edit_tmux_screenshot.png?v=1&type=image)

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

![Cursor highlight](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/grayscale_dark_tmux.png?v=1&type=image)

You can also have a block-styled cursor:

![Block cursor](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/block_cursor_terminal_screenshot.png?v=1&type=image)

Change the cursor character to underline:

![Underline cursor char](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/custom_cursor_char.png?v=1&type=image)

Override the cursor block style:

![Custom block style](https://github.com/James4ever0/agi_computer_control/blob/master/propaganda/custom_block_style.png?v=1&type=image)

## Usage

### Terminal environment integration

First, install required binaries:

```bash
sudo apt install -y tmux tmuxp aha
```

Next, install the following dependencies:

```bash
pip install parse playwright beautifulsoup4

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

Finally copy the [`lib.py`](https://github.com/James4Ever0/agi_computer_control/blob/master/tmux_trials/lib.py), then run [`test_lib.py`](https://github.com/James4Ever0/agi_computer_control/blob/master/tmux_trials/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:

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

To interact with the environment:

```python
# 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`](https://github.com/James4Ever0/agi_computer_control/blob/master/tmux_trials/generate_funckeys_alias.py)

You can read the test file for further integration.

## Star History

<img src="https://api.star-history.com/svg?repos=james4ever0/agent-terminal-adaptor&Timeline" style="filter: invert(100%);"></img>
