motif64

m64_9d6a8d0db091 / README.md

46 lines, 2.1 KBraw

opencode-inside

The opencode coding agent running inside a capsule, on DeepSeek V4.1 Flash through OpenRouter. Builds on openrouter-secrets: same network rule, same key handling.

What it shows

  • A Dockerfile instead of runtime.image. m64 builds it on the first serve. Everything is installed at build time and pinned: FROM by digest, npm install -g opencode-ai@1.18.23, every pip package with ==. At run time the container has no network except what you grant.
  • Warming at build time (warm_opencode.sh): opencode installs npm packages on its first start. The build does that once, where it has network, so a run never tries to reach the npm registry.
  • The agent.session kind (agent_gateway.py): a small session API that m64's front lets through. Create a session, send it a task, read its files. See AGENT.md for every route.
  • [runtime.app]: opencode's own server (web UI and API) on a second port, reported as app_url. /human/ links to it, and opencode attach <app_url> drives the agent from your own terminal.
  • The key in the gate: opencode.json points opencode at http://openrouter.ai with apiKey: "{env:OPENROUTER_API_KEY}". In the container that variable is only a placeholder; the gate puts the real key in.

Run it

m64 config secrets set OPENROUTER_API_KEY      # once
m64 check examples/opencode-inside
m64 serve examples/opencode-inside --allow-external-network
m64 status                                      # url and app_url

The first serve builds the image: a few minutes. capsule.toml targets linux-x86_64; the Dockerfile builds the same on ARM (linux-aarch64).

What to look at

  • /human/: links to the full opencode web UI, and shows the opencode attach line for your own terminal.
  • /agent: the session API, with copy-paste curl lines.
  • m64 net <id>: the agent's connections. Only openrouter.ai:443 is allowed; anything else it tries is refused and logged.
  • Sessions share one container and one user: serve one capsule per person or project, not per session.