A CLI tool that wraps AI coding assistants (Claude Code, Codex, Gemini CLI) with a PTY and exposes an HTTP API for external text injection.
AiBridge enables desktop applications, browser extensions, and other tools to inject context into terminal-based AI assistants without manual copy-paste.
- PTY Wrapper - Full terminal emulation with raw mode support
- HTTP API - Simple REST API for text injection
- Idle Detection - Auto-detects when the AI assistant is ready for input
- Injection Queue - FIFO queue with priority support
- Multi-tool Support - Built-in patterns for Claude Code, Codex, and Gemini CLI
- Paranoid Mode - Inject text without auto-submitting for review
curl -fsSL https://raw.githubusercontent.com/MobAI-App/aibridge/main/install.sh | bashDownload the latest Windows release from [GitHub Releases] (https://github.com/MobAI-App/aibridge/releases).
| Platform | Architecture | Download |
|---|---|---|
| macOS | Apple Silicon | aibridge_*_darwin_arm64.tar.gz |
| macOS | Intel | aibridge_*_darwin_amd64.tar.gz |
| Linux | x86_64 | aibridge_*_linux_amd64.tar.gz |
| Linux | ARM64 | aibridge_*_linux_arm64.tar.gz |
| Windows | x86_64 | aibridge_*_windows_amd64.zip |
| Windows | ARM64 | aibridge_*_windows_arm64.zip |
go install github.com/MobAI-App/aibridge/cmd/aibridge@latestgit clone https://github.com/MobAI-App/aibridge.git
cd aibridge
go build -o aibridge ./cmd/aibridge# Wrap Claude Code
aibridge claude
# Wrap with custom port
aibridge -p 8080 claude
# Paranoid mode - inject without auto-submit
aibridge --paranoid claudeOnce aibridge is running, inject text via HTTP:
# Simple injection
curl -X POST http://localhost:9999/inject \
-H "Content-Type: application/json" \
-d '{"text": "explain this code"}'
# Priority injection (skips to front of queue)
curl -X POST http://localhost:9999/inject \
-H "Content-Type: application/json" \
-d '{"text": "urgent request", "priority": true}'
# Synchronous injection (blocks until injected)
curl -X POST "http://localhost:9999/inject?sync=true" \
-H "Content-Type: application/json" \
-d '{"text": "wait for this"}'| Flag | Short | Default | Description |
|---|---|---|---|
--port |
-p |
9999 | HTTP server port |
--host |
127.0.0.1 | HTTP server host | |
--busy-pattern |
(auto) | Custom busy detection regex | |
--timeout |
-t |
300 | Sync injection timeout (seconds) |
--verbose |
-v |
false | Enable verbose logging |
--paranoid |
false | Inject text without hitting Enter | |
--version |
Print version and exit |
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/status |
GET | Bridge status |
/inject |
POST | Queue text injection |
/queue |
DELETE | Clear pending injections |
Returns health status.
{"status": "ok", "version": "1.0.0"}Returns bridge status.
{
"idle": true,
"queue_length": 0,
"child_running": true,
"child_tool": "claude",
"uptime_seconds": 123.45
}Queue text for injection.
Request:
{
"text": "your prompt here",
"priority": false
}Response:
{
"id": "uuid",
"queued": true,
"position": 1
}Query Parameters:
sync=true- Block until text is injected
Error Codes:
400- Invalid JSON or empty text408- Sync injection timeout429- Queue full (max 100 items)503- Child process not running
Clear all pending injections.
{"cleared": 5}AiBridge detects when the AI assistant is busy using regex patterns matched against terminal output. When the pattern stops appearing for 500ms, the tool is considered idle.
| Tool | Pattern |
|---|---|
| Claude Code | esc to interrupt |
| Codex | esc to interrupt |
| Gemini | esc to cancel |
aibridge --busy-pattern 'processing' some-tool┌─────────────────────────────────────────────────────┐
│ AiBridge │
├─────────────────────────────────────────────────────┤
│ HTTP Server (localhost:9999) │
│ ├── GET /health │
│ ├── GET /status │
│ ├── POST /inject │
│ └── DELETE /queue │
├─────────────────────────────────────────────────────┤
│ Injection Queue (FIFO + Priority) │
├─────────────────────────────────────────────────────┤
│ Busy Detector (Regex Pattern Matching) │
├─────────────────────────────────────────────────────┤
│ PTY Manager (Raw Mode, Window Resize) │
├─────────────────────────────────────────────────────┤
│ Child Process (claude, codex, gemini, etc.) │
└─────────────────────────────────────────────────────┘
- Go 1.22+
go build -o aibridge ./cmd/aibridgego test ./...github.com/creack/pty- PTY supportgithub.com/spf13/cobra- CLI frameworkgithub.com/google/uuid- Injection IDsgolang.org/x/term- Raw terminal mode
- Localhost only - HTTP server binds to 127.0.0.1 by default
- No authentication - Designed for local development use
- CORS enabled - Allows requests from any origin for browser extensions
MIT License - see LICENSE for details.
Contributions are welcome! Please open an issue or submit a pull request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request