{"_id":"@agent-controller/runtime-opencode","_rev":"6-fac52d2e4e60b0b77559e0508154bcf4","name":"@agent-controller/runtime-opencode","dist-tags":{"latest":"0.7.0"},"versions":{"0.3.1":{"name":"@agent-controller/runtime-opencode","version":"0.3.1","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"author":{"name":"CCDevelopForFun"},"license":"MIT","_id":"@agent-controller/runtime-opencode@0.3.1","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"dist":{"shasum":"6e07763e1cb85f657cfc6c9643e6321aa905f672","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.3.1.tgz","fileCount":15,"integrity":"sha512-c5bIrkoEHLqqHfmevJz2ZVOXWxvGwX4KXS3TBmr82UZlxxFhVuPKRsRSSBmNn0c8zk656RzyNjZz75IBMIjVwQ==","signatures":[{"sig":"MEUCIQDMK6M/K/JLNf5vJW5bBYI7ZTeIMrGY274/8od//TIF/gIgKb9X7MPg6BU6dsbA0Rqsm4Xns09OeEVe3sSamqIjBX4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":117182},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"gitHead":"047c7239f8f9cc7aec54233ea2e1177de0c968c5","scripts":{"test":"npm run build && vitest run","build":"tsc -p .","test:watch":"vitest"},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"repository":{"url":"git+https://github.com/CCDevelopForFun/agent-controller.git","type":"git","directory":"runtime-opencode"},"_npmVersion":"10.9.8","description":"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.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@opencode-ai/sdk":"^1.15.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/runtime-opencode_0.3.1_1780680200428_0.6235450048334918","host":"s3://npm-registry-packages-npm-production"}},"0.3.2":{"name":"@agent-controller/runtime-opencode","version":"0.3.2","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"author":{"name":"CCDevelopForFun"},"license":"MIT","_id":"@agent-controller/runtime-opencode@0.3.2","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"dist":{"shasum":"cd1bd2072c726674b4a6acfd90af7b411fa60d36","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.3.2.tgz","fileCount":15,"integrity":"sha512-zyle3coNRBMkJS2eNuc9G5opXN6upgQBzXsDo4LHzmjerU/K/Kg6x33yFf7YC1oFBjY4F6i4aP3KByo5NZGyiw==","signatures":[{"sig":"MEQCICmlnd7gbRDbsgoL6/9jO4WC4C07uPwvstAV6IiWpV6/AiA0wXGdaJ6b1mth6qq65G5X1JJ+sBoUkR0rxM/sCvT2Bw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":117182},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"gitHead":"dbe80a180e0c09f29f50830ca6ba48b58e3d0bc9","scripts":{"test":"npm run build && vitest run","build":"tsc -p .","test:watch":"vitest"},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"repository":{"url":"git+https://github.com/CCDevelopForFun/agent-controller.git","type":"git","directory":"runtime-opencode"},"_npmVersion":"10.9.8","description":"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.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@opencode-ai/sdk":"^1.15.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/runtime-opencode_0.3.2_1780933808701_0.16677649647936366","host":"s3://npm-registry-packages-npm-production"}},"0.3.3":{"name":"@agent-controller/runtime-opencode","version":"0.3.3","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"author":{"name":"CCDevelopForFun"},"license":"MIT","_id":"@agent-controller/runtime-opencode@0.3.3","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"dist":{"shasum":"59149c50337ee9852036e2c43370da37219d7207","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.3.3.tgz","fileCount":17,"integrity":"sha512-oRlMOt7llFAEd7yyAmsaJKfseHZzVMqJzdjWTxreQVjyou+Z2FUvYDoN6Bir98ELmu6hKwJGT7oJixPDr8G2aw==","signatures":[{"sig":"MEYCIQDMgQk5uLiMq1Q+zUgEWxoyqKWs1WWDs7SpW944pR1GigIhAJeH3dRUFcYl1CIi3DnHbTaQk3xtYaIphC8rnz8rovxB","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":119893},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"gitHead":"18a06f9e32e628d6364f644211e84e34e465d036","scripts":{"test":"npm run build && vitest run","build":"tsc -p .","test:watch":"vitest"},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"repository":{"url":"git+https://github.com/CCDevelopForFun/agent-controller.git","type":"git","directory":"runtime-opencode"},"_npmVersion":"10.9.8","description":"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.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@opencode-ai/sdk":"^1.15.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/runtime-opencode_0.3.3_1781022527651_0.7535908192544516","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@agent-controller/runtime-opencode","version":"0.4.0","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"author":{"name":"CCDevelopForFun"},"license":"MIT","_id":"@agent-controller/runtime-opencode@0.4.0","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"dist":{"shasum":"8ce046f0f2ed9015131662550f0a2ee083b6064e","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.4.0.tgz","fileCount":17,"integrity":"sha512-zkH4SfBndxqMbo7Cwax9cEiaIuNH4LaPCDNtOOXWxzrGqOhkmSYHHZa03ge45EsN6fLTIt8mVCp4fwwvKhjc+Q==","signatures":[{"sig":"MEUCIHy/V6GRG96HPU8aa32KdPC726l1iMq7j+s8yWTzQfF+AiEAkBA4vB9dQM1W8znRYpSkQwKmwoasXB9wz9YjNvNNczI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":119893},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"gitHead":"50ef945bbc9b46e7ee854710ab07a78ff38fbfa1","scripts":{"test":"npm run build && vitest run","build":"tsc -p .","test:watch":"vitest"},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"repository":{"url":"git+https://github.com/CCDevelopForFun/agent-controller.git","type":"git","directory":"runtime-opencode"},"_npmVersion":"10.9.8","description":"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.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@opencode-ai/sdk":"^1.15.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/runtime-opencode_0.4.0_1781034727537_0.19698384846568984","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@agent-controller/runtime-opencode","version":"0.5.0","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"author":{"name":"CCDevelopForFun"},"license":"MIT","_id":"@agent-controller/runtime-opencode@0.5.0","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"dist":{"shasum":"a120e2239f44ef96ea6df6c6a0d8275fd6821992","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.5.0.tgz","fileCount":17,"integrity":"sha512-0KwxQqJYeqQ+LpLHJpCnEBGb/Q8Q9+1BizZvQvrpwiKLQrRhlCqGvZLKch/FbyPsKAzPmXyV23Tc+HeA37UKtQ==","signatures":[{"sig":"MEQCIGlj4Fc8ZYEadHcveBE3GFQWAyHMiTNzwBg88/MMIx+xAiBAU41a42FmOVnpyOa9OVf2bbgI5NR6k9OQmY8m8GD1aQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":120408},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=22"},"gitHead":"1269a33a5f11a6039b552eb63d4495cc4dc9e7c0","scripts":{"test":"npm run build && vitest run","build":"tsc -p .","test:watch":"vitest"},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"repository":{"url":"git+https://github.com/CCDevelopForFun/agent-controller.git","type":"git","directory":"runtime-opencode"},"_npmVersion":"10.9.8","description":"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.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@opencode-ai/sdk":"^1.15.12"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"latest","typescript":"latest","@types/node":"latest"},"_npmOperationalInternal":{"tmp":"tmp/runtime-opencode_0.5.0_1781126260545_0.6712601271012124","host":"s3://npm-registry-packages-npm-production"}},"0.7.0":{"name":"@agent-controller/runtime-opencode","version":"0.7.0","description":"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.","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"repository":{"type":"git","url":"git+https://github.com/CCDevelopForFun/agent-controller.git","directory":"runtime-opencode"},"license":"MIT","author":{"name":"CCDevelopForFun"},"type":"module","main":"dist/index.js","publishConfig":{"access":"public"},"engines":{"node":">=22"},"scripts":{"build":"tsc -p .","test":"npm run build && vitest run","test:watch":"vitest"},"dependencies":{"@opencode-ai/sdk":"^1.15.12","@opentelemetry/api":"^1.9.1","@opentelemetry/core":"^2.8.0","@opentelemetry/exporter-trace-otlp-http":"^0.219.0","@opentelemetry/resources":"^2.8.0","@opentelemetry/sdk-trace-base":"^2.8.0","@opentelemetry/sdk-trace-node":"^2.8.0","@opentelemetry/semantic-conventions":"^1.41.1"},"devDependencies":{"@types/node":"latest","typescript":"latest","vitest":"latest"},"_id":"@agent-controller/runtime-opencode@0.7.0","gitHead":"d52d44af91e84a6fd78b195b1cfe30c7b0354bff","types":"./dist/index.d.ts","_nodeVersion":"22.23.0","_npmVersion":"10.9.8","dist":{"integrity":"sha512-90wXOkzmb3rfbb+s+n4rwFfbwDpOxIEZpg1l3LJxA5Ske7lZSzQJ2kuOG8L7xryMkaeh8gALhGas5SlSQ7rQ7w==","shasum":"a3a97ce5846364877c17c085faa85741add82ca2","tarball":"https://registry.npmjs.org/@agent-controller/runtime-opencode/-/runtime-opencode-0.7.0.tgz","fileCount":19,"unpackedSize":144874,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCID+nLW5U+SkKnfk+J/LxmQOuO+YU/8S7usA2RnuiinY2AiBvujkGPbM2YSk97CDf0De0xG4OgTiEClsipsvgafs7Jg=="}]},"_npmUser":{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"},"directories":{},"maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/runtime-opencode_0.7.0_1782491214978_0.8581534180586352"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-05T17:23:20.250Z","modified":"2026-06-26T16:26:55.276Z","0.3.1":"2026-06-05T17:23:20.586Z","0.3.2":"2026-06-08T15:50:08.866Z","0.3.3":"2026-06-09T16:28:47.807Z","0.4.0":"2026-06-09T19:52:07.689Z","0.5.0":"2026-06-10T21:17:40.700Z","0.7.0":"2026-06-26T16:26:55.140Z"},"bugs":{"url":"https://github.com/CCDevelopForFun/agent-controller/issues"},"author":{"name":"CCDevelopForFun"},"license":"MIT","homepage":"https://github.com/CCDevelopForFun/agent-controller#readme","keywords":["agent-controller","adl","opencode","agent","ai-agents","llm","anthropic","runtime-adapter"],"repository":{"type":"git","url":"git+https://github.com/CCDevelopForFun/agent-controller.git","directory":"runtime-opencode"},"description":"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.","maintainers":[{"name":"ccdevelopforfun","email":"zhenglinchen123@gmail.com"}],"readme":"# `@agent-controller/runtime-opencode` — opencode runtime adapter\n\nNode/TypeScript adapter that runs an [agent-controller](https://github.com/CCDevelopForFun/agent-controller) `CompiledSpec` against the [sst/opencode](https://opencode.ai) 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`](https://www.npmjs.com/package/@agent-controller/runtime)); both consume the same `CompiledSpec` and emit the same wire-event format.\n\nRequires **Node 22+**.\n\n## Install\n\n```bash\nnpm install -g @agent-controller/runtime-opencode\n# or per-project\nnpm install --save-dev @agent-controller/runtime-opencode\n```\n\nThe `opencode` CLI must also be on `PATH`. Install with `npm install -g opencode-ai` or follow https://opencode.ai/docs/.\n\n## Use with `agentctl`\n\n`agentctl` (the Go CLI) spawns this package as a subprocess when `spec.runtime.type` is `local-opencode`. The example specs under [`examples/`](https://github.com/CCDevelopForFun/agent-controller/tree/main/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:\n\n```bash\n# 1) Write a self-contained spec (no tools[]/extensions[]/skills[]/subagents[])\ncat > /tmp/hello-opencode.yaml <<'EOF'\napiVersion: agent-controller.dev/v1alpha1\nkind: Agent\nmetadata: { name: hello-opencode }\nspec:\n  model: { provider: anthropic, name: claude-sonnet-4-20250514 }\n  persona: { role: Helpful demo, instructions: Answer concisely. }\n  task: Say hello.\n  tools: []\n  runtime: { type: local-opencode }\nEOF\n\n# 2) Point agentctl at the adapter and run\nexport ANTHROPIC_API_KEY=sk-ant-...\n\n# global install\nAGENT_CONTROLLER_RUNTIME=\"$(npm root -g)/@agent-controller/runtime-opencode/dist/index.js\" \\\n  agentctl run /tmp/hello-opencode.yaml\n\n# or per-project\nAGENT_CONTROLLER_RUNTIME=\"./node_modules/@agent-controller/runtime-opencode/dist/index.js\" \\\n  agentctl run /tmp/hello-opencode.yaml\n```\n\nCredentials 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.\n\n`agentctl` (matching version) is available from the [GitHub Releases page](https://github.com/CCDevelopForFun/agent-controller/releases) as cross-platform binaries.\n\n## Architecture role\n\nThis package is the **subprocess** spawned by `agentctl run` when `spec.runtime.type` is `local-opencode`. It:\n\n1. Reads a `CompiledSpec` JSON document from stdin\n2. 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)\n3. Builds an opencode-native config (`cfg.agent[primary]`, `cfg.agent[subagent_N]`, `cfg.mcp[server_N]`) from the spec via `buildOpencodeConfig`\n4. Spawns opencode via `@opencode-ai/sdk`'s `createOpencode()` with an isolated `HOME` / `XDG_*` / cwd so ambient user config can't leak undeclared capabilities\n5. Submits the task via `session.promptAsync()` (non-blocking)\n6. Consumes the SSE event stream via a producer-consumer queue\n7. Translates opencode events into wire-protocol events (tool.call/result, message, session.ended/error/warning, hallucination warnings)\n8. Disables opencode's native agents (`plan`, `build`, `general`, `explore`, `scout`) so the `task` tool can't bypass the ADL allowlist\n\n## ADL allowlist preservation\n\nSeveral layers of defense keep ADL's \"only declared capabilities are reachable\" contract intact:\n\n1. Opencode permissions start from a deny baseline (`\"*\": \"deny\"` + every known opencode tool explicitly denied), then declared tools become `allow`\n2. Native opencode agents are disabled so the `task` tool can't delegate to undeclared agents\n3. 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\n4. Opencode-incompatible spec shapes are rejected at `agentctl compile` (v0.3.0)\n\n## Capability differences vs the Pi adapter\n\nSee [`docs/architecture/harness-matrix.md`](https://github.com/CCDevelopForFun/agent-controller/blob/main/docs/architecture/harness-matrix.md) for the per-feature table. Highlights:\n\n| Feature | Pi adapter | opencode adapter |\n|---|---|---|\n| Custom Pi-format tools / extensions | ✅ | ❌ rejected at `agentctl compile` |\n| Session resume (`--resume`) | ✅ | ❌ rejected by `agentctl run` |\n| `task` tool / native subagent delegation | via vendored ext | ✅ native |\n| `cancelled` reason on SIGINT | ❌ (surfaces as `error`) | ✅ |\n| `bash` allowlist via tool `config` | ❌ rejected at `agentctl compile` (use [`@gotgenes/pi-permission-system`](https://www.npmjs.com/package/@gotgenes/pi-permission-system)) | ❌ rejected at `agentctl compile` |\n\n## Building from source\n\n```bash\ngit clone https://github.com/CCDevelopForFun/agent-controller.git\ncd agent-controller/runtime-opencode\nnpm install --ignore-scripts\nnpm run build           # tsc → dist/\nnpm test                # vitest\n```\n\n## Cross-references\n\n- [agent-controller README](https://github.com/CCDevelopForFun/agent-controller#readme) — project overview + quickstart\n- [Dual-adapter architecture overview](https://github.com/CCDevelopForFun/agent-controller/blob/main/docs/architecture/overview.md)\n- [Harness capability matrix](https://github.com/CCDevelopForFun/agent-controller/blob/main/docs/architecture/harness-matrix.md)\n\n## License\n\nMIT — see [LICENSE](https://github.com/CCDevelopForFun/agent-controller/blob/main/LICENSE).\n","readmeFilename":"README.md"}