Skip to content

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.

4.7 KB
Raw Blame
# Cloud Build → Cloud Run for the programmable-orders engine (workers/agent-orders).
#
# Background daemon deployed as a SERVICE: it runs the sweep timer continuously
# and binds a tiny liveness endpoint on $PORT (index.js) so the Cloud Run startup
# probe passes. Deployed with --no-cpu-throttling and --min-instances=1 so the
# timer keeps ticking between probes. Build context is the REPO ROOT (the
# Dockerfile copies api/, src/, and compiles the agent-payments-sdk workspace).
#
# Ships in ORDERS_MODE=simulate (real quotes, no broadcast). Flip
# ORDERS_MODE=live only after the RPC secret is set and agent wallets are funded.
#
# ── SECRET SETUP (already done; here for a rebuild from scratch) ──────────────
# All four secrets below exist in aerial-vehicle-466722-p5 and are readable by the
# runtime service account, so a deploy needs no secret work. To recreate them
# (values come from .env / the three-ws-api service env, never from a commit):
#   printf '%s' "$DATABASE_URL"          | gcloud secrets create agent-orders-database-url --data-file=-
#   printf '%s' "$JWT_SECRET"            | gcloud secrets create agent-orders-jwt-secret --data-file=-
#   printf '%s' "$WALLET_ENCRYPTION_KEY" | gcloud secrets create agent-orders-wallet-encryption-key --data-file=-
#   printf '%s' "$SOLANA_RPC_URL"        | gcloud secrets create agent-orders-solana-rpc-url --data-file=-
#   for s in agent-orders-database-url agent-orders-jwt-secret \
#            agent-orders-wallet-encryption-key agent-orders-solana-rpc-url; do \
#     gcloud secrets add-iam-policy-binding "$s" \
#       --member=serviceAccount:three-ws@$PROJECT_ID.iam.gserviceaccount.com \
#       --role=roles/secretmanager.secretAccessor; done
#
# Do NOT point this worker at the project's generic JWT_SECRET / WALLET_ENCRYPTION_KEY
# secrets: both hold values that no longer match what three-ws-api runs with, so
# the worker would fail to decrypt custodial agent keys and every live fill would
# die at key recovery. The agent-orders-* copies above are verified against the
# running service.
#
# The worker never serves user requests, so it needs no rate-limit backend: the
# execution path (executeAgentTrade + guards + firewall) touches Postgres and RPC
# only. Nothing here mounts Upstash.
#
#   gcloud builds submit --config workers/agent-orders/cloudbuild.yaml . \
#     --region us-central1 --project aerial-vehicle-466722-p5 \
#     --substitutions=SHORT_SHA=manual$(date +%s)
#
# SHORT_SHA is only populated for trigger-driven builds; a manual submit must pass
# it or the image tag comes out empty and the build fails at push.

# Builds run as the pinned three-ws-build service account: the project's default
# compute service account was deleted, so an unpinned submit fails with
# "Unknown service account".
serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]

substitutions:
  _REGION: us-central1
  _SERVICE: agent-orders
  _REPO: workers
  _MIN_INSTANCES: "1"
  _MAX_INSTANCES: "1"
  _ORDERS_MODE: simulate

steps:
  - id: build
    name: gcr.io/cloud-builders/docker
    args:
      - build
      - --file
      - workers/agent-orders/Dockerfile
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest
      - --cache-from
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest
      - .
    timeout: 1200s

  - id: push
    name: gcr.io/cloud-builders/docker
    args:
      - push
      - --all-tags
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}

  - id: deploy
    name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
    entrypoint: gcloud
    args:
      - run
      - deploy
      - ${_SERVICE}
      - --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
      - --region=${_REGION}
      - --platform=managed
      - --no-cpu-throttling
      - --cpu=1
      - --memory=1Gi
      - --min-instances=${_MIN_INSTANCES}
      - --max-instances=${_MAX_INSTANCES}
      - --no-allow-unauthenticated
      - --service-account=three-ws@$PROJECT_ID.iam.gserviceaccount.com
      - --set-env-vars=NODE_ENV=production,ORDERS_MODE=${_ORDERS_MODE},ORDERS_NETWORK=mainnet,ORDERS_GLOBAL_KILL=0,ORDERS_HEARTBEAT_MS=30000
      - --set-secrets=DATABASE_URL=agent-orders-database-url:latest,JWT_SECRET=agent-orders-jwt-secret:latest,WALLET_ENCRYPTION_KEY=agent-orders-wallet-encryption-key:latest,SOLANA_RPC_URL=agent-orders-solana-rpc-url:latest

images:
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest

options:
  machineType: E2_HIGHCPU_8
  logging: CLOUD_LOGGING_ONLY