nucel-agent-opencode
OpenCode provider for the Nucel Agent SDK — an HTTP client for the OpenCode server.
Features
- HTTP REST client — talks to
opencode serve(no subprocess management) - Session management —
POST /sessionthenPOST /session/{id}/prompt - Native session resume —
resume()re-uses the existing OpenCode session ID - MCP support — OpenCode's native MCP integration is exposed to the agent
- Budget enforcement — client-side cost guard before each query
- Directory header — sets
x-opencode-directoryso the server scopes file operations to the right working directory - System prompt + model override — passed in the JSON body
How it works
OpenCode runs as a long-lived server (opencode serve, default port 4096).
This provider:
- Issues
POST {base_url}/sessionto create a new session, returning a server session ID. - Issues
POST {base_url}/session/{id}/promptwith: - Parses the response — concatenates all
parts[].textentries withtype == "text", falls back to the top-leveltextfield ifpartsis empty. - Reads cost from the response's
costfield.
For resume(session_id, …), the existing OpenCode session ID is reused instead
of creating a new one.
Usage
[]
= "0.1"
= { = "1", = ["full"] }
use ;
use Path;
async
Capabilities
session_resume: true (native via session ID)
token_usage: true
mcp_support: true
autonomous_mode: true
structured_output: false
Requirements
- OpenCode installed:
npm install -g opencode - Server running:
opencode serve(defaulthttp://127.0.0.1:4096) - (Optional) API key if your OpenCode server enforces auth
availability()always returnsavailable: truefor OpenCode — the executor can't easily probe the network here, so thereasonfield is used as a hint ("Runopencode serveto start server at …") rather than a hard error. Connection errors surface fromspawn()/query()asAgentError::Provider.
Source
License
Apache-2.0