semvec/pypi-packages huggingface dataset:
termexec 0.0.3
Terminal executor for AI agents, with ANSI escape sequence support and image screenshots
Requires Python: >=3.8

<!-- TODO: save the last time terminal has content update, and use the timestamp for activity monitoring, signal 'terminal idle' event if no activity in the next X seconds -->


<div>
<p align="center"><h1 align="center">Terminal Executor</h1></p>
<p align="center">Terminal executor for AI agents, with ANSI escape sequence support and image screenshots.</p>
<p align="center">
<a href="https://github.com/james4ever0/termexec/blob/main/LICENSE"><img alt="License: UNLICENSE"
 src="https://img.shields.io/badge/license-UNLICENSE-green.svg?style=flat"></a>
<a href="https://pypi.org/project/termexec/"><img alt="PyPI" src="https://img.shields.io/pypi/v/termexec"></a>
<a href="https://pepy.tech/projects/termexec"><img src="https://static.pepy.tech/badge/termexec" alt="PyPI Downloads"></a>
<a href="https://github.com/james4ever0/termexec"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>
</div>

## Demo

Using termexec for solving the "vimgolf-test" challenge:

![vimgolf-test-success](https://github.com/user-attachments/assets/011c21d7-5b4b-4836-ac14-e4b8126c3ab4)

More info at [vimgolf-gym](https://github.com/james4ever0/vimgolf-gym)

## Installation

```bash
# install from pypi
pip install termexec

# or install the latest version from github
pip install git+https://github.com/james4ever0/termexec.git
```

Note: if your platform does not have prebuilt binaries of agg-python-bindings, just install cargo and rustc so the source code could compile.

## Usage

```python
from termexec import TerminalExecutor
import time

# Initializes executor with a command to run in terminal emulator, using avt as backend, with automatic context cleanup
with TerminalExecutor(['bash'], width=80, height=24) as executor:
    # Waits for the terminal emulator to be ready.
    time.sleep(1)  # Adjust sleep time as necessary for your environment

    # Or if you prefer to wait for terminal idle event
    try:
        executor.terminal.wait_for_terminal_idle(duration=1, timeout=10)
    except TimeoutError:
        print("Terminal did not become idle in time.")

    # Get the current display of the terminal emulator as a string.
    terminal_text = executor.display
    print("Terminal Display:")
    print(terminal_text)

    # Send input to the terminal emulator.
    executor.input("echo Hello, World!\n")
    print("After input:")
    print(executor.display)

    # Saves the current display of the terminal emulator as a .png file
    executor.screenshot("screenshot.png")
    print("Screenshot saved as screenshot.png")

    # Get the PID of the terminal process.
    print("Terminal process PID:", executor.terminal.pty_process.pid)
```

## Alternatives

- Xterm.js running in phantomjs, electron or headless playwright

- LXterminal running in kiosk mode with x11vnc and novnc

## License

The Unlicense
gitcg 0.17.4
Genius Invokation TCG (Python binding)
Requires Python: >=3.11

# Genius Invokation TCG (Python binding)

This Python binding of GI-TCG is based on the C Binding and Python `ctypes` FFI.

A very simple usage example:

```py
from gitcg import Deck, Player, Game

# Set players initial deck
DECK0 = Deck(characters=[1411, 1510, 2103], cards=[214111, 311503, ...])
DECK1 = Deck(characters=[1609, 2203, 1608], cards=[312025, 321002, ...])

class MyPlayer(Player):
    # implements on_notify, on_action, etc.
    # See `gitcg.Player`'s documentation for detail.
    pass

# Initialize the game
game = Game(create_param=CreateParam(deck0=DECK0, deck1=DECK1))
game.set_player(0, MyPlayer())
game.set_player(1, MyPlayer())

# Start and step the game until end
game.start()
while game.is_running():
    game.step()
```

Here is [a generated API documentation](https://pybinding.gi-tcg.guyutongxue.site).
wd-mcp 0.1.0
Document conversion MCP server with SSE support
Requires Python: >=3.10

# 文档转换 MCP 服务器

一个支持多种文档格式转换和Server-Sent Events (SSE)的MCP服务器。

## 功能特性

- 🔄 **多格式转换**: 支持 Markdown、HTML、文本、PDF、DOCX 等格式之间的转换
- 🌐 **REST API**: 提供完整的HTTP API接口
- 📡 **SSE支持**: 实时事件推送，支持转换进度监控
- 🔌 **MCP协议**: 完全兼容Model Context Protocol
- ⚡ **异步处理**: 高性能异步文档转换
- 🛡️ **错误处理**: 完善的错误处理和状态管理

## 支持的格式

- **文本格式**: txt, md (Markdown), html
- **文档格式**: pdf, docx, doc

## 安装依赖

```bash
# 安装Python依赖
pip install -r requirements.txt

# 或使用poetry
poetry install
```

## 使用方法

### 1. REST API 模式

启动HTTP服务器：

```bash
python main.py --api
```

服务器将在 `http://localhost:8000` 启动。

#### API 端点

- `GET /formats` - 获取支持的格式列表
- `POST /convert` - 文档转换
- `GET /events` - SSE事件流
- `GET /status/{job_id}` - 获取转换状态

#### 转换示例

```bash
# 使用curl转换文档
curl -X POST http://localhost:8000/convert \
  -F "source_format=md" \
  -F "target_format=html" \
  -F "content=# Hello World\n\nThis is **markdown** text."

# 使用PowerShell
$params = @{
    source_format='md'
    target_format='html'
    content='# Hello World`n`nThis is **markdown** text.'
}
Invoke-RestMethod -Uri 'http://localhost:8000/convert' -Method Post -Body $params
```

### 2. MCP 协议模式

启动MCP服务器：

```bash
python main.py
```

这将启动stdio模式的MCP服务器，可以与支持MCP协议的客户端集成。

#### MCP 工具

- `convert_document` - 转换文档格式
- `list_supported_formats` - 列出支持的格式
- `get_conversion_status` - 获取转换状态

### 3. 测试功能

运行测试脚本验证所有功能：

```bash
python test_api.py
```

## 配置选项

服务器支持通过环境变量进行配置：

```bash
# 服务器配置
export SERVER_HOST=0.0.0.0
export SERVER_PORT=8000

# 文件处理
export MAX_FILE_SIZE=10485760  # 10MB
export TEMP_DIR=./temp

# SSE配置
export SSE_HEARTBEAT_INTERVAL=30
export SSE_CONNECTION_TIMEOUT=300
```

## 项目结构

```
wd_mcp/
├── main.py                 # 主服务器文件
├── document_converter.py   # 文档转换器
├── sse_manager.py         # SSE事件管理器
├── config.py              # 配置管理
├── client_example.py      # 客户端示例
├── test_api.py           # API测试脚本
├── pyproject.toml        # 项目配置
└── README.md             # 项目说明
```

## 开发说明

### 添加新的转换格式

1. 在 `document_converter.py` 中添加转换逻辑
2. 更新 `SUPPORTED_FORMATS` 列表
3. 实现相应的转换方法

### 自定义SSE事件

1. 在 `sse_manager.py` 中定义新的事件类型
2. 使用 `broadcast_event` 方法发送事件

## 示例客户端

查看 `client_example.py` 了解如何：

- 使用MCP协议与服务器交互
- 监听SSE事件流
- 调用REST API

## 错误处理

服务器提供详细的错误信息：

- 格式不支持
- 文件大小超限
- 转换失败
- 网络连接问题

## 性能优化

- 异步文档处理
- 连接池管理
- 临时文件自动清理
- 内存使用优化

## 许可证

MIT License

## 贡献

欢迎提交Issue和Pull Request！

---

**注意**: 确保安装了所需的依赖包，特别是用于PDF和DOCX处理的库。