Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(deploy): one-command Cloud Shell deploy for the CPU editing workers
nirholas229eaa60231f
diff --git a/docs/roadmap/generation-suite.md b/docs/roadmap/generation-suite.mdindex a3b4c8ab7..1a850a7a2 100644--- a/docs/roadmap/generation-suite.md+++ b/docs/roadmap/generation-suite.md@@ -62,11 +62,12 @@ photo, draft tier, under 2 minutes, zero console errors.Everything here is written and containerized; it needs deployment + env wiring.-1. **Deploy automation for the editing workers.** `workers/deploy/deploy-all.sh` only covers- the avatar pipeline (controller / mesh models / unirig). Extend it (or add- `deploy-editing.sh`) to build + deploy `remesh`, `stylize`, `segment`, `rembg`, `texture`,- `model-text2motion` from their existing Dockerfiles/cloudbuild.yaml, and print the URL +- key pairs for Vercel env.+1. **Deploy automation for the editing workers.** ✅ Built 2026-06-12:+ `workers/deploy/deploy-editing.sh` provisions + deploys `stylize`, `remesh`, `segment`,+ `rembg` (CPU-only, default set) and optionally `texture` / `model-text2motion` (GPU),+ prints the URL + key pairs, and with `VERCEL_TOKEN` upserts them into Vercel production+ via REST. ❌ Not yet run — needs a privileged GCP identity (Cloud Shell):+ `PROJECT_ID=… ./workers/deploy/deploy-editing.sh`.2. **Set the env vars** (names): `GCP_REMESH_URL`, `GCP_STYLIZE_URL`, `GCP_SEGMENT_URL`,`GCP_REMBG_URL`, `GCP_TEXTURE_URL`, `GCP_TEXT2MOTION_URL`, `GCP_TRIPOSG_URL`(+ shared `GCP_RECONSTRUCTION_KEY`), `LONGCAT_WORKER_URL`/`LONGCAT_WORKER_KEY`.diff --git a/workers/deploy/README.md b/workers/deploy/README.mdindex 0b02b4344..78a099f96 100644--- a/workers/deploy/README.md+++ b/workers/deploy/README.md@@ -97,6 +97,37 @@ Watch logs with `gcloud run services logs read avatar-pipeline-controller --regi---+## Editing workers — `deploy-editing.sh` (no GPU, no weights)++The mesh-editing services behind `/api/forge-stylize`, `/api/forge-remesh`,+`/api/forge-segment` and `/api/forge-rembg` are **CPU-only** — no GPU quota, no+staged weights. A clean project deploys in ~10 minutes:++```bash+# in Cloud Shell, from a clone of this repo:+PROJECT_ID=your-project-id ./workers/deploy/deploy-editing.sh++# just one service:+PROJECT_ID=your-project-id SERVICES="stylize" ./workers/deploy/deploy-editing.sh++# also wire the Vercel production env vars automatically (REST, not the CLI —+# the CLI silently writes empty sensitive values):+PROJECT_ID=your-project-id VERCEL_TOKEN=xxxx ./workers/deploy/deploy-editing.sh+```++It is idempotent and shares all infrastructure with `deploy-all.sh` (same+service account, output bucket, and `avatar-reconstruction-key` secret), so it+can run before, after, or instead of the avatar pipeline. It prints — and with+`VERCEL_TOKEN`, sets — the env vars the site needs: `GCP_STYLIZE_URL`,+`GCP_REMESH_URL`, `GCP_SEGMENT_URL`, `GCP_REMBG_URL`, `GCP_RECONSTRUCTION_KEY`.+Redeploy the site afterwards for the env to take effect.++GPU extras: `SERVICES="texture text2motion"` deploys the retexture and+text→animation workers too, but those need L4 quota and staged weights+(`stage-weights.sh`), like the avatar fleet.++---+## Cost (covered by credits)GPU services scale to **zero** when idle (`min-instances=0`), so you pay L4 timediff --git a/workers/deploy/deploy-editing.sh b/workers/deploy/deploy-editing.shnew file mode 100755index 000000000..f2b421ff3--- /dev/null+++ b/workers/deploy/deploy-editing.sh@@ -0,0 +1,221 @@+#!/usr/bin/env bash+#+# deploy-editing.sh — provision + deploy the three.ws mesh-editing workers+# (stylize / remesh / segment / rembg, optionally texture / text2motion)+# to Google Cloud Run, idempotently.+#+# These are the services behind /api/forge-stylize, /api/forge-remesh,+# /api/forge-segment, /api/forge-rembg, /api/studio/retexture-* and+# /api/forge-motion. The default set is CPU-only: no GPU quota, no staged+# weights — a clean project deploys in ~10 minutes.+#+# Fastest path: run this in Google Cloud Shell from a clone of the repo —+# it is pre-authenticated and has gcloud + docker. See README.md.+#+# Usage:+# PROJECT_ID=my-proj ./workers/deploy/deploy-editing.sh+# PROJECT_ID=my-proj SERVICES="stylize" ./workers/deploy/deploy-editing.sh+#+# Env:+# PROJECT_ID required — target GCP project+# REGION default us-central1+# SERVICES default "stylize remesh segment rembg" (all CPU).+# GPU extras (need L4 quota + staged weights — see+# stage-weights.sh): texture text2motion+# OUTPUT_BUCKET default three-ws-avatar-reconstructions+# WEIGHTS_BUCKET default three-ws-model-weights (GPU services only)+# RUN_SA / BUILD_SA default avatar-reconstruction-sa@$PROJECT_ID (created+# if missing; same identity builds and runs)+#+# Optional Vercel auto-wiring — set these and the script upserts the+# GCP_*_URL vars + GCP_RECONSTRUCTION_KEY into Vercel production for you+# (the Vercel CLI silently writes EMPTY sensitive values, so we use REST):+# VERCEL_TOKEN a Vercel API token (vercel.com/account/tokens)+# VERCEL_PROJECT_ID default prj_IWZmEnqR1pCZRCRuvhCFCDcOx5Wc (3dagent)+# VERCEL_TEAM_ID default team_zRpaxHPiMnQGXurBbegM3PCA++set -euo pipefail++PROJECT_ID="${PROJECT_ID:?set PROJECT_ID to your GCP project}"+REGION="${REGION:-us-central1}"+SERVICES="${SERVICES:-stylize remesh segment rembg}"+OUTPUT_BUCKET="${OUTPUT_BUCKET:-three-ws-avatar-reconstructions}"+WEIGHTS_BUCKET="${WEIGHTS_BUCKET:-three-ws-model-weights}"+SECRET_NAME="avatar-reconstruction-key"+VERCEL_PROJECT_ID="${VERCEL_PROJECT_ID:-prj_IWZmEnqR1pCZRCRuvhCFCDcOx5Wc}"+VERCEL_TEAM_ID="${VERCEL_TEAM_ID:-team_zRpaxHPiMnQGXurBbegM3PCA}"++REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+cd "$REPO_ROOT"++log() { printf '\033[1;36m[deploy]\033[0m %s\n' "$*"; }+ok() { printf '\033[1;32m[deploy] ✓\033[0m %s\n' "$*"; }+warn() { printf '\033[1;33m[deploy] ! \033[0m %s\n' "$*"; }+die() { printf '\033[1;31m[deploy] ERROR:\033[0m %s\n' "$*" >&2; exit 1; }++command -v gcloud >/dev/null 2>&1 || die "gcloud not found on PATH"+gcloud auth print-access-token >/dev/null 2>&1 || die "gcloud is not authenticated — run 'gcloud auth login'"++# service key -> worker dir | Cloud Run service name | Vercel env var | needs GPU/weights+svc_dir() { case "$1" in stylize) echo stylize;; remesh) echo remesh;; segment) echo segment;; rembg) echo rembg;; texture) echo texture;; text2motion) echo model-text2motion;; *) echo "";; esac; }+svc_run() { case "$1" in stylize) echo stylize-service;; remesh) echo remesh-service;; segment) echo segment-service;; rembg) echo rembg-service;; texture) echo texture-service;; text2motion) echo model-text2motion;; *) echo "";; esac; }+svc_envvar() { case "$1" in stylize) echo GCP_STYLIZE_URL;; remesh) echo GCP_REMESH_URL;; segment) echo GCP_SEGMENT_URL;; rembg) echo GCP_REMBG_URL;; texture) echo GCP_TEXTURE_URL;; text2motion) echo GCP_TEXT2MOTION_URL;; *) echo "";; esac; }+svc_gpu() { case "$1" in texture|text2motion) echo yes;; *) echo no;; esac; }++for svc in $SERVICES; do+ [ -n "$(svc_dir "$svc")" ] || die "unknown service '$svc' (valid: stylize remesh segment rembg texture text2motion)"+ if [ "$(svc_gpu "$svc")" = yes ]; then+ warn "'$svc' needs Cloud Run L4 GPU quota in $REGION and staged weights (./workers/deploy/stage-weights.sh)"+ fi+done++TAG="$(git rev-parse --short HEAD 2>/dev/null || echo manual)"++# ── 1. project + APIs ─────────────────────────────────────────────────────────+log "project: $PROJECT_ID region: $REGION services: $SERVICES"+gcloud config set project "$PROJECT_ID" >/dev/null+log "enabling required APIs (idempotent)…"+gcloud services enable \+ run.googleapis.com cloudbuild.googleapis.com artifactregistry.googleapis.com \+ storage.googleapis.com secretmanager.googleapis.com iam.googleapis.com \+ --project "$PROJECT_ID" >/dev/null+ok "APIs enabled"++RUN_SA="${RUN_SA:-avatar-reconstruction-sa@${PROJECT_ID}.iam.gserviceaccount.com}"+BUILD_SA="${BUILD_SA:-$RUN_SA}"++# ── 2. build/runtime service account ──────────────────────────────────────────+if gcloud iam service-accounts describe "$RUN_SA" >/dev/null 2>&1; then+ ok "service account $RUN_SA exists"+else+ log "creating service account ${RUN_SA%%@*}…"+ gcloud iam service-accounts create "${RUN_SA%%@*}" \+ --display-name="three.ws avatar/editing workers (build + runtime)" >/dev/null+ ok "created $RUN_SA"+fi++# ── 3. output bucket ──────────────────────────────────────────────────────────+if gcloud storage buckets describe "gs://$OUTPUT_BUCKET" >/dev/null 2>&1; then+ ok "bucket gs://$OUTPUT_BUCKET exists"+else+ log "creating bucket gs://$OUTPUT_BUCKET…"+ gcloud storage buckets create "gs://$OUTPUT_BUCKET" --location="$REGION" --uniform-bucket-level-access >/dev/null+ ok "created gs://$OUTPUT_BUCKET"+fi+# Result meshes are fetched by URL from the browser/Vercel, so public-read.+gcloud storage buckets add-iam-policy-binding "gs://$OUTPUT_BUCKET" \+ --member=allUsers --role=roles/storage.objectViewer >/dev/null 2>&1 || \+ warn "could not make $OUTPUT_BUCKET public-read (org policy may block allUsers) — result URLs will 403"++# ── 4. shared API key secret ──────────────────────────────────────────────────+if gcloud secrets describe "$SECRET_NAME" >/dev/null 2>&1; then+ ok "secret $SECRET_NAME exists"+else+ log "creating secret $SECRET_NAME with a fresh random key…"+ openssl rand -hex 32 | gcloud secrets create "$SECRET_NAME" --data-file=- >/dev/null+ ok "created secret $SECRET_NAME"+fi++# ── 5. IAM for the build + runtime service account ────────────────────────────+log "ensuring $RUN_SA has the needed build + runtime roles…"+for role in roles/secretmanager.secretAccessor roles/storage.objectAdmin \+ roles/run.admin roles/artifactregistry.writer roles/logging.logWriter \+ roles/cloudbuild.builds.builder; do+ gcloud projects add-iam-policy-binding "$PROJECT_ID" \+ --member="serviceAccount:${RUN_SA}" --role="$role" --condition=None >/dev/null 2>&1 \+ || warn "could not grant $role to $RUN_SA (may already be bound or need an admin)"+done+gcloud iam service-accounts add-iam-policy-binding "$RUN_SA" \+ --member="serviceAccount:${RUN_SA}" --role="roles/iam.serviceAccountUser" --condition=None >/dev/null 2>&1 \+ || warn "could not grant actAs-self to $RUN_SA"+ok "build + runtime IAM configured"++# ── 6. build + deploy each worker ─────────────────────────────────────────────+declare -A SERVICE_URL+for svc in $SERVICES; do+ dir="workers/$(svc_dir "$svc")"+ runname="$(svc_run "$svc")"+ repo="$runname"+ [ -d "$dir" ] || die "worker dir not found: $dir"++ if ! gcloud artifacts repositories describe "$repo" --location="$REGION" >/dev/null 2>&1; then+ log "creating Artifact Registry repo '$repo'…"+ gcloud artifacts repositories create "$repo" --repository-format=docker --location="$REGION" >/dev/null+ fi++ subs="SHORT_SHA=${TAG},_REGION=${REGION},_GCS_BUCKET=${OUTPUT_BUCKET},_RUN_SA=${RUN_SA}"+ [ "$(svc_gpu "$svc")" = yes ] && subs="${subs},_WEIGHTS_BUCKET=${WEIGHTS_BUCKET}"++ log "building + deploying '$runname' (several minutes)…"+ gcloud builds submit \+ --config "$dir/cloudbuild.yaml" \+ --region "$REGION" \+ --service-account="projects/${PROJECT_ID}/serviceAccounts/${BUILD_SA}" \+ --default-buckets-behavior=regional-user-owned-bucket \+ --substitutions="$subs" \+ . \+ || die "build/deploy failed for $runname — inspect the Cloud Build log above"++ url="$(gcloud run services describe "$runname" --region "$REGION" --format='value(status.url)')"+ [ -n "$url" ] || die "could not resolve URL for $runname after deploy"+ SERVICE_URL["$svc"]="$url"+ ok "$runname → $url"+done++API_KEY_VALUE="$(gcloud secrets versions access latest --secret="$SECRET_NAME")"++# ── 7. health checks ──────────────────────────────────────────────────────────+for svc in $SERVICES; do+ url="${SERVICE_URL[$svc]}"+ if curl -fsS --max-time 60 "$url/health" >/dev/null 2>&1; then+ ok "$svc health OK"+ else+ warn "$svc /health not ready yet (cold start) — retry: curl $url/health"+ fi+done++# ── 8. Vercel env wiring ──────────────────────────────────────────────────────+vercel_upsert() {+ local key="$1" value="$2"+ curl -fsS -X POST \+ "https://api.vercel.com/v10/projects/${VERCEL_PROJECT_ID}/env?upsert=true&teamId=${VERCEL_TEAM_ID}" \+ -H "Authorization: Bearer ${VERCEL_TOKEN}" \+ -H "Content-Type: application/json" \+ -d "{\"key\":\"${key}\",\"value\":\"${value}\",\"type\":\"sensitive\",\"target\":[\"production\"]}" \+ >/dev/null+}++if [ -n "${VERCEL_TOKEN:-}" ]; then+ log "upserting Vercel production env vars via REST…"+ for svc in $SERVICES; do+ vercel_upsert "$(svc_envvar "$svc")" "${SERVICE_URL[$svc]}" \+ && ok "Vercel: $(svc_envvar "$svc") set" \+ || warn "Vercel: failed to set $(svc_envvar "$svc")"+ done+ vercel_upsert "GCP_RECONSTRUCTION_KEY" "$API_KEY_VALUE" \+ && ok "Vercel: GCP_RECONSTRUCTION_KEY set" \+ || warn "Vercel: failed to set GCP_RECONSTRUCTION_KEY"+ warn "env vars apply on the NEXT production deploy — push to main or redeploy from the Vercel dashboard"+else+ log "VERCEL_TOKEN not set — skipping Vercel wiring; set the vars below manually"+fi++# ── 9. handoff ────────────────────────────────────────────────────────────────+cat <<EOF++────────────────────────────────────────────────────────────────────────+ DEPLOY COMPLETE. Vercel (Production) needs these, then a redeploy:+────────────────────────────────────────────────────────────────────────+EOF+for svc in $SERVICES; do+ printf ' %-24s = %s\n' "$(svc_envvar "$svc")" "${SERVICE_URL[$svc]}"+done+cat <<EOF+ GCP_RECONSTRUCTION_KEY = ${API_KEY_VALUE}++ Verify after redeploy (expect 202 with a job_id, then a result GLB):+ curl -X POST https://three.ws/api/forge-stylize \\+ -H 'content-type: application/json' \\+ -d '{"mesh_url":"<your GLB url>","style":"voxel"}'+────────────────────────────────────────────────────────────────────────+EOF