#!/usr/bin/env bash
set -euo pipefail
# Run from the app checkout. T3_HOME is a fresh dev home belonging to this checkout.
# Configure the Codex instance with an isolated, authenticated CODEX_HOME and:
#   config.launchArgs = '-c sandbox_workspace_write.network_access=true'
# Start the server with T3CODE_DEV_SEED=0 vp run dev.
# Repeat with defaultRuntimeMode set to auto, then auto-accept-edits.
: "${T3_HOME:?}" "${PROJECT:?}" "${PROBE_MODEL:?}"
if [[ ${SKIP_ADD:-0} != 1 ]]; then
node apps/server/src/bin.ts project add --base-dir "$T3_HOME" --title 'Sandbox network proof' "$PROJECT"
fi
node apps/server/src/bin.ts thread start --base-dir "$T3_HOME" --provider codex --model "$PROBE_MODEL" --title "${PROBE_TITLE:-Sandbox network probe}" --wait --json "$PROJECT" "$(cat <<'PROMPT'
Run the following shell command once in the current sandbox. Do not escalate, retry, or change configuration. Report stdout and stderr in a fenced code block.
```sh
echo NET_DISABLED=${CODEX_SANDBOX_NETWORK_DISABLED:-unset}; curl --max-time 20 -sS -o /dev/null -w "HTTP_STATUS=%{http_code}\n" https://api.github.com/zen
```
PROMPT
)"
