@lemantorus/opencode-tunnel
v1.0.0
Published
Beautiful TUI for managing OpenCode web server with tunneling
Maintainers
Readme
OpenCode Tunnel
Terminal UI for managing OpenCode web server with Cloudflare tunneling. Get a public HTTPS URL to access OpenCode from anywhere, including mobile devices.
Note: This is an unofficial community project and is not affiliated with OpenCode or Anomaly.
Features
- Terminal UI - Beautiful interface right in your terminal
- Cloudflare Quick Tunnel - Public URL without registration
- Named Tunnel - Stable URL for permanent use
- QR Code - Scan and connect from mobile
- SSE Proxy - Full Server-Sent Events support
- Voice Input - Dictate text via Groq Whisper API
- Cross-platform - macOS, Linux, Windows
- Mobile App - OpenCode Mobile for iOS and Android
Architecture
┌──────────────────┐ ┌──────────────┐ ┌─────────────────────┐
│ OpenCode │ │ Proxy │ │ Cloudflare │
│ Server │─────▶│ (SSE) │─────▶│ Quick Tunnel │
│ Port: 33333 │ │ Port: 33334│ │ .trycloudflare.com│
└──────────────────┘ └──────────────┘ └─────────────────────┘
│
┌───────────────────────────────┘
│
▼
┌──────────────────────┐
│ OpenCode Mobile │
│ ┌──────────────┐ │
│ │ QR Scanner │ │
│ │ Voice Input │ │
│ │ WebView │ │
│ └──────────────┘ │
└──────────────────────┘How it works:
- OpenCode Server starts on port 33333
- Proxy starts on port 33334 and proxies requests + SSE events
- Cloudflare Tunnel creates a public HTTPS URL
- Mobile app scans QR and connects
- Voice messages are transcribed via Groq Whisper
Screenshots
TUI Interface
| Initial State | Port Configuration |
|:-------------:|:------------------:|
|
|
|
| Configuration | Tunnel Running |
|:-------------:|:--------------:|
|
|
|
| QR Code for Mobile |
|:------------------:|
|
|
Mobile App
| QR Scanner & Connections | Chats in App |
|:------------------------:|:------------:|
|
|
|
Requirements
| Component | Version | Installation |
|-----------|---------|--------------|
| Node.js | 18+ | nodejs.org |
| OpenCode | latest | npm i -g opencode-ai |
| cloudflared | latest | See below |
Installing cloudflared
macOS (Homebrew):
brew install cloudflaredLinux (Debian/Ubuntu):
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
sudo chmod +x cloudflared
sudo mv cloudflared /usr/local/bin/Linux (Arch):
yay -S cloudflared-binWindows (PowerShell):
winget install Cloudflare.cloudflaredWindows (Manual):
- Download from GitHub Releases
- Extract
cloudflared.exeto a folder in PATH
Installation
From Source
# Clone the repository
git clone https://github.com/lemantorus/opencode-tunnel.git
cd opencode-tunnel
# Install dependencies
npm install
# Build
npm run build
# Run
npm startGlobal Installation (Optional)
npm link
opencode-tunnelUsage
Starting
npm startOn first run, TUI automatically:
- Starts OpenCode Server on port 33333
- Starts Proxy on port 33334
- Creates Cloudflare Quick Tunnel
- Shows QR code for mobile
Keyboard Controls
| Key | Action |
|-----|--------|
| S | Start/stop OpenCode Server |
| P | Start/stop Proxy |
| T | Connect/disconnect Tunnel |
| R | Start/stop everything |
| C | Open configuration |
| L | Change ports |
| Q | Quit |
Configuration Screen (C)
In configuration you can set:
- Tunnel Token - Token for Named Tunnel (optional)
- Tunnel Hostname - Named Tunnel URL (optional)
- Groq Token - Token for voice input (optional)
- Enable Logs - Logging to
~/.opencode-tunnel/proxy.log
Changing Ports (L)
Defaults:
- Server Port:
33333 - Proxy Port:
33334
You can change them if ports are occupied.
Mobile App
Download
Download the latest version from GitHub Releases:
| Platform | File |
|----------|------|
| Android | opencode-mobile-{version}.apk |
| iOS | opencode-mobile-{version}.ipa |
Installing Android APK
- Download APK file
- Open on your device
- Allow installation from unknown sources if prompted
- Install
App Features
- QR Scanner - Scan QR from TUI for quick connection
- Connection History - Saved servers with online indicator
- Voice Input - Microphone button for dictating messages
- Navigation - Back and home buttons for easy navigation
How to Connect
- Launch TUI on your computer
- Wait for tunnel creation and QR display
- Open OpenCode Mobile
- Tap "Scan QR"
- Point camera at QR code
- Done! You're connected to OpenCode
Voice Input
Voice input uses Groq Whisper API for speech-to-text transcription.
Getting Groq Token
- Register at console.groq.com
- Go to API Keys
- Create a new key
- Copy the token
Configuration
- In TUI press
Cfor configuration - Paste Groq Token
- Press
Enterto save
Usage
- Connect to server via mobile app
- A microphone button appears in the text input field
- Tap to start recording (button turns red)
- Speak
- Tap again to stop
- Text is automatically inserted into the input field
Named vs Quick Tunnel
Quick Tunnel (Default)
- Free, no registration
- Randomly generated URL:
https://xxx-xxx-xxx.trycloudflare.com - URL changes on each reconnect
- Suitable for temporary use
Named Tunnel
- Stable URL:
https://your-subdomain.yourdomain.com - Requires Cloudflare account
- Configure once
Setting up Named Tunnel:
- Create a tunnel in Cloudflare Zero Trust
- Copy the tunnel token
- In TUI press
C - Paste Tunnel Token
- Paste Tunnel Hostname (your public URL)
- Save
Configuration File
Configuration is stored in ~/.opencode-tunnel/config.json:
{
"tunnelToken": "your-cloudflare-tunnel-token",
"tunnelHostname": "https://your-subdomain.yourdomain.com",
"groqToken": "your-groq-api-key",
"serverPort": 33333,
"proxyPort": 33334,
"enableLogs": false
}Logs
When logging is enabled (enableLogs: true), log file location:
~/.opencode-tunnel/proxy.logContains:
- Proxy requests
- SSE events
- Errors
Troubleshooting
"opencode not found"
npm i -g opencode-ai"cloudflared not found"
Install cloudflared (see Installing cloudflared)
"Port already in use"
Change ports via L key or kill the process:
# Find process on port
lsof -i :33333
# Kill process
kill -9 <PID>QR not scanning
- Make sure tunnel is connected (status "connected")
- Try increasing terminal window size
- Check URL under QR code
Voice input not working
- Check Groq Token in configuration
- Ensure app has microphone access
- Check internet connection
Tunnel not connecting
- Check internet connection
- Verify cloudflared is installed and accessible
- For Named Tunnel: verify token
Development
# Install dependencies
npm install
# Development mode
npm run dev
# Build
npm run build
# Type check
npx tsc --noEmitMobile App Development
cd opencode-mobile
npm install
npm startReleasing
To create a new release:
- Update version in
package.jsonandopencode-mobile/app.json - Create and push a tag:
git tag v1.0.0
git push origin v1.0.0- GitHub Actions will automatically build APK and upload to Releases
Required GitHub Secrets:
EXPO_TOKEN- Get from expo.dev/settings/access-tokens
License
MIT
