Skip to main content

Cross-Platform Headless TUI Automation Interaction Screenshot Utility with AI Semantic Analysis

Project description

🚀 binterint: Cross-Platform Headless TUI Automation

binterint (Binary Terminal Interaction) is a powerful, OS-independent utility designed to interact with and automate Terminal User Interfaces (TUIs) headlessly. It virtualizes a terminal environment, allowing you to spawn processes, interact with them programmatically, and capture high-fidelity semantic screenshots for AI-driven automation.


✨ Key Features

  • 🤖 Autonomous Navigation: New auto command that uses rule-based semantic analysis to navigate TUIs toward a goal without external APIs.
  • 🌐 OS-Independent PTY: Seamlessly handles Pseudo-Terminals on both Windows (pywinpty) and Unix/macOS (ptyprocess).
  • 🛡️ Unicode Stability: Automatic PYTHONUTF8 injection ensures TUI stability and prevents encoding crashes on Windows.
  • 📸 Headless Rendering: Custom PILLOW-based renderer that converts terminal buffer state to high-quality PNGs with Roboto Mono bundling.
  • 🧠 Hybrid Semantic Analysis: Combines fast local heuristics for hotkeys with optional Gemini/OpenAI Vision for complex spatial reasoning.
  • 🛠️ Developer First: Pydantic-powered data validation and a clean CLI/Python API.

🚀 Installation

Install directly from source:

pip install .

📖 Usage

CLI Quickstart

Run a TUI application headlessly and take a screenshot after it settles:

binterint run "python sample_tui.py" --out screenshot.png --wait 2.0

🤖 Autonomous Mode

Let binterint intelligently navigate the TUI to achieve a goal using rules and pattern matching:

binterint auto "python sample_tui.py" --goal "Click button 1 and exit"

Interactive Mode

Explore a TUI session and inspect semantic elements:

binterint interact "htop"

LLM Setup

To enable AI-based semantic analysis, add your API keys to a .env file in your project root:

GOOGLE_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key

Python API with AI Analysis

import asyncio
from binterint.controller import TUIController
from binterint.semantic import SemanticAnalyzer

async def main():
    ctrl = TUIController(cols=80, rows=24)
    analyzer = SemanticAnalyzer()

    # Spawn and wait
    ctrl.spawn(["python", "sample_tui.py"])
    ctrl.sync(1.0)

    # Capture screenshot
    img_path = "state.png"
    ctrl.take_screenshot(img_path)

    # Use AI to find elements
    elements = await analyzer.analyze_screenshot(img_path)
    
    for el in elements:
        # Map normalized coords to terminal grid
        grid = analyzer.map_to_grid(el.x, el.y, 80, 24)
        print(f"Found {el.type} '{el.label}' at Col {grid['col']}, Row {grid['row']}")

    ctrl.stop()

if __name__ == "__main__":
    asyncio.run(main())

🎨 Visuals

The headless renderer ensures that even in non-GUI environments, your TUI screenshots look premium and consistent:

Sample Render Success from source sample_tui.py


🛠️ Project Structure

  • binterint/: The core Python package.
    • pty_engine.py: Multi-platform PTY abstraction.
    • renderer.py: PILLOW-based terminal renderer.
    • semantic.py: AI-driven element detection and coordinate mapping.
  • tests/: Comprehensive test suite including LLM capability mocking.
  • sample_tui.py: A cross-platform ANSI-based TUI for testing.

⚖️ License

MIT License. See LICENSE for details.

Project details


Download files

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

Source Distribution

binterint-0.1.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

binterint-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file binterint-0.1.1.tar.gz.

File metadata

  • Download URL: binterint-0.1.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for binterint-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c630289bd2078bcd5382023b5dfe039e2153cbf71a073ffe4de40edc634cab89
MD5 39ce4bb440aa1bcdb7e3ba06d66c1195
BLAKE2b-256 6a438b111884d918d7ca697621034b53c3d09ce787d37e3351625e10f5252254

See more details on using hashes here.

Provenance

The following attestation bundles were made for binterint-0.1.1.tar.gz:

Publisher: publish.yml on djmahe4/binterint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file binterint-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: binterint-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for binterint-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b05d926e1ca003233c3b9f9c675a55146864002e198cfdd508bf91b329dc721
MD5 8e2e1d117da92b6323d395aac188057f
BLAKE2b-256 435baec5f66e60e388219deb6db2a962e55e85723bd35f0f2b40ae866b234afb

See more details on using hashes here.

Provenance

The following attestation bundles were made for binterint-0.1.1-py3-none-any.whl:

Publisher: publish.yml on djmahe4/binterint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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