set -e; for v in SUPABASE_URL SUPABASE_PROJECT_REF SUPABASE_ANON_KEY SUPABASE_SERVICE_ROLE_KEY SUPABASE_DB_URL SUPABASE_DB_PASSWORD; do if [ -n "${!v:-}" ]; then echo "$v=set"; else echo "$v=missing"; fi; doneSUPABASE_URL=set SUPABASE_PROJECT_REF=set SUPABASE_ANON_KEY=set SUPABASE_SERVICE_ROLE_KEY=set SUPABASE_DB_URL=set SUPABASE_DB_PASSWORD=set
command -v curl >/dev/null && echo curl=available; command -v jq >/dev/null && echo jq=available || true
curl=available jq=available
set -euo pipefail
base="${SUPABASE_URL%/}"
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
chmod 700 "$tmp"
create_or_update() {
local email="$1" password="$2" body="$tmp/body"
printf '%s' "{\"email\":\"$email\",\"password\":\"$password\",\"email_confirm\":true}" > "$tmp/request"
local code
code=$(curl -sS -o "$body" -w '%{http_code}' -X POST "$base/auth/v1/admin/users" \
-H "Authorization: Bearer ${SUPABASE_SERVICE_ROLE_KEY}" \
-H "apikey: ${SUPABASE_SERVICE_ROLE_KEY}" -H 'Content-Type: application/json' \
--data-binary "@$tmp/request")
if [ "$code" = 200 ] || [ "$code" = 201 ]; then
id=$(jq -r '.id // empty' "$body")
[ -n "$id" ] || { echo "create returned no user id for $email" >&2; cat "$body" >&2; exit 1; }
echo "created $email"
elif [ "$code" = 422 ] || [ "$code" = 400 ]; then
# Locate an existing account, then reset its password and confirm it.
found=''
for page in 1 2 3 4 5; do
curl -sS -f "$base/auth/v1/admin/users?page=$page&per_page=1000" \
-H "Authorization: Bearer ${SUPABASE_SERVICE_ROLE_KEY}" -H "apikey: ${SUPABASE_SERVICE_ROLE_KEY}" > "$tmp/users"
found=$(jq -r --arg e "$email" '.users[]? | select(.email == $e) | .id' "$tmp/users" | head -n1)
[ -n "$found" ] && break
[ "$(jq '.users | length' "$tmp/users")" -lt 1000 ] && break
done
[ -n "$found" ] || { echo "cannot create/find $email (HTTP $code): $(cat "$body")" >&2; exit 1; }
id="$found"
printf '%s' "{\"password\":\"$password\",\"email_confirm\":true}" > "$tmp/request"
code2=$(curl -sS -o "$body" -w '%{http_code}' -X PUT "$base/auth/v1/admin/users/$id" \
-H "Authorization: Bearer ${SUPABASE_SERVICE_ROLE_KEY}" -H "apikey: ${SUPABASE_SERVICE_ROLE_KEY}" \
-H 'Content-Type: application/json' --data-binary "@$tmp/request")
case "$code2" in 200|201) echo "updated $email";; *) echo "update failed for $email HTTP $code2: $(cat "$body")" >&2; exit 1;; esac
else
echo "create failed for $email HTTP $code: $(cat "$body")" >&2; exit 1
fi
}
create_or_update 'dana@cari.dev' 'Passw0rd-dana-91'
create_or_update 'omar@cari.dev' 'Passw0rd-omar-17'
# Verify password grant and require an access token for each.
verify() {
local email="$1" password="$2" out code token
out=$(curl -sS -X POST "$base/auth/v1/token?grant_type=password" \
-H "apikey: ${SUPABASE_ANON_KEY}" -H 'Content-Type: application/json' \
--data "{\"email\":\"$email\",\"password\":\"$password\"}")
token=$(printf '%s' "$out" | jq -r '.access_token // empty')
[ -n "$token" ] || { echo "sign-in failed for $email: $(printf '%s' "$out" | jq -c 'del(.access_token,.refresh_token)')" >&2; exit 1; }
echo "verified $email: access token returned"
}
verify 'dana@cari.dev' 'Passw0rd-dana-91'
verify 'omar@cari.dev' 'Passw0rd-omar-17'created dana@cari.dev created omar@cari.dev verified dana@cari.dev: access token returned verified omar@cari.dev: access token returned
A shell script executed against the live project and asserted on the state the agent left behind. No model judged another model.
Raw transcript · Task definition and verifier · Every attempt