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: runtime tests, pay page, nav, pump, marketplace + vercel route updates
nirholas5e24fc8d5dbe
diff --git a/api/pump/[action].js b/api/pump/[action].jsindex 1ed3050ff..d5e53d4fa 100644--- a/api/pump/[action].js+++ b/api/pump/[action].js@@ -485,8 +485,8 @@ const buildMetadataSchema = z.object({description: z.string().trim().max(500).default(''),avatar_id: z.string().uuid().optional(),agent_id: z.string().uuid().optional(),- // Base64 data URL: "data:image/png;base64,..." — max ~4 MB image.- image_data_url: z.string().max(6_000_000).optional(),+ // Base64 data URL: "data:image/png;base64,..." — max 4 MB raw (≈5.5 MB base64).+ image_data_url: z.string().max(5_500_000).optional(),});async function handleBuildMetadata(req, res) {diff --git a/public/nav.html b/public/nav.htmlindex 83fdf2b20..4c6cd3a9b 100644--- a/public/nav.html+++ b/public/nav.html@@ -43,6 +43,12 @@Solana<span class="nav-caret" aria-hidden="true">▾</span></button><ul class="nav-menu" role="menu" aria-label="Solana">+ <li role="none">+ <a href="/pay" role="menuitem"+ ><span class="nav-mi-title">Pay-per-call (x402) <span style="display:inline-block;padding:1px 6px;margin-left:6px;background:linear-gradient(135deg,#8b5cf6,#22d3ee);color:#0a0b10;border-radius:4px;font-size:9px;font-weight:700;letter-spacing:0.06em;vertical-align:1px">NEW</span></span+ ><span class="nav-mi-sub">$0.001 per MCP tool call · live demo</span></a+ >+ </li><li role="none"><a href="/pumpfun" role="menuitem"><span class="nav-mi-title">Pump.fun stream</spandiff --git a/public/pay/index.html b/public/pay/index.htmlindex 94f59019d..c6246abb2 100644--- a/public/pay/index.html+++ b/public/pay/index.html@@ -481,6 +481,31 @@font-weight: 600; font-size: 14px; cursor: pointer;}.walkthrough button:hover { background: #7c3aed; }++ /* Mobile polish */+ @media (max-width: 640px) {+ header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }+ .brand .sub { display: none; }+ .header-right { width: 100%; gap: 6px; }+ .pill { font-size: 11px; padding: 5px 10px; flex: 1; justify-content: center; min-width: 0; overflow: hidden; }+ .pill #walletText, .pill #tickerText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .conv { padding: 16px 16px; }+ .composer { padding: 12px 16px; }+ aside.status { padding: 16px 16px; }+ .quick { gap: 6px; }+ .quick button { font-size: 11px; padding: 5px 10px; }+ footer.feed { padding: 6px 14px; gap: 8px; font-size: 10px; }+ .feed-label { display: none; }+ .walkthrough { padding: 22px 22px; }+ .walkthrough h1 { font-size: 19px; }+ .mv-block model-viewer { height: 280px; }+ .avatars-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }+ .avatar-card model-viewer { height: 110px; }+ }+ @media (max-width: 420px) {+ .quick button[data-cmd="search_public_avatars:"] { display: none; }+ .pill .label { display: none; }+ }</style></head><body>diff --git a/src/element.js b/src/element.jsindex bda4806dc..42af7b192 100644--- a/src/element.js+++ b/src/element.js@@ -3,7 +3,7 @@import { Box3 } from 'three';import { Viewer } from './viewer.js';-import { Runtime } from './runtime/index.js';+import { Runtime, skillAccessFromAgentDetail } from './runtime/index.js';import { SceneController } from './runtime/scene.js';import { SkillRegistry } from './skills/index.js';import { Memory } from './memory/index.js';@@ -1357,12 +1357,37 @@ class Agent3DElement extends HTMLElement {agentId: _backendId || undefined,apiOrigin: _scriptOrigin || window.location.origin,};++ // Fetch skill prices + purchased state so the runtime can gate paid skills.+ // Failures here fall back to "all-allowed" — monetization is opt-in.+ let _skillAccess;+ if (_backendId) {+ try {+ const detailBase = _scriptOrigin || window.location.origin;+ const r = await fetch(+ `${detailBase}/api/marketplace/agents/${_backendId}`,+ { credentials: 'include' },+ );+ if (r.ok) {+ const j = await r.json();+ const a = j?.data?.agent;+ if (a && (a.skill_prices || a.purchased_skills)) {+ _skillAccess = skillAccessFromAgentDetail(a);+ }+ }+ } catch (e) {+ console.warn('[agent-3d] skill-access fetch failed; defaulting to allow-all', e);+ }+ }+this._runtime = new Runtime({manifest,viewer: this._scene,memory: this._memory,skills: this._skills,providerConfig,+ agentId: _backendId || undefined,+ skillAccess: _skillAccess,});// Re-dispatch runtime events on the hostfor (const ev of [@@ -1371,6 +1396,7 @@ class Agent3DElement extends HTMLElement {'brain:message','skill:tool-start','skill:tool-called',+ 'skill:payment-required','voice:speech-start','voice:speech-end','voice:transcript',diff --git a/src/marketplace.js b/src/marketplace.jsindex b7f279498..eb5f9444e 100644--- a/src/marketplace.js+++ b/src/marketplace.js@@ -312,13 +312,18 @@ function updateHeroMeta() {$('market-hero-title').textContent = a.name || 'Untitled avatar';$('market-hero-desc').textContent =a.description ||- (a.author?.handle- ? `A 3D avatar by ${a.author.handle}.`- : 'A 3D avatar published to the community.');+ 'A 3D avatar published to the community. Use it as the visual identity for a new agent.';const view = $('market-hero-view');if (view) {- view.onclick = () => {- location.href = a.avatarId ? `/avatars/${a.avatarId}` : a.viewerUrl || '/';+ view.onclick = () => openAvatarModal(a);+ }+ const fork = $('market-hero-fork');+ if (fork) {+ fork.hidden = false;+ fork.textContent = 'Start an agent →';+ fork.onclick = () => {+ activeAvatar = a;+ startAgentFromAvatar();};}renderHeroStats();diff --git a/tests/src/eth-vanity-validation.test.js b/tests/src/eth-vanity-validation.test.jsindex 56ef15e08..a8b40698b 100644--- a/tests/src/eth-vanity-validation.test.js+++ b/tests/src/eth-vanity-validation.test.js@@ -101,8 +101,8 @@ describe('eth vanity · eip55Checksum', () => {// Mixed['de709f2102306220921060314715629080e2fb77', 'de709f2102306220921060314715629080e2fb77'],['fb6916095ca1df60bb79ce92ce3ea74c37c5d359', 'fB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'],- ['dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb', 'DBF03B407c01E7cD3CBea99509d93f8DDDC8C6FB'],- ['d1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', 'D1220A0cf47C7B9Be7A2E6BA89F429762e7b9aDb'],+ ['dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb', 'dbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB'],+ ['d1220a0cf47c7b9be7a2e6ba89f429762e7b9adb', 'D1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb'],];for (const [lower, expected] of VECTORS) {diff --git a/tests/src/runtime.test.js b/tests/src/runtime.test.jsindex 89b1fa18e..96d4a57b5 100644--- a/tests/src/runtime.test.js+++ b/tests/src/runtime.test.js@@ -189,6 +189,91 @@ describe('Runtime — tool dispatch', () => {});});+// ── Skill access gate ────────────────────────────────────────────────────────++describe('Runtime — skill access gate', () => {+ it('blocks paid skill, dispatches skill:payment-required, returns 402 result to the LLM', async () => {+ const provider = mockProvider([toolResp('premium_search', {}), textResp('blocked')]);+ const skillInvoke = vi.fn().mockResolvedValue({ ok: true });+ const skills = {+ findSkillForTool: vi.fn().mockReturnValue({ invoke: skillInvoke }),+ allTools: () => [],+ systemPrompt: () => '',+ };+ const skillAccess = vi.fn().mockResolvedValue({+ allowed: false,+ price: { amount: '1000000', currency_mint: 'EPjF...', chain: 'solana' },+ });+ const rt = makeRuntime(provider, { skills });+ rt.skillAccess = skillAccess;++ const events = collect(rt, 'skill:payment-required');+ await rt.send('use premium_search');++ expect(skillInvoke).not.toHaveBeenCalled();+ expect(skillAccess).toHaveBeenCalledWith('premium_search');+ expect(events).toHaveLength(1);+ expect(events[0].skill).toBe('premium_search');+ expect(events[0].price).toEqual({ amount: '1000000', currency_mint: 'EPjF...', chain: 'solana' });++ // The 402 result is fed back to the LLM as a tool_result with is_error=true+ const secondCall = provider.complete.mock.calls[1][0];+ const toolResultMsg = secondCall.messages.find(+ (m) => m.role === 'user' && Array.isArray(m.content),+ );+ expect(toolResultMsg).toBeDefined();+ expect(toolResultMsg.content[0].is_error).toBe(true);+ const parsed = JSON.parse(toolResultMsg.content[0].content);+ expect(parsed.error).toBe('payment_required');+ expect(parsed.skill).toBe('premium_search');+ });++ it('allows paid skill once skillAccess returns allowed:true (purchased state)', async () => {+ const provider = mockProvider([toolResp('premium_search', {}), textResp('done')]);+ const skillInvoke = vi.fn().mockResolvedValue({ ok: true, data: 'results' });+ const skills = {+ findSkillForTool: vi.fn().mockReturnValue({ invoke: skillInvoke }),+ allTools: () => [],+ systemPrompt: () => '',+ };+ const rt = makeRuntime(provider, { skills });+ rt.skillAccess = vi.fn().mockResolvedValue({ allowed: true });++ const events = collect(rt, 'skill:payment-required');+ await rt.send('use premium_search');++ expect(skillInvoke).toHaveBeenCalled();+ expect(events).toHaveLength(0);+ });++ it('default skillAccess (alwaysAllow) does not gate any tool', async () => {+ const provider = mockProvider([toolResp('any_skill', {}), textResp('ok')]);+ const skillInvoke = vi.fn().mockResolvedValue({ result: 'free' });+ const skills = {+ findSkillForTool: vi.fn().mockReturnValue({ invoke: skillInvoke }),+ allTools: () => [],+ systemPrompt: () => '',+ };+ const rt = makeRuntime(provider, { skills });++ await rt.send('use any_skill');+ expect(skillInvoke).toHaveBeenCalled();+ });++ it('built-in tools bypass the gate even when skillAccess would deny them', async () => {+ const provider = mockProvider([toolResp('lookAt', { target: 'user' }), textResp('ok')]);+ const rt = makeRuntime(provider);+ // A pathological gate that denies everything — should not affect built-ins+ rt.skillAccess = vi.fn().mockResolvedValue({ allowed: false });++ const events = collect(rt, 'skill:payment-required');+ await rt.send('hi');++ expect(rt.skillAccess).not.toHaveBeenCalled();+ expect(events).toHaveLength(0);+ });+});+// ── MAX_TOOL_ITERATIONS guard ─────────────────────────────────────────────────describe('Runtime — MAX_TOOL_ITERATIONS', () => {diff --git a/vercel.json b/vercel.jsonindex d56a14fbe..967053425 100644--- a/vercel.json+++ b/vercel.json@@ -1156,6 +1156,14 @@"path": "/api/cron/audit-log-cleanup","schedule": "0 4 * * *"},+ {+ "path": "/api/cron/expire-pending-purchases",+ "schedule": "*/5 * * * *"+ },+ {+ "path": "/api/cron/cleanup-csrf-tokens",+ "schedule": "17 * * * *"+ },{"path": "/api/cron/erc8004-crawl","schedule": "*/15 * * * *"