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: add talking head functionality with state management and toggle option
nirholas174e7085a393
diff --git a/chat/src/App.svelte b/chat/src/App.svelteindex 6d6629158..e0c489bdd 100644--- a/chat/src/App.svelte+++ b/chat/src/App.svelte@@ -22,7 +22,7 @@} from './providers.js';import ModelSelector from './ModelSelector.svelte';import CompanyLogo from './CompanyLogo.svelte';- import { controller, remoteServer, config, params, toolSchema, syncServer, brandConfig, ttsEnabled, localAgentId, route, mode, websiteCategory } from './stores.js';+ import { controller, remoteServer, config, params, toolSchema, syncServer, brandConfig, ttsEnabled, localAgentId, talkingHeadEnabled, route, mode, websiteCategory } from './stores.js';import AuthPage from './manus/pages/AuthPage.svelte';import Pricing from './manus/pages/Pricing.svelte';import MarketingPage from './manus/pages/MarketingPage.svelte';@@ -1167,6 +1167,8 @@// Floating 3D agentlet agentEl;let talkingHead;+ let talkingHeadReady = false;+ let pendingSpeak = null;let agentVisible = true;let agentScriptLoaded = false;let agentPickerOpen = false;@@ -1210,16 +1212,28 @@agentEl.speak(last.content);const emotion = detectEmotion(last.content);if (emotion) setTimeout(() => agentEl?.expressEmotion(emotion), 600);- } else if (talkingHead && agentVisible) {- talkingHead.speak({ text: last.content });+ } else if ($talkingHeadEnabled && agentVisible) {+ if (talkingHeadReady) {+ talkingHead.speak({ text: last.content });+ } else {+ pendingSpeak = last.content;+ }}- if ($ttsEnabled && window.speechSynthesis && !talkingHead) {+ if ($ttsEnabled && window.speechSynthesis && !$talkingHeadEnabled) {window.speechSynthesis.cancel();const utt = new SpeechSynthesisUtterance(last.content);window.speechSynthesis.speak(utt);}}++ function onTalkingHeadReady() {+ talkingHeadReady = true;+ if (pendingSpeak) {+ talkingHead.speak({ text: pendingSpeak });+ pendingSpeak = null;+ }+ }</script><svelte:window@@ -1660,8 +1674,8 @@background="transparent"style="width:220px;height:220px;border-radius:16px;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.18);"></agent-3d>- {:else if !effectiveAgentId && agentVisible}- <TalkingHead bind:this={talkingHead} />+ {:else if $talkingHeadEnabled && agentVisible}+ <TalkingHead bind:this={talkingHead} on:ready={onTalkingHeadReady} />{/if}<div class="flex items-center gap-1.5">@@ -1675,6 +1689,22 @@<Icon icon={feSpeaker} class="h-3.5 w-3.5 {$ttsEnabled ? 'text-indigo-500' : 'text-slate-400'}" /></button>+ <!-- TalkingHead toggle (when no agent-3d) -->+ {#if !effectiveAgentId}+ <button+ class="flex h-8 w-8 items-center justify-center rounded-full bg-white shadow-md ring-1 transition hover:bg-gray-50+ {$talkingHeadEnabled ? 'ring-indigo-400' : 'ring-gray-200'}"+ title={$talkingHeadEnabled ? 'Hide avatar' : 'Show 3D avatar'}+ on:click={() => {+ talkingHeadEnabled.update(v => !v);+ talkingHeadReady = false;+ pendingSpeak = null;+ }}+ >+ <Icon icon={feCpu} class="h-3.5 w-3.5 {$talkingHeadEnabled ? 'text-indigo-500' : 'text-slate-400'}" />+ </button>+ {/if}+<!-- Agent picker --><buttonclass="flex h-8 w-8 items-center justify-center rounded-full bg-white shadow-md ring-1 ring-gray-200 transition hover:bg-gray-50"@@ -1684,7 +1714,7 @@<Icon icon={feUsers} class="h-3.5 w-3.5 text-slate-600" /></button>- <!-- Show/hide toggle (only when agent set) -->+ <!-- Show/hide toggle (when agent-3d is set) -->{#if effectiveAgentId}<buttonclass="flex h-8 w-8 items-center justify-center rounded-full bg-white shadow-md ring-1 ring-gray-200 transition hover:bg-gray-50"diff --git a/chat/src/Message.svelte b/chat/src/Message.svelteindex abb29e7d2..910936d53 100644--- a/chat/src/Message.svelte+++ b/chat/src/Message.svelte@@ -22,20 +22,13 @@import Icon from './Icon.svelte';import MessageContent from './MessageContent.svelte';import { formatModelName, hasCompanyLogo } from './providers.js';- import { config, localAgentId, brandConfig } from './stores.js';-- $: effectiveAgentId = $localAgentId || $brandConfig.agent_id || '';-- $: lastAssistantIndex = convo.messages.reduce(- (last, m, idx) => (m.role === 'assistant' ? idx : last),- -1- );- $: isLastAssistant = message.role === 'assistant' && i === lastAssistantIndex;+ import { config } from './stores.js';import Toolcall from './Toolcall.svelte';import ToolcallButton from './ToolcallButton.svelte';const dispatch = createEventDispatcher();+export let message;export let i;export let convo;@@ -176,17 +169,7 @@? 'border border-teal-200 bg-teal-100 pb-px': ''}">- {#if isLastAssistant && effectiveAgentId}- <!-- svelte-ignore custom-element-no-implicit-ns -->- <agent-3d- agent-id={effectiveAgentId}- mode="embed"- width="36"- height="36"- background="transparent"- style="width:100%;height:100%;border-radius:inherit;overflow:hidden;pointer-events:none;"- ></agent-3d>- {:else if message.role === 'assistant' && hasLogo}+ {#if message.role === 'assistant' && hasLogo}<CompanyLogo model={message.model} size="w-full h-full" rounded="rounded-[inherit]" />{:else}<span class="m-auto">diff --git a/chat/src/stores.js b/chat/src/stores.jsindex 506c7d7ee..37052d492 100644--- a/chat/src/stores.js+++ b/chat/src/stores.js@@ -63,6 +63,7 @@ export const toolSchema = persisted('toolSchemaGroups', []);export const ttsEnabled = persisted('ttsEnabled', false);export const localAgentId = persisted('localAgentId', '');+export const talkingHeadEnabled = persisted('talkingHeadEnabled', false);export const route = writable(typeof window !== 'undefined' ? (window.location.hash.slice(1) || 'chat') : 'chat'