OpenCode plugin reference

Install, options, environment variables, tools and commands of @gitterm/opencode, the plugin for sandboxes and /cloud.

View as markdown

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

Shell
npx @gitterm/cli setup

gitterm setup installs the plugin for OpenCode, sets up your other agents, and signs you in. To install only the plugin:

Shell
opencode plugin add @gitterm/opencode

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

JSONC
{
  "$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.

You haveSandbox tools/cloud and /cloud-return
A Gitterm login (gitterm.dev or self-hosted), no sandboxYes, billed to your Gitterm planYes
A Gitterm login and a sandbox accountYes, with that accountYes
A sandbox account with your own provider key, no loginYesNo: moving needs a Gitterm login
NeitherNoYes: /cloud signs you in

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:

JSONC
// 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.

OptionTypeRequiredDefaultWhat it does
sandboxobject or falseNoYour Gitterm loginThe sandbox account and its settings, see Sandbox options. false turns the sandbox tools off.
cloudbooleanNotruefalse turns /cloud and /cloud-return off.
serverUrlstringNoSaved CLI loginGitterm API URL, for /cloud and for sandboxes billed to Gitterm.
tokenstringNoSaved CLI loginGitterm API token. Prefer gitterm login or GITTERM_API_TOKEN.
providerobjectNoYour Gitterm defaultProvider for the cloud workspace, for example { "type": "e2b" }. Must be enabled on your deployment.
connectionsstring[]Only for private repositoriesNoneSaved Gitterm connections to attach, by id, name, or integration key. "github" picks a connection that covers the repository.
namestringNoThe conversation titleCloud workspace name.
persistentbooleanNoNot requestedRequests persistent storage for the cloud workspace where the provider supports it.
envFilesstring[]NoNoneEnv files, relative to the checkout, whose variables the cloud workspace gets. Later files win.
localServerUrlstringOnly for standalone OpenCode serversDiscovered automaticallyLoopback URL of your local OpenCode server: localhost, 127.0.0.1, or [::1], with no credentials in the URL.
localServerPasswordstringOnly if that server needs oneNonePassword for that local server.

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.

OptionTypeRequiredDefaultWhat it does
accountstringNoNoneWith accounts: name of the account the tools use.
accountsobjectNoNoneMap of account name to account fields, for several accounts. A single account inline is named after its provider, or gitterm without one.
limitsobjectNoSee limitsCaps on what the agent can start.
excludestring[]NoNoneExtra glob patterns sandbox_sync never uploads. Secret-like files are always left out.
maxSourceMiBintegerNo100Maximum working tree size before compression for sandbox_sync, in MiB. Accepts 1–1024.
publicPreviewsbooleanNofalseCreates every sandbox with public previews, without asking. Setting it is your approval. Whether a preview can be public depends on the provider and the kind of account; see Previews by provider.
snapshotsbooleanNofalseLets the agent save a set-up sandbox as a snapshot, so the project's next sandboxes start from it. See Setup snapshots.
envFilesstring[]NoNoneEnv files, relative to the checkout, whose variables every sandbox command gets. Later files win.

Account names use letters, digits, _, ., and -, start with a letter or digit, and are at most 63 characters.

Account fields

FieldApplies toRequiredDefaultWhat it does
apiKeyDirectYes, except e2b, daytona, exedevTheir CLI loginProvider key, as "{env:VAR}" or "{file:path}". It makes the account direct; without it the account is managed. E2B, Daytona, and exe.dev accounts can leave it out and use their CLI login. See Direct accounts.
providerDirectYesNonee2b, daytona, vercel, boat, exedev, or railway.
providerManagedNoThe server's defaultOne the deployment offers, for example e2b or (managed only) aws. Gitterm's own sandboxes on gitterm.dev.
sizeManagedNoYour plan's defaultMachine size: small or medium on gitterm.dev, or one of a self-hosted deployment's machine profiles.
allowUnboundedLifetimeDirect exedev, railwayYes (true)falseAccepts that a crashed sandbox runs until you destroy it.
templateDirect e2bNobaseE2B template.
targetDirect daytonaNoDaytona's defaultRegion: us or eu.
snapshotDirect daytonaNoNoneDaytona snapshot to use instead of the default image.
teamId, projectIdDirect vercelYesNoneVercel team and project.
runtimeDirect vercelNonode24node24, node22, or python3.13.
sizeDirect boatNoBoat's defaultsmall, default, or large.
imageDirect exedevNonode:22-bookwormContainer image.
projectId, environmentIdDirect railwayYesNoneRailway project and environment.
imageDirect railwayNonode:22-bookworm-slimContainer image. Gitterm's command server runs in it.
apiUrlDirect railwayNoRailway's APIRailway API URL. Default: backboard.railway.app/graphql/v2.
serverUrlManagedNoCLI loginGitterm API URL, for self-hosted deployments.
tokenManagedNoCLI loginGitterm API token. Prefer gitterm login or GITTERM_API_TOKEN.

For what each provider does with a sandbox, see Providers.

Limits

Set these under sandbox.limits. Any field you leave out uses its default.

LimitDefaultWhat it does
maxSandboxes2Live sandboxes per account. sandbox_create fails at the limit.
maxLifetimeMinutes60Longest lifetime sandbox_create accepts.
defaultLifetimeMinutes30Lifetime when the agent does not set one.
maxJobMinutes30Longest job timeout. Jobs default to 10 minutes or this, whichever is less. Preview servers run until the sandbox's lifetime ends, or this long where the sandbox has none.

Providers also cap the lifetime: 24 hours, or 5 hours on Vercel.

Environment variables

VariableWhat it does
GITTERM_API_TOKENGitterm API token. Overrides the saved login.
GITTERM_SERVER_URLGitterm API URL. Overrides the saved login.
GITTERM_OPENCODE_LOCAL_SERVER_URLSame as the localServerUrl option.
GITTERM_OPENCODE_LOCAL_SERVER_PASSWORDSame as the localServerPassword option.
XDG_STATE_HOMEBase directory for local sandbox records. Default ~/.local/state.
XDG_CACHE_HOMEBase directory for downloaded artifacts. Default ~/.cache.

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.

ToolWhat it does
sandbox_createCreates a sandbox
sandbox_listShows the selected account, who is charged, limits, and sandboxes
sandbox_syncUploads the checkout
sandbox_execRuns a command as a job
sandbox_jobReads a job's status and output, or cancels it
sandbox_previewExposes a port, optionally starting a server first
sandbox_artifactDownloads a file a job produced
sandbox_applyCopies a downloaded file into the checkout
sandbox_pausePauses a sandbox, keeping its files
sandbox_destroyDeletes a sandbox
sandbox_snapshotSaves or deletes a setup snapshot (with snapshots)

Which tools ask for approval, and how to pre-approve them: Approvals.

Commands

CommandWhat it does
/cloudMoves this session into a cloud workspace. Run again in the same session to reconnect, or to retry a move that failed. See Move a session.
/cloud-returnBrings the session, and the cloud's commits, changes and conversation, back to this checkout, then ends the workspace. See Bring a session back.

/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

  1. Install @gitterm/opencode. gitterm setup does it, and says when an old plugin is still in your config.

  2. Move the options:

    • From @gitterm/opencode-cloud: keep them as they are, at the top level.
    • From @gitterm/opencode-sandbox: put them under sandbox.
  3. Remove the old plugins, so /cloud isn't added twice:

    Shell
    opencode plugin remove @gitterm/opencode-cloud
    opencode plugin remove @gitterm/opencode-sandbox