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()

Command Line Interface (CLI)

oauth-cli-coder provides a CLI tool oauth-coder for easy interaction from shell scripts or agent harnesses without writing Python code.

Ask a question

oauth-coder ask claude "how's it going?" --model claude-3-5-sonnet-20241022

Run a slash command

oauth-coder slash claude /compact

Persistent Sessions

You can reuse a session across multiple CLI calls by specifying a --session-id:

oauth-coder ask claude "Analyze this repo" --session-id my-project
oauth-coder slash claude /compact --session-id my-project

Close a session

oauth-coder stop claude --session-id my-project

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.2.0.tar.gz (6.8 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.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for oauth_cli_coder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 10e5fc3a2d2e41cbff60e053bf1b046ed739cb9e4b44251ba2ef85f5717cd964
MD5 1670fd4f9effc7ea47df0e225ba67c04
BLAKE2b-256 1de444bbde523f807bc143a8211a0e6b204733bf50826122d0a4cc2b106cdf9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oauth_cli_coder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8b14051e4fc325cd988093f1b1ac35cc3f3655358f2b6da5e7dc8f86cf2bfec
MD5 5308e905b0ea42ed2985d722040e93df
BLAKE2b-256 f461631eaf5bbffc2bbf04522616b1cf7d028460ad4b6a1537c661b277874234

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