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
add xspace-agent/xspace-agent/agent-voice-chat/public/index.html
overstepping6b221c3a1347
diff --git a/xspace-agent/xspace-agent/agent-voice-chat/public/index.html b/xspace-agent/xspace-agent/agent-voice-chat/public/index.htmlnew file mode 100644index 000000000..e7343e1e2--- /dev/null+++ b/xspace-agent/xspace-agent/agent-voice-chat/public/index.html@@ -0,0 +1,375 @@+<!DOCTYPE html>+<html lang="en" data-theme="luxury">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>AI Voice Chat</title>+ <meta name="description" content="AI Voice Chat - Talk to AI agents in real-time voice conversations">+ <meta name="theme-color" content="#09090b">+ <link rel="icon" href="/favicon.svg" type="image/svg+xml">+ <link rel="preconnect" href="https://fonts.googleapis.com">+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css" rel="stylesheet" type="text/css" />+ <script src="https://cdn.tailwindcss.com"></script>+ <script>+ tailwind.config = {+ theme: {+ extend: {+ fontFamily: { sans: ['Inter', 'system-ui', 'sans-serif'] },+ }+ }+ }+ </script>+ <style>+ body {+ font-family: 'Inter', system-ui, sans-serif;+ background: radial-gradient(ellipse at top, #1a1025 0%, #09090b 60%);+ min-height: 100vh;+ }+ /* Glassmorphism cards */+ .glass-card {+ background: rgba(255,255,255,0.03);+ backdrop-filter: blur(20px);+ -webkit-backdrop-filter: blur(20px);+ border: 1px solid rgba(255,255,255,0.06);+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);+ }+ .glass-card:hover {+ background: rgba(255,255,255,0.07);+ border-color: rgba(255,255,255,0.15);+ transform: translateY(-6px);+ box-shadow: 0 20px 60px -15px rgba(0,0,0,0.5);+ }+ /* Ambient glow effect on cards */+ .agent-card { position: relative; overflow: hidden; }+ .agent-card::before {+ content: '';+ position: absolute;+ inset: -1px;+ border-radius: inherit;+ padding: 1px;+ background: linear-gradient(135deg, transparent 40%, var(--card-primary, #a78bfa) 100%);+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);+ -webkit-mask-composite: xor;+ mask-composite: exclude;+ opacity: 0;+ transition: opacity 0.4s ease;+ }+ .agent-card:hover::before { opacity: 1; }++ /* Subtle grid background */+ .bg-grid {+ background-image:+ linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),+ linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);+ background-size: 60px 60px;+ }++ /* Animated gradient text */+ .gradient-text {+ background: linear-gradient(135deg, #c4b5fd 0%, #f0abfc 50%, #fbbf24 100%);+ -webkit-background-clip: text;+ -webkit-text-fill-color: transparent;+ background-clip: text;+ }++ /* Spinner */+ .spinner {+ width: 28px; height: 28px;+ border: 3px solid rgba(255,255,255,0.08);+ border-top-color: #a78bfa;+ border-radius: 50%;+ animation: spin 0.8s linear infinite;+ margin: 0 auto 10px;+ }+ @keyframes spin { to { transform: rotate(360deg); } }++ /* Error banner */+ .error-banner {+ background: rgba(239, 68, 68, 0.1);+ border: 1px solid rgba(239, 68, 68, 0.3);+ border-radius: 12px;+ padding: 16px;+ color: #fca5a5;+ display: flex;+ align-items: center;+ gap: 10px;+ flex-wrap: wrap;+ }+ .retry-btn {+ background: rgba(239, 68, 68, 0.15);+ border: 1px solid rgba(239, 68, 68, 0.3);+ border-radius: 8px;+ padding: 6px 14px;+ color: #fca5a5;+ cursor: pointer;+ font-size: 0.85rem;+ margin-left: auto;+ transition: all 0.2s;+ }+ .retry-btn:hover { background: rgba(239, 68, 68, 0.3); }+ </style>+</head>+<body class="bg-grid">+ <!-- Ambient blobs -->+ <div class="fixed inset-0 pointer-events-none overflow-hidden -z-10" aria-hidden="true">+ <div class="absolute -top-40 -left-40 w-96 h-96 bg-purple-600/10 rounded-full blur-3xl"></div>+ <div class="absolute top-1/3 -right-20 w-80 h-80 bg-fuchsia-600/8 rounded-full blur-3xl"></div>+ <div class="absolute -bottom-32 left-1/3 w-72 h-72 bg-amber-500/6 rounded-full blur-3xl"></div>+ </div>++ <div class="min-h-screen flex items-center justify-center p-6" role="main">+ <div class="w-full max-w-2xl text-center">+ <!-- Header -->+ <div class="mb-2">+ <span class="inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-medium tracking-wide uppercase bg-white/5 border border-white/10 text-zinc-400 mb-6">+ <span class="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span>+ Live+ </span>+ </div>+ <h1 class="text-4xl sm:text-5xl font-bold gradient-text mb-3 tracking-tight">AI Voice Chat</h1>+ <p class="text-zinc-500 mb-10 text-lg">Talk to AI agents in real-time. Click an agent to start a voice conversation.</p>++ <!-- Agents -->+ <div class="flex gap-5 justify-center flex-wrap" id="agentsContainer" role="list" aria-label="Available AI agents" aria-live="polite" aria-busy="true">+ <div aria-hidden="true" class="spinner"></div>+ <div class="text-zinc-500 text-sm">Loading agents...</div>+ </div>++ <!-- Rooms -->+ <div class="mt-14 pt-10 border-t border-white/5">+ <h2 class="text-sm font-semibold uppercase tracking-widest text-zinc-500 mb-5">Rooms</h2>+ <div class="flex gap-3 justify-center flex-wrap mb-5">+ <input type="text" id="roomIdInput" placeholder="Room ID (or leave blank)" aria-label="Room ID"+ class="input input-bordered bg-white/5 border-white/10 text-white placeholder:text-zinc-600 focus:border-purple-500 focus:outline-none w-52 text-sm">+ <button class="btn btn-primary btn-sm px-5 font-semibold" id="createRoomBtn" aria-label="Create a new room">Create Room</button>+ <button class="btn btn-ghost btn-sm px-5 font-semibold border border-white/10 hover:bg-white/5" id="joinRoomBtn" aria-label="Join existing room by ID">Join Room</button>+ </div>+ <div class="flex flex-col gap-2 text-left" id="roomList" role="list" aria-label="Active rooms" aria-live="polite" aria-busy="true">+ <div class="text-zinc-600 text-sm text-center py-2 no-rooms">Loading rooms...</div>+ </div>+ </div>+ </div>+ </div>+ <script>+ let agents = []++ /** Convert any CSS color to rgba(r,g,b,alpha) safely */+ function primaryWithAlpha(color, alpha) {+ if (color.startsWith("#")) {+ const hex = color.length === 4+ ? color.slice(1).split("").map(c => c + c).join("")+ : color.slice(1)+ const r = parseInt(hex.slice(0, 2), 16)+ const g = parseInt(hex.slice(2, 4), 16)+ const b = parseInt(hex.slice(4, 6), 16)+ return `rgba(${r},${g},${b},${alpha})`+ }+ if (color.startsWith("rgb(")) {+ return color.replace("rgb(", "rgba(").replace(")", `,${alpha})`)+ }+ return color+ }++ function showError(containerId, message, retryFn) {+ const container = document.getElementById(containerId)+ container.setAttribute("aria-busy", "false")+ const banner = document.createElement("div")+ banner.className = "error-banner"+ banner.setAttribute("role", "alert")+ const msg = document.createElement("span")+ msg.textContent = message+ banner.appendChild(msg)+ if (retryFn) {+ const btn = document.createElement("button")+ btn.className = "retry-btn"+ btn.textContent = "Retry"+ btn.setAttribute("aria-label", "Retry")+ btn.addEventListener("click", retryFn)+ banner.appendChild(btn)+ }+ container.innerHTML = ""+ container.appendChild(banner)+ }++ function showInlineError(message) {+ const existing = document.getElementById("roomErrorAlert")+ if (existing) existing.remove()+ const banner = document.createElement("div")+ banner.id = "roomErrorAlert"+ banner.className = "error-banner"+ banner.setAttribute("role", "alert")+ banner.style.marginTop = "10px"+ banner.textContent = message+ document.getElementById("roomList").insertAdjacentElement("beforebegin", banner)+ setTimeout(() => banner.remove(), 5000)+ }++ async function loadAgents() {+ const container = document.getElementById("agentsContainer")+ container.setAttribute("aria-busy", "true")+ container.innerHTML = "<div aria-hidden=\"true\" class=\"spinner\"></div><div class=\"loading\">Loading agents...</div>"+ try {+ const res = await fetch("/api/agents")+ if (!res.ok) throw new Error(`Server error ${res.status}`)+ const json = await res.json()+ agents = json.data || json+ container.innerHTML = ""+ container.setAttribute("aria-busy", "false")++ if (agents.length === 0) {+ container.innerHTML = '<div class="text-zinc-600 text-sm">No agents available</div>'+ return+ }++ agents.forEach(agent => {+ const card = document.createElement("a")+ card.href = "/voice/" + encodeURIComponent(agent.id)+ card.className = "agent-card glass-card rounded-2xl px-10 py-8 cursor-pointer no-underline text-white block"+ card.setAttribute("role", "listitem")+ card.setAttribute("aria-label", `Start voice chat with ${agent.name}`)++ const primary = agent.theme?.primary || "#a78bfa"+ card.style.setProperty("--card-primary", primary)++ card.addEventListener("mouseenter", () => {+ card.style.boxShadow = `0 20px 60px -10px ${primary}30`+ })+ card.addEventListener("mouseleave", () => {+ card.style.boxShadow = "none"+ })+ card.addEventListener("keydown", e => {+ if (e.key === "Enter" || e.key === " ") {+ e.preventDefault()+ card.click()+ }+ })++ const emojiDiv = document.createElement("div")+ emojiDiv.className = "text-4xl mb-4"+ emojiDiv.setAttribute("aria-hidden", "true")+ emojiDiv.textContent = "🎤"+ const nameDiv = document.createElement("div")+ nameDiv.className = "text-xl font-semibold tracking-tight"+ nameDiv.textContent = agent.name+ const descDiv = document.createElement("div")+ descDiv.className = "text-zinc-500 mt-2 text-sm"+ descDiv.textContent = agent.id++ card.appendChild(emojiDiv)+ card.appendChild(nameDiv)+ card.appendChild(descDiv)+ container.appendChild(card)+ })+ } catch (err) {+ showError("agentsContainer", "Failed to load agents: " + err.message, loadAgents)+ }+ }++ async function loadRooms() {+ const container = document.getElementById("roomList")+ container.setAttribute("aria-busy", "true")+ try {+ const res = await fetch("/api/rooms")+ if (!res.ok) throw new Error(`Server error ${res.status}`)+ const json = await res.json()+ const rooms = json.data || json+ container.setAttribute("aria-busy", "false")++ if (rooms.length === 0) {+ container.innerHTML = '<div class="text-zinc-600 text-sm text-center py-2">No active rooms</div>'+ return+ }++ container.innerHTML = ""+ rooms.forEach(room => {+ const div = document.createElement("div")+ div.className = "flex items-center justify-between glass-card rounded-xl px-4 py-3"+ div.setAttribute("role", "listitem")+ const firstAgent = agents[0]+ const joinUrl = firstAgent+ ? `/voice/${firstAgent.id}?room=${encodeURIComponent(room.id)}`+ : "#"++ const codeEl = document.createElement("code")+ codeEl.className = "bg-white/10 px-2 py-0.5 rounded text-sm font-mono text-white"+ codeEl.textContent = room.id+ const metaSpan = document.createElement("span")+ metaSpan.className = "text-zinc-500 text-xs ml-2"+ metaSpan.textContent = `${Number(room.clientCount)} client(s) · ${Number(room.agentCount)} agent(s)`+ const infoDiv = document.createElement("div")+ infoDiv.className = "flex items-center"+ infoDiv.appendChild(codeEl)+ infoDiv.appendChild(metaSpan)++ const joinLink = document.createElement("a")+ joinLink.href = joinUrl+ joinLink.className = "btn btn-primary btn-xs font-semibold"+ joinLink.setAttribute("aria-label", `Join room ${room.id}`)+ joinLink.textContent = "Join"++ div.appendChild(infoDiv)+ div.appendChild(joinLink)+ container.appendChild(div)+ })+ } catch (err) {+ showError("roomList", "Failed to load rooms: " + err.message, loadRooms)+ }+ }++ document.getElementById("createRoomBtn").addEventListener("click", async () => {+ const roomIdInput = document.getElementById("roomIdInput")+ const createBtn = document.getElementById("createRoomBtn")+ const body = {}+ if (roomIdInput.value.trim()) body.id = roomIdInput.value.trim()++ createBtn.disabled = true+ createBtn.textContent = "Creating..."+ try {+ const res = await fetch("/api/rooms", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(body)+ })+ if (!res.ok) {+ const errBody = await res.json().catch(() => ({}))+ throw new Error(errBody.error?.message || `Server error ${res.status}`)+ }+ const json = await res.json()+ const room = json.data || json+ roomIdInput.value = ""+ const firstAgent = agents[0]+ if (firstAgent) {+ window.location.href = `/voice/${firstAgent.id}?room=${encodeURIComponent(room.id)}`+ } else {+ loadRooms()+ }+ } catch (err) {+ showInlineError("Failed to create room: " + err.message)+ } finally {+ createBtn.disabled = false+ createBtn.textContent = "Create Room"+ }+ })++ document.getElementById("joinRoomBtn").addEventListener("click", () => {+ const roomId = document.getElementById("roomIdInput").value.trim()+ if (!roomId) {+ showInlineError("Please enter a Room ID to join")+ document.getElementById("roomIdInput").focus()+ return+ }+ const firstAgent = agents[0]+ if (firstAgent) {+ window.location.href = `/voice/${firstAgent.id}?room=${encodeURIComponent(roomId)}`+ }+ })++ loadAgents()+ loadRooms()+ </script>+</body>+</html>++