npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agent-controller/runtime-opencode

v0.5.0

Published

opencode runtime adapter for agent-controller — runs an ADL CompiledSpec against an opencode session via @opencode-ai/sdk and emits the NDJSON wire-event stream.

Readme

@agent-controller/runtime-opencode — opencode runtime adapter

Node/TypeScript adapter that runs an agent-controller CompiledSpec against the sst/opencode CLI via the official @opencode-ai/sdk, and emits the NDJSON wire-event stream that agentctl consumes. Sibling to the Pi adapter (@agent-controller/runtime); both consume the same CompiledSpec and emit the same wire-event format.

Requires Node 22+.

Install

npm install -g @agent-controller/runtime-opencode
# or per-project
npm install --save-dev @agent-controller/runtime-opencode

The opencode CLI must also be on PATH. Install with npm install -g opencode-ai or follow https://opencode.ai/docs/.

Use with agentctl

agentctl (the Go CLI) spawns this package as a subprocess when spec.runtime.type is local-opencode. The example specs under examples/ reference cwd-relative registry entries that ship with the source repo but not with this npm package. For an npm-only install, use a self-contained spec:

# 1) Write a self-contained spec (no tools[]/extensions[]/skills[]/subagents[])
cat > /tmp/hello-opencode.yaml <<'EOF'
apiVersion: agent-controller.dev/v1alpha1
kind: Agent
metadata: { name: hello-opencode }
spec:
  model: { provider: anthropic, name: claude-sonnet-4-20250514 }
  persona: { role: Helpful demo, instructions: Answer concisely. }
  task: Say hello.
  tools: []
  runtime: { type: local-opencode }
EOF

# 2) Point agentctl at the adapter and run
export ANTHROPIC_API_KEY=sk-ant-...

# global install
AGENT_CONTROLLER_RUNTIME="$(npm root -g)/@agent-controller/runtime-opencode/dist/index.js" \
  agentctl run /tmp/hello-opencode.yaml

# or per-project
AGENT_CONTROLLER_RUNTIME="./node_modules/@agent-controller/runtime-opencode/dist/index.js" \
  agentctl run /tmp/hello-opencode.yaml

Credentials via environment: ANTHROPIC_API_KEY (and / or ANTHROPIC_BASE_URL). Auth from ~/.opencode/auth.json is intentionally NOT used — the adapter isolates HOME to prevent ambient config leakage.

agentctl (matching version) is available from the GitHub Releases page as cross-platform binaries.

Architecture role

This package is the subprocess spawned by agentctl run when spec.runtime.type is local-opencode. It:

  1. Reads a CompiledSpec JSON document from stdin
  2. Rejects unsupported ADL surface (spec.sessionId) at startup with a clear error (other opencode-incompatible shapes — spec.extensions[], spec.installs[], custom Pi-extension tools, built-ins with config — are rejected at agentctl compile since v0.3.0)
  3. Builds an opencode-native config (cfg.agent[primary], cfg.agent[subagent_N], cfg.mcp[server_N]) from the spec via buildOpencodeConfig
  4. Spawns opencode via @opencode-ai/sdk's createOpencode() with an isolated HOME / XDG_* / cwd so ambient user config can't leak undeclared capabilities
  5. Submits the task via session.promptAsync() (non-blocking)
  6. Consumes the SSE event stream via a producer-consumer queue
  7. Translates opencode events into wire-protocol events (tool.call/result, message, session.ended/error/warning, hallucination warnings)
  8. Disables opencode's native agents (plan, build, general, explore, scout) so the task tool can't bypass the ADL allowlist

ADL allowlist preservation

Several layers of defense keep ADL's "only declared capabilities are reachable" contract intact:

  1. Opencode permissions start from a deny baseline ("*": "deny" + every known opencode tool explicitly denied), then declared tools become allow
  2. Native opencode agents are disabled so the task tool can't delegate to undeclared agents
  3. MCP server names are validated against [A-Za-z0-9._-]+ (no glob metacharacters), against opencode built-in prefixes (repo, doom, external), and for sanitization collisions
  4. Opencode-incompatible spec shapes are rejected at agentctl compile (v0.3.0)

Capability differences vs the Pi adapter

See docs/architecture/harness-matrix.md for the per-feature table. Highlights:

| Feature | Pi adapter | opencode adapter | |---|---|---| | Custom Pi-format tools / extensions | ✅ | ❌ rejected at agentctl compile | | Session resume (--resume) | ✅ | ❌ rejected by agentctl run | | task tool / native subagent delegation | via vendored ext | ✅ native | | cancelled reason on SIGINT | ❌ (surfaces as error) | ✅ | | bash allowlist via tool config | ❌ rejected at agentctl compile (use @gotgenes/pi-permission-system) | ❌ rejected at agentctl compile |

Building from source

git clone https://github.com/CCDevelopForFun/agent-controller.git
cd agent-controller/runtime-opencode
npm install --ignore-scripts
npm run build           # tsc → dist/
npm test                # vitest

Cross-references

License

MIT — see LICENSE.