
Product
Introducing Manifest Alerts
Socket now detects supply chain risks in project manifests, starting with missing lockfiles that can make dependency installs non-reproducible.
@freestyle-sh/with-opencode
Advanced tools
[OpenCode](https://opencode.ai) integration for [Freestyle](https://freestyle.sh) VMs. Provides a fully configured OpenCode AI coding assistant server in your Freestyle VM.
OpenCode integration for Freestyle VMs. Provides a fully configured OpenCode AI coding assistant server in your Freestyle VM.
bun add @freestyle-sh/with-opencode freestyle
import { freestyle, VmSpec } from "freestyle";
import { VmOpenCode } from "@freestyle-sh/with-opencode";
const { vm } = await freestyle.vms.create({
spec: new VmSpec({
with: {
opencode: new VmOpenCode(),
},
}),
});
// Expose the web UI
const { url } = await vm.opencode.routeWeb();
console.log(`OpenCode UI: ${url}`);
const { client } = await vm.opencode.client();
// Use the OpenCode SDK client to interact with the server
const sessions = await client.session.list();
const { url } = await vm.opencode.routeWeb({
domain: "my-opencode.example.com",
});
const { client } = await vm.opencode.client({
domain: "my-opencode-api.example.com",
});
import { freestyle, VmSpec } from "freestyle";
import { VmOpenCode } from "@freestyle-sh/with-opencode";
const { vm } = await freestyle.vms.create({
spec: new VmSpec({
with: {
opencode: new VmOpenCode({
server: {
username: "serveradmin",
password: "secret-server-pass",
},
web: {
username: "webadmin",
password: "secret-web-pass",
},
}),
},
}),
});
// URLs will include credentials automatically
const { url } = await vm.opencode.routeWeb();
const { client } = await vm.opencode.client();
new VmOpenCode({
server: {
port: 4096, // Optional: API server port (default: 4096)
username: "admin", // Optional: Basic auth username (default: "opencode" when password is set)
password: "secret", // Optional: Basic auth password
},
web: {
port: 4097, // Optional: Web UI port (default: 4097)
username: "admin", // Optional: Basic auth username (default: "opencode" when password is set)
password: "secret", // Optional: Basic auth password
},
env: {
ANTHROPIC_API_KEY: "sk-ant-...", // Optional: Environment variables for OpenCode
},
});
| Option | Type | Default | Description |
|---|---|---|---|
server.port | number | 4096 | Port for the OpenCode API server |
server.username | string | "opencode" | Basic auth username (only used if password set) |
server.password | string | - | Basic auth password for the API server |
web.port | number | 4097 | Port for the OpenCode web UI |
web.username | string | "opencode" | Basic auth username (only used if password set) |
web.password | string | - | Basic auth password for the web UI |
env | Record<string, string> | {} | Environment variables passed to OpenCode processes |
OpenCode requires API keys to interact with AI providers. When running in a Freestyle VM, pass the required keys using the env option.
Note: Environment variables are stored as plain text in the VM's startup scripts. Users with direct or indirect access to the VM may be able to view these values. Use appropriately scoped API keys and rotate them if the VM is shared or exposed.
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | API key for Claude models |
OPENAI_API_KEY | API key for OpenAI models |
OPENROUTER_API_KEY | API key for OpenRouter |
See OpenCode Providers for all supported providers and their environment variables.
const { vm } = await freestyle.vms.create({
spec: new VmSpec({
with: {
opencode: new VmOpenCode({
env: {
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!,
},
}),
},
}),
});
vm.opencode.routeWeb(options?)Exposes the OpenCode web UI on a public domain.
Options:
domain?: string - Custom domain to use. If not specified, generates a random subdomain.Returns: Promise<{ url: string }> - URL includes credentials if authentication is configured.
const { url } = await vm.opencode.routeWeb();
console.log(`OpenCode UI available at: ${url}`);
vm.opencode.client(options?)Creates an OpenCode SDK client connected to the server. The client is automatically configured with credentials if authentication is enabled.
Options:
domain?: string - Custom domain for the API endpoint. If not specified, generates a random subdomain.Returns: Promise<{ client: OpencodeClient }>
const { client } = await vm.opencode.client();
// List sessions
const sessions = await client.session.list();
// Create a new session
const session = await client.session.create({ path: "/workspace" });
vm.opencode.serverPort()Returns the configured API server port.
Returns: number
vm.opencode.webPort()Returns the configured web UI port.
Returns: number
The package uses systemd services to install and run OpenCode during VM creation:
opencode serve)opencode web)Both services are configured to restart automatically and listen on all interfaces (0.0.0.0).
FAQs
[OpenCode](https://opencode.ai) integration for [Freestyle](https://freestyle.sh) VMs. Provides a fully configured OpenCode AI coding assistant server in your Freestyle VM.
The npm package @freestyle-sh/with-opencode receives a total of 464 weekly downloads. As such, @freestyle-sh/with-opencode popularity was classified as not popular.
We found that @freestyle-sh/with-opencode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now detects supply chain risks in project manifests, starting with missing lockfiles that can make dependency installs non-reproducible.

Research
/Security News
The trojanized extensions use TinyGo-compiled WebAssembly and Solana transaction memos to resolve command-and-control infrastructure.

Security News
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.