#!/bin/sh # One-shot agent dispatcher inside the container. # # 1. Loads the contract-generated system prompt (contracts + optional # mission section from MOSAIC_MISSION_FILE). # 2. Dispatches to /opt/mosaic/adapters//adapter.sh per # the contract in /opt/mosaic/adapters/README.md. set -eu REQUEST="${*:-Return your startup marker and nothing else.}" ADAPTER="${MOSAIC_ADAPTER:-pi}" case "$ADAPTER" in # Allowlist mirrors scripts/mosaic-config.mjs; pattern check first so a # crafted name cannot escape the adapters directory. *[!A-Za-z0-9._-]*|'') echo "run-agent: invalid adapter name: '$ADAPTER'" >&2 exit 2 ;; esac ADAPTER_SCRIPT="/opt/mosaic/adapters/$ADAPTER/adapter.sh" if [ ! -x "$ADAPTER_SCRIPT" ]; then echo "run-agent: unknown or non-executable adapter: $ADAPTER" >&2 exit 2 fi /opt/mosaic/src/load-contracts.sh /opt/mosaic/contracts /var/lib/mosaic/system-prompt.md export MOSAIC_SYSTEM_PROMPT_FILE="/var/lib/mosaic/system-prompt.md" export MOSAIC_REQUEST="$REQUEST" exec "$ADAPTER_SCRIPT"