AI coding agent

Run OpenCode safely on your Mac, in a sandbox VM

Create a MacVisor AI sandbox with --agent opencode and OpenCode runs with every permission allowed inside a disposable Linux or macOS VM, on a copy of your project. It reaches local or cloud models through MacVisor's gateway, so no key enters the VM, and its changes reach your project only when you apply the diff.

  • Apple Silicon (M1 or later)
  • macOS 27 on the Mac
  • A local model server or a cloud key

30 days free, no key or payment details. Apple Silicon with macOS 27.

A stylised MacVisor window with a Linux sandbox running the OpenCode terminal interface, connected through MacVisor's gateway to a model on the Mac.

OpenCode is an open-source terminal agent with its own permission rules for edits and commands. In a MacVisor sandbox they are all set to allow, and the VM takes their place as the boundary.

Create the sandbox

mvz sandbox create ~/src/app --agent opencode --model qwen3-coder:30b

Or in the app: New AI Sandbox…, then OpenCode as the agent. Add --os macos for a macOS 27 sandbox.

MacVisor installs OpenCode with its official install script, into ~/.opencode/bin, and puts that folder on the sandbox's path. While it installs, the sandbox may reach opencode.ai, GitHub and the npm registry. Those come off the allow list before the pristine checkpoint.

It then writes ~/.config/opencode/opencode.json in the VM:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "macvisor": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MacVisor",
      "options": { "baseURL": "http://127.0.0.1:11500/v1", "apiKey": "macvisor-sandbox" },
      "models": { "qwen3-coder:30b": { "name": "qwen3-coder:30b" } }
    }
  },
  "model": "macvisor/qwen3-coder:30b",
  "autoupdate": false,
  "share": "disabled",
  "permission": "allow"
}

The address is MacVisor's gateway as the VM sees it, and the key is a placeholder that the gateway ignores. The VM never holds a real key. Sharing is off, so no session leaves the VM as a share link, and OpenCode doesn't update itself or fetch its online models list.

Run, review and apply

mvz sandbox run app-1 -- "replace the hand-written SQL in reports/ with the query builder"
mvz sandbox attach app-1                 # the OpenCode interface
mvz sandbox diff app-1
mvz sandbox apply app-1 --branch

run starts opencode run on your prompt and streams the result. attach, or Run Agent in the app, opens OpenCode's terminal interface in the project folder. --model on run passes -m macvisor/<model> for that run.

A changed opencode.json or AGENTS.md in your project is flagged when you review, because OpenCode on your Mac reads them.

Models

OpenCode reaches the gateway through the OpenAI-compatible provider, so the model name decides the route:

  • any name a local server has (Ollama, LM Studio, llama.cpp, oMLX and others), such as qwen3-coder:30b;
  • claude-* for Anthropic, gpt-* for OpenAI, or openrouter/<model>, each with a key stored by mvz ai keys set.

A sandbox set up with a local model stays on local models unless you allow the cloud with --cloud, so OpenCode can't move to a paid model on its own. mvz ai log app-1 shows each request's model, time and tokens.

Internet access

With the default allow list, OpenCode reaches the models and nothing else until you add a site. Add the package registries your project uses:

mvz sandbox allow app-1 npm github
mvz sandbox log app-1 --egress

To give the sandbox the open internet instead, create it with --egress open. It is then on the network like any other VM.

AI sandboxes are a Tech Preview, in every license and the free 30-day trial. See AI sandboxes and the overview.

FAQ

Common questions

More in the documentation and known limitations.

How does OpenCode reach models in a MacVisor sandbox?

MacVisor adds a provider called macvisor to OpenCode's config in the VM, using OpenCode's OpenAI-compatible provider pointed at MacVisor's gateway. The sandbox's model is listed under it as macvisor/ followed by the model name, and the gateway sends each request to the local server or the cloud provider.

Does OpenCode ask for permission in the sandbox?

No. MacVisor sets OpenCode's permission setting to allow, so it edits files and runs commands in the VM without asking. Its changes stay in the VM until you review the diff and apply it on the Mac.

Can OpenCode share sessions from the sandbox?

No. MacVisor turns OpenCode's session sharing off in the VM, along with its auto-update and its fetch of the online models list.

Which models can OpenCode use?

Any model MacVisor's gateway can reach: a local server such as Ollama, LM Studio, llama.cpp or oMLX, or Anthropic, OpenAI or OpenRouter models with a key stored in the Mac's Keychain.

Run your Mac like a virtualization host.

macOS, Windows 11, Linux and FreeBSD VMs that keep running with the app closed, with snapshots, networks, backups and the mvz command line.