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: enhance database connection handling to support multiple aliases; improve error logging during outages
qbdz34c1593844fd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ca65bb71..0d8c769aa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,9 +27,11 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Deploy your agent to the live wall in four guided steps** — Going live is now a wizard, not a docs hunt. Open the agent screen with no agent picked and a four-step flow walks you through it: choose your agent, generate its key in one click (shown once, with a copy button), copy the exact run command for your setup — local npm, Docker, or Browserbase — and then watch a live status strip that flips to “You’re live on the wall” the instant your agent pushes its first frame, with a direct link to its card on the public wall. A progress tracker, a searchable agent list, inline error recovery, and a “not appearing?” troubleshooter round it out. (`/agent-screen`) `[feature, improvement]`- **Fixed the footer overlapping the Payment Sessions page** — On the Agent Payment Sessions page the site footer was rendering on top of the whole page, hiding your sessions, stats, and the New Session button behind it. It now sits where it belongs at the bottom of the page. (`/payments`) `[fix]`- **Full interactive trading chart on every coin page** — Each coin's profile page now lets you switch its price chart between the fast native view and a full interactive DexScreener terminal — candlesticks, zoom, on-chart trades and liquidity — embedded right on the page and keyed to the coin's mint, with a one-tap link to open it in DexScreener. The chart matches your light/dark theme and only loads the heavier terminal when you choose it, so the page stays quick by default. (`/launches`) `[improvement]`+- **Homepage backdrop no longer trips up unusual browsers** — The animated dragon backdrop on the homepage now checks that your browser fully supports canvas text rendering before it draws, and simply skips itself if not. Some headless and embedded browsers ship a canvas that's missing text-measurement support, which previously threw a silent error on page load; the backdrop now bows out cleanly on those clients while everyone else sees it as normal. `[fix]`- **Live 3D sentiment heatmap on agent screens** — A live 3D market-sentiment heatmap now runs on agent screens — tokens glow by momentum with $THREE at the center, and the agent calls out the movers in real time. Cold-blue tiles cool off, green-hot ones surge, and the field breathes with the market. Press H to open it, hover a tile for details, or click ◎ $THREE to focus the camera on the anchor. (`/agent-screen`) `[feature]`- **Live agent wall spins up a real browser feed the instant you look** — Scroll the live agent wall and the card you're actually looking at now spins up a real browser feed within seconds — no more waiting on every agent at once. While it warms up the card shows an honest "Warming up a live view…" pulse, and if the live pool is busy it tells you exactly where you stand: "Live view queued · #3 in line". Scroll past and the slot quietly frees for the next viewer. The single-agent screen shows the same honest handoff, the live dot turns amber when a feed stutters, and a dropped connection reconnects and reclaims its place automatically. (`/agents-live`) `[feature, improvement]`- **Live Avatar Forge: build a 3D avatar on camera** — On an agent's live screen you can now type a prompt and watch a 3D avatar get generated, rigged, and animated in real time — free. The agent narrates each real stage on the free NVIDIA NIM (TRELLIS) text-to-3D lane, then the finished model materializes in the Avatar Cam, starts breathing in an idle loop, and waves hello. Open it in the 3D viewer or grab the model URL to set as your agent's look. Fresh forges also surface on the live agents wall. (`/agent-screen`) `[feature]`+- **Live data feeds stay online through database hiccups** — The Galaxy money-cam, Money Pulse, marketplace, and holder snapshots now find the platform's database automatically when it's connected through Vercel's or Neon's standard integration, instead of only looking under one exact setting name. A naming mismatch had previously left those feeds blank even though the database was healthy. The connection is now resolved from any of the standard names (and dashboard copy-paste whitespace is trimmed), so the live feeds keep showing real data. `[fix, infra]`- **Live portfolio scoreboard: net worth, 24h P&L, and a sparkline on every agent screen** — Watching an agent is now watching the score. The live agent screen carries a new Portfolio HUD — net worth in SOL and USD, a 24h change that ticks green or red, and a sparkline drawn from real value history — with the ranked holdings below it and $THREE pinned and featured at the top. On the live wall, each card gains a compact 24h change badge in its corner, so you can see at a glance which agents are winning. Every number is real on-chain valuation: holdings are valued live, owners get pushed updates between polls, and a wallet with no history yet shows an honest empty state instead of a fake curve. (`/agent-screen`) `[feature]`- **Live Trading Desk: watch an agent trade with a real-time PnL ticker** — An agent's live screen now reads like a trading desk. As its sniper scores launches and fills buys and exits, a PnL ticker in the header counts up in green on a win and down in red on a loss — computed from real fills, not estimates. Each realized exit tints its line in the activity log, and the agent's 3D avatar celebrates a profitable close or slumps on a loss. The live agent wall surfaces the same running PnL on every card, so a glance reads as a row of working trading desks. Click the ticker for a win/loss and realized breakdown. (`/agents-live`) `[feature]`- **Meet the agent behind each coin in interactive 3D** — Every coin page now shows the launching agent as a live, interactive 3D avatar right on the page — drag to orbit, scroll to zoom — instead of a flat thumbnail. Agents with their own model show it; the rest wear the shared base avatar so the stage is never empty. A "See in world" link drops that avatar straight into the walkable $THREE world. The 3D view only loads once it scrolls into view, so pages stay fast, and it falls back gracefully if a model can't load. (`/launches`) `[feature]`diff --git a/api/_lib/cosmetics-economy.js b/api/_lib/cosmetics-economy.jsindex 8b17ad896..211318787 100644--- a/api/_lib/cosmetics-economy.js+++ b/api/_lib/cosmetics-economy.js@@ -18,6 +18,7 @@import bs58 from 'bs58';import { sql } from './db.js';+import { databaseConfigured } from './env.js';import { getCosmetic } from './cosmetics.js';import { verifySiwsSignature } from './siws.js';import { transferSolanaUSDC } from './solana-transfer.js';@@ -45,7 +46,7 @@ export function isWallet(addr) {// True only when a durable economy DB is configured. Recording is best-effort: a// missing DB must never block an R22 unlock the buyer already paid for.export function economyDbConfigured() {- return !!process.env.DATABASE_URL;+ return databaseConfigured();}// ── Creator resolution ─────────────────────────────────────────────────────diff --git a/api/_lib/diorama-store.js b/api/_lib/diorama-store.jsindex 83446dc36..e78582a16 100644--- a/api/_lib/diorama-store.js+++ b/api/_lib/diorama-store.js@@ -14,10 +14,11 @@import { randomUUID } from 'node:crypto';import { sql } from './db.js';+import { databaseConfigured } from './env.js';import { normalizeDiorama } from '../../src/diorama/schema.js';export function dioramaStoreEnabled() {- return Boolean(process.env.DATABASE_URL);+ return databaseConfigured();}let _ensured = null;diff --git a/api/_lib/env.js b/api/_lib/env.jsindex 595f00729..bbcc31fc4 100644--- a/api/_lib/env.js+++ b/api/_lib/env.js@@ -162,6 +162,52 @@ const REDIS_CACHE_SOURCES = [['cache_KV_REST_API_URL', 'cache_KV_REST_API_TOKEN'],];+// Postgres connection-string aliases, in priority order. The bare DATABASE_URL+// is what every consumer expects, but the Vercel Postgres / Neon Marketplace+// integration injects the live connection string under DIFFERENT names —+// POSTGRES_URL (pooled), DATABASE_URL_UNPOOLED / POSTGRES_URL_NON_POOLING+// (direct), POSTGRES_PRISMA_URL (pgbouncer params), NEON_DATABASE_URL — and+// only mirrors it to DATABASE_URL if you wire that alias by hand. When the+// integration is connected but DATABASE_URL was never duplicated, every+// DB-backed read throws "Missing required env var: DATABASE_URL" and the whole+// data plane (galaxy, pulse, marketplace, holder snapshots) silently degrades+// to empty — the June 2026 incident. Resolving from the aliases makes the+// connection work the instant the integration is attached, with no dashboard+// step, exactly as pickPair() does for the Vercel-KV/Upstash Redis aliases.+// Pooled URLs come first: the @neondatabase/serverless HTTP driver is+// serverless-friendly and a pooled endpoint survives request fan-out best.+const DATABASE_URL_SOURCES = [+ 'DATABASE_URL',+ 'POSTGRES_URL',+ 'DATABASE_URL_UNPOOLED',+ 'POSTGRES_URL_NON_POOLING',+ 'NEON_DATABASE_URL',+ 'POSTGRES_PRISMA_URL',+];++// Resolve the first alias that holds a usable Postgres connection string.+// Trims dashboard-pasted whitespace/newlines (cred()) — an untrimmed trailing+// "\n" makes neon() throw "is not a valid URL" — and requires a postgres(ql)://+// scheme so a stray, unrelated value on one alias can't shadow a real URL on a+// lower-priority one. Returns undefined when no alias is configured.+function resolveDatabaseUrl() {+ for (const name of DATABASE_URL_SOURCES) {+ const v = cred(opt(name));+ if (v && /^postgres(ql)?:\/\//i.test(v)) return v;+ }+ return undefined;+}++// Public predicate for the "is the DB configured?" gates scattered across the+// store modules (forge-store, persona-store, …). They historically read+// `process.env.DATABASE_URL` directly, which reports "unconfigured" — silently+// disabling persistence — whenever the connection string lives under an alias.+// Routing them through this keeps a single source of truth for what counts as a+// configured database.+export function databaseConfigured() {+ return Boolean(resolveDatabaseUrl());+}+export const env = {get APP_ORIGIN() {return normalizeAppOrigin(opt('PUBLIC_APP_ORIGIN'));@@ -178,8 +224,14 @@ export const env = {return opt('VERCEL_ENV');},+ // Resolved from DATABASE_URL or any standard Vercel-Postgres/Neon integration+ // alias (see DATABASE_URL_SOURCES). Still throws when NONE is set so the+ // db.js graceful-degradation path (isDbUnavailableError → shared 503) keeps+ // working — the message is unchanged on purpose so that classifier matches.get DATABASE_URL() {- return req('DATABASE_URL');+ const url = resolveDatabaseUrl();+ if (!url) throw new Error('Missing required env var: DATABASE_URL');+ return url;},get S3_ENDPOINT() {diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.jsindex b298c02f7..4b8df81dc 100644--- a/api/_lib/forge-store.js+++ b/api/_lib/forge-store.js@@ -16,6 +16,7 @@import { createHash } from 'node:crypto';import { randomUUID } from 'node:crypto';import { sql, isDbUnavailableError } from './db.js';+import { databaseConfigured } from './env.js';import { putObject, publicUrl } from './r2.js';import { recordGenerationEvent } from './forge-events.js';@@ -34,7 +35,7 @@ const MAX_IMAGE_BYTES = 8 * 1024 * 1024;// deployment degrades to the stateless path instead of throwing on first use.export function forgeStoreEnabled() {return Boolean(- process.env.DATABASE_URL &&+ databaseConfigured() &&process.env.S3_ENDPOINT &&process.env.S3_BUCKET &&process.env.S3_PUBLIC_DOMAIN &&diff --git a/api/_lib/http.js b/api/_lib/http.jsindex 035f2f619..fcb9d14fd 100644--- a/api/_lib/http.js+++ b/api/_lib/http.js@@ -163,6 +163,24 @@ function correlationId() {return Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');}+// Throttle the log line for a database-unavailable outage to one per scope per+// minute (per warm lambda instance). A missing/rotated DATABASE_URL makes every+// DB-backed read reject, so without this a single misconfiguration produced+// thousands of identical `[api] unhandled` error lines + Sentry events in a few+// minutes — drowning real faults. The outage is already surfaced once via the+// deduped `db:unavailable` ops alert; here we only need a breadcrumb, at warn.+const _dbDownLoggedAt = new Map();+function logDbUnavailableOnce(scope, msg) {+ const now = Date.now();+ const last = _dbDownLoggedAt.get(scope) || 0;+ if (now - last < 60_000) return;+ _dbDownLoggedAt.set(scope, now);+ // Bound the map so a high-cardinality scope set (many distinct URLs) can't+ // grow it unbounded across a long-lived warm instance.+ if (_dbDownLoggedAt.size > 256) _dbDownLoggedAt.clear();+ console.warn(`[api] database unavailable — degrading ${scope}: ${msg}`);+}+// Log + capture + alert a server fault under a fresh correlation id WITHOUT// writing a response, and return the ref. The body-writing helpers below build// on this, but it's also the seam for handlers that must answer in a non-JSON@@ -175,6 +193,16 @@ function correlationId() {export function reportServerError(err, { code = 'internal_error', status = 500, context = {} } = {}) {const ref = correlationId();const detail = err?.message || String(err ?? 'unknown error');+ // A DB outage is infrastructure, not a code fault: throttle the log, skip the+ // Sentry capture, and collapse to the single shared `db:unavailable` alert so a+ // missing DATABASE_URL degrades quietly instead of flooding error tracking.+ if (isDbUnavailableError(err)) {+ logDbUnavailableOnce(code, detail);+ try {+ sendOpsAlert('database unavailable', `${detail}\nref ${ref}`, { signature: 'db:unavailable' });+ } catch { /* alerts best-effort */ }+ return ref;+ }console.error(`[server-error ${ref}] ${code} (${status}): ${detail}`);try {captureException(err instanceof Error ? err : new Error(detail), { ref, code, status, ...context });@@ -194,6 +222,19 @@ export function reportServerError(err, { code = 'internal_error', status = 500,// is logged + captured server-side under a correlation id the caller can quote// to support; the client only sees a generic description + the ref.export function serverError(res, status, code, err, extra = {}) {+ // Coerce a DB outage to 503 + Retry-After regardless of the caller's status, so+ // boundaries that catch internally (sitemap, deployments) advertise "retry+ // shortly" to clients and CDNs exactly like wrap() does, instead of a hard 500.+ if (isDbUnavailableError(err)) {+ const ref = reportServerError(err, { code, status: 503 });+ if (typeof res.setHeader === 'function') res.setHeader('retry-after', '30');+ return json(res, 503, {+ error: 'service_unavailable',+ error_description: 'database temporarily unavailable — retry shortly',+ ref,+ ...extra,+ }, { 'cache-control': 'no-store' });+ }const ref = reportServerError(err, { code, status });return json(res, status, {error: code,@@ -383,17 +424,21 @@ export function wrap(handler) {const status = dbDown ? 503 : (err.status || 500);if (status >= 500) {const ref = correlationId();- // Redact coordinates / device tokens so a 5xx on a geolocated read never- // spills the caller's position or credential to an off-box sink.- console.error(`[api] unhandled [ref ${ref}]`, err);- captureException(err, { ref, url: redactUrl(req.url), method: req.method });if (dbDown) {- // During a DB outage every endpoint fails — fire a single shared alert- // rather than one per endpoint per hour to avoid alert fatigue.+ // During a DB outage EVERY endpoint that doesn't catch internally lands+ // here. A missing/rotated DATABASE_URL would otherwise emit one+ // `[api] unhandled` error line + one Sentry event per request — thousands+ // in minutes. It's infrastructure, not a code bug: throttle the log, skip+ // the Sentry capture, and fire only the single shared deduped alert.+ logDbUnavailableOnce(`${req.method} ${redactUrl(req.url)}`, err?.message || String(err));sendOpsAlert('database unavailable', `${err?.message || String(err)}\nref ${ref}`, {signature: 'db:unavailable',});} else {+ // Redact coordinates / device tokens so a 5xx on a geolocated read never+ // spills the caller's position or credential to an off-box sink.+ console.error(`[api] unhandled [ref ${ref}]`, err);+ captureException(err, { ref, url: redactUrl(req.url), method: req.method });sendOpsAlert(`unhandled 5xx in ${req.method} ${redactUrl(req.url)}`, `${err?.message || String(err)}\nref ${ref}`, {signature: `unhandled:${redactUrl(req.url)}:${err?.message}`,});diff --git a/api/_lib/persona-store.js b/api/_lib/persona-store.jsindex c789a7f05..a1de40826 100644--- a/api/_lib/persona-store.js+++ b/api/_lib/persona-store.js@@ -26,9 +26,10 @@ import { promises as fs } from 'node:fs';import os from 'node:os';import path from 'node:path';import { sql } from './db.js';+import { databaseConfigured } from './env.js';import { putObject, copyObject, publicUrl } from './r2.js';-const dbConfigured = () => !!process.env.DATABASE_URL;+const dbConfigured = () => databaseConfigured();const r2Configured = () => !!(process.env.S3_BUCKET && process.env.S3_PUBLIC_DOMAIN);// ── pure helpers (no backend — unit-testable on their own) ────────────────────diff --git a/api/cron/three-holders-snapshot.js b/api/cron/three-holders-snapshot.jsindex 4a75773e4..811f96e4a 100644--- a/api/cron/three-holders-snapshot.js+++ b/api/cron/three-holders-snapshot.js@@ -20,6 +20,7 @@ import { error, json, method, wrapCron } from '../_lib/http.js';import { env } from '../_lib/env.js';import { constantTimeEquals } from '../_lib/crypto.js';import { refreshThreeHolderSnapshot } from '../_lib/coin/three-holders.js';+import { isDbUnavailableError } from '../_lib/db.js';// Vercel cron invokes with `Authorization: Bearer <CRON_SECRET>`; manual probes// may use `X-Cron-Secret: <CRON_SECRET>`. Accept either, constant-time.@@ -63,7 +64,12 @@ export default wrapCron(async (req, res) => {// it out of alerting; reserve error for unexpected faults (a bug, a bad// schema migration).const msg = err?.message || String(err);- const transient = /terminated|fetch failed|ECONNRESET|ETIMEDOUT|EAI_AGAIN|socket hang up|429|rate.?limit|network|password authentication failed|table unavailable/i.test(msg);+ // A DB outage (missing/rotated DATABASE_URL, suspended Neon compute) is+ // operationally expected and self-heals on the next tick — classify it with+ // the same isDbUnavailableError gate the rest of the platform uses so it+ // warns rather than firing a per-tick error into alerting.+ const transient = isDbUnavailableError(err)+ || /terminated|fetch failed|ECONNRESET|ETIMEDOUT|EAI_AGAIN|socket hang up|429|rate.?limit|network|password authentication failed|table unavailable/i.test(msg);if (transient) console.warn('[three-holders-snapshot] refresh deferred (transient upstream):', msg);else console.error('[three-holders-snapshot] refresh failed:', msg);return json(res, 200, { ok: false, refreshed: false, error: msg });diff --git a/api/irl/interactions-stream.js b/api/irl/interactions-stream.jsindex a16225164..6c302fb86 100644--- a/api/irl/interactions-stream.js+++ b/api/irl/interactions-stream.js@@ -36,6 +36,7 @@import { cors, method } from '../_lib/http.js';import { getSessionUser } from '../_lib/auth.js';import { sql } from '../_lib/db.js';+import { databaseConfigured } from '../_lib/env.js';import { readDeviceToken } from '../_lib/irl-auth.js';import { createPollBreaker, pruneSeen } from '../_lib/sse-poll-breaker.js';@@ -338,7 +339,7 @@ export default async function handleIrlInteractionsStream(req, res) {// No DB configured (e.g. local dev without DATABASE_URL): keep the socket alive// with heartbeats so the client's fallback poll path still runs, emit nothing.- if (!process.env.DATABASE_URL) {+ if (!databaseConfigured()) {const hb = setInterval(() => {if (closed || res.writableEnded) { clearInterval(hb); return; }res.write(':hb\n\n');diff --git a/api/marketplace/[action].js b/api/marketplace/[action].jsindex f93e4da35..974f790e7 100644--- a/api/marketplace/[action].js+++ b/api/marketplace/[action].js@@ -723,6 +723,10 @@ async function handleDetail(req, res, id) {ON ap.item_type = 'agent' AND ap.item_id = a.id AND ap.is_active = trueWHERE a.id = ${id} AND a.deleted_at IS NULL`;+ } else if (isDbUnavailableError(err)) {+ console.warn('[marketplace/detail] db unavailable:', err?.message);+ res.setHeader('retry-after', '30');+ return error(res, 503, 'service_unavailable', 'database temporarily unavailable — retry shortly');} else {console.error('[marketplace/detail]', err?.message || err);return error(res, 500, 'db_error', 'Failed to load agent');diff --git a/data/changelog.json b/data/changelog.jsonindex 09ccafbf9..d87cb7836 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,23 @@{"$comment": "Curated changelog entries for three.ws \u2014 the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-06-29",+ "title": "Live data feeds stay online through database hiccups",+ "summary": "The Galaxy money-cam, Money Pulse, marketplace, and holder snapshots now find the platform's database automatically when it's connected through Vercel's or Neon's standard integration, instead of only looking under one exact setting name. A naming mismatch had previously left those feeds blank even though the database was healthy. The connection is now resolved from any of the standard names (and dashboard copy-paste whitespace is trimmed), so the live feeds keep showing real data.",+ "tags": [+ "fix",+ "infra"+ ]+ },+ {+ "date": "2026-06-29",+ "title": "Homepage backdrop no longer trips up unusual browsers",+ "summary": "The animated dragon backdrop on the homepage now checks that your browser fully supports canvas text rendering before it draws, and simply skips itself if not. Some headless and embedded browsers ship a canvas that's missing text-measurement support, which previously threw a silent error on page load; the backdrop now bows out cleanly on those clients while everyone else sees it as normal.",+ "tags": [+ "fix"+ ]+ },{"date": "2026-06-29","title": "Pages stay graceful when the database has a hiccup",diff --git a/public/changelog.json b/public/changelog.jsonindex 9bb6228fa..d366533c6 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-29T21:28:34.659Z",+ "generated_at": "2026-06-29T21:41:44.096Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -217,6 +217,16 @@"improvement"]},+ {+ "date": "2026-06-29",+ "type": "update",+ "title": "Homepage backdrop no longer trips up unusual browsers",+ "summary": "The animated dragon backdrop on the homepage now checks that your browser fully supports canvas text rendering before it draws, and simply skips itself if not. Some headless and embedded browsers ship a canvas that's missing text-measurement support, which previously threw a silent error on page load; the backdrop now bows out cleanly on those clients while everyone else sees it as normal.",+ "link": null,+ "tags": [+ "fix"+ ]+ },{"date": "2026-06-29","type": "update",@@ -248,6 +258,17 @@"feature"]},+ {+ "date": "2026-06-29",+ "type": "update",+ "title": "Live data feeds stay online through database hiccups",+ "summary": "The Galaxy money-cam, Money Pulse, marketplace, and holder snapshots now find the platform's database automatically when it's connected through Vercel's or Neon's standard integration, instead of only looking under one exact setting name. A naming mismatch had previously left those feeds blank even though the database was healthy. The connection is now resolved from any of the standard names (and dashboard copy-paste whitespace is trimmed), so the live feeds keep showing real data.",+ "link": null,+ "tags": [+ "fix",+ "infra"+ ]+ },{"date": "2026-06-29","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 21f6d9544..0ed61729f 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -174,6 +174,14 @@<category>improvement</category><description>Each coin's profile page now lets you switch its price chart between the fast native view and a full interactive DexScreener terminal — candlesticks, zoom, on-chart trades and liquidity — embedded right on the page and keyed to the coin's mint, with a one-tap link to open it in DexScreener. The chart matches your light/dark theme and only loads the heavier terminal when you choose it, so the page stays quick by default.</description></item>+ <item>+ <title>Homepage backdrop no longer trips up unusual browsers</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-06-29:Homepage backdrop no longer trips up unusual browsers</guid>+ <pubDate>Mon, 29 Jun 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The animated dragon backdrop on the homepage now checks that your browser fully supports canvas text rendering before it draws, and simply skips itself if not. Some headless and embedded browsers ship a canvas that's missing text-measurement support, which previously threw a silent error on page load; the backdrop now bows out cleanly on those clients while everyone else sees it as normal.</description>+ </item><item><title>Live 3D sentiment heatmap on agent screens</title><link>https://three.ws/agent-screen</link>@@ -198,6 +206,14 @@<category>feature</category><description>On an agent's live screen you can now type a prompt and watch a 3D avatar get generated, rigged, and animated in real time — free. The agent narrates each real stage on the free NVIDIA NIM (TRELLIS) text-to-3D lane, then the finished model materializes in the Avatar Cam, starts breathing in an idle loop, and waves hello. Open it in the 3D viewer or grab the model URL to set as your agent's look. Fresh forges also surface on the live agents wall.</description></item>+ <item>+ <title>Live data feeds stay online through database hiccups</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-06-29:Live data feeds stay online through database hiccups</guid>+ <pubDate>Mon, 29 Jun 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The Galaxy money-cam, Money Pulse, marketplace, and holder snapshots now find the platform's database automatically when it's connected through Vercel's or Neon's standard integration, instead of only looking under one exact setting name. A naming mismatch had previously left those feeds blank even though the database was healthy. The connection is now resolved from any of the standard names (and dashboard copy-paste whitespace is trimmed), so the live feeds keep showing real data.</description>+ </item><item><title>Live portfolio scoreboard: net worth, 24h P&L, and a sparkline on every agent screen</title><link>https://three.ws/agent-screen</link>diff --git a/public/dragon-section.js b/public/dragon-section.jsindex fa2a78973..296178c13 100644--- a/public/dragon-section.js+++ b/public/dragon-section.js@@ -8,6 +8,13 @@canvas.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;';container.appendChild(canvas);const ctx = canvas.getContext('2d');+ // Some headless/embedded browsers (e.g. Lightpanda) hand back a 2D context that+ // omits the text-metrics APIs this decorative backdrop relies on. Bail cleanly+ // rather than throwing an unhandledrejection out of layoutAllText().+ if (!ctx || typeof ctx.measureText !== 'function' || typeof ctx.fillText !== 'function') {+ container.removeChild(canvas);+ return;+ }const dpr = Math.min(window.devicePixelRatio || 1, 2);let W = 0, H = 0, animId = null, initialized = false, paused = false;diff --git a/public/features.json b/public/features.jsonindex 6a74069b6..4a5416b0f 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-29T21:28:34.643Z",+ "generated_at": "2026-06-29T21:41:44.083Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/db-unconfigured.test.js b/tests/db-unconfigured.test.jsindex 7f88b5e39..0568eb504 100644--- a/tests/db-unconfigured.test.js+++ b/tests/db-unconfigured.test.js@@ -16,7 +16,20 @@ import { describe, it, expect, beforeAll } from 'vitest';// throws `Missing required env var: DATABASE_URL` on an empty/unset value.let sql, sqlValues, isDbUnavailableError;beforeAll(async () => {- delete process.env.DATABASE_URL;+ // env.js now resolves the connection string from DATABASE_URL OR any standard+ // Vercel-Postgres/Neon integration alias, so clearing the bare name alone no+ // longer guarantees the unconfigured path — a developer's .env.local may set+ // POSTGRES_URL etc. Clear every source so this regression is honest everywhere.+ for (const name of [+ 'DATABASE_URL',+ 'POSTGRES_URL',+ 'DATABASE_URL_UNPOOLED',+ 'POSTGRES_URL_NON_POOLING',+ 'NEON_DATABASE_URL',+ 'POSTGRES_PRISMA_URL',+ ]) {+ delete process.env[name];+ }// Fresh module instance so the lazy client starts uninitialized.const mod = await import('../api/_lib/db.js?unconfigured');({ sql, sqlValues, isDbUnavailableError } = mod);diff --git a/tests/env-database-url.test.js b/tests/env-database-url.test.jsnew file mode 100644index 000000000..4a992421a--- /dev/null+++ b/tests/env-database-url.test.js@@ -0,0 +1,84 @@+/**+ * env.js Postgres connection-string resolution — unit test.+ *+ * The Vercel Postgres / Neon Marketplace integration injects the live+ * connection string under names OTHER than the bare DATABASE_URL the code reads+ * (POSTGRES_URL, DATABASE_URL_UNPOOLED, POSTGRES_URL_NON_POOLING,+ * NEON_DATABASE_URL, POSTGRES_PRISMA_URL). When the integration is attached but+ * DATABASE_URL was never mirrored by hand, every DB-backed read threw+ * "Missing required env var: DATABASE_URL" and the whole data plane degraded to+ * empty (the June 2026 incident). env.DATABASE_URL now resolves from any of+ * those aliases — in priority order, trimming dashboard paste artifacts and+ * requiring a postgres(ql):// scheme — and databaseConfigured() mirrors it for+ * the store-module gates. This pins that contract.+ */++import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { env, databaseConfigured } from '../api/_lib/env.js';++const KEYS = [+ 'DATABASE_URL',+ 'POSTGRES_URL',+ 'DATABASE_URL_UNPOOLED',+ 'POSTGRES_URL_NON_POOLING',+ 'NEON_DATABASE_URL',+ 'POSTGRES_PRISMA_URL',+];+let saved;++beforeEach(() => {+ saved = {};+ for (const k of KEYS) {+ saved[k] = process.env[k];+ delete process.env[k];+ }+});++afterEach(() => {+ for (const k of KEYS) {+ if (saved[k] === undefined) delete process.env[k];+ else process.env[k] = saved[k];+ }+});++describe('env.DATABASE_URL connection-string resolution', () => {+ it('uses the bare DATABASE_URL when set', () => {+ process.env.DATABASE_URL = 'postgresql://u:[email protected]/main';+ expect(env.DATABASE_URL).toBe('postgresql://u:[email protected]/main');+ expect(databaseConfigured()).toBe(true);+ });++ it('resolves from POSTGRES_URL when DATABASE_URL is absent (Vercel Postgres integration)', () => {+ process.env.POSTGRES_URL = 'postgres://u:[email protected]/main';+ expect(env.DATABASE_URL).toBe('postgres://u:[email protected]/main');+ expect(databaseConfigured()).toBe(true);+ });++ it('resolves from DATABASE_URL_UNPOOLED / NEON_DATABASE_URL aliases', () => {+ process.env.NEON_DATABASE_URL = 'postgresql://u:[email protected]/main';+ expect(env.DATABASE_URL).toBe('postgresql://u:[email protected]/main');+ });++ it('prefers the canonical name over a lower-priority alias', () => {+ process.env.DATABASE_URL = 'postgresql://primary@db/main';+ process.env.POSTGRES_URL = 'postgresql://alias@db/main';+ expect(env.DATABASE_URL).toBe('postgresql://primary@db/main');+ });++ it('trims a dashboard-pasted trailing newline (would otherwise break neon())', () => {+ process.env.DATABASE_URL = 'postgresql://u:[email protected]/main\n';+ expect(env.DATABASE_URL).toBe('postgresql://u:[email protected]/main');+ });++ it('ignores a non-postgres value on a higher-priority name and falls through', () => {+ // A stray/garbage value on DATABASE_URL must not shadow a real URL on an alias.+ process.env.DATABASE_URL = 'not-a-connection-string';+ process.env.POSTGRES_URL = 'postgresql://u:[email protected]/main';+ expect(env.DATABASE_URL).toBe('postgresql://u:[email protected]/main');+ });++ it('throws the unchanged "Missing required env var" message when no source is set', () => {+ expect(() => env.DATABASE_URL).toThrow('Missing required env var: DATABASE_URL');+ expect(databaseConfigured()).toBe(false);+ });+});diff --git a/tests/http-db-unavailable-boundary.test.js b/tests/http-db-unavailable-boundary.test.jsnew file mode 100644index 000000000..daffd4a2b--- /dev/null+++ b/tests/http-db-unavailable-boundary.test.js@@ -0,0 +1,95 @@+/**+ * http.js error boundary — database-unavailable degradation.+ *+ * A missing/rotated DATABASE_URL makes every DB-backed read reject. Two contracts+ * keep that from turning into a log + alert + Sentry storm:+ * 1. wrap() classifies the DB-down error as 503 (Retry-After) and does NOT emit+ * the per-request `[api] unhandled` error line — it throttles to a warn.+ * 2. serverError() coerces a DB-down error to 503 + Retry-After regardless of+ * the caller's nominal status (sitemap/deployments pass 500/502).+ */++import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';+import { wrap, serverError } from '../api/_lib/http.js';++// Minimal ServerResponse stand-in: case-insensitive header store + end capture.+function fakeRes() {+ const headers = {};+ return {+ statusCode: 0,+ body: undefined,+ ended: false,+ headersSent: false,+ writableEnded: false,+ setHeader(k, v) { headers[String(k).toLowerCase()] = v; },+ getHeader(k) { return headers[String(k).toLowerCase()]; },+ end(b) { this.body = b; this.ended = true; this.writableEnded = true; },+ _headers: headers,+ };+}++function dbDownError() {+ // The exact shape thrown by the env accessor when DATABASE_URL is absent.+ return new Error('Missing required env var: DATABASE_URL');+}++let errSpy, warnSpy;+beforeEach(() => {+ errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});+ warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});+});+afterEach(() => {+ errSpy.mockRestore();+ warnSpy.mockRestore();+});++describe('wrap() under a DB outage', () => {+ it('returns 503 + Retry-After and does not log [api] unhandled at error level', async () => {+ const handler = wrap(async () => { throw dbDownError(); });+ const res = fakeRes();+ await handler({ method: 'GET', url: '/api/galaxy/flows', headers: {} }, res);++ expect(res.statusCode).toBe(503);+ expect(res.getHeader('retry-after')).toBe('30');+ expect(JSON.parse(res.body).error).toBe('service_unavailable');++ // No `[api] unhandled` error line — the outage is throttled to a warn instead.+ const unhandled = errSpy.mock.calls.some((c) => String(c[0]).includes('[api] unhandled'));+ expect(unhandled).toBe(false);+ });++ it('still logs and 500s a genuine (non-DB) handler bug', async () => {+ const handler = wrap(async () => { throw new Error('boom'); });+ const res = fakeRes();+ await handler({ method: 'GET', url: '/api/whatever', headers: {} }, res);++ expect(res.statusCode).toBe(500);+ const unhandled = errSpy.mock.calls.some((c) => String(c[0]).includes('[api] unhandled'));+ expect(unhandled).toBe(true);+ });+});++describe('serverError() under a DB outage', () => {+ it('coerces a DB-down error to 503 + Retry-After regardless of the nominal status', () => {+ const res = fakeRes();+ serverError(res, 500, 'sitemap_failed', dbDownError());++ expect(res.statusCode).toBe(503);+ expect(res.getHeader('retry-after')).toBe('30');+ expect(JSON.parse(res.body).error).toBe('service_unavailable');++ // Reported as a throttled warn, not the `[server-error]` error line.+ const serverErr = errSpy.mock.calls.some((c) => String(c[0]).includes('[server-error'));+ expect(serverErr).toBe(false);+ });++ it('keeps a genuine 5xx as-is with the [server-error] log line', () => {+ const res = fakeRes();+ serverError(res, 502, 'pulse_failed', new Error('upstream exploded'));++ expect(res.statusCode).toBe(502);+ expect(JSON.parse(res.body).error).toBe('pulse_failed');+ const serverErr = errSpy.mock.calls.some((c) => String(c[0]).includes('[server-error'));+ expect(serverErr).toBe(true);+ });+});