{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"OpenCode Integration","description":"Control the power of AI Agents in runtime."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"opencode-integration","__idx":0},"children":["OpenCode Integration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Connect OpenCode to Capsule Security for visibility into AI coding agent activity, including prompts, tool execution, agent replies and subagents - with inline blocking on policy-violating prompts and tool calls."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This integration uses ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://opencode.ai/docs/plugins"},"children":["OpenCode's plugin system"]}," to capture and govern AI coding agent activity. The Capsule plugin runs in-process inside OpenCode, forwards events to your Capsule tenant over HTTPS, and applies policy verdicts to prompts before they reach the model and to tool calls before they execute."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The plugin targets OpenCode 1.x (the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["opencode-ai"]}," npm package). OpenCode 2.x has a different plugin API and is not supported yet."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following events are captured:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Event"},"children":["Event"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["chat.message"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Blocking"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The prompt the developer submitted - can drop it before it reaches the model"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["tool.execute.before"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Blocking"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tool execution requests, including MCP tools and skill loads - can stop the call before it runs"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["tool.execute.after"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Observation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tool output after execution"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["tool.execute.error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Observation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A tool call that failed, including one Capsule blocked"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["assistant.message"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Observation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Each finished block of agent reply text"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["session.created"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Observation"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A new session, including the child session a subagent runs in"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When Capsule blocks a tool call, the tool does not run and the model receives the policy reason as the tool's error. When Capsule blocks a prompt, it is not saved or sent to the model, and the OpenCode TUI shows the policy reason as a session error. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["opencode run"]}," reports a generic server error for a blocked prompt instead."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Subagents run in child sessions, so their prompts and tool calls go through the same checks. Text OpenCode adds to a prompt itself, such as the contents of an attached file, is not part of the policy check on that prompt."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Before you begin, ensure you have:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["OpenCode"]}," 1.x installed"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Capsule Security"]}," account with admin access"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Network access from your developer machines to your Capsule agentsecurity endpoint (e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://agents.capsule.security"]},")"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-1-generate-a-plugin-token","__idx":3},"children":["Step 1: Generate a Plugin Token"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Log in to the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Capsule Security"]}," portal"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Integrations"]}," and locate ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["OpenCode"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Install"]}," - Capsule generates a JWT scoped to your tenant and OpenCode environment. The token contains the tenant and environment claims required by the agentsecurity endpoint; treat it as a secret."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Copy the generated token. You will reference it from your Capsule plugin configuration in Step 3."]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-2-register-the-plugin","__idx":4},"children":["Step 2: Register the Plugin"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["OpenCode installs npm plugins listed in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["plugin"]}," array of its config. Add the Capsule package to your global config, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.config/opencode/opencode.json"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\"@capsulesecurity/opencode-capsule\"]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["OpenCode installs the package on next start. To pin a version, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"@capsulesecurity/opencode-capsule@1.0.0\""]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To roll the plugin out to every user of a machine, add the same entry to the system-wide config instead. OpenCode reads it on every start, alongside each user's own config:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"OS"},"children":["OS"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"System-wide config"},"children":["System-wide config"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["macOS"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/Library/Application Support/opencode/opencode.json"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Linux"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/etc/opencode/opencode.json"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Windows"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["%ProgramData%\\opencode\\opencode.json"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-configure-the-plugin","__idx":5},"children":["Step 3: Configure the Plugin"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Capsule plugin reads its settings from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.config/opencode/capsule.json"]}," (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$XDG_CONFIG_HOME/opencode/capsule.json"]}," when ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["XDG_CONFIG_HOME"]}," is set):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"endpoint\": \"https://agents.capsule.security\",\n  \"token\": \"<token-from-step-1>\",\n  \"blockOnRisk\": true,\n  \"failOpen\": true,\n  \"timeoutMs\": 5000\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configuration-options","__idx":6},"children":["Configuration Options"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every option can also be supplied as an environment variable."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endpoint"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["token"]}," come from the environment when both are set there, otherwise from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["capsule.json"]},", and the"," ","remaining settings come from that same source. Environment variables still override the other options. Plugin options"," ","in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["opencode.json"]}," and anything in a project directory are never read, so cloning an untrusted repository cannot"," ","redirect your prompts and tool calls to someone else's server or turn enforcement off."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Option"},"children":["Option"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Env var"},"children":["Env var"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Default"},"children":["Default"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endpoint"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_ENDPOINT"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["(required)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Capsule agentsecurity endpoint, e.g. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://agents.capsule.security"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["token"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_TOKEN"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["(required)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JWT generated in Step 1, scoped to your tenant and environment"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["blockOnRisk"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_BLOCK_ON_RISK"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Apply server ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["block"]}," decisions inline. Set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," to run in observe-only mode"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failOpen"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_FAIL_OPEN"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["boolean"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["When Capsule is unreachable or returns an error, allow the prompt or tool call. Set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," to fail closed"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timeoutMs"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_TIMEOUT_MS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["5000"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Per-request timeout in milliseconds. OpenCode does not time out plugins itself, so this bounds every blocking check"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["user"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_USER"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["OS user name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["User identifier sent on every event"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Without ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endpoint"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["token"]}," the plugin writes a warning to the OpenCode log and stays inactive. It never breaks the agent loop."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"token-storage","__idx":7},"children":["Token Storage"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Never commit the JWT to version control. Recommended approaches:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Keep the token in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.config/opencode/capsule.json"]}," outside any repository"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CAPSULE_TOKEN"]}," from your secret manager (1Password, AWS Secrets Manager, HashiCorp Vault) at shell startup"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For MDM-managed deployments, deliver it through the same channel that distributes the OpenCode configuration"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-4-restart-opencode","__idx":8},"children":["Step 4: Restart OpenCode"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For the plugin to take effect, restart any running OpenCode sessions:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Exit OpenCode"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Restart OpenCode so it installs the package and loads the plugin"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-5-verify-the-installation","__idx":9},"children":["Step 5: Verify the Installation"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Start a new OpenCode session and execute a simple task to generate activity:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Create a new file called test.txt with the content \"Hello World\"\n"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Log in to the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Capsule Security"]}," portal"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Inventory > Agents"]}," and confirm your OpenCode agent appears. OpenCode has no persistent agent identifier, so an agent is identified by the working directory and the user running it."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Click on the agent and review the audit logs to verify events are captured:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Session start event"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The prompt you submitted"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Tool execution (write tool)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The agent reply"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"troubleshooting","__idx":10},"children":["Troubleshooting"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If events are not appearing:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Verify the endpoint is reachable"]}," from the host running OpenCode:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -sS -o /dev/null -w \"%{http_code}\\n\" https://agents.capsule.security/health\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Verify the configuration is found"]}," - the plugin writes a warning to the OpenCode log and stays inactive when ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endpoint"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["token"]}," is missing. Check that ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.config/opencode/capsule.json"]}," is valid JSON. Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["opencode --print-logs"]}," to see the log on stderr."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check that plugins are enabled"]}," - OpenCode skips npm plugins when ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPENCODE_PURE=1"]}," is set."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Check for timeouts"]}," - if your network has high latency to the Capsule endpoint, increase ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timeoutMs"]}," or confirm ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failOpen"]}," is set appropriately."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Contact Capsule Security support"]}," if issues persist."]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"security-considerations","__idx":11},"children":["Security Considerations"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Capsule plugin runs in-process inside OpenCode with full system permissions and observes every prompt, tool call and agent reply. Before deploying:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Protect the JWT"]}," - anyone with the token can post events on behalf of your tenant. Rotate it through the portal if it is exposed."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Choose ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failOpen"]}," deliberately"]}," - ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failOpen: true"]}," (the default) prioritizes developer productivity; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failOpen: false"]}," prioritizes policy enforcement and will block prompts and tool execution when Capsule is unreachable."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Pin a plugin version"]}," in production, using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"@capsulesecurity/opencode-capsule@&lt;version&gt;\""]},", and review changelogs before upgrading."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use TLS-only endpoints"]},". The plugin sends a Bearer token on every request - never configure an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://"]}," endpoint."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Understand the coverage boundary"]}," - shell commands a developer runs directly with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["!"]}," in the OpenCode prompt do not go through the tool hooks, so they are not checked."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"support","__idx":12},"children":["Support"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For help with this integration:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Email"]},": support@capsule.security"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Include"]},": Your organization ID, integration status, plugin version, and any error messages"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"references","__idx":13},"children":["References"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://opencode.ai/docs"},"children":["OpenCode Documentation"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://opencode.ai/docs/plugins"},"children":["OpenCode Plugins"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/@capsulesecurity/opencode-capsule"},"children":["Capsule OpenCode Plugin on npm"]}]}]}]},"headings":[{"value":"OpenCode Integration","id":"opencode-integration","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Step 1: Generate a Plugin Token","id":"step-1-generate-a-plugin-token","depth":2},{"value":"Step 2: Register the Plugin","id":"step-2-register-the-plugin","depth":2},{"value":"Step 3: Configure the Plugin","id":"step-3-configure-the-plugin","depth":2},{"value":"Configuration Options","id":"configuration-options","depth":3},{"value":"Token Storage","id":"token-storage","depth":3},{"value":"Step 4: Restart OpenCode","id":"step-4-restart-opencode","depth":2},{"value":"Step 5: Verify the Installation","id":"step-5-verify-the-installation","depth":2},{"value":"Troubleshooting","id":"troubleshooting","depth":3},{"value":"Security Considerations","id":"security-considerations","depth":2},{"value":"Support","id":"support","depth":2},{"value":"References","id":"references","depth":2}],"frontmatter":{"seo":{"title":"OpenCode Integration"}},"lastModified":"2026-11-04T20:48:54.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/opencode","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}