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(agent-orders): load .env.local so the documented worker run finds its credentials
nirholas5f894a15eff8
diff --git a/CLAUDE.md b/CLAUDE.mdindex 047427bd6..b5625eb4f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -34,7 +34,7 @@ Agents stopping mid-task to ask a question is a failure mode the owner explicitl| Missing env var / credential | Look in `.env` and `.env.local`, then the Cloud Run service (`gcloud run services describe three-ws-api --region us-central1 --project aerial-vehicle-466722-p5 --format=yaml`), then Secret Manager (`gcloud secrets list`). Never trust `vercel env pull` (returns empty for secrets). Update single vars with `--update-env-vars` (merges); `--set-env-vars` REPLACES the whole set, so never use it for one key. If a credential truly exists nowhere, build the feature fully wired behind the env var, prove it with a mock-free dry run, and list the single missing var in your report. || A QA login for authed page testing | `AUDIT_EMAIL` / `AUDIT_PASSWORD` in `.env` are a real production QA account. Unauthenticated sweep: `npm run audit:web`. Authed sweep: `npm run audit:web:login`. || GCP access / project facts | Already authenticated in this workspace. Project `aerial-vehicle-466722-p5`, region `us-central1`. Fleet + quota + pre-approved scaling: `docs/ops/gcp-credits-plan.md`. Full production runbook (LB/DNS/TLS/env/rollback): `docs/ops/gcp-production.md`. Logs: `gcloud logging read 'resource.type="cloud_run_revision" resource.labels.service_name="three-ws-api" textPayload:"<term>"' --freshness=24h`. |-| The database | `DATABASE_URL` in `.env` (Neon); production's authoritative copy is on the Cloud Run service env. Migrations: `npm run db:status` previews pending ones, `npm run db:check` is the deploy gate (exit 4 if pending), and **`npm run db:migrate` APPLIES immediately, with no dry run** (the npm script hardcodes `--apply`). Read `db:status` before you ever run `db:migrate`; it applies every pending migration in `api/_lib/migrations/`, not just yours. `forge_creations` carries per-generation backend/status/error/prompt: the fastest ground truth for generation issues. |+| The database | `DATABASE_URL` in `.env.local` (Neon); `.env` currently holds only the QA audit login, so a script that loads `.env` alone dies on `missing required env var: DATABASE_URL`. Production's authoritative copy is on the Cloud Run service env. Migrations: `npm run db:status` previews pending ones, `npm run db:check` is the deploy gate (exit 4 if pending), and **`npm run db:migrate` APPLIES immediately, with no dry run** (the npm script hardcodes `--apply`). Read `db:status` before you ever run `db:migrate`; it applies every pending migration in `api/_lib/migrations/`, not just yours. `forge_creations` carries per-generation backend/status/error/prompt: the fastest ground truth for generation issues. || GCP quota hit | File the increase request immediately (`gcloud` or console link in your report), then route around it: lower minScale on an idle service, use another region, or queue behind existing capacity. Never park the task on the quota. || Third-party API down / throttled | Every lane has a failover chain (forge lanes, LLM chain, RPC providers). Use it. If a chain is missing a rung, adding one is part of the task. || Ambiguous product decision | Pick the option that is most reversible and closest to existing platform patterns, implement it, and record the decision + alternative in your report. A shipped reasonable default beats a stalled question. |@@ -305,7 +305,7 @@ The whole build + submit + purge in one command: `npm run deploy:gcp:full`.- Frontend: vanilla JS modules + Vite (`npm run dev`, port 3000).- 3D: Three.js with glTF/GLB.- Backend touchpoints: serverless-style handlers in `api/`, workers in `workers/`.-- **Production runs on Google Cloud Run, NOT Vercel** (migrated 2026-07-07 after Vercel disabled the deployment). One container ([server/index.mjs](server/index.mjs)) serves the static frontend, the vercel.json route table, and all `api/**` handlers; the crons (105 as of 2026-08-11, see vercel.json) run on Cloud Scheduler. `vercel.json` is a LIVE config file: `server/index.mjs` reads its `routes` array on boot (split at the `{handle:"filesystem"}` marker into pre- and post-filesystem phases), and `scripts/create-gcp-scheduler.mjs` reads its `crons` array to sync Cloud Scheduler jobs. The server itself never reads `crons`. Never delete `vercel.json` as a leftover. GCP builds/deploys must pin the `three-ws-build@` (build) and `three-ws@` (runtime) service accounts; the project's default compute SA was deleted. Deploys: see the "Deploy runbook" section above.+- **Production runs on Google Cloud Run, NOT Vercel** (migrated 2026-07-07 after Vercel disabled the deployment). One container ([server/index.mjs](server/index.mjs)) serves the static frontend, the vercel.json route table, and all `api/**` handlers; the crons (106 as of 2026-08-14, see vercel.json) run on Cloud Scheduler. `vercel.json` is a LIVE config file: `server/index.mjs` reads its `routes` array on boot (split at the `{handle:"filesystem"}` marker into pre- and post-filesystem phases), and `scripts/create-gcp-scheduler.mjs` reads its `crons` array to sync Cloud Scheduler jobs. The server itself never reads `crons`. Never delete `vercel.json` as a leftover. GCP builds/deploys must pin the `three-ws-build@` (build) and `three-ws@` (runtime) service accounts; the project's default compute SA was deleted. Deploys: see the "Deploy runbook" section above.- **Env-var trap:** `vercel env pull` returns EMPTY for secret-type vars. Never trust a Vercel env export as complete. Production env lives on the Cloud Run service (`gcloud run services describe/update three-ws-api --region us-central1`).- Solana/agent SDKs in `sdk/`, `solana-agent-sdk/`, `agent-payments-sdk/`.- Real APIs in use: Pump.fun feed, Solana RPC, OpenAI/Anthropic via worker proxies. Never mock these.diff --git a/package.json b/package.jsonindex 94668f658..d25c4e5a8 100644--- a/package.json+++ b/package.json@@ -340,8 +340,8 @@"worker:oracle": "node --env-file-if-exists=.env workers/oracle/index.js","worker:sniper": "node workers/agent-sniper/index.js","worker:sniper:live": "SNIPER_MODE=live node workers/agent-sniper/index.js",- "worker:orders": "node --env-file-if-exists=.env workers/agent-orders/index.js",- "worker:orders:live": "ORDERS_MODE=live node --env-file-if-exists=.env workers/agent-orders/index.js",+ "worker:orders": "node --env-file-if-exists=.env --env-file-if-exists=.env.local workers/agent-orders/index.js",+ "worker:orders:live": "ORDERS_MODE=live node --env-file-if-exists=.env --env-file-if-exists=.env.local workers/agent-orders/index.js","worker:okx-bot": "node workers/okx-chat-bot/index.js","worker:mm": "node workers/agent-mm/index.js","worker:mm:live": "MM_MODE=live node workers/agent-mm/index.js",diff --git a/prompts/swarm-100/worker-agent-orders.md b/prompts/swarm-100/worker-agent-orders.mddeleted file mode 100644index 63bd4985e..000000000--- a/prompts/swarm-100/worker-agent-orders.md+++ /dev/null@@ -1,98 +0,0 @@-# Worker audit: workers/agent-orders--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Read workers/agent-orders/README.md and its build config (cloudbuild.yaml,- Dockerfile, package.json; whichever exist).-2. Is it deployed?-- export PATH="$HOME/google-cloud-sdk/bin:$PATH"- gcloud run services list --project aerial-vehicle-466722-p5 --region us-central1 | grep -i "agent-orders" || echo "not deployed as its own service"--3. If deployed: which commit is the running revision built from, and does main- contain fixes it has not picked up? A fix in main can sit undeployed for- days; never call a bug unfixed without checking the running revision.-4. Logs, last 24h, if deployed:-- gcloud logging read 'resource.type="cloud_run_revision" resource.labels.service_name="<service name from step 2>"' --freshness=24h --limit 100 --project aerial-vehicle-466722-p5--## Task: bring this worker to verified-healthy--1. README accuracy: what it does, how to run it, its inputs and outputs. Fix- every stale claim; a README that lies fails the audit.-2. Build it the way its own config says. The build must succeed from a clean- checkout of this worktree. Model workers that need weights stage them from- gs://three-ws-model-weights (staging weights is part of the job, not a- blocker).-3. Run its tests; add a smoke test if it has none that proves its core path.-4. If deployed: last 24h of logs free of unhandled errors; fix root causes in- code and commit. Redeploying is owner-gated: prepare everything so the- deploy is one command and say so in the report.-5. If not deployed by design: its README must state how and where it runs, and- that path must be verified locally.--## Definition of done--- [ ] Build succeeds from this worktree with the worker's own config.-- [ ] Tests pass, including at least one core-path smoke test.-- [ ] README verified accurate against the code.-- [ ] If deployed: running revision identified, 24h logs clean or root causes- fixed and committed (deploy itself flagged for the owner).-- [ ] npm run check:rules -- --paths <touched files> exits 0.--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |-| Playwright browser missing | npx playwright install chromium |-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |--## Close out (required)--1. Verify every Definition of done line with the actual command output in- front of you. Never claim a line you did not verify.-2. Commit with explicit paths and a subject that describes the diff (house- style: type(scope): what changed and why a reader cares).-3. Delete this prompt file in that same commit:-- git rm prompts/swarm-100/worker-agent-orders.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/workers/agent-orders/README.md b/workers/agent-orders/README.mdindex 5e27dfc65..88bcb182f 100644--- a/workers/agent-orders/README.md+++ b/workers/agent-orders/README.md@@ -83,9 +83,14 @@ npm run worker:orders # ORDERS_MODE=simulate (real quotes, no broadcastnpm run worker:orders:live # ORDERS_MODE=live (real fills)```-Both scripts load the repo-root `.env` if it exists (`node --env-file-if-exists`),-so a local run needs no extra flags. The container sets its env from Cloud Run-instead and ships no `.env`. On boot the worker prints one JSON line per event+Both scripts load the repo-root `.env` **and** `.env.local` if they exist+(`node --env-file-if-exists`, applied in that order so `.env.local` wins), so a+local run needs no extra flags. Loading both matters: in this worktree `.env`+holds only the QA audit login and the worker's own credentials+(`DATABASE_URL`, `JWT_SECRET`, `WALLET_ENCRYPTION_KEY`, `SOLANA_RPC_URL`) live in+`.env.local`. Reading `.env` alone makes the worker die at boot on+`missing required env var: DATABASE_URL`. The container sets its env from Cloud+Run instead and ships neither file. On boot the worker prints one JSON line per event(`boot`, `housekeeping`, `fill`, …) and writes a `bot_heartbeat` row under theworker name `agent-orders`, which is the fastest liveness check:@@ -139,13 +144,16 @@ node --env-file-if-exists=.env -e "import('./workers/agent-orders/market.js').thAnd a short `npm run worker:orders` run writes the heartbeat row and answers theliveness endpoint (`PORT=8791 npm run worker:orders`, then-`curl localhost:8791`). Both were last exercised on 2026-08-11: quote resolved in-~4 s through the RPC failover chain, sweeps ran at 318 ms each.+`curl localhost:8791`). Both were last exercised on 2026-08-14: the quote came+back as a real graduated-AMM price in ~12 s through the RPC failover chain, and a+30 s boot ran 5 sweeps (427 ms each), answered `/` with+`{"ok":true,"worker":"agent-orders",…}`, wrote `bot_heartbeat`, and drained+cleanly on SIGTERM.## Deploy**Status: built and wired, not yet running in production** (re-checked-2026-08-11: no `agent-orders` service, no job, and no image in the `workers`+2026-08-14: no `agent-orders` service, no job, and no image in the `workers`Artifact Registry repo). No order fires on its own until someone runs the commandbelow. Orders createdthrough the API sit in `active` until then, which is the honest failure mode@@ -168,7 +176,9 @@ must pass it or the image tag comes out empty. The four secrets the config mount(`agent-orders-database-url`, `agent-orders-jwt-secret`,`agent-orders-wallet-encryption-key`, `agent-orders-solana-rpc-url`) already existand are readable by the `three-ws@` runtime service account; all four were-re-checked on 2026-08-11 and hash identical to what `three-ws-api` runs with. Do **not** repoint them at+re-checked on 2026-08-14 (each carries the `roles/secretmanager.secretAccessor`+binding, and each payload hashes identical to the value `three-ws-api` runs+with). Do **not** repoint them atthe project's generic `JWT_SECRET` / `WALLET_ENCRYPTION_KEY` secrets: those holdolder values and would break custodial key recovery on every live fill.@@ -191,15 +201,30 @@ gcloud builds submit . \```Same Dockerfile, same repo-root context, no push and no deploy. Last green-2026-08-11 (build `c5f6ba8a`, 4m30s, all 14 layers).+2026-08-14 (build `28d998f3`, 4m43s, all 14 layers, 95.7 MiB uploaded).The equivalent local build is `docker build -f workers/agent-orders/Dockerfile-t agent-orders .`, but expect it to fail on a dev container: the image installs-the whole root workspace (3078 packages) and then compiles `agent-payments-sdk`,+the whole root workspace (3000+ packages) and then compiles `agent-payments-sdk`,which is more memory than a Codespace has, and the local context is not filteredby `.gcloudignore` so it also walks a multi-GB `dist/`. Cloud Build is thesupported path.+A green build proves less than it looks like it does, because two ways of+breaking this image only show up when the container boots. Re-check both if you+add an import to any file under `workers/agent-orders/`:++- **Every module the worker reaches must be inside the Dockerfile's `COPY` set**+ (`agent-payments-sdk/`, `api/`, `src/`, `workers/agent-orders/`, and the single+ file `workers/agent-sniper/amm-exit.js`). Reaching outside it builds fine and+ then dies at `ERR_MODULE_NOT_FOUND` on the first sweep.+- **Every bare import must be a prod dependency.** The image runs+ `npm prune --omit=dev`, so an import that resolves to a devDependency+ disappears from the shipped layer.++Both held on 2026-08-14: 59 modules reached, all inside the `COPY` set, and all+17 distinct bare specifiers resolve to prod dependencies or the workspace SDK.+One thing about the build log is worth knowing before you read it as a failure:the repo-root `package-lock.json` is out of sync with `package.json`, so theimage's `npm ci` exits with EUSAGE (missing `@ethereum-attestation-service/*`