2026-06-18 07:12:57 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# Entrypoint for the roboco-agent-grok image.
|
|
|
|
|
#
|
|
|
|
|
# Renders opencode.json from the RoboCo spawn env (OPENAI_* + ROBOCO_*, set by
|
|
|
|
|
# GrokProvider) plus the mounted Claude Code mcp-config.json, then runs opencode
|
|
|
|
|
# non-interactively. opencode speaks the OpenAI protocol, so grok-build-0.1 runs
|
|
|
|
|
# natively against api.x.ai/v1 with no shim, while still reaching the RoboCo MCP
|
|
|
|
|
# gateway (roboco-flow / roboco-do / ...) translated into opencode's mcp config.
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
# Generate opencode.json (provider + model + MCP gateway + permissions +
|
|
|
|
|
# instructions). Writes to opencode's global config dir by default.
|
|
|
|
|
python -m roboco.llm.providers.opencode_config
|
|
|
|
|
|
|
|
|
|
# Run the agent. The prompt comes from an env var (never an untrusted argv
|
|
|
|
|
# positional); `--` separates it from flags so a prompt starting with `--`
|
|
|
|
|
# cannot be parsed as CLI options. The model also comes from the rendered
|
|
|
|
|
# config; --model is passed explicitly as belt-and-suspenders.
|
2026-06-18 09:57:20 +02:00
|
|
|
#
|
|
|
|
|
# `< /dev/null` is REQUIRED: without a closed stdin, `opencode run` hangs after
|
|
|
|
|
# init in a headless / no-TTY environment (it blocks waiting on stdin). Verified
|
|
|
|
|
# live — closing stdin lets the run proceed to the model call and exit cleanly.
|
2026-06-18 07:12:57 +02:00
|
|
|
exec opencode run \
|
|
|
|
|
--model "xai/${ROBOCO_AGENT_MODEL:-grok-build-0.1}" \
|
2026-06-18 09:57:20 +02:00
|
|
|
-- "${ROBOCO_INITIAL_PROMPT:-}" < /dev/null
|