@absmartly/ai-cli-bridge
v1.3.0
Published
HTTP bridge server for ABsmartly Extension to communicate with AI CLIs
Readme
@absmartly/ai-cli-bridge
HTTP bridge server that enables the ABsmartly Browser Extension to communicate with AI CLIs (Claude Code, Codex) for AI-powered A/B testing features.
Prerequisites
- Node.js 16+
- Claude Code CLI authenticated:
npx @anthropic-ai/claude-code login - Codex CLI authenticated (if using Codex):
codex login
Quick Start
npx @absmartly/ai-cli-bridgeThe server will start on http://localhost:3000 by default.
Usage
1. Login to your CLI (one-time setup)
npx @anthropic-ai/claude-code loginFollow the prompts to authenticate with your Claude subscription.
2. Start the bridge server (Claude default)
npx @absmartly/ai-cli-bridge3. Configure ABsmartly Extension
In the extension settings:
- Select "Claude Subscription" as your AI provider
- The extension will automatically connect to
http://localhost:3000
Use Codex CLI
npx @absmartly/ai-cli-bridge --codexnpx @absmartly/ai-cli-bridge --provider=codexThe Codex provider uses codex exec under the hood and enforces the same JSON schema as Claude.
Custom Port
PORT=3001 npx @absmartly/ai-cli-bridgeAPI Endpoints
GET /health- Health check and auth statusGET /auth/status- Provider authentication statusPOST /conversations- Create new conversationPOST /conversations/:id/messages- Send message to provider CLIGET /conversations/:id/stream- Stream provider responses (SSE)POST /conversations/:id/approve- Approve tool usePOST /conversations/:id/deny- Deny tool use
Provider Selection
Set a default provider via environment variable:
AI_CLI_PROVIDER=codexOr pass a provider at startup:
npx @absmartly/ai-cli-bridge --codexnpx @absmartly/ai-cli-bridge --provider=codexnpx @absmartly/ai-cli-bridge --provider codexOr pass a provider per conversation:
{ "provider": "codex" }How It Works
- Authentication Check: Reads credentials for the selected provider (Claude or Codex)
- CLI Spawn: Spawns the selected provider CLI (Claude Code or Codex)
- HTTP Bridge: Provides REST API for the browser extension to communicate
- Message Forwarding: Routes messages between the extension and the CLI
- Server-Sent Events: Streams responses back to the extension in real-time
Troubleshooting
"Claude CLI not logged in"
Run: npx @anthropic-ai/claude-code login
"Codex CLI not logged in"
Run: codex login
"Port already in use"
Either:
- Kill the existing process:
pkill -f ai-cli-bridge - Or use a different port:
PORT=3001 npx @absmartly/ai-cli-bridge
Extension can't connect
- Ensure the bridge is running:
http://localhost:3000/healthshould return JSON - Check the port matches in extension settings
- Restart the extension
Notes
- Codex runs a single
codex execper message (no persistent session yet). - Image inputs are supported for Claude and Codex (Codex uses
codex exec --image).
Testing
Filter mocked tests by provider:
TEST_PROVIDER=codex npm testRun real provider tests:
RUN_PROVIDER_TESTS=1 TEST_PROVIDER=codex npm run test:providersRun vision test (Codex only):
RUN_PROVIDER_TESTS=1 RUN_VISION_TESTS=1 TEST_PROVIDER=codex npm run test:providersRUN_PROVIDER_TESTS=1 RUN_VISION_TESTS=1 TEST_PROVIDER=claude npm run test:providersSet a model for tests:
RUN_PROVIDER_TESTS=1 RUN_VISION_TESTS=1 TEST_PROVIDER=claude TEST_MODEL=opus npm run test:providersLicense
MIT
