Skip to content

About

Reach OpenCode from your tailnet with an embedded Tailscale node.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

OpenCode Tailscale

Works with OpenCode

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.

Install

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 build

Add the absolute path to the checkout or extracted archive (not dist/) to plugins in your global OpenCode config, usually ~/.config/opencode/opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["/absolute/path/to/opencode-tsnet"]
}

Connect

  1. Open Settings → Tailscale in Desktop, or run /tailscale in the host's TUI.
  2. Sign in to Tailscale, then turn on Serve over Tailscale.
  3. 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.

Run headless

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/null

Closing Desktop or the TUI leaves the node running. opencode service stop stops it.

Access and removal

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

Development

Run bun run check to type-check and build. See DESIGN.md for design decisions.

MIT

About

Reach OpenCode from your tailnet with an embedded Tailscale node.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages