Skip to content

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.

fix: mark subproject commits as dirty for worktree consistency and update routing for SPA support

nirholas1ded082f6277
diff --git a/api/agent-page.js b/api/agent-page.js
index 95f3c403b..4e9a40c7e 100644
--- a/api/agent-page.js
+++ b/api/agent-page.js
@@ -126,7 +126,7 @@ function renderHtml(p) {
</div>
<script>
(function () {
- window.location.replace(${JSON.stringify(p.pageUrl)});
+ window.location.replace(${JSON.stringify(p.pageUrl)} + '?_spa=1');
})();
</script>
<script type="application/ld+json">
diff --git a/api/cron/index-delegations.js b/api/cron/index-delegations.js
index 23b6c7be9..10c088a2c 100644
--- a/api/cron/index-delegations.js
+++ b/api/cron/index-delegations.js
@@ -34,18 +34,49 @@ const BLOCKS_PER_DAY = {
11155111: 7200, // Sepolia ~12 s/block
};
-// Public RPC fallbacks — override per chain via env RPC_<chainId>.
-const PUBLIC_RPC = {
- 1: 'https://cloudflare-eth.com',
- 8453: 'https://mainnet.base.org',
- 84532: 'https://sepolia.base.org',
- 11155111: 'https://rpc.sepolia.org',
- 421614: 'https://sepolia-rollup.arbitrum.io/rpc',
- 11155420: 'https://sepolia.optimism.io',
+// Public RPC fallbacks per chain — tried in order. Override primary via env RPC_<chainId>.
+const PUBLIC_RPCS = {
+ 1: [
+ 'https://cloudflare-eth.com',
+ 'https://eth.llamarpc.com',
+ 'https://rpc.ankr.com/eth',
+ 'https://ethereum.publicnode.com',
+ 'https://1rpc.io/eth',
+ ],
+ 8453: [
+ 'https://mainnet.base.org',
+ 'https://base.llamarpc.com',
+ 'https://rpc.ankr.com/base',
+ 'https://base.publicnode.com',
+ 'https://1rpc.io/base',
+ ],
+ 84532: [
+ 'https://sepolia.base.org',
+ 'https://base-sepolia-rpc.publicnode.com',
+ 'https://rpc.ankr.com/base_sepolia',
+ ],
+ 11155111: [
+ 'https://rpc.sepolia.org',
+ 'https://ethereum-sepolia-rpc.publicnode.com',
+ 'https://rpc.ankr.com/eth_sepolia',
+ 'https://1rpc.io/sepolia',
+ ],
+ 421614: [
+ 'https://sepolia-rollup.arbitrum.io/rpc',
+ 'https://arbitrum-sepolia.publicnode.com',
+ 'https://rpc.ankr.com/arbitrum_sepolia',
+ ],
+ 11155420: [
+ 'https://sepolia.optimism.io',
+ 'https://optimism-sepolia.publicnode.com',
+ 'https://rpc.ankr.com/optimism_sepolia',
+ ],
};
-function rpcUrl(chainId) {
- return process.env[`RPC_${chainId}`] ?? PUBLIC_RPC[chainId] ?? null;
+function rpcUrls(chainId) {
+ const envUrl = process.env[`RPC_${chainId}`];
+ const fallbacks = PUBLIC_RPCS[chainId] ?? [];
+ return envUrl ? [envUrl, ...fallbacks] : fallbacks;
}
export default wrap(async (req, res) => {
@@ -107,10 +138,10 @@ export default wrap(async (req, res) => {
// ─── Chain indexer ────────────────────────────────────────────────────────────
async function indexChain(chainId, contract) {
- const url = rpcUrl(chainId);
- if (!url) throw new Error(`no RPC URL configured for chain ${chainId}`);
+ const urls = rpcUrls(chainId);
+ if (!urls.length) throw new Error(`no RPC URL configured for chain ${chainId}`);
- const latestHex = await rpc(url, 'eth_blockNumber', []);
+ const latestHex = await rpc(urls, 'eth_blockNumber', []);
const latestBlock = parseInt(latestHex, 16);
const [cursor] = await sql`
@@ -129,7 +160,7 @@ async function indexChain(chainId, contract) {
while (fromBlock <= latestBlock) {
toBlock = Math.min(fromBlock + BLOCK_CAP - 1, latestBlock);
- const logs = await rpc(url, 'eth_getLogs', [
+ const logs = await rpc(urls, 'eth_getLogs', [
{
address: contract,
topics: [[DISABLED_TOPIC, REDEEMED_TOPIC]],
@@ -143,7 +174,7 @@ async function indexChain(chainId, contract) {
const uniqueBlocks = [...new Set(logs.map((l) => l.blockNumber))];
const blockTs = {};
for (const bn of uniqueBlocks) {
- const block = await rpc(url, 'eth_getBlockByNumber', [bn, false]);
+ const block = await rpc(urls, 'eth_getBlockByNumber', [bn, false]);
blockTs[bn] = new Date(parseInt(block.timestamp, 16) * 1000).toISOString();
}
@@ -192,25 +223,31 @@ async function indexChain(chainId, contract) {
// ─── RPC helper ──────────────────────────────────────────────────────────────
-async function rpc(url, method, params) {
- const ac = new AbortController();
- const t = setTimeout(() => ac.abort(), RPC_TIMEOUT_MS);
- try {
- const res = await fetch(url, {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
- signal: ac.signal,
- });
- if (!res.ok) throw new Error(`RPC HTTP ${res.status} from ${url}`);
- const data = await res.json();
- if (data.error) {
- throw new Error(
- `RPC ${method} error: ${data.error.message ?? JSON.stringify(data.error)}`,
- );
+async function rpc(urls, method, params) {
+ let lastErr;
+ for (const url of urls) {
+ const ac = new AbortController();
+ const t = setTimeout(() => ac.abort(), RPC_TIMEOUT_MS);
+ try {
+ const res = await fetch(url, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
+ signal: ac.signal,
+ });
+ if (!res.ok) throw new Error(`RPC HTTP ${res.status} from ${url}`);
+ const data = await res.json();
+ if (data.error) {
+ throw new Error(
+ `RPC ${method} error: ${data.error.message ?? JSON.stringify(data.error)}`,
+ );
+ }
+ return data.result;
+ } catch (err) {
+ lastErr = err;
+ } finally {
+ clearTimeout(t);
}
- return data.result;
- } finally {
- clearTimeout(t);
}
+ throw lastErr;
}
diff --git a/home.html b/home.html
index 507e39a6e..3d55fbd26 100644
--- a/home.html
+++ b/home.html
@@ -577,27 +577,37 @@
const wrap = canvas.closest('.h-avatar-wrap');
- /* falling: expand to full hero width and slide model across the scene */
- function doFalling() {
+ /* falling: play clip in the circle, then expand and slowly slide across */
+ async function doFalling() {
+ try { await viewer.playClip('falling'); } catch (_) {}
+
+ /* wait for the actual clip to finish on the ground */
+ const clipDur = viewer.currentAction
+ ? viewer.currentAction.getClip().duration * 1000
+ : 2200;
+ await new Promise(r => setTimeout(r, clipDur));
+
+ /* expand to full-width and slide the model slowly across the ground */
wrap.classList.add('h-avatar-wrap--traversing');
- viewer.playClip('falling').catch(() => {});
- const dur = 2800;
+ const SLIDE_DUR = 3200;
+ const SLIDE_DIST = 8;
const t0 = performance.now();
- (function step(now) {
- const t = Math.min((now - t0) / dur, 1);
- const ease = t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
- const x = -4.5 + 9 * ease;
- if (viewer.model) viewer.model.position.x = x;
- viewer._focusX = x;
- if (t < 1) {
- requestAnimationFrame(step);
- } else {
- if (viewer.model) viewer.model.position.x = 0;
- viewer._focusX = 0;
- wrap.classList.remove('h-avatar-wrap--traversing');
- viewer.playClip('dance').catch(() => {});
- }
- })(performance.now());
+ await new Promise(r => {
+ (function step(now) {
+ const t = Math.min((now - t0) / SLIDE_DUR, 1);
+ const x = SLIDE_DIST * t;
+ if (viewer.model) viewer.model.position.x = x;
+ viewer._focusX = x;
+ if (t < 1) { requestAnimationFrame(step); }
+ else { r(); }
+ })(performance.now());
+ });
+
+ /* reset + back to dance */
+ if (viewer.model) viewer.model.position.x = 0;
+ viewer._focusX = 0;
+ wrap.classList.remove('h-avatar-wrap--traversing');
+ viewer.playClip('dance').catch(() => {});
}
viewer.loadModel('/avatars/cz.glb', { autoPlay: false })
diff --git a/src/home-act2-viewer.js b/src/home-act2-viewer.js
index 86bb79bcd..1dfe8999a 100644
--- a/src/home-act2-viewer.js
+++ b/src/home-act2-viewer.js
@@ -273,12 +273,13 @@ export class Act2Viewer {
const phi = phiDeg * (Math.PI / 180);
const sinPhi = Math.sin(phi);
const cosPhi = Math.cos(phi);
+ const fx = this._focusX;
this.camera.position.set(
- radius * sinPhi * Math.sin(theta),
+ fx + radius * sinPhi * Math.sin(theta),
this._modelFocusY + radius * cosPhi,
radius * sinPhi * Math.cos(theta),
);
- this.camera.lookAt(this._focusX, this._modelFocusY, 0);
+ this.camera.lookAt(fx, this._modelFocusY, 0);
}
setExposure(v) {
diff --git a/vercel.json b/vercel.json
index af20e3ac7..aa347e832 100644
--- a/vercel.json
+++ b/vercel.json
@@ -88,6 +88,11 @@
},
"dest": "/agent-embed.html"
},
+ {
+ "src": "/agent/([^/]+)",
+ "has": [{ "type": "query", "key": "_spa", "value": "1" }],
+ "dest": "/agent-home.html"
+ },
{ "src": "/agent/([^/]+)", "dest": "/api/agent-page?id=$1" },
{ "src": "/agent", "dest": "/agent-home.html" },
diff --git a/vite.config.js b/vite.config.js
index 1a7b6c760..291aa9a50 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -133,6 +133,7 @@ const appConfig = {
],
},
workbox: {
+ maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
globPatterns: ['**/*.{js,css,ico,png,svg,woff2}'],
navigateFallback: null,
skipWaiting: true,