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
refactor(cron): drop the dead error/env imports the shared requireCron gate replaced
nirholas471ca34d3494
diff --git a/api/cron/relayer-balance-check.js b/api/cron/relayer-balance-check.jsindex 3b679476e..038d057e6 100644--- a/api/cron/relayer-balance-check.js+++ b/api/cron/relayer-balance-check.js@@ -21,8 +21,7 @@// Signer secrets themselves are optional: an unconfigured signer is skipped, not// flagged — only configured-but-underfunded signers alert.-import { error, json, method, wrapCron } from '../_lib/http.js';-import { env } from '../_lib/env.js';+import { json, method, wrapCron } from '../_lib/http.js';import { sendOpsAlert } from '../_lib/alerts.js';import { SOLANA_SIGNERS, resolveSignerPubkey } from '../_lib/solana-signers.js';import { requireCron } from '../_lib/cron-auth.js';diff --git a/api/cron/rewards-distribute.js b/api/cron/rewards-distribute.jsindex d8a29579d..5646ee3c8 100644--- a/api/cron/rewards-distribute.js+++ b/api/cron/rewards-distribute.js@@ -16,8 +16,7 @@// Standalone (not [name].js) so the import graph stays minimal — just the token// config, the holder snapshot reader, and the pure distribution math.-import { error, json, method, wrapCron } from '../_lib/http.js';-import { env } from '../_lib/env.js';+import { json, method, wrapCron } from '../_lib/http.js';import { TOKEN_MINT, ATOMICS_PER_TOKEN, treasuryWalletOrNull, rewardsWalletOrNull } from '../_lib/token/config.js';import { fetchHolderBalances } from '../_lib/coin/holders.js';import { getBalances } from '../_lib/balances.js';diff --git a/api/cron/signal-fanout.js b/api/cron/signal-fanout.jsindex 833c87c6e..2e5aefa96 100644--- a/api/cron/signal-fanout.js+++ b/api/cron/signal-fanout.js@@ -18,7 +18,7 @@// Bounded so a 2-minute cron can never run away: only feeds with recent publisher// activity emit, and each subscription delivers at most N emissions per run.-import { error, json, method, wrapCron } from '../_lib/http.js';+import { json, method, wrapCron } from '../_lib/http.js';import { sql } from '../_lib/db.js';import { syncFeedEmissions, deliverSubscription } from '../_lib/signal-engine.js';import { requireCron } from '../_lib/cron-auth.js';diff --git a/api/cron/sniper-evolve.js b/api/cron/sniper-evolve.jsindex 76a210c73..aeff8953f 100644--- a/api/cron/sniper-evolve.js+++ b/api/cron/sniper-evolve.js@@ -16,8 +16,7 @@// SNIPER_EVOLVE_APPLY = 1 enact mutations (default: dry-run, log only)// plus the EVOLVE_* tunables read by runEvolve (fleet budget, floors, samples).-import { error, json, method, wrapCron } from '../_lib/http.js';-import { env } from '../_lib/env.js';+import { json, method, wrapCron } from '../_lib/http.js';import { runEvolve } from '../../scripts/sniper-evolve.mjs';import { requireCron } from '../_lib/cron-auth.js';diff --git a/api/cron/sniper-loops-health.js b/api/cron/sniper-loops-health.jsindex 9c19f8715..934529d5f 100644--- a/api/cron/sniper-loops-health.js+++ b/api/cron/sniper-loops-health.js@@ -13,7 +13,7 @@// rather than swallowed: an unqueryable ledger is exactly the kind of silence// this watchdog exists to catch.-import { error, json, method, wrapCron } from '../_lib/http.js';+import { json, method, wrapCron } from '../_lib/http.js';import { sql } from '../_lib/db.js';import { sendOpsAlert } from '../_lib/alerts.js';import { LOOPS, classifyLlmRouting, classifyLoopHealth, describeStale, findWalletlessArms, isFallbackAnswer } from '../_lib/sniper-loops-health.js';diff --git a/api/cron/sniper-optimize.js b/api/cron/sniper-optimize.jsindex c1ed8a13c..826c66c52 100644--- a/api/cron/sniper-optimize.js+++ b/api/cron/sniper-optimize.js@@ -28,8 +28,7 @@// SNIPER_OPTIMIZER_WINDOW = 24h | 7d | 30d (default 7d)// SNIPER_OPTIMIZER_MAX_APPLIES = integer (default 5 arms mutated/run)-import { error, json, method, wrapCron } from '../_lib/http.js';-import { env } from '../_lib/env.js';+import { json, method, wrapCron } from '../_lib/http.js';import { sql } from '../_lib/db.js';import { recordDecision } from '../_lib/reasoning-ledger.js';import { proposeAdjustments } from '../_lib/sniper-optimizer.js';@@ -193,8 +192,8 @@ export default wrapCron(async (req, res) => {if (willApply) {// Enact each proposal on the strategy row (bounded values only).for (const p of proposals) {- await applyProposal(r.strategy_id, p.field, p.to);- }+ await applyProposal(r.strategy_id, p.field, p.to);+ }// Log the tuning to the agent's tamper-evident ledger so the loop's// own decisions are auditable next to the trades that drove them.const dec = await recordDecision({diff --git a/public/changelog.json b/public/changelog.jsonindex 03e1073dc..e3a68276e 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-10T16:28:46.720Z",+ "generated_at": "2026-08-10T16:34:05.109Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -9,23 +9,22 @@{"date": "2026-08-10","type": "update",- "title": "The embed release manifest answers cheap polls and says plainly when a build is missing",- "summary": "Sites that pin an <agent-3d> bundle version can poll /api/agent-3d/versions to learn about a new release. That endpoint now returns an ETag derived from the manifest contents, so a poller that sends the tag back gets an empty 304 Not Modified between releases instead of re-downloading the same JSON, and gets the full manifest the moment a new version publishes. When a deploy ships without the manifest the endpoint used to answer \"not found\" whether the file was missing or corrupt; it now says which of the two it is, so the fix is obvious from the response alone. The manifest is also documented for embedders alongside the static /agent-3d/versions.json copy.",- "link": "/docs/web-component",+ "title": "The CA to x402 tool now always hands you a three.ws payment address",+ "summary": "Paste a contract address into the CA to x402 tool and it generates a paid data service for that token, complete with copy-paste commands you run to pay for and call it. Those commands were built from the web address in your browser's request, which anyone could forge: a crafted link could have handed a visitor a set of \"pay here\" commands pointing at somebody else's server, and because the answer is cached at the edge, that swapped copy could then have been served on to other visitors. The generated endpoint and every snippet are now pinned to three.ws itself, so what you copy is always ours no matter how the page was reached.",+ "link": "/ca2x402","tags": [- "improvement",- "sdk"+ "security",+ "fix"]},{"date": "2026-08-10","type": "update",- "title": "The public asset catalog now answers a bad filter honestly",- "summary": "The open asset list at /api/assets, which anyone can call to browse our accessories, starter animations, and lighting environments, used to answer a mistyped filter with an empty list and a 200 OK, then cache that empty answer for an hour. A typo looked exactly like an empty catalog. It now returns a clear error naming the accepted values, and never caches it. Two more fixes came out of the same pass: browsers can read the response cross-origin on error replies and preflight checks, not just on success, and HEAD requests from uptime monitors and CDNs are answered instead of rejected. The environment list is also read straight from the viewer's own presets now, so names can no longer drift between the site and the API.",- "link": null,+ "title": "The chat plugin now tells you when your Agent ID is wrong",+ "summary": "In the SperaxOS and LobeChat plugin, a mistyped or deleted Agent ID used to come back as a cheerful confirmation while the avatar panel stayed empty, so the model told you it had bound an agent that does not exist. The plugin now checks the ID against your real agents before answering: a bad ID returns a clear error pointing you back to the dashboard to recopy it, and a good one comes back with the agent name so you can see at a glance which identity the panel is wearing. Stray spaces around a pasted ID are trimmed instead of breaking the binding.",+ "link": "/docs/embedding","tags": [- "fix",- "improvement"+ "fix"]},{@@ -3947,7 +3946,7 @@"type": "update","title": "Solana name registration works again, and embeds stop crashing on older phones","summary": "Claiming a .sol domain for an agent, and claiming your own name under threews.sol, both ran against a Solana naming library so old that the functions doing the registering had been renamed out from under us: the calls resolved to nothing and the whole attempt failed. The library is now current, every naming path has been re-checked against the live Solana mainnet, and handing a fresh subdomain to its new owner no longer trips over an account that the same transaction is still creating. Looking up a wallet's primary name also stops reporting a name the wallet no longer owns. Separately, the embeddable 3D avatar used a newer JavaScript feature than some older Android browsers ship, so the avatar page went blank instead of loading; the missing piece is now included in the embed, which matters because the embed is designed to run on other people's sites where we do not get to pick the browser.",- "link": "/embed",+ "link": "/docs/embedding","tags": ["fix"]diff --git a/scripts/sniper-evolve.mjs b/scripts/sniper-evolve.mjsindex 13e488153..0aa2c7e23 100644--- a/scripts/sniper-evolve.mjs+++ b/scripts/sniper-evolve.mjs@@ -43,6 +43,7 @@ import { execSync } from 'node:child_process';import './lib/gcloud-path.mjs';import { createRequire } from 'node:module';import { budgetWeightFor, classifyAutonomy } from '../api/_lib/sniper-autonomy.js';+import { resolveDatabaseUrl as resolveConfiguredDatabaseUrl } from '../api/_lib/env.js';const require = createRequire(import.meta.url);const { Pool } = require('@neondatabase/serverless');@@ -61,8 +62,18 @@ const REVIVE_AFTER_HOURS = num('EVOLVE_REVIVE_HOURS', 24); // re-test a r// safety field appearing here would be a bug; the list is short and reviewed.const WRITABLE = new Set(['enabled', 'daily_budget_lamports']);+// Ask the platform's own resolver first. It reads every DATABASE_URL alias and+// the .env file, which is how the connection string is configured everywhere+// except a bare shell, so the cron (api/cron/sniper-evolve.js) resolves without+// ever reaching for a CLI. That mattered: a raw `process.env.DATABASE_URL` read+// missed the alias set, and the gcloud fallback below then ran inside the+// request, where it either fails on expired local credentials or, in the Cloud+// Run container that has no gcloud binary, turns the whole cron into an error+// response. The shellout survives only as the last resort for an operator+// running the CLI on a machine with no env configured at all.function resolveDatabaseUrl() {- if (process.env.DATABASE_URL) return process.env.DATABASE_URL;+ const configured = resolveConfiguredDatabaseUrl();+ if (configured) return configured;const svc = JSON.parse(execSync('gcloud run services describe three-ws-api --region us-central1 --project aerial-vehicle-466722-p5 --format=json',{ encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },diff --git a/tests/agent-trade-endpoint.test.js b/tests/agent-trade-endpoint.test.jsindex c77e5eca6..9473b6856 100644--- a/tests/agent-trade-endpoint.test.js+++ b/tests/agent-trade-endpoint.test.js@@ -467,3 +467,68 @@ describe('POST /api/agents/:id/trade — execution', () => {expect(ammExit.buildAmmSellInstructions).toHaveBeenCalled();});});++// ── PUT /trade/limits input validation ───────────────────────────────────────+// normalizeTradeLimits coerces anything it cannot read into "no cap" (or the+// default), so before the boundary validated its input a typo like+// { per_trade_sol: -1 } DELETED the owner's existing per-trade ceiling and+// answered 200 as though it had tightened it. A spend guardrail must never be+// relaxed by a value the server could not parse.++describe('PUT /api/agents/:id/trade/limits — input validation', () => {+ async function putLimits(body) {+ const req = mockReq({ method: 'PUT', url: `/api/agents/${AGENT_ID}/trade/limits`, body });+ const res = mockRes();+ await handler(req, res, AGENT_ID, 'limits');+ return res;+ }++ function savedLimits() {+ const write = sqlState.calls.filter((c) => /update agent_identities set meta/.test(c.q)).pop();+ return write ? JSON.parse(write.values[0]).trade_limits : null;+ }++ it('rejects a negative cap instead of silently clearing it', async () => {+ const res = await putLimits({ per_trade_sol: -1 });+ expect(res.statusCode).toBe(400);+ expect(res.json.error).toBe('validation_error');+ expect(savedLimits()).toBeNull();+ });++ it('rejects an unparseable cap instead of silently clearing it', async () => {+ const res = await putLimits({ daily_budget_sol: 'abc' });+ expect(res.statusCode).toBe(400);+ expect(savedLimits()).toBeNull();+ });++ it('rejects max_concurrent below 1, which normalization would read as "no ceiling"', async () => {+ const res = await putLimits({ max_concurrent: 0 });+ expect(res.statusCode).toBe(400);+ expect(savedLimits()).toBeNull();+ });++ it('rejects a non-boolean kill switch', async () => {+ const res = await putLimits({ kill_switch: 'yes' });+ expect(res.statusCode).toBe(400);+ expect(savedLimits()).toBeNull();+ });++ it('rejects an out-of-range price-impact breaker', async () => {+ const res = await putLimits({ max_price_impact_pct: 500 });+ expect(res.statusCode).toBe(400);+ expect(savedLimits()).toBeNull();+ });++ it('accepts real caps, numeric strings, and an explicit null clear', async () => {+ const set = await putLimits({ per_trade_sol: 0.5, daily_budget_sol: '2', max_concurrent: 3, kill_switch: true });+ expect(set.statusCode).toBe(200);+ expect(set.json.data.limits.per_trade_sol).toBe(0.5);+ expect(set.json.data.limits.daily_budget_sol).toBe(2);+ expect(set.json.data.limits.max_concurrent).toBe(3);+ expect(set.json.data.limits.kill_switch).toBe(true);++ const cleared = await putLimits({ per_trade_sol: null });+ expect(cleared.statusCode).toBe(200);+ expect(cleared.json.data.limits.per_trade_sol).toBeNull();+ });+});