Reach OpenCode from your tailnet without installing Tailscale on the host or running as root. The plugin embeds a tsnet node in the OpenCode background service. Inspired by Rex Server.
Requires OpenCode V2 compatible with @opencode/plugin 2.3.0, on macOS or Linux (ARM64 or x86-64). Use a release archive if available, or build with Bun and Go 1.27.4+:
git clone https://github.com/Pavior0/opencode-tsnet.git
cd opencode-tsnet
bun install --frozen-lockfile
bun run buildAdd the absolute path to the checkout or extracted archive (not dist/) to plugins in your global OpenCode config, usually ~/.config/opencode/opencode.jsonc:
- Open Settings → Tailscale in Desktop, or run /tailscale in the host's TUI.
- Sign in to Tailscale, then turn on Serve over Tailscale.
- Choose Pair a device. On a device connected to the same tailnet, scan the QR code in OpenCode or open the one-time link.
A remote TUI needs no plugin. Set OPENCODE_PASSWORD to the host's OpenCode password or a redeemed pairing token, then pass the address shown in settings:
opencode --server 'http://opencode.example.ts.net:41680'If you have only a pairing link, request it once with Accept: application/json and use the returned token.
Use the managed OpenCode service, not opencode serve or --standalone. After each unattended start or restart, make a local request to activate the plugin:
opencode service start
opencode api get /api/plugin >/dev/nullClosing Desktop or the TUI leaves the node running. opencode service stop stops it.
- The plugin adds a tailnet-only listener on port
41680. OpenCode still requires authentication. The plugin doesn't change existing OpenCode bindings or enable Funnel. - Turning off serving disconnects devices but doesn't revoke their OpenCode credentials. Remove a lost device from the tailnet and rotate the OpenCode password if its credentials may have leaked.
- To uninstall, sign out and remove the plugin from
plugins. If sign-out can't be confirmed, remove the node in the Tailscale admin console.
Node state defaults to ~/.local/state/opencode-tsnet/node (or the equivalent under XDG_STATE_HOME). The bundled binary runs as the OpenCode service user; options.nodePath can override it with an absolute path.
Run bun run check to type-check and build. See DESIGN.md for design decisions.
{ "$schema": "https://opencode.ai/config.json", "plugins": ["/absolute/path/to/opencode-tsnet"] }