Skip to content

lemantorus/opencode-mobile

Repository files navigation

OpenCode Tunnel

npm version License: MIT Platform Mobile

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:

  1. OpenCode Server starts on port 33333
  2. Proxy starts on port 33334 and proxies requests + SSE events
  3. Cloudflare Tunnel creates a public HTTPS URL
  4. Mobile app scans QR and connects
  5. Voice messages are transcribed via Groq Whisper

Screenshots

TUI Interface

Initial State Port Configuration
Disabled Ports
Configuration Tunnel Running
Config Running
QR Code for Mobile
QR

Mobile App

QR Scanner & Connections Chats in App
Mobile Chats

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 cloudflared

Linux (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-bin

Windows (PowerShell):

winget install Cloudflare.cloudflared

Windows (Manual):

  1. Download from GitHub Releases
  2. Extract cloudflared.exe to a folder in PATH

Installation

From npm (Recommended)

npm install -g @lemantorus/opencode-tunnel

Then run:

opencode-tunnel

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 start

Usage

Starting

If installed globally via npm:

opencode-tunnel

If running from source:

npm start

On first run, TUI automatically:

  1. Starts OpenCode Server on port 33333
  2. Starts Proxy on port 33334
  3. Creates Cloudflare Quick Tunnel
  4. 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

  1. Download APK file
  2. Open on your device
  3. Allow installation from unknown sources if prompted
  4. 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

  1. Launch TUI on your computer
  2. Wait for tunnel creation and QR display
  3. Open OpenCode Mobile
  4. Tap "Scan QR"
  5. Point camera at QR code
  6. Done! You're connected to OpenCode

Voice Input

Voice input uses Groq Whisper API for speech-to-text transcription.

Getting Groq Token

  1. Register at console.groq.com
  2. Go to API Keys
  3. Create a new key
  4. Copy the token

Configuration

  1. In TUI press C for configuration
  2. Paste Groq Token
  3. Press Enter to save

Usage

  1. Connect to server via mobile app
  2. A microphone button appears in the text input field
  3. Tap to start recording (button turns red)
  4. Speak
  5. Tap again to stop
  6. 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:

  1. Create a tunnel in Cloudflare Zero Trust
  2. Copy the tunnel token
  3. In TUI press C
  4. Paste Tunnel Token
  5. Paste Tunnel Hostname (your public URL)
  6. 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.log

Contains:

  • 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 --noEmit

Mobile App Development

See opencode-mobile/README.md

cd opencode-mobile
npm install
npm start

License

MIT

About

OpenCode for mobiles

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors