Skip to main content

Seamlessly interact with AI CLI coders (Claude, Gemini, Codex) via tmux TUI sessions.

Project description

oauth-cli-coder

Seamlessly interact with AI CLI coders (Claude Code, Gemini CLI, Codex) via tmux TUI sessions.

The Problem

Many AI-powered CLI tools (like Anthropic's claude or Google's gemini CLI) are designed for interactive terminal use (TUI). When an agent harness like OpenClaw or Claude Code needs to drive these tools, they often run into issues with:

  • Authentication: CLI tools use their own OAuth/browser flows. Running them via simple API calls doesn't leverage existing local credentials.
  • TUI States: Startup warnings, trust dialogs, and upgrade prompts can block simple non-interactive pipes.
  • Session Context: Maintaining a long-lived conversation requires a stable environment.

The Solution

oauth-cli-coder wraps these CLI tools in a tmux session.

  • It starts the real CLI (e.g. claude) in a background tmux pane.
  • It types into the pane as if a human was using it.
  • It parses the terminal output to extract the AI's response.
  • No -c required: It doesn't use simple command-line execution (claude -c "..."), but interacts with the full TUI environment, preserving the native user experience and OAuth context.

Installation

pip install oauth-cli-coder

Requires: tmux must be installed on your system.

Usage

Claude Code

from oauth_cli_coder import ClaudeProvider

# Starts a tmux session and launches 'claude'
coder = ClaudeProvider(model="claude-3-5-sonnet-20241022")

# Send a prompt and get the response
response = coder.ask("What is the current git status?")
print(response)

# Send a slash command
coder.slash_command("/compact")

# Cleanup
coder.close()

Gemini CLI

from oauth_cli_coder import GeminiProvider

coder = GeminiProvider()
print(coder.ask("Hello!"))
coder.close()

Advanced: TUI State Assessment

The library uses rule-based logic to get past common prompts (e.g., trust dialogs). If you have the gemini CLI installed, it can optionally use an LLM to assess complex TUI states and decide which keys to send to reach the main prompt.

Why 'OAuth'?

By running the actual CLI binary in a real terminal (tmux), the tool can access your existing OAuth tokens, browser sessions, and local configuration. This means you don't need to manage separate API keys for your automation—if you are logged in on your terminal, the library can use it.

License

MIT

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

oauth_cli_coder-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

oauth_cli_coder-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file oauth_cli_coder-0.1.0.tar.gz.

File metadata

  • Download URL: oauth_cli_coder-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.23

File hashes

Hashes for oauth_cli_coder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85045cc10eb3d54faf13185a9aff30c21e0f688dfecce78b0de510d92806e7c2
MD5 6d32c718d86af475ea2d616f81ca3b9c
BLAKE2b-256 ab46644496db9c226bf4f89a77680cc783edf4e3d3059875bf69562c75a9e527

See more details on using hashes here.

File details

Details for the file oauth_cli_coder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for oauth_cli_coder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5aa61134daa4d9ab95e446c6aedf7077375c0858f5ee26ba74433c1b8965b17b
MD5 537c637e89b049efda76630970e43836
BLAKE2b-256 20dcd2f96139275c28939eca73e232dc6737539477b54e9c5a6ce2d5d2e65e72

See more details on using hashes here.

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