OpenCode plugin reference
Install, options, environment variables, tools and commands of @gitterm/opencode, the plugin for sandboxes and /cloud.
This is the reference for @gitterm/opencode, Gitterm's OpenCode plugin: every option, account field, limit, environment variable, tool, and command. Use it to look up a field. For step-by-step use, see Sandbox setup, Move a session and Bring a session back.
It needs OpenCode 2.3.0 or later. It replaces @gitterm/opencode-sandbox and @gitterm/opencode-cloud; see Moving from the old plugins.
Install
npx @gitterm/cli setupgitterm setup installs the plugin for OpenCode, sets up your other agents, and signs you in. To install only the plugin:
opencode plugin add @gitterm/opencodeThis adds it to your global OpenCode config. You can instead list it under plugins in a project's opencode.json, or in ~/.config/opencode/opencode.json for all projects. To pass options, replace the string entry with an object. Keep your other settings and plugin entries.
{
"$schema": "https://opencode.ai/config.json",
"plugins": [
{
"package": "@gitterm/opencode",
"options": {
"sandbox": { "provider": "e2b", "apiKey": "{env:E2B_API_KEY}" },
},
},
],
}Restart OpenCode after changing the options. When you load the plugin from a local path, point package at the package directory, not a file.
What turns on
Each part of the plugin turns on by itself when it can work. To turn one off, see Turn a part off.
A sandbox account here means the plugin's sandbox option or, without it, the gitterm CLI's settings file that gitterm sandbox setup writes. Restart OpenCode after signing in or changing these, so the tools appear.
Turn a part off
Set "sandbox": false or "cloud": false in the plugin's options. In your global config it applies everywhere. For one project only, add the plugin to that project's opencode.json with its own options. They replace the global options in that project, so repeat any you still want there:
// opencode.json in the project
{
"plugins": [{ "package": "@gitterm/opencode", "options": { "cloud": false } }],
}To leave the plugin out of a project entirely, add "-gitterm" to that project's plugins. gitterm project disable turns either part off for a project too, for every agent on your machine; see Turn Gitterm off for a project.
Sign in
Moving a session, and sandboxes billed to a Gitterm plan, need a Gitterm account. Sandboxes with your own provider key do not.
You don't have to sign in first: if you aren't signed in, or your login expired, /cloud shows a link, a QR code and a code. Open the link, sign in or create an account, and approve the code. The dialog closes by itself and /cloud carries on. Esc cancels.
The login is saved where the CLI keeps it, so gitterm login signs the plugin in too, and the plugin's login signs in the CLI. For a self-hosted deployment, set the serverUrl option, or run gitterm login --server <url>, where <url> is your Gitterm API URL. You can instead set GITTERM_API_TOKEN (and GITTERM_SERVER_URL) before starting OpenCode; a token set this way or in token is never replaced by signing in.
Your model keys stay on your computer. In the cloud, the agent can use free models, or the models you add under Models in Gitterm, which we recommend. With none added, /cloud suggests it before creating a workspace: continue with the free models, or add one at the link it shows and choose Check again; the same /cloud carries on.
Options
Every option is optional.
serverUrl and token resolve in this order: the option, then GITTERM_SERVER_URL / GITTERM_API_TOKEN, then the saved CLI login. The server defaults to https://api.gitterm.dev.
Sandbox options
These go in sandbox, next to one account's fields. For several accounts, put them under sandbox.accounts instead. Without sandbox, the plugin uses ~/.config/gitterm/sandbox.json (which gitterm sandbox setup writes), and without that, the Gitterm account you are signed in to.
Account names use letters, digits, _, ., and -, start with a letter or digit, and are at most 63 characters.
Account fields
For what each provider does with a sandbox, see Providers.
Limits
Set these under sandbox.limits. Any field you leave out uses its default.
Providers also cap the lifetime: 24 hours, or 5 hours on Vercel.
Environment variables
Set variables before OpenCode starts. This includes variables you reference with {env:VAR} and variables you pass to jobs with secretEnv. Plugins run in OpenCode's background service, so a variable on the opencode command line (VAR=value opencode) doesn't reach them once the service is running. Set it on the service and restart it (opencode service set env VAR value, then opencode service restart), or use {file:path} instead.
Tools
With a sandbox account, the plugin adds these tools. sandbox_snapshot needs snapshots, and sandbox_pause a provider that can pause. You ask in plain words and the agent picks them; their arguments are in Tools.
Which tools ask for approval, and how to pre-approve them: Approvals.
Commands
/cloud-return appears only while a session of the checkout is in the cloud. It needs a Gitterm server that includes cloud return (managed Gitterm does); against an older self-hosted server, /cloud fails until the server is updated.
In the OpenCode terminal
The right sidebar has a Sandboxes list with this checkout's live sandboxes, newest first. Each line shows the sandbox name and a dot for its state (green running, yellow pending or paused, red deleting), then any running jobs, preview ports, and its purpose or provider. It refreshes every few seconds from the local sandbox records, never calls the provider, and is hidden when the checkout has no sandboxes.
While a session is in the cloud, the sidebar also has a Cloud block, and a status line above the prompt says what the cloud agent is doing: working, needs your input, idle, paused, or deleted. The plugin notifies you when the cloud agent finishes or needs your input, and sending a message in that session locally asks first. Status checks are marked as passive, so they don't keep the workspace from pausing when it is idle.
The desktop app gets the sandbox tools, the check before sending and both commands, but not the sidebar, status line or notifications.
Moving from the old plugins
-
Install
@gitterm/opencode.gitterm setupdoes it, and says when an old plugin is still in your config. -
Move the options:
- From
@gitterm/opencode-cloud: keep them as they are, at the top level. - From
@gitterm/opencode-sandbox: put them undersandbox.
- From
-
Remove the old plugins, so
/cloudisn't added twice:Shell opencode plugin remove @gitterm/opencode-cloud opencode plugin remove @gitterm/opencode-sandbox