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
// Dynamic sitemap index. Returns the top-level sitemap.xml that Google /
// Bing crawl first; each entry points at a chunked sub-sitemap (core
// landing pages, agents, avatars, widgets, public profiles).
//
// Why an index instead of one giant file:
// - 50k URL / 50MB per-file cap from sitemaps.org spec
// - lets each entity type set its own lastmod / changefreq
// - per-file caches in Vercel's CDN — re-render only the type that changed
//
// Wired via vercel.json rewrite: /sitemap.xml → /api/sitemap
import { sql } from './_lib/db.js';
import { env } from './_lib/env.js';
import { method } from './_lib/http.js';
const ORIGIN = env.APP_ORIGIN;
function xml(res, body) {
res.setHeader('content-type', 'application/xml; charset=utf-8');
res.setHeader('cache-control', 'public, s-maxage=600, stale-while-revalidate=86400');
res.statusCode = 200;
res.end(body);
}
function fmtDate(d) {
const t = d instanceof Date ? d : new Date(d);
if (Number.isNaN(t.getTime())) return new Date().toISOString().slice(0, 10);
return t.toISOString().slice(0, 10);
}
// Coalesce on created_at because most rows in this DB never get an explicit
// updated_at write — many writes happen via INSERT rather than UPDATE, so
// `max(updated_at)` returns NULL even when there's plenty of content.
async function newestTimestamp(table, where = '') {
try {
const rows = await sql.unsafe(
`select max(coalesce(updated_at, created_at)) as ts from ${table} ${where ? 'where ' + where : ''}`,
);
return rows?.[0]?.ts || null;
} catch {
return null;
}
}
// agent_identities has no updated_at on every row — use created_at directly.
async function newestCreated(table, where = '') {
try {
const rows = await sql.unsafe(
`select max(created_at) as ts from ${table} ${where ? 'where ' + where : ''}`,
);
return rows?.[0]?.ts || null;
} catch {
return null;
}
}
export default async function handler(req, res) {
// A crawler surface is GET (and HEAD) only. Without this, a POST or DELETE
// got the sitemap back with a 200, which is a lie about what the route does.
if (!method(req, res, ['GET'])) return;
const [agentsTs, avatarsTs, widgetsTs, usersTs, subdomainsTs] = await Promise.all([
newestCreated('agent_identities', 'deleted_at is null and is_public = true'),
newestTimestamp('avatars', "visibility = 'public' and deleted_at is null"),
newestTimestamp('widgets', 'is_public = true and deleted_at is null'),
// Must match profilesSitemap()'s predicate in api/sitemap/[type].js. The
// seed crons mint a service_account row about once a minute, so without
// the flag this reported "profiles.xml changed" on every crawl of a feed
// that only lists human profiles.
newestTimestamp('users', 'deleted_at is null and username is not null and service_account = false'),
newestCreated('user_subdomains'),
]);
// Always emit every sub-sitemap entry — the sub-sitemap itself decides if
// it has zero rows. An empty <urlset> is valid and lets Google retry later
// without us having to remember to "turn it on" once content appears.
const today = fmtDate(new Date());
const entries = [
{ loc: `${ORIGIN}/sitemap/core.xml`, lastmod: today },
{ loc: `${ORIGIN}/sitemap/agents.xml`, lastmod: fmtDate(agentsTs || today) },
{ loc: `${ORIGIN}/sitemap/avatars.xml`, lastmod: fmtDate(avatarsTs || today) },
{ loc: `${ORIGIN}/sitemap/widgets.xml`, lastmod: fmtDate(widgetsTs || today) },
{ loc: `${ORIGIN}/sitemap/profiles.xml`, lastmod: fmtDate(usersTs || subdomainsTs || today) },
// Story pages for recent news — the archive appender refreshes hourly,
// so the newest articles are always crawlable within the hour.
{ loc: `${ORIGIN}/sitemap/news.xml`, lastmod: today },
];
const body =
`<?xml version="1.0" encoding="UTF-8"?>\n` +
`<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +
entries
.map(
(e) => `\t<sitemap>\n\t\t<loc>${e.loc}</loc>\n\t\t<lastmod>${e.lastmod}</lastmod>\n\t</sitemap>`,
)
.join('\n') +
`\n</sitemapindex>\n`;
return xml(res, body);
}