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
fix(sniper): ship data/plans.json in the worker image and boot-check the image file set before building
nirholasb17456355c03
diff --git a/scripts/deploy-sniper.mjs b/scripts/deploy-sniper.mjsindex bc0b6aea9..3fe3aa788 100644--- a/scripts/deploy-sniper.mjs+++ b/scripts/deploy-sniper.mjs@@ -11,6 +11,9 @@* 2. enable the required GCP APIs (idempotent)* 3. ensure the runtime service account + the Artifact Registry repo exist* 4. preflight the secrets the service config mounts (warn if missing)+ * 4b. boot the worker from exactly the files the Dockerfile COPYs, so a runtime+ * read outside that set fails here in seconds instead of as a revision+ * Cloud Run refuses to start after a full build* 5. build + push the image via Cloud Build (deploy/sniper/cloudbuild.yaml)* 6. deploy the service (deploy/sniper/cloudrun.yaml) — minScale=maxScale=1,* no CPU throttling, default SNIPER_MODE=simulate@@ -34,8 +37,9 @@import { spawnSync } from 'node:child_process';import './lib/gcloud-path.mjs';import { fileURLToPath } from 'node:url';-import { dirname, resolve } from 'node:path';-import { existsSync, readFileSync } from 'node:fs';+import { dirname, resolve, basename, join } from 'node:path';+import { tmpdir } from 'node:os';+import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync } from 'node:fs';const __dirname = dirname(fileURLToPath(import.meta.url));const REPO_ROOT = resolve(__dirname, '..');@@ -161,6 +165,79 @@ function checkSecrets() {}}+/**+ * The source paths the sniper Dockerfile COPYs into /app, as+ * [{ from, to }] pairs relative to the repo root and to /app. Only plain+ * `COPY <src...> <dest>` lines (no --from/--chown flags) are read, and a+ * trailing `*` glob (package-lock.json*) is kept only when the file exists.+ */+function dockerfileCopies(dockerfile) {+ const pairs = [];+ for (const raw of dockerfile.split('\n')) {+ const line = raw.trim();+ if (!/^COPY\s/i.test(line) || /\s--/.test(line)) continue;+ const parts = line.split(/\s+/).slice(1);+ const dest = parts.pop();+ for (const srcRaw of parts) {+ const src = srcRaw.replace(/\*$/, '');+ const to = dest.endsWith('/') ? join(dest, basename(src)) : dest;+ pairs.push({ from: src, to: to.replace(/^\.\//, ''), optional: srcRaw.endsWith('*') });+ }+ }+ return pairs;+}++/**+ * Boot workers/agent-sniper/index.js from a tree holding ONLY what the image+ * holds (the Dockerfile's COPY set plus the installed node_modules), with the+ * database env stripped. A healthy module graph loads completely and then stops+ * at the config check with "missing required env var: DATABASE_URL"; anything+ * else (ENOENT on a data file, ERR_MODULE_NOT_FOUND on a path the image lacks)+ * is exactly what would crash the revision before its health port opens.+ * On 2026-09-29 a read of data/plans.json did that, and Cloud Run refused the+ * revision after a full 8-minute build.+ */+function verifyImageBoots() {+ log('booting the worker from the image file set (Dockerfile COPYs only)…');+ const stage = mkdtempSync(join(tmpdir(), 'sniper-image-'));+ let failure;+ try {+ failure = bootFromStage(stage);+ } finally {+ rmSync(stage, { recursive: true, force: true });+ }+ if (failure) die(failure);+ ok('worker module graph loads from the image file set');+}++/** Stage the image file set into `stage` and boot it. Returns an error message, or null. */+function bootFromStage(stage) {+ const pairs = dockerfileCopies(readFileSync(resolve(REPO_ROOT, 'workers/agent-sniper/Dockerfile'), 'utf8'));+ for (const { from, to, optional } of pairs) {+ const src = resolve(REPO_ROOT, from);+ if (!existsSync(src)) {+ if (optional) continue;+ return `the Dockerfile COPYs ${from}, which does not exist in the build context`;+ }+ const dst = join(stage, to);+ mkdirSync(dirname(dst), { recursive: true });+ cpSync(src, dst, { recursive: true, filter: (p) => !p.split(/[\\/]/).includes('node_modules') });+ }+ const modules = resolve(REPO_ROOT, 'node_modules');+ if (!existsSync(modules)) return 'node_modules is missing: run `npm install` so the boot check can load the worker';+ symlinkSync(modules, join(stage, 'node_modules'), 'dir');++ const env = { ...process.env, NODE_ENV: 'production', SNIPER_MODE: 'simulate' };+ for (const k of ['DATABASE_URL', 'POSTGRES_URL', 'NEON_DATABASE_URL', 'PORT']) delete env[k];+ const res = spawnSync(process.execPath, ['workers/agent-sniper/index.js'], {+ cwd: stage, env, encoding: 'utf8', timeout: 60_000,+ });+ const out = `${res.stdout || ''}${res.stderr || ''}`;+ if (/missing required env var: DATABASE_URL/.test(out)) return null;+ const detail = out.split('\n').filter(Boolean).slice(0, 12).join('\n');+ return 'the worker does not boot from the image file set. A module or data file it loads is not COPYd by workers/agent-sniper/Dockerfile:\n' + detail;+}+function build() {if (SKIP_BUILD) { warn('--skip-build: reusing the current :latest image'); return; }log('building + pushing image via Cloud Build (this can take several minutes)…');@@ -248,6 +325,7 @@ async function main() {ensureServiceAccount();ensureRepo();checkSecrets();+ verifyImageBoots();build();deploy();await verifyHeartbeat();diff --git a/workers/agent-sniper/Dockerfile b/workers/agent-sniper/Dockerfileindex 0a1a17a94..5545e8091 100644--- a/workers/agent-sniper/Dockerfile+++ b/workers/agent-sniper/Dockerfile@@ -31,8 +31,14 @@ RUN npm ci --ignore-scripts || npm install --ignore-scripts# createMayhemFilter from packages/agent-sniper/src/mayhem-filter.js (self-contained,# only depends on @solana/web3.js which is already a root dependency) — only src/ is# copied, not the whole package (its own node_modules/tests/bin are unused at runtime).+# data/plans.json is read at module load by api/payments/_config.js, which the+# sniper reaches through api/_lib/pump-platform-fee.js (the trade fee). Without+# it the worker dies with ENOENT before it opens the health port, so Cloud Run+# refuses the revision. `npm run deploy:sniper` boots this exact COPY set before+# it builds (verifyImageBoots), so a new runtime read outside it fails there.COPY agent-payments-sdk ./agent-payments-sdkCOPY api ./api+COPY data/plans.json ./data/plans.jsonCOPY src ./srcCOPY packages/agent-sniper/src ./packages/agent-sniper/srcCOPY workers/agent-sniper ./workers/agent-sniperdiff --git a/workers/agent-sniper/README.md b/workers/agent-sniper/README.mdindex 1f83e021b..9e9f08dae 100644--- a/workers/agent-sniper/README.md+++ b/workers/agent-sniper/README.md@@ -374,10 +374,13 @@ with tiny caps to land one real trade. `Ctrl-C` drains in-flight buys and exits.The worker runs in production as **its own Cloud Run service, `agent-sniper`**(project `aerial-vehicle-466722-p5`, region `us-central1`), separate from-`three-ws-api`. It has no HTTP port: it is a long-lived background process, so-it runs with `--no-cpu-throttling` and `minScale=maxScale=1` (see the-single-worker assumption above; a second instance would race the budget and-concurrency caps).+`three-ws-api`. It is a long-lived background process, so it runs with+`--no-cpu-throttling` and `minScale=maxScale=1` (see the single-worker+assumption above; a second instance would race the budget and concurrency+caps). Its only HTTP surface is a tiny liveness endpoint on `$PORT`, opened+because Cloud Run refuses a revision whose startup probe cannot connect: a+worker that crashes while loading its modules never opens it, so the rollout+fails and traffic stays on the previous revision.**It does not ride along with an API deploy.** A fix merged to `main` keepsrunning the old image until this service is explicitly rolled, which has more@@ -390,8 +393,18 @@ gcloud run services describe agent-sniper --region us-central1 \--format="value(status.latestReadyRevisionName)"```-Build (from the REPO ROOT, because the Dockerfile copies `api/`, `src/`, `packages/`,-and `agent-payments-sdk/`), then roll the service onto the new image:+The deploy is one command, `npm run deploy:sniper` (`scripts/deploy-sniper.mjs`).+On an existing service it rolls `gcloud run services update --image`, which keeps+the running env (including `SNIPER_MODE=live`) instead of re-applying the+checked-in manifest. Before it spends a Cloud Build it boots `index.js` from a+tree holding only what the Dockerfile COPYs, so a module or data file the image+lacks fails in seconds rather than as a refused revision after the build. That+refusal happened on 2026-09-29 (revision `agent-sniper-00034`): the image lacked+`data/plans.json`, which `api/payments/_config.js` reads at load.++By hand: build (from the REPO ROOT, because the Dockerfile copies `api/`, `src/`,+`data/plans.json`, `packages/agent-sniper/src` and `agent-payments-sdk/`), then+roll the service onto the new image:```bashgcloud builds submit --config workers/agent-sniper/cloudbuild.yaml \