[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69A44T8CV3NG03TADY2XJ70":3,"skill-same:01M69A44T8CV3NG03TADY2XJ70":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":24,"linkOnly":25,"markdownContent":26,"markdownBody":27,"frontMatter":28,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M69A44T8CV3NG03TADY2XJ70","add-opencode",null,"Use OpenCode as an agent provider (AGENT_PROVIDER=opencode). OpenRouter, OpenAI, Google, DeepSeek, etc. via OpenCode config — not the Anthropic Agent SDK. Per-session and per-group via agent_provider; host passes OPENCODE_* and XDG mount when spawning containers.","microsoft\u002Famplifier-app-nanoclaw","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M69A31J3GTKVZDZZVPRQWWR5",5,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fadd-opencode\u002FSKILL.md",[],[19,20,21,22,23],"add opencode","google","containers","sdk","config","2026-11-10 10:12:30",false,"---\nname: add-opencode\ndescription: Use OpenCode as an agent provider (AGENT_PROVIDER=opencode). OpenRouter, OpenAI, Google, DeepSeek, etc. via OpenCode config — not the Anthropic Agent SDK. Per-session and per-group via agent_provider; host passes OPENCODE_* and XDG mount when spawning containers.\n---\n\n# OpenCode agent provider\n\nNanoClaw runs agents in a long-lived **poll loop** inside the container. The backend is selected with **`AGENT_PROVIDER`** (`claude` | `opencode` | `mock`).\n\nTrunk ships with only the `claude` provider baked in. This skill copies the OpenCode provider files in from the `providers` branch, wires them into the host and container barrels, installs dependencies, and rebuilds the image.\n\n## Install\n\n### Pre-flight\n\nIf all of the following are already present, skip to **Configuration**:\n\n- `src\u002Fproviders\u002Fopencode.ts`\n- `container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts`\n- `import '.\u002Fopencode.js';` line in `src\u002Fproviders\u002Findex.ts`\n- `import '.\u002Fopencode.js';` line in `container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts`\n- `@opencode-ai\u002Fsdk` in `container\u002Fagent-runner\u002Fpackage.json`\n- `opencode-ai@${OPENCODE_VERSION}` in the pnpm global-install block in `container\u002FDockerfile`\n\nMissing pieces — continue below. All steps are idempotent; re-running is safe.\n\n### 1. Fetch the providers branch\n\n```bash\ngit fetch origin providers\n```\n\n### 2. Copy the OpenCode source files\n\nWholesale copies (owned entirely by this skill — user edits to these files won't survive a re-run, as designed):\n\n```bash\ngit show origin\u002Fproviders:src\u002Fproviders\u002Fopencode.ts                                    > src\u002Fproviders\u002Fopencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts             > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts      > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.test.ts > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.test.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.factory.test.ts > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.factory.test.ts\n```\n\n### 3. Append the self-registration imports\n\nEach barrel gets one line appended at the end — skip if the line is already present.\n\n`src\u002Fproviders\u002Findex.ts`:\n\n```typescript\nimport '.\u002Fopencode.js';\n```\n\n`container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts`:\n\n```typescript\nimport '.\u002Fopencode.js';\n```\n\n### 4. Add the agent-runner dependency\n\nPinned. Bump deliberately, not with `bun update`. Use `1.4.17` — must match the `opencode-ai` CLI version pinned in step 5. The 1.14.x SDK has a completely different API and is **incompatible** with the current provider code.\n\n```bash\ncd container\u002Fagent-runner && bun add @opencode-ai\u002Fsdk@1.4.17 && cd -\n```\n\n### 5. Add `opencode-ai` to the container Dockerfile\n\nTwo edits to `container\u002FDockerfile`, both idempotent (skip if already present):\n\n**(a)** In the \"Pin CLI versions\" ARG block (around line 18), add after `ARG VERCEL_VERSION=latest`:\n\n```dockerfile\nARG OPENCODE_VERSION=1.4.17\n```\n\n> **Do not use `latest`** — the CLI and SDK must be the same version. `latest` silently upgrades the CLI to 1.14.x which has a breaking session API change (UUID session IDs → `ses_` prefix) incompatible with SDK 1.4.x.\n\n**(b)** In the `pnpm install -g` block (around line 80), append `\"opencode-ai@${OPENCODE_VERSION}\"` to the list:\n\n```dockerfile\n    pnpm install -g \\\n        \"@anthropic-ai\u002Fclaude-code@${CLAUDE_CODE_VERSION}\" \\\n        \"agent-browser@${AGENT_BROWSER_VERSION}\" \\\n        \"vercel@${VERCEL_VERSION}\" \\\n        \"opencode-ai@${OPENCODE_VERSION}\"\n```\n\n### 6. Build\n\n```bash\npnpm run build                                         # host\npnpm exec tsc -p container\u002Fagent-runner\u002Ftsconfig.json --noEmit   # container typecheck\n.\u002Fcontainer\u002Fbuild.sh                                   # agent image\n```\n\n> **Build cache gotcha:** The container buildkit caches COPY steps aggressively. If provider files were already present in the build context before, the new files may not be picked up. If you see \"Unknown provider: opencode\" after the build, prune the builder and rebuild:\n> ```bash\n> docker builder prune -f && .\u002Fcontainer\u002Fbuild.sh\n> ```\n\n### 7. Propagate to existing per-group overlays\n\nEach agent group has a live source overlay at `data\u002Fv2-sessions\u002F\u003Cgroup-id>\u002Fagent-runner-src\u002Fproviders\u002F` that **overrides the image at runtime**. This overlay is created when the group is first wired and never auto-updated by image rebuilds. Any group that already existed before this skill ran needs the new files copied in manually.\n\n```bash\nfor overlay in data\u002Fv2-sessions\u002F*\u002Fagent-runner-src\u002Fproviders\u002F; do\n  [ -d \"$overlay\" ] || continue\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts \"$overlay\"\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts \"$overlay\"\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts \"$overlay\"\n  echo \"Updated: $overlay\"\ndone\n```\n\n## Configuration\n\n### Host `.env` (typical)\n\nSet model\u002Fprovider strings in the form OpenCode expects (often `provider\u002Fmodel-id`). **Put comments on their own lines** — a `#` inside a value is kept verbatim and breaks model IDs.\n\nThese variables are read **on the host** and passed into the container only when the effective provider is `opencode`. They do not switch the provider by themselves; the DB still needs `agent_provider` set (below).\n\n- `OPENCODE_PROVIDER` — OpenCode provider id, e.g. `openrouter`, `anthropic`, `deepseek`.\n- `OPENCODE_MODEL` — full model id in `provider\u002Fmodel` form, e.g. `deepseek\u002Fdeepseek-chat`.\n- `OPENCODE_SMALL_MODEL` — optional second model for lighter tasks; defaults to `OPENCODE_MODEL` if unset.\n- `ANTHROPIC_BASE_URL` — **required for non-`anthropic` providers.** The opencode container provider passes this as the `baseURL` for the upstream provider config so requests route through OneCLI's credential proxy or directly to the provider's API. Set it to the provider's API base URL (e.g. `https:\u002F\u002Fapi.deepseek.com\u002Fv1`, `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1`).\n\nCredentials: register provider API keys in OneCLI with the matching `--host-pattern` (e.g. `api.deepseek.com`, `openrouter.ai`). OneCLI injects them via `HTTPS_PROXY` in the container — the key never lives in `.env` or the container environment.\n\nAfter adding a secret, **grant the agent access** — agents in `selective` mode only receive secrets they've been explicitly assigned:\n\nUse the safe merge pattern — `set-secrets` replaces the entire list, so always read first:\n\n```bash\nAGENT_ID=$(onecli agents list | jq -r '.data[] | select(.identifier==\"\u003CagentGroupId>\") | .id')\nCURRENT=$(onecli agents secrets --id \"$AGENT_ID\" | jq -r '[.data[]] | join(\",\")')\nMERGED=$(printf '%s' \"$CURRENT,\u003Cnew-secret-id>\" | tr ',' '\\n' | sort -u | paste -sd ',' -)\nonecli agents set-secrets --id \"$AGENT_ID\" --secret-ids \"$MERGED\"\nonecli agents secrets --id \"$AGENT_ID\"\n```\n\n#### Example: DeepSeek\n\n```env\nOPENCODE_PROVIDER=deepseek\nOPENCODE_MODEL=deepseek\u002Fdeepseek-chat\nOPENCODE_SMALL_MODEL=deepseek\u002Fdeepseek-chat\nANTHROPIC_BASE_URL=https:\u002F\u002Fapi.deepseek.com\u002Fv1\n```\n\nRegister the key:\n```bash\nonecli secrets create --name \"DeepSeek\" --type generic \\\n  --value YOUR_KEY --host-pattern \"api.deepseek.com\" \\\n  --header-name \"Authorization\" --value-format \"Bearer {value}\"\n```\n\n#### Example: OpenRouter\n\n```env\nOPENCODE_PROVIDER=openrouter\nOPENCODE_MODEL=openrouter\u002Fanthropic\u002Fclaude-sonnet-4\nOPENCODE_SMALL_MODEL=openrouter\u002Fanthropic\u002Fclaude-haiku-4.5\nANTHROPIC_BASE_URL=https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\n```\n\nRegister the key:\n```bash\nonecli secrets create --name \"OpenRouter\" --type generic \\\n  --value YOUR_KEY --host-pattern \"openrouter.ai\" \\\n  --header-name \"Authorization\" --value-format \"Bearer {value}\"\n```\n\n#### Example: Anthropic (no ANTHROPIC_BASE_URL needed)\n\nWhen `OPENCODE_PROVIDER` is `anthropic`, OpenCode uses normal Anthropic env inside the container — the proxy + placeholder key pattern is unchanged and `ANTHROPIC_BASE_URL` is not required.\n\n```env\nOPENCODE_PROVIDER=anthropic\nOPENCODE_MODEL=anthropic\u002Fclaude-sonnet-4-20250514\nOPENCODE_SMALL_MODEL=anthropic\u002Fclaude-haiku-4-5-20251001\n```\n\n#### OpenCode Zen (`x-api-key`, not Bearer)\n\nZen's HTTP API (e.g. `POST …\u002Fzen\u002Fv1\u002Fmessages`) expects the key in the **`x-api-key`** header. If OneCLI injects **`Authorization: Bearer …`** only, Zen often returns **401 \u002F \"Missing API key\"** even though the gateway is working.\n\n**Naming:** NanoClaw **`AGENT_PROVIDER=opencode`** (DB `agent_provider`) means \"run the **OpenCode agent provider**.\" Separately, **`OPENCODE_PROVIDER=opencode`** in `.env` is OpenCode's **Zen provider id** inside the OpenCode config (see [Zen docs](https:\u002F\u002Fopencode.ai\u002Fdocs\u002Fzen\u002F)).\n\n**Host `.env` (typical Zen shape):**\n\n```env\nOPENCODE_PROVIDER=opencode\nOPENCODE_MODEL=opencode\u002Fbig-pickle\nOPENCODE_SMALL_MODEL=opencode\u002Fbig-pickle\nANTHROPIC_BASE_URL=https:\u002F\u002Fopencode.ai\u002Fzen\u002Fv1\n```\n\nUse a real Zen model id from the docs; `big-pickle` is one example.\n\n**OneCLI:** register the Zen key with **`x-api-key`**, not Bearer:\n\n```bash\nonecli secrets create --name \"OpenCode Zen\" --type generic \\\n  --value YOUR_ZEN_KEY --host-pattern opencode.ai \\\n  --header-name \"x-api-key\" --value-format \"{value}\"\n```\n\n### Per group \u002F per session\n\nSet `\"provider\": \"opencode\"` in the group's **`container.json`** (`groups\u002F\u003Cfolder>\u002Fcontainer.json`) — the in-container runner reads `provider` from there, not from the DB. The DB columns **`agent_groups.agent_provider`** and **`sessions.agent_provider`** (session overrides group) only drive host-side provider contribution — per-session XDG mount, `OPENCODE_*` env passthrough — and do not propagate into `container.json` at spawn time. Set both, or just edit `container.json`; if they disagree, the runner uses `container.json` and the host-side resolver falls back through session → group → `container.json` → `'claude'`.\n\nExtra MCP servers still come from **`NANOCLAW_MCP_SERVERS`** \u002F `container_config.mcpServers` on the host; the runner merges them into the same `mcpServers` object passed to **both** Claude and OpenCode providers.\n\n## Operational notes\n\n- OpenCode keeps a local **`opencode serve`** process and SSE subscription; the provider tears down with **`stream.return`** and **SIGKILL** on the server process on **`abort()`** \u002F shared runtime reset to avoid MCP\u002Fzombie hangs.\n- Session continuation uses UUID format (SDK 1.4.x \u002F CLI 1.4.x). Stale sessions are cleared by `isSessionInvalid` on OpenCode-specific error patterns. If you see UUID-related errors after an accidental CLI upgrade, clear `session_state` in `outbound.db` and wipe the `opencode-xdg` directory under the session folder.\n- **`NO_PROXY`** for localhost matters when the OpenCode client talks to `127.0.0.1` inside the container while HTTP(S)_PROXY is set (e.g. OneCLI).\n\n## Verify\n\n```bash\ngrep -q \".\u002Fopencode.js\" container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts && echo \"container barrel: OK\"\ngrep -q \".\u002Fopencode.js\" src\u002Fproviders\u002Findex.ts && echo \"host barrel: OK\"\ngrep -q \"@opencode-ai\u002Fsdk\" container\u002Fagent-runner\u002Fpackage.json && echo \"agent-runner dep: OK\"\ngrep -q \"opencode-ai@\" container\u002FDockerfile && echo \"Dockerfile install: OK\"\ncd container\u002Fagent-runner && bun test src\u002Fproviders\u002F && cd -\n```\n","# OpenCode agent provider\n\nNanoClaw runs agents in a long-lived **poll loop** inside the container. The backend is selected with **`AGENT_PROVIDER`** (`claude` | `opencode` | `mock`).\n\nTrunk ships with only the `claude` provider baked in. This skill copies the OpenCode provider files in from the `providers` branch, wires them into the host and container barrels, installs dependencies, and rebuilds the image.\n\n## Install\n\n### Pre-flight\n\nIf all of the following are already present, skip to **Configuration**:\n\n- `src\u002Fproviders\u002Fopencode.ts`\n- `container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts`\n- `import '.\u002Fopencode.js';` line in `src\u002Fproviders\u002Findex.ts`\n- `import '.\u002Fopencode.js';` line in `container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts`\n- `@opencode-ai\u002Fsdk` in `container\u002Fagent-runner\u002Fpackage.json`\n- `opencode-ai@${OPENCODE_VERSION}` in the pnpm global-install block in `container\u002FDockerfile`\n\nMissing pieces — continue below. All steps are idempotent; re-running is safe.\n\n### 1. Fetch the providers branch\n\n```bash\ngit fetch origin providers\n```\n\n### 2. Copy the OpenCode source files\n\nWholesale copies (owned entirely by this skill — user edits to these files won't survive a re-run, as designed):\n\n```bash\ngit show origin\u002Fproviders:src\u002Fproviders\u002Fopencode.ts                                    > src\u002Fproviders\u002Fopencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts             > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts      > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.test.ts > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.test.ts\ngit show origin\u002Fproviders:container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.factory.test.ts > container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.factory.test.ts\n```\n\n### 3. Append the self-registration imports\n\nEach barrel gets one line appended at the end — skip if the line is already present.\n\n`src\u002Fproviders\u002Findex.ts`:\n\n```typescript\nimport '.\u002Fopencode.js';\n```\n\n`container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts`:\n\n```typescript\nimport '.\u002Fopencode.js';\n```\n\n### 4. Add the agent-runner dependency\n\nPinned. Bump deliberately, not with `bun update`. Use `1.4.17` — must match the `opencode-ai` CLI version pinned in step 5. The 1.14.x SDK has a completely different API and is **incompatible** with the current provider code.\n\n```bash\ncd container\u002Fagent-runner && bun add @opencode-ai\u002Fsdk@1.4.17 && cd -\n```\n\n### 5. Add `opencode-ai` to the container Dockerfile\n\nTwo edits to `container\u002FDockerfile`, both idempotent (skip if already present):\n\n**(a)** In the \"Pin CLI versions\" ARG block (around line 18), add after `ARG VERCEL_VERSION=latest`:\n\n```dockerfile\nARG OPENCODE_VERSION=1.4.17\n```\n\n> **Do not use `latest`** — the CLI and SDK must be the same version. `latest` silently upgrades the CLI to 1.14.x which has a breaking session API change (UUID session IDs → `ses_` prefix) incompatible with SDK 1.4.x.\n\n**(b)** In the `pnpm install -g` block (around line 80), append `\"opencode-ai@${OPENCODE_VERSION}\"` to the list:\n\n```dockerfile\n    pnpm install -g \\\n        \"@anthropic-ai\u002Fclaude-code@${CLAUDE_CODE_VERSION}\" \\\n        \"agent-browser@${AGENT_BROWSER_VERSION}\" \\\n        \"vercel@${VERCEL_VERSION}\" \\\n        \"opencode-ai@${OPENCODE_VERSION}\"\n```\n\n### 6. Build\n\n```bash\npnpm run build                                         # host\npnpm exec tsc -p container\u002Fagent-runner\u002Ftsconfig.json --noEmit   # container typecheck\n.\u002Fcontainer\u002Fbuild.sh                                   # agent image\n```\n\n> **Build cache gotcha:** The container buildkit caches COPY steps aggressively. If provider files were already present in the build context before, the new files may not be picked up. If you see \"Unknown provider: opencode\" after the build, prune the builder and rebuild:\n> ```bash\n> docker builder prune -f && .\u002Fcontainer\u002Fbuild.sh\n> ```\n\n### 7. Propagate to existing per-group overlays\n\nEach agent group has a live source overlay at `data\u002Fv2-sessions\u002F\u003Cgroup-id>\u002Fagent-runner-src\u002Fproviders\u002F` that **overrides the image at runtime**. This overlay is created when the group is first wired and never auto-updated by image rebuilds. Any group that already existed before this skill ran needs the new files copied in manually.\n\n```bash\nfor overlay in data\u002Fv2-sessions\u002F*\u002Fagent-runner-src\u002Fproviders\u002F; do\n  [ -d \"$overlay\" ] || continue\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fopencode.ts \"$overlay\"\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Fmcp-to-opencode.ts \"$overlay\"\n  cp container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts \"$overlay\"\n  echo \"Updated: $overlay\"\ndone\n```\n\n## Configuration\n\n### Host `.env` (typical)\n\nSet model\u002Fprovider strings in the form OpenCode expects (often `provider\u002Fmodel-id`). **Put comments on their own lines** — a `#` inside a value is kept verbatim and breaks model IDs.\n\nThese variables are read **on the host** and passed into the container only when the effective provider is `opencode`. They do not switch the provider by themselves; the DB still needs `agent_provider` set (below).\n\n- `OPENCODE_PROVIDER` — OpenCode provider id, e.g. `openrouter`, `anthropic`, `deepseek`.\n- `OPENCODE_MODEL` — full model id in `provider\u002Fmodel` form, e.g. `deepseek\u002Fdeepseek-chat`.\n- `OPENCODE_SMALL_MODEL` — optional second model for lighter tasks; defaults to `OPENCODE_MODEL` if unset.\n- `ANTHROPIC_BASE_URL` — **required for non-`anthropic` providers.** The opencode container provider passes this as the `baseURL` for the upstream provider config so requests route through OneCLI's credential proxy or directly to the provider's API. Set it to the provider's API base URL (e.g. `https:\u002F\u002Fapi.deepseek.com\u002Fv1`, `https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1`).\n\nCredentials: register provider API keys in OneCLI with the matching `--host-pattern` (e.g. `api.deepseek.com`, `openrouter.ai`). OneCLI injects them via `HTTPS_PROXY` in the container — the key never lives in `.env` or the container environment.\n\nAfter adding a secret, **grant the agent access** — agents in `selective` mode only receive secrets they've been explicitly assigned:\n\nUse the safe merge pattern — `set-secrets` replaces the entire list, so always read first:\n\n```bash\nAGENT_ID=$(onecli agents list | jq -r '.data[] | select(.identifier==\"\u003CagentGroupId>\") | .id')\nCURRENT=$(onecli agents secrets --id \"$AGENT_ID\" | jq -r '[.data[]] | join(\",\")')\nMERGED=$(printf '%s' \"$CURRENT,\u003Cnew-secret-id>\" | tr ',' '\\n' | sort -u | paste -sd ',' -)\nonecli agents set-secrets --id \"$AGENT_ID\" --secret-ids \"$MERGED\"\nonecli agents secrets --id \"$AGENT_ID\"\n```\n\n#### Example: DeepSeek\n\n```env\nOPENCODE_PROVIDER=deepseek\nOPENCODE_MODEL=deepseek\u002Fdeepseek-chat\nOPENCODE_SMALL_MODEL=deepseek\u002Fdeepseek-chat\nANTHROPIC_BASE_URL=https:\u002F\u002Fapi.deepseek.com\u002Fv1\n```\n\nRegister the key:\n```bash\nonecli secrets create --name \"DeepSeek\" --type generic \\\n  --value YOUR_KEY --host-pattern \"api.deepseek.com\" \\\n  --header-name \"Authorization\" --value-format \"Bearer {value}\"\n```\n\n#### Example: OpenRouter\n\n```env\nOPENCODE_PROVIDER=openrouter\nOPENCODE_MODEL=openrouter\u002Fanthropic\u002Fclaude-sonnet-4\nOPENCODE_SMALL_MODEL=openrouter\u002Fanthropic\u002Fclaude-haiku-4.5\nANTHROPIC_BASE_URL=https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\n```\n\nRegister the key:\n```bash\nonecli secrets create --name \"OpenRouter\" --type generic \\\n  --value YOUR_KEY --host-pattern \"openrouter.ai\" \\\n  --header-name \"Authorization\" --value-format \"Bearer {value}\"\n```\n\n#### Example: Anthropic (no ANTHROPIC_BASE_URL needed)\n\nWhen `OPENCODE_PROVIDER` is `anthropic`, OpenCode uses normal Anthropic env inside the container — the proxy + placeholder key pattern is unchanged and `ANTHROPIC_BASE_URL` is not required.\n\n```env\nOPENCODE_PROVIDER=anthropic\nOPENCODE_MODEL=anthropic\u002Fclaude-sonnet-4-20250514\nOPENCODE_SMALL_MODEL=anthropic\u002Fclaude-haiku-4-5-20251001\n```\n\n#### OpenCode Zen (`x-api-key`, not Bearer)\n\nZen's HTTP API (e.g. `POST …\u002Fzen\u002Fv1\u002Fmessages`) expects the key in the **`x-api-key`** header. If OneCLI injects **`Authorization: Bearer …`** only, Zen often returns **401 \u002F \"Missing API key\"** even though the gateway is working.\n\n**Naming:** NanoClaw **`AGENT_PROVIDER=opencode`** (DB `agent_provider`) means \"run the **OpenCode agent provider**.\" Separately, **`OPENCODE_PROVIDER=opencode`** in `.env` is OpenCode's **Zen provider id** inside the OpenCode config (see [Zen docs](https:\u002F\u002Fopencode.ai\u002Fdocs\u002Fzen\u002F)).\n\n**Host `.env` (typical Zen shape):**\n\n```env\nOPENCODE_PROVIDER=opencode\nOPENCODE_MODEL=opencode\u002Fbig-pickle\nOPENCODE_SMALL_MODEL=opencode\u002Fbig-pickle\nANTHROPIC_BASE_URL=https:\u002F\u002Fopencode.ai\u002Fzen\u002Fv1\n```\n\nUse a real Zen model id from the docs; `big-pickle` is one example.\n\n**OneCLI:** register the Zen key with **`x-api-key`**, not Bearer:\n\n```bash\nonecli secrets create --name \"OpenCode Zen\" --type generic \\\n  --value YOUR_ZEN_KEY --host-pattern opencode.ai \\\n  --header-name \"x-api-key\" --value-format \"{value}\"\n```\n\n### Per group \u002F per session\n\nSet `\"provider\": \"opencode\"` in the group's **`container.json`** (`groups\u002F\u003Cfolder>\u002Fcontainer.json`) — the in-container runner reads `provider` from there, not from the DB. The DB columns **`agent_groups.agent_provider`** and **`sessions.agent_provider`** (session overrides group) only drive host-side provider contribution — per-session XDG mount, `OPENCODE_*` env passthrough — and do not propagate into `container.json` at spawn time. Set both, or just edit `container.json`; if they disagree, the runner uses `container.json` and the host-side resolver falls back through session → group → `container.json` → `'claude'`.\n\nExtra MCP servers still come from **`NANOCLAW_MCP_SERVERS`** \u002F `container_config.mcpServers` on the host; the runner merges them into the same `mcpServers` object passed to **both** Claude and OpenCode providers.\n\n## Operational notes\n\n- OpenCode keeps a local **`opencode serve`** process and SSE subscription; the provider tears down with **`stream.return`** and **SIGKILL** on the server process on **`abort()`** \u002F shared runtime reset to avoid MCP\u002Fzombie hangs.\n- Session continuation uses UUID format (SDK 1.4.x \u002F CLI 1.4.x). Stale sessions are cleared by `isSessionInvalid` on OpenCode-specific error patterns. If you see UUID-related errors after an accidental CLI upgrade, clear `session_state` in `outbound.db` and wipe the `opencode-xdg` directory under the session folder.\n- **`NO_PROXY`** for localhost matters when the OpenCode client talks to `127.0.0.1` inside the container while HTTP(S)_PROXY is set (e.g. OneCLI).\n\n## Verify\n\n```bash\ngrep -q \".\u002Fopencode.js\" container\u002Fagent-runner\u002Fsrc\u002Fproviders\u002Findex.ts && echo \"container barrel: OK\"\ngrep -q \".\u002Fopencode.js\" src\u002Fproviders\u002Findex.ts && echo \"host barrel: OK\"\ngrep -q \"@opencode-ai\u002Fsdk\" container\u002Fagent-runner\u002Fpackage.json && echo \"agent-runner dep: OK\"\ngrep -q \"opencode-ai@\" container\u002FDockerfile && echo \"Dockerfile install: OK\"\ncd container\u002Fagent-runner && bun test src\u002Fproviders\u002F && cd -\n```\n",{"name":5,"description":7},"main","85a2d934766d21e4696ac1b00157179f28bca9e3",".claude\u002Fskills\u002Fadd-opencode",2,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-10-30 04:24:16",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add microsoft\u002Famplifier-app-nanoclaw --skill add-opencode",{"tool":44,"command":45},"bunx","bunx skills add microsoft\u002Famplifier-app-nanoclaw --skill add-opencode",{"tool":47,"command":48},"pnpm","pnpm dlx skills add microsoft\u002Famplifier-app-nanoclaw --skill add-opencode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fadd-opencode\u002FSKILL.md",true,[],[53,62,69,80,94,107],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":24},"01M69A6E27JZN10H82TZ2GMC3A","whatsapp-formatting","Format messages for WhatsApp, including mentions that render as real WhatsApp tags. Use when responding in a WhatsApp conversation (platform_id \u002F chatJid ends with @s.whatsapp.net or @g.us).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fwhatsapp-formatting\u002FSKILL.md",[],[60,61],"whatsapp","whatsapp formatting",{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":24},"01M69A6CGJ968RNVGYTRSWZKWB","welcome","Introduce yourself to a newly connected channel. Triggered automatically when a channel is first wired. Send a friendly greeting and brief overview of what you can do.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fwelcome\u002FSKILL.md",[],[64],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":24},"01M69A6ADX690STSN63WKRD37K","vercel-cli","Deploy apps to Vercel. Use when asked to deploy, ship, or publish a web application, or manage Vercel projects, domains, and environment variables.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fvercel-cli\u002FSKILL.md",[],[76,77,78,79],"cli","vercel cli","web","deploy",{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":91,"publishedAt":24},"01M69A68WJ94V4MXGXGK9T0QG7","slack-formatting","Format messages for Slack using mrkdwn syntax. Use when responding to Slack channels (folder starts with \"slack_\" or JID contains slack identifiers).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fslack-formatting\u002FSKILL.md",[86],{"categoryNo":87,"categoryName":88,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000005","邮件与沟通","SCENARIO","使用场景",[92,93],"slack","slack formatting",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":103,"publishedAt":24},"01M69A673Z17TDXK3DBC5YJFM7","self-customize","Customize your own agent — add capabilities, install packages, add MCP servers, edit code or CLAUDE.md. Use when the user asks you to add a feature, install a tool, or modify how you work. For non-trivial code changes, delegate to a builder agent via create_agent.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fself-customize\u002FSKILL.md",[100],{"categoryNo":101,"categoryName":102,"taxonomyType":89,"taxonomyTypeDesc":90},"01JBSEEDCAT000000000000023","Skill与智能体开发",[104,105,106],"customize","self customize","MCP",{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":114,"publishedAt":24},"01M69A657JFNEG45Z1Y05BVK5R","onecli-gateway","OneCLI Gateway: transparent HTTPS proxy that injects stored credentials into outbound calls. You MUST use this skill when the user asks you to read emails, check calendar, access GitHub repos, create issues, check Stripe payments, or interact with ANY external service or API. Do NOT use browser extensions or OAuth CLI tools. Make HTTP requests directly; the gateway injects credentials automatically.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Famplifier-app-nanoclaw\u002Fblob\u002Fmain\u002Fcontainer\u002Fskills\u002Fonecli-gateway\u002FSKILL.md",[113],{"categoryNo":101,"categoryName":102,"taxonomyType":89,"taxonomyTypeDesc":90},[115,76,116,117],"onecli gateway","github","repos"]