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(agent-gateway): add the Cloud Run Dockerfile and cloudbuild.yaml the deploy runbook needs
nirholas5db1cbc8f16d
diff --git a/workers/agent-gateway/Dockerfile b/workers/agent-gateway/Dockerfilenew file mode 100644index 000000000..b6059930d--- /dev/null+++ b/workers/agent-gateway/Dockerfile@@ -0,0 +1,63 @@+# syntax=docker/dockerfile:1.7-labs+# agent-gateway: the chat gateway worker (Cloud Run service).+#+# Build from the REPO ROOT. The worker runs the shared gateway core in+# api/_lib/gateway, which reaches the copilot engine, the agent wallet and the+# trade engine, so the image carries the same install the API image does (root+# workspaces, built SDKs) plus the worker's own two dependencies (grammy,+# discord.js) and the distro ffmpeg the voice path transcodes with+# (api/_lib/gateway/audio.js reads FFMPEG_PATH).+#+# docker build -f workers/agent-gateway/Dockerfile -t agent-gateway .+# docker run --env-file .env.local -e TELEGRAM_BOT_TOKEN=... -p 8080:8080 agent-gateway+#+# Deploy: workers/agent-gateway/cloudbuild.yaml (README.md has the command).++FROM node:24-slim++WORKDIR /app++# node-gyp toolchain for the root install's native deps (no Node 24 prebuilts),+# and ffmpeg for voice notes in and spoken replies out.+RUN apt-get update \+ && apt-get install -y --no-install-recommends python3 make g++ ffmpeg ca-certificates \+ && rm -rf /var/lib/apt/lists/*++ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \+ PUPPETEER_SKIP_DOWNLOAD=1++# The npm that produced package-lock.json; see the root Dockerfile for why a+# floating npm breaks `npm ci` on an untouched lockfile.+ARG NPM_VERSION=11.9.0+RUN npm install -g npm@${NPM_VERSION}++# 1. Root manifests only, so the large `npm ci` layer survives source changes.+COPY --parents package.json package-lock.json .npmrc* **/package.json /app/+RUN npm ci --ignore-scripts --no-audit --no-fund++# 2. The worker's own dependencies, from its own lockfile. Node resolves them+# from workers/agent-gateway/node_modules for the worker's files and falls+# back to /app/node_modules for everything under api/.+COPY workers/agent-gateway/package.json workers/agent-gateway/package-lock.json ./workers/agent-gateway/+RUN npm --prefix workers/agent-gateway ci --omit=dev --no-audit --no-fund++# 3. Full source, then the deferred lifecycle scripts the API image runs too+# (native rebuilds, the root postinstall that builds the workspace SDKs).+COPY . .+RUN npm rebuild && npm run postinstall++# 4. Drop the root devDependencies; the worker's tree was installed without them.+RUN npm prune --omit=dev --ignore-scripts --no-audit --no-fund++ENV NODE_ENV=production \+ NODE_OPTIONS=--no-deprecation \+ FFMPEG_PATH=/usr/bin/ffmpeg \+ PORT=8080++# Same permission normalisation as the root image (it explains the find), then+# drop root: the worker never writes under /app.+RUN find /app \( \( -type d ! -perm -555 \) -o \( -type f \( ! -perm -444 -o \( -perm /111 ! -perm -111 \) \) \) \) -exec chmod a+rX {} ++USER node++EXPOSE 8080+CMD ["node", "workers/agent-gateway/src/index.js"]diff --git a/workers/agent-gateway/cloudbuild.yaml b/workers/agent-gateway/cloudbuild.yamlnew file mode 100644index 000000000..d7c1f7fc0--- /dev/null+++ b/workers/agent-gateway/cloudbuild.yaml@@ -0,0 +1,120 @@+# Cloud Build -> Cloud Run for the chat gateway worker (workers/agent-gateway).+#+# Submit from the REPO ROOT (the Dockerfile builds the root install and copies+# api/, which the gateway core lives in):+#+# gcloud builds submit --config workers/agent-gateway/cloudbuild.yaml . \+# --region us-central1 --project aerial-vehicle-466722-p5 \+# --substitutions=SHORT_SHA=manual$(date +%s)+#+# SHORT_SHA is only set for trigger-driven builds; a manual submit must pass it+# or the image tag is empty and the push fails.+#+# The service's environment is derived from the live three-ws-api service on+# every deploy (scripts/deploy-env.mjs): literals by value, credentials by+# Secret Manager reference, platform treasury and payer signers left out. A+# variable the gateway needs (DISCORD_BOT_TOKEN, DISCORD_APP_ID,+# DISCORD_PUBLIC_KEY, TELEGRAM_BOT_TOKEN) therefore belongs on three-ws-api,+# which needs it too for the receivers and the settings page, and reaches the+# worker on its next deploy. Gateway tuning knobs ride in as substitutions.+#+# Always on: --no-cpu-throttling keeps the drain loop and the Discord gateway+# connection running between requests, and min-instances 1 keeps one worker up.+# The VPC connector matches three-ws-api: the rate limiter's Redis endpoint is a+# private address. Ingress is closed (no unauthenticated invokes); nothing calls+# this service over HTTP except Cloud Run's own probes.+#+# Builds run as the pinned three-ws-build service account (the project's+# default compute service account was deleted) and the service runs as three-ws.++serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]++substitutions:+ _REGION: us-central1+ _SERVICE: agent-gateway+ _REPO: workers+ _SOURCE_SERVICE: three-ws-api+ _MIN_INSTANCES: "1"+ _MAX_INSTANCES: "1"+ _CONCURRENCY: "8"+ _MAX_ATTEMPTS: "5"++steps:+ - id: pull-cache+ name: gcr.io/cloud-builders/docker+ entrypoint: bash+ args: ['-c', 'docker pull ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:latest || exit 0']++ - id: build+ name: gcr.io/cloud-builders/docker+ env: ['DOCKER_BUILDKIT=1']+ args:+ - build+ - --file+ - workers/agent-gateway/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+ - --build-arg+ - BUILDKIT_INLINE_CACHE=1+ - .+ timeout: 1800s++ - id: push+ name: gcr.io/cloud-builders/docker+ args: ['push', '--all-tags', '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}']++ - id: read-api-env+ name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim+ entrypoint: bash+ args: ['-c', 'gcloud run services describe ${_SOURCE_SERVICE} --region=${_REGION} --project=$PROJECT_ID --format=json > /workspace/api-service.json']++ - id: derive-env+ name: node:24-slim+ entrypoint: node+ args:+ - workers/agent-gateway/scripts/deploy-env.mjs+ - /workspace/api-service.json+ - /workspace/gateway-env.yaml+ - /workspace/gateway-secrets.txt+ - --set+ - GATEWAY_CONCURRENCY=${_CONCURRENCY}+ - --set+ - GATEWAY_MAX_ATTEMPTS=${_MAX_ATTEMPTS}++ - id: deploy+ name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim+ entrypoint: bash+ args:+ - -c+ - >-+ gcloud run deploy ${_SERVICE}+ --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/${_SERVICE}:$SHORT_SHA+ --region=${_REGION}+ --project=$PROJECT_ID+ --platform=managed+ --service-account=three-ws@$PROJECT_ID.iam.gserviceaccount.com+ --no-allow-unauthenticated+ --no-cpu-throttling+ --cpu=1+ --memory=2Gi+ --min-instances=${_MIN_INSTANCES}+ --max-instances=${_MAX_INSTANCES}+ --vpc-connector=three-ws-vpc+ --vpc-egress=private-ranges-only+ --env-vars-file=/workspace/gateway-env.yaml+ --set-secrets="$$(cat /workspace/gateway-secrets.txt)"+ && rm -f /workspace/api-service.json /workspace/gateway-env.yaml /workspace/gateway-secrets.txt++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++timeout: 2700s