Submatter/docker/opencode/entrypoint.sh
Randall Stillwell 9572eac3eb
Some checks are pending
CI / Lint, type-check, test (push) Waiting to run
Deploy homelab (CT 116) / Deploy to CT 116 (push) Waiting to run
feat(worker): OpenCode harness for Submatter Phase B
Add WORKER_SESSION_TYPE=opencode with a headless OpenCode session adapter,
compose profile, and OmniRoute plugin config. Prefer OpenCode over the
unused OpenHands agent-server path; fix missing yaml runtime dependency.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 12:47:56 -05:00

27 lines
905 B
Bash

#!/bin/sh
# Seed OmniRoute auth for headless OpenCode, then start serve/web.
set -eu
CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME:-/data}/.config}"
DATA_HOME="${XDG_DATA_HOME:-${HOME:-/data}/.local/share}"
mkdir -p "$CONFIG_HOME/opencode" "$DATA_HOME/opencode" /data/bin
# Container has no desktop — stub xdg-open so `opencode web` does not exit.
if [ ! -x /data/bin/xdg-open ]; then
printf '#!/bin/sh\nexit 0\n' > /data/bin/xdg-open
chmod +x /data/bin/xdg-open
fi
export PATH="/data/bin:${PATH}"
if [ -f /config/opencode.json ]; then
cp /config/opencode.json "$CONFIG_HOME/opencode/opencode.json"
fi
if [ -n "${OMNIROUTE_API_KEY:-}" ]; then
# Keys must not contain double-quotes; OmniRoute keys are hex/base64-safe.
printf '{"omniroute":{"type":"api","key":"%s"}}\n' "$OMNIROUTE_API_KEY" \
> "$DATA_HOME/opencode/auth.json"
chmod 600 "$DATA_HOME/opencode/auth.json" || true
fi
exec "$@"