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(Avatar, Convo): enhance avatar drag-and-drop functionality and error handling for unsupported tools
nirholas2eed06110f7e
diff --git a/chat/src/App.svelte b/chat/src/App.svelteindex f42adf62f..c61127d0d 100644--- a/chat/src/App.svelte+++ b/chat/src/App.svelte@@ -834,6 +834,9 @@const seconds = err.retryAfter ?? 30;rateLimitedUntil = Date.now() + seconds * 1000;convo.messages[i].error = `Slow down — too many requests. Try again in ${seconds}s.`;+ } else if (err.code === 'tools_unsupported') {+ const tools = err.toolNames?.length ? err.toolNames.join(', ') : 'the enabled tools';+ convo.messages[i].error = `**${err.modelId}** doesn't support tool use. Disable ${tools} in the Tools panel, or switch to a tool-capable model like \`anthropic/claude-sonnet-4.5\` or \`openai/gpt-5-mini\`.`;} else {convo.messages[i].error = err.message || String(err);}@@ -1569,32 +1572,73 @@}// Drag state for the floating agent widget+ /** @type {{ x: number | null, y: number | null }} */let dragPos = { x: null, y: null };let dragging = false;let dragOffset = { x: 0, y: 0 };+ let dragStart = { x: 0, y: 0 };+ let dragMoved = false;+ /** @type {'dying' | 'falling' | null} */+ let avatarExitAnim = null;+ /** @param {MouseEvent} e */function onAvatarDragStart(e) {if (e.button !== 0) return;- if (e.target.closest('button, input, a, select')) return;+ if (/** @type {HTMLElement} */ (e.target).closest('button, input, a, select')) return;+ if (avatarExitAnim) return;e.preventDefault();- const rect = e.currentTarget.getBoundingClientRect();+ const rect = /** @type {HTMLElement} */ (e.currentTarget).getBoundingClientRect();dragOffset = { x: e.clientX - rect.left, y: e.clientY - rect.top };+ dragStart = { x: e.clientX, y: e.clientY };+ dragMoved = false;dragging = true;window.addEventListener('mousemove', onAvatarDragMove);window.addEventListener('mouseup', onAvatarDragEnd);}+ /** @param {MouseEvent} e */function onAvatarDragMove(e) {if (!dragging) return;+ if (!dragMoved && Math.hypot(e.clientX - dragStart.x, e.clientY - dragStart.y) > 5) {+ dragMoved = true;+ }+ if (!dragMoved) return;const x = Math.max(0, Math.min(window.innerWidth - 240, e.clientX - dragOffset.x));const y = Math.max(0, Math.min(window.innerHeight - 60, e.clientY - dragOffset.y));dragPos = { x, y };}function onAvatarDragEnd() {+ const wasClick = dragging && !dragMoved;dragging = false;window.removeEventListener('mousemove', onAvatarDragMove);window.removeEventListener('mouseup', onAvatarDragEnd);+ if (wasClick) killAvatar();+ }++ function killAvatar() {+ if (!agentVisible || avatarExitAnim) return;+ avatarExitAnim = 'dying';+ try { agentEl?.play?.('dying', { loop: false }); } catch {}+ setTimeout(() => {+ agentVisible = false;+ avatarExitAnim = null;+ }, 1200);+ }++ function reviveAvatar() {+ if (agentVisible) return;+ avatarExitAnim = 'falling';+ agentVisible = true;+ const playFalling = () => { try { agentEl?.play?.('falling', { loop: false }); } catch {} };+ let attempts = 0;+ const tryPlay = () => {+ if (agentEl && agentReady) { playFalling(); return; }+ if (agentEl) { agentEl.addEventListener('agent:ready', playFalling, { once: true }); return; }+ if (attempts++ < 40) setTimeout(tryPlay, 50);+ };+ tryPlay();+ setTimeout(() => { avatarExitAnim = null; }, 1200);}$: effectiveAgentId = $localAgentId || $brandConfig.agent_id || '';@@ -1613,7 +1657,9 @@$: if (agentEl && !agentReady) {agentEl.addEventListener('agent:ready', () => {agentReady = true;- agentEl.play(generating ? 'walk' : 'idle', { loop: true }).catch(() => {});+ if (!avatarExitAnim) {+ agentEl.play(generating ? 'walk' : 'idle', { loop: true }).catch(() => {});+ }if (agentPendingSpeak) {agentEl.speak(agentPendingSpeak);agentPendingSpeak = null;@@ -1621,7 +1667,7 @@}, { once: true });}- $: if (agentEl && agentReady) {+ $: if (agentEl && agentReady && !avatarExitAnim) {if (generating) {agentEl.play('walk', { loop: true }).catch(() => {});} else {@@ -2288,8 +2334,10 @@{#if true}<!-- svelte-ignore a11y-no-static-element-interactions --><div- class="z-[100] flex flex-col items-end gap-2 select-none"+ class="z-[100] flex flex-col items-end gap-2 select-none avatar-floater"class:cursor-grabbing={dragging}+ class:avatar-dying={avatarExitAnim === 'dying'}+ class:avatar-falling={avatarExitAnim === 'falling'}style={dragPos.x !== null? `position: fixed; left: ${dragPos.x}px; top: ${dragPos.y}px;`: 'position: absolute; bottom: 0; right: 0;'}@@ -2353,7 +2401,7 @@</div><div class="pointer-events-none absolute bottom-[72px] inset-x-0 h-8 z-[98] bg-gradient-to-t from-paper to-transparent" />- {#if $toolSchema.length > 0}+ {#if $toolSchema.length > 0 || (!agentVisible && (effectiveAgentId || $talkingHeadEnabled))}<div class="flex flex-wrap gap-1.5 px-4 pt-2 pb-0">{#each $toolSchema as group}<span class="inline-flex items-center gap-1 rounded-full border border-indigo-200 bg-indigo-50 px-2.5 py-0.5 text-[11px] font-medium text-indigo-700">@@ -2373,6 +2421,15 @@>+ Add skill</button>+ {#if !agentVisible && (effectiveAgentId || $talkingHeadEnabled)}+ <button+ class="inline-flex items-center gap-1 rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-0.5 text-[11px] font-medium text-emerald-700 hover:bg-emerald-100"+ on:click={reviveAvatar}+ title="Bring the avatar back"+ >+ Bring avatar back+ </button>+ {/if}</div>{/if}<Composer@@ -2554,6 +2611,23 @@border-color: #E5E3DC;}+ .avatar-floater {+ transition: transform 1100ms cubic-bezier(0.55, 0, 0.7, 0.2), opacity 1100ms ease-in;+ }+ .avatar-dying {+ transform: translateY(120vh) rotate(35deg);+ opacity: 0;+ pointer-events: none;+ }+ .avatar-falling {+ animation: avatar-fall-in 900ms cubic-bezier(0.2, 0.8, 0.3, 1) both;+ }+ @keyframes avatar-fall-in {+ 0% { transform: translateY(-120vh) rotate(-25deg); opacity: 0; }+ 70% { transform: translateY(8px) rotate(2deg); opacity: 1; }+ 100% { transform: translateY(0) rotate(0); opacity: 1; }+ }+.thought-bubble {position: relative;width: 280px;diff --git a/chat/src/Message.svelte b/chat/src/Message.svelteindex 4f2ca3a38..ac13d549b 100644--- a/chat/src/Message.svelte+++ b/chat/src/Message.svelte@@ -2,7 +2,6 @@import { createEventDispatcher, tick } from 'svelte';import { v4 as uuidv4 } from 'uuid';import Button from './Button.svelte';- import CompanyLogo from './CompanyLogo.svelte';import {feCheck,feCheckCircle,@@ -160,6 +159,15 @@: 'relative flex w-full gap-x-3.5 self-start'}">{#if message.role !== 'user'}+ <div class="relative shrink-0">+ {#if message.role === 'assistant' && hasLogo && message.thinking && message.thoughts}+ <div+ class="absolute bottom-full left-1/2 mb-2 -translate-x-1/2 w-56 max-h-32 overflow-hidden rounded-2xl bg-white border border-slate-200 shadow-md px-3 py-2 text-[11px] leading-snug text-slate-700 animate-pulse"+ >+ <div class="line-clamp-5 italic">{message.thoughts}</div>+ <span class="absolute -bottom-1.5 left-1/2 -translate-x-1/2 h-3 w-3 rotate-45 bg-white border-r border-b border-slate-200"></span>+ </div>+ {/if}<buttondisabled={message.role === 'system'}on:click={() => {@@ -179,23 +187,19 @@: ''}">{#if message.role === 'assistant' && hasLogo}- {#if effectiveAgentId}- <span class="w-full h-full overflow-hidden inline-block shrink-0 rounded-[inherit]">- <!-- svelte-ignore custom-element-no-implicit-ns -->- <agent-3d- agent-id={effectiveAgentId}- mode="inline"- width="128"- height="128"- background="transparent"- kiosk- name-plate="off"- style="width:100%;height:100%;display:block;"- ></agent-3d>- </span>- {:else}- <CompanyLogo model={message.model} size="w-full h-full" rounded="rounded-[inherit]" />- {/if}+ <span class="w-full h-full overflow-hidden inline-block shrink-0 rounded-[inherit]">+ <!-- svelte-ignore custom-element-no-implicit-ns -->+ <agent-3d+ agent-id={effectiveAgentId}+ mode="inline"+ width="128"+ height="128"+ background="transparent"+ kiosk+ name-plate="off"+ style="width:100%;height:100%;display:block;"+ ></agent-3d>+ </span>{:else}<span class="m-auto">{#if message.role === 'system'}@@ -208,6 +212,7 @@</span>{/if}</button>+ </div>{/if}<!-- svelte-ignore a11y-no-static-element-interactions -->diff --git a/chat/src/convo.js b/chat/src/convo.jsindex 45e3f3f1c..4b981ee18 100644--- a/chat/src/convo.js+++ b/chat/src/convo.js@@ -199,6 +199,16 @@ export async function complete(convo, onupdate, onabort) {err.retryAfter =body?.retryAfter ?? (Number.isFinite(headerRetry) && headerRetry > 0 ? headerRetry : 30);err.scope = body?.scope;+ console.warn('[rate_limited 429]', {+ retryAfter: err.retryAfter,+ scope: err.scope,+ retryAfterHeader: response.headers.get('retry-after'),+ body,+ });+ } else if (activeSchema.length > 0 && /no endpoints?\s+(?:found|available)\s+that support tool/i.test(msg)) {+ err.code = 'tools_unsupported';+ err.modelId = model.id;+ err.toolNames = activeSchema.map((t) => t.function?.name || t.name).filter(Boolean);}throw err;}diff --git a/public/chat/index.html b/public/chat/index.htmlindex 85631b546..0a413f131 100644--- a/public/chat/index.html+++ b/public/chat/index.html@@ -43,8 +43,8 @@}}</script>- <script type="module" crossorigin src="/chat/assets/index-LB3jJ7Ru.js"></script>- <link rel="stylesheet" crossorigin href="/chat/assets/index-B-I9zSRy.css">+ <script type="module" crossorigin src="/chat/assets/index-BuK81Na5.js"></script>+ <link rel="stylesheet" crossorigin href="/chat/assets/index-Ddt4Owxb.css"></head><body><div id="app"></div>