Package Exports
Readme
@whatcode-ai/sdk
SDK and CLI to start opencode and optionally expose it over HTTPS via Tailscale.
Install
npm install @whatcode-ai/sdkCLI
# start opencode
npx @whatcode-ai/sdk
# start opencode + expose via Tailscale
npx @whatcode-ai/sdk --tailscaleOptions
| Flag | Alias | Default | Description |
|---|---|---|---|
--tailscale |
-t |
false |
Expose opencode over HTTPS on your Tailscale tailnet |
--hostname |
-H |
0.0.0.0 |
Hostname to bind the opencode server to |
--port |
-p |
4096 |
Port to bind the opencode server to |
--timeout |
Timeout (ms) for the opencode server to start | ||
--help |
Show help |
Programmatic usage
import { createWhatcodeServer } from '@whatcode-ai/sdk';
await createWhatcodeServer({
tailscale: true, // optional
});createWhatcodeServer(config)
| Option | Type | Default | Description |
|---|---|---|---|
tailscale |
boolean |
undefined |
When true, exposes opencode via Tailscale serve |
hostname |
string |
0.0.0.0 |
Hostname to bind the opencode server to |
port |
number |
4096 |
Port to bind the opencode server to |
timeout |
number |
undefined |
Timeout in milliseconds for the opencode server to start |
signal |
AbortSignal |
undefined |
AbortSignal to stop the opencode server programmatically |
How it works
- Checks if opencode is already running on port
4096. - If not, starts the opencode server bound to
0.0.0.0. - If
tailscale: true, verifies Tailscale is installed and authenticated, runstailscale serve --bg 4096, and prints the HTTPS URL to use in your app.
Requirements
License
MIT