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.

1.6 KB
Raw Blame
<script lang="ts">
	
	// The wallet identity of the agent you're chatting with. Tip it for a good
	// answer, copy its address, or open its full wallet on three.ws. Thin Svelte
	// wrapper over the shared portable wallet (one module, mounted everywhere the
	// avatar appears) so the chat never forks the wallet logic. Reads only public
	// data from the CORS:* wallet-embed endpoint; it is the visitor view by
	// construction (no owner controls in chat).
	import { onMount, onDestroy, untrack } from 'svelte';
	import { mountPortableWallet } from '$shared/portable-wallet.js';

	
	interface Props {
		agentId?: string;
		/** 'chip' toggles a popover; 'card' renders the wallet open inline. */
		variant?: string;
	}

	let { agentId = '', variant = 'chip' }: Props = $props();

	let host = $state();
	let mount = null;
	let mountedId = $state(null);

	function remount(id) {
		if (mount) {
			try { mount.destroy(); } catch { /* already gone */ }
			mount = null;
		}
		mountedId = null;
		if (!host || !id) return;
		mount = mountPortableWallet(host, {
			agentId: id,
			variant,
			tip: true,
			qr: true,
			share: true,
			theme: 'light',
		});
		mountedId = id;
	}

	onMount(() => remount(agentId));
	onDestroy(() => { try { mount?.destroy(); } catch { /* gone */ } });

	// Re-mount when the active agent changes.
	$effect.pre(() => {
		const id = agentId;
		if (host && id !== mountedId) untrack(() => remount(id));
	});
</script>

<span class="agent-wallet" bind:this={host}></span>

<style>
	.agent-wallet {
		display: inline-flex;
		align-items: center;
		max-width: 100%;
	}
</style>