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.

feat: marketplace v2, creators API, avatar actions, billing receipts, trials, themes, cron

nirholas8fdd52f8673a
diff --git a/api/_lib/demo-avatars.js b/api/_lib/demo-avatars.js
index b70f406a7..da963fb82 100644
--- a/api/_lib/demo-avatars.js
+++ b/api/_lib/demo-avatars.js
@@ -44,148 +44,82 @@ export const DEMO_AVATARS = [
demoItem({ id: "avatar_demo_disk_default-avatar", slug: "demo-default-avatar", name: "Default Avatar", description: "Neutral starter humanoid — a clean base for skinning, retargeting, and accessories.", tags: ["humanoid","starter"], glbUrl: "https://three.ws/avatars/default.glb", image: null, sortDate: "2025-03-31T23:00:00.000Z", attribution: {"handle":"three.ws","displayName":"three.ws starter","url":"https://three.ws","license":"CC-BY 4.0"}, author: {"handle":"three.ws","displayName":"three.ws starter","profileUrl":"https://three.ws"} }),
demoItem({ id: "avatar_demo_disk_robot-expressive", slug: "demo-robot-expressive", name: "Robot Expressive", description: "Expressive robot character with multiple animation clips: idle, walk, run, jump, dance.", tags: ["robot","animated","rigged"], glbUrl: "https://three.ws/animations/robotexpressive.glb", image: null, sortDate: "2025-03-31T22:00:00.000Z", attribution: {"handle":"three.ws","displayName":"three.ws starter","url":"https://three.ws","license":"CC-BY 4.0"}, author: {"handle":"three.ws","displayName":"three.ws starter","profileUrl":"https://three.ws"} }),
demoItem({ id: "avatar_demo_disk_soldier", slug: "demo-soldier", name: "Soldier", description: "Rigged soldier character with locomotion animations baked in.", tags: ["humanoid","animated","rigged"], glbUrl: "https://three.ws/animations/soldier.glb", image: null, sortDate: "2025-03-31T21:00:00.000Z", attribution: {"handle":"three.ws","displayName":"three.ws starter","url":"https://three.ws","license":"CC-BY 4.0"}, author: {"handle":"three.ws","displayName":"three.ws starter","profileUrl":"https://three.ws"} }),
- demoItem({ id: "avatar_demo_k_alphablendmodetest", slug: "demo-alpha-blend-mode-test", name: "Alpha Blend Mode Test", description: "Plate of swatches showing alpha-blend, alpha-mask, and opaque modes side by side.", tags: ["test","material"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AlphaBlendModeTest/glTF-Binary/AlphaBlendModeTest.glb", image: null, sortDate: "2025-03-31T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_animatedcolorscube", slug: "demo-animated-colors-cube", name: "Animated Colors Cube", description: "Cube with animated per-vertex color values for animation channel testing.", tags: ["animated","primitive"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnimatedColorsCube/glTF-Binary/AnimatedColorsCube.glb", image: null, sortDate: "2025-03-31T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_animatedmorphcube", slug: "demo-animated-morph-cube", name: "Animated Morph Cube", description: "Cube morphing through blend-shape targets — a baseline morph-target test.", tags: ["animated","morph","primitive"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnimatedMorphCube/glTF-Binary/AnimatedMorphCube.glb", image: null, sortDate: "2025-03-31T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_animationpointeruvs", slug: "demo-animation-pointer-uvs", name: "Animation Pointer U Vs", description: "KHR_animation_pointer demo: animated UV transforms driven by pointer paths.", tags: ["animated","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnimationPointerUVs/glTF-Binary/AnimationPointerUVs.glb", image: null, sortDate: "2025-03-31T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_anisotropybarnlamp", slug: "demo-anisotropy-barn-lamp", name: "Anisotropy Barn Lamp", description: "Barn-style lamp with brushed-metal anisotropic shading on the housing.", tags: ["object","lighting","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnisotropyBarnLamp/glTF-Binary/AnisotropyBarnLamp.glb", image: null, sortDate: "2025-03-31T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_anisotropydisctest", slug: "demo-anisotropy-disc-test", name: "Anisotropy Disc Test", description: "Disc demonstrating brushed-metal anisotropic highlights at varying angles.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnisotropyDiscTest/glTF-Binary/AnisotropyDiscTest.glb", image: null, sortDate: "2025-03-31T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_anisotropyrotationtest", slug: "demo-anisotropy-rotation-test", name: "Anisotropy Rotation Test", description: "Anisotropy rotation test — checks correct tangent rotation across UVs.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnisotropyRotationTest/glTF-Binary/AnisotropyRotationTest.glb", image: null, sortDate: "2025-03-31T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_anisotropystrengthtest", slug: "demo-anisotropy-strength-test", name: "Anisotropy Strength Test", description: "Anisotropy strength sweep from 0 to 1 across a row of spheres.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnisotropyStrengthTest/glTF-Binary/AnisotropyStrengthTest.glb", image: null, sortDate: "2025-03-31T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_antiquecamera", slug: "demo-antique-camera", name: "Antique Camera", description: "Vintage twin-lens reflex camera with leather wrap and chrome detailing.", tags: ["object","photography","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AntiqueCamera/glTF-Binary/AntiqueCamera.glb", image: null, sortDate: "2025-03-31T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_attenuationtest", slug: "demo-attenuation-test", name: "Attenuation Test", description: "Volume attenuation test — colored glass blocks of varying thickness.", tags: ["test","material","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AttenuationTest/glTF-Binary/AttenuationTest.glb", image: null, sortDate: "2025-03-31T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_avocado", slug: "demo-avocado", name: "Avocado", description: "A photorealistic avocado — a Khronos classic for testing physically-based rendering.", tags: ["food","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Avocado/glTF-Binary/Avocado.glb", image: null, sortDate: "2025-03-31T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_barramundifish", slug: "demo-barramundi-fish", name: "Barramundi Fish", description: "Detailed barramundi fish with realistic scales and PBR materials.", tags: ["animal","fish","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BarramundiFish/glTF-Binary/BarramundiFish.glb", image: null, sortDate: "2025-03-31T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boombox", slug: "demo-boom-box", name: "Boom Box", description: "Retro boombox with intricate textures — a benchmark PBR asset.", tags: ["object","audio","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoomBox/glTF-Binary/BoomBox.glb", image: null, sortDate: "2025-03-31T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_box", slug: "demo-box", name: "Box", description: "The simplest possible glTF: a single textured cube.", tags: ["primitive","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Box/glTF-Binary/Box.glb", image: null, sortDate: "2025-03-31T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boxanimated", slug: "demo-box-animated", name: "Box Animated", description: "A simple box with a baked transform animation.", tags: ["primitive","animated","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoxAnimated/glTF-Binary/BoxAnimated.glb", image: null, sortDate: "2025-03-31T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boxinterleaved", slug: "demo-box-interleaved", name: "Box Interleaved", description: "A box with interleaved vertex attributes — a glTF format test.", tags: ["primitive","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoxInterleaved/glTF-Binary/BoxInterleaved.glb", image: null, sortDate: "2025-03-31T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boxtextured", slug: "demo-box-textured", name: "Box Textured", description: "A box with a texture map applied.", tags: ["primitive","textured"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoxTextured/glTF-Binary/BoxTextured.glb", image: null, sortDate: "2025-03-31T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boxtexturednonpoweroftwo", slug: "demo-box-textured-non-power-of-two", name: "Box Textured Non Power Of Two", description: "A textured box demonstrating non-power-of-two textures.", tags: ["primitive","textured","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoxTexturedNonPowerOfTwo/glTF-Binary/BoxTexturedNonPowerOfTwo.glb", image: null, sortDate: "2025-03-31T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_boxvertexcolors", slug: "demo-box-vertex-colors", name: "Box Vertex Colors", description: "A box with per-vertex colors instead of textures.", tags: ["primitive","colors"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoxVertexColors/glTF-Binary/BoxVertexColors.glb", image: null, sortDate: "2025-03-31T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_brainstem", slug: "demo-brain-stem", name: "Brain Stem", description: "Walking humanoid figure with skinned mesh and animations.", tags: ["humanoid","rigged","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BrainStem/glTF-Binary/BrainStem.glb", image: null, sortDate: "2025-03-31T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_carconcept", slug: "demo-car-concept", name: "Car Concept", description: "Concept car with sculpted bodywork and clear-coat materials.", tags: ["vehicle","concept","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CarConcept/glTF-Binary/CarConcept.glb", image: null, sortDate: "2025-03-31T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_carbonfibre", slug: "demo-carbon-fibre", name: "Carbon Fibre", description: "Carbon-fibre weave material test — anisotropy and clear-coat.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CarbonFibre/glTF-Binary/CarbonFibre.glb", image: null, sortDate: "2025-03-30T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_cesiumman", slug: "demo-cesium-man", name: "Cesium Man", description: "The iconic Cesium Man — walking animation, fully rigged.", tags: ["humanoid","rigged","animated","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CesiumMan/glTF-Binary/CesiumMan.glb", image: null, sortDate: "2025-03-30T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_cesiummilktruck", slug: "demo-cesium-milk-truck", name: "Cesium Milk Truck", description: "Cesium Milk Truck rolling along — wheel rotation animation.", tags: ["vehicle","animated","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CesiumMilkTruck/glTF-Binary/CesiumMilkTruck.glb", image: null, sortDate: "2025-03-30T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_chairdamaskpurplegold", slug: "demo-chair-damask-purplegold", name: "Chair Damask Purplegold", description: "Ornate damask chair with gold leaf and patterned upholstery.", tags: ["furniture","pbr","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ChairDamaskPurplegold/glTF-Binary/ChairDamaskPurplegold.glb", image: null, sortDate: "2025-03-30T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_chronographwatch", slug: "demo-chronograph-watch", name: "Chronograph Watch", description: "Detailed chronograph wristwatch with metallic finish and glass face.", tags: ["object","pbr","metal"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ChronographWatch/glTF-Binary/ChronographWatch.glb", image: null, sortDate: "2025-03-30T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_clearcoatcarpaint", slug: "demo-clear-coat-car-paint", name: "Clear Coat Car Paint", description: "Clear-coat car paint material test under varied lighting.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ClearCoatCarPaint/glTF-Binary/ClearCoatCarPaint.glb", image: null, sortDate: "2025-03-30T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_clearcoattest", slug: "demo-clear-coat-test", name: "Clear Coat Test", description: "Clear-coat extension reference test.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ClearCoatTest/glTF-Binary/ClearCoatTest.glb", image: null, sortDate: "2025-03-30T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_clearcoatwicker", slug: "demo-clearcoat-wicker", name: "Clearcoat Wicker", description: "Wicker pattern with clear-coat layer.", tags: ["material","pbr","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ClearcoatWicker/glTF-Binary/ClearcoatWicker.glb", image: null, sortDate: "2025-03-30T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_commercialrefrigerator", slug: "demo-commercial-refrigerator", name: "Commercial Refrigerator", description: "Commercial glass-door refrigerator with transmission.", tags: ["object","commercial","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CommercialRefrigerator/glTF-Binary/CommercialRefrigerator.glb", image: null, sortDate: "2025-03-30T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparealphacoverage", slug: "demo-compare-alpha-coverage", name: "Compare Alpha Coverage", description: "Side-by-side comparison of alpha-coverage approaches for foliage and fabric.", tags: ["test","material"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareAlphaCoverage/glTF-Binary/CompareAlphaCoverage.glb", image: null, sortDate: "2025-03-30T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareambientocclusion", slug: "demo-compare-ambient-occlusion", name: "Compare Ambient Occlusion", description: "Ambient occlusion on/off comparison on a reference object.", tags: ["test","material"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareAmbientOcclusion/glTF-Binary/CompareAmbientOcclusion.glb", image: null, sortDate: "2025-03-30T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareanisotropy", slug: "demo-compare-anisotropy", name: "Compare Anisotropy", description: "Comparison spheres demonstrating anisotropic vs isotropic specular.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareAnisotropy/glTF-Binary/CompareAnisotropy.glb", image: null, sortDate: "2025-03-30T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparebasecolor", slug: "demo-compare-base-color", name: "Compare Base Color", description: "Base color sweep across the sRGB cube for material correctness checks.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareBaseColor/glTF-Binary/CompareBaseColor.glb", image: null, sortDate: "2025-03-30T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareclearcoat", slug: "demo-compare-clearcoat", name: "Compare Clearcoat", description: "Clearcoat extension comparison — with vs without the clear-coat layer.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareClearcoat/glTF-Binary/CompareClearcoat.glb", image: null, sortDate: "2025-03-30T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparedispersion", slug: "demo-compare-dispersion", name: "Compare Dispersion", description: "Comparison of glass with and without chromatic dispersion.", tags: ["test","material","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareDispersion/glTF-Binary/CompareDispersion.glb", image: null, sortDate: "2025-03-30T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareemissivestrength", slug: "demo-compare-emissive-strength", name: "Compare Emissive Strength", description: "KHR_materials_emissive_strength comparison — HDR-bright vs LDR emission.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareEmissiveStrength/glTF-Binary/CompareEmissiveStrength.glb", image: null, sortDate: "2025-03-30T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareior", slug: "demo-compare-ior", name: "Compare Ior", description: "Index-of-refraction comparison sweeping IOR from 1.0 to 2.4.", tags: ["test","material","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareIor/glTF-Binary/CompareIor.glb", image: null, sortDate: "2025-03-30T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareiridescence", slug: "demo-compare-iridescence", name: "Compare Iridescence", description: "Iridescence on/off comparison highlighting thin-film color shifts.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareIridescence/glTF-Binary/CompareIridescence.glb", image: null, sortDate: "2025-03-30T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparemetallic", slug: "demo-compare-metallic", name: "Compare Metallic", description: "Metallic factor sweep from 0 (dielectric) to 1 (metal).", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareMetallic/glTF-Binary/CompareMetallic.glb", image: null, sortDate: "2025-03-30T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparenormal", slug: "demo-compare-normal", name: "Compare Normal", description: "Normal map intensity comparison across multiple bump strengths.", tags: ["test","material"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareNormal/glTF-Binary/CompareNormal.glb", image: null, sortDate: "2025-03-30T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_compareroughness", slug: "demo-compare-roughness", name: "Compare Roughness", description: "Roughness sweep from mirror to fully rough across spheres.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareRoughness/glTF-Binary/CompareRoughness.glb", image: null, sortDate: "2025-03-30T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparesheen", slug: "demo-compare-sheen", name: "Compare Sheen", description: "KHR_materials_sheen comparison — fabric-like grazing-angle highlights.", tags: ["test","material","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareSheen/glTF-Binary/CompareSheen.glb", image: null, sortDate: "2025-03-30T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparespecular", slug: "demo-compare-specular", name: "Compare Specular", description: "KHR_materials_specular comparison sweeping specular factor.", tags: ["test","material","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareSpecular/glTF-Binary/CompareSpecular.glb", image: null, sortDate: "2025-03-30T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparetransmission", slug: "demo-compare-transmission", name: "Compare Transmission", description: "Transmission on/off comparison — solid vs see-through materials.", tags: ["test","material","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareTransmission/glTF-Binary/CompareTransmission.glb", image: null, sortDate: "2025-03-30T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_comparevolume", slug: "demo-compare-volume", name: "Compare Volume", description: "Volume thickness comparison demonstrating refraction depth.", tags: ["test","material","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CompareVolume/glTF-Binary/CompareVolume.glb", image: null, sortDate: "2025-03-29T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_cubevisibility", slug: "demo-cube-visibility", name: "Cube Visibility", description: "Visibility flag test — cubes hidden via the visibility extension.", tags: ["test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CubeVisibility/glTF-Binary/CubeVisibility.glb", image: null, sortDate: "2025-03-29T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_damagedhelmet", slug: "demo-damaged-helmet", name: "Damaged Helmet", description: "Battle-worn sci-fi helmet — possibly the most-rendered glTF in history.", tags: ["object","armor","pbr","iconic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DamagedHelmet/glTF-Binary/DamagedHelmet.glb", image: null, sortDate: "2025-03-29T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_diffusetransmissionplant", slug: "demo-diffuse-transmission-plant", name: "Diffuse Transmission Plant", description: "Botanical leaves demonstrating diffuse transmission for thin foliage.", tags: ["plant","transmission","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DiffuseTransmissionPlant/glTF-Binary/DiffuseTransmissionPlant.glb", image: null, sortDate: "2025-03-29T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_diffusetransmissionteacup", slug: "demo-diffuse-transmission-teacup", name: "Diffuse Transmission Teacup", description: "Bone china teacup with translucent walls.", tags: ["object","transmission","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DiffuseTransmissionTeacup/glTF-Binary/DiffuseTransmissionTeacup.glb", image: null, sortDate: "2025-03-29T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_diffusetransmissiontest", slug: "demo-diffuse-transmission-test", name: "Diffuse Transmission Test", description: "KHR_materials_diffuse_transmission test on thin foliage panels.", tags: ["test","material","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DiffuseTransmissionTest/glTF-Binary/DiffuseTransmissionTest.glb", image: null, sortDate: "2025-03-29T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_directionallight", slug: "demo-directional-light", name: "Directional Light", description: "Directional (sun) light reference scene with shadow-casting plane.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DirectionalLight/glTF-Binary/DirectionalLight.glb", image: null, sortDate: "2025-03-29T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_dispersiontest", slug: "demo-dispersion-test", name: "Dispersion Test", description: "Chromatic dispersion test — light splitting across a glass prism.", tags: ["test","glass","material"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DispersionTest/glTF-Binary/DispersionTest.glb", image: null, sortDate: "2025-03-29T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_dragonattenuation", slug: "demo-dragon-attenuation", name: "Dragon Attenuation", description: "Glass dragon demonstrating volume attenuation and transmission.", tags: ["creature","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DragonAttenuation/glTF-Binary/DragonAttenuation.glb", image: null, sortDate: "2025-03-29T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_dragondispersion", slug: "demo-dragon-dispersion", name: "Dragon Dispersion", description: "Glass dragon with chromatic dispersion for prismatic light.", tags: ["creature","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DragonDispersion/glTF-Binary/DragonDispersion.glb", image: null, sortDate: "2025-03-29T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_duck", slug: "demo-duck", name: "Duck", description: "The Khronos Duck — every 3D dev has met this duck.", tags: ["animal","iconic","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Duck/glTF-Binary/Duck.glb", image: null, sortDate: "2025-03-29T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_emissivestrengthtest", slug: "demo-emissive-strength-test", name: "Emissive Strength Test", description: "Emissive intensity sweep showing HDR brightness in scene-referred lighting.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/EmissiveStrengthTest/glTF-Binary/EmissiveStrengthTest.glb", image: null, sortDate: "2025-03-29T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_fox", slug: "demo-fox", name: "Fox", description: "Stylized fox with three baked animations — Survey, Walk, Run.", tags: ["animal","animated","rigged","iconic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Fox/glTF-Binary/Fox.glb", image: null, sortDate: "2025-03-29T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_glamvelvetsofa", slug: "demo-glam-velvet-sofa", name: "Glam Velvet Sofa", description: "Velvet sofa demonstrating sheen for fabric materials.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlamVelvetSofa/glTF-Binary/GlamVelvetSofa.glb", image: null, sortDate: "2025-03-29T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_glassbrokenwindow", slug: "demo-glass-broken-window", name: "Glass Broken Window", description: "Shattered window pane with refraction and transmission.", tags: ["object","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassBrokenWindow/glTF-Binary/GlassBrokenWindow.glb", image: null, sortDate: "2025-03-29T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_glasshurricanecandleholder", slug: "demo-glass-hurricane-candle-holder", name: "Glass Hurricane Candle Holder", description: "Hurricane candle holder with thick glass and a flickering candle.", tags: ["object","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassHurricaneCandleHolder/glTF-Binary/GlassHurricaneCandleHolder.glb", image: null, sortDate: "2025-03-29T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_glassvaseflowers", slug: "demo-glass-vase-flowers", name: "Glass Vase Flowers", description: "Cut-glass vase with flowers — refraction through curved glass.", tags: ["object","glass","plant"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassVaseFlowers/glTF-Binary/GlassVaseFlowers.glb", image: null, sortDate: "2025-03-29T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_iortestgrid", slug: "demo-iortest-grid", name: "IOR Test Grid", description: "IOR test grid — glass spheres at every common index of refraction.", tags: ["test","material","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IORTestGrid/glTF-Binary/IORTestGrid.glb", image: null, sortDate: "2025-03-29T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_interpolationtest", slug: "demo-interpolation-test", name: "Interpolation Test", description: "Animation interpolation modes: STEP, LINEAR, CUBICSPLINE side by side.", tags: ["test","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/InterpolationTest/glTF-Binary/InterpolationTest.glb", image: null, sortDate: "2025-03-29T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_iridescenceabalone", slug: "demo-iridescence-abalone", name: "Iridescence Abalone", description: "Abalone shell with natural iridescence.", tags: ["object","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceAbalone/glTF-Binary/IridescenceAbalone.glb", image: null, sortDate: "2025-03-29T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_iridescencelamp", slug: "demo-iridescence-lamp", name: "Iridescence Lamp", description: "Lamp shade with iridescent thin-film effect.", tags: ["object","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceLamp/glTF-Binary/IridescenceLamp.glb", image: null, sortDate: "2025-03-29T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_iridescencesuzanne", slug: "demo-iridescence-suzanne", name: "Iridescence Suzanne", description: "Blender Suzanne with iridescent thin-film material.", tags: ["classic","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceSuzanne/glTF-Binary/IridescenceSuzanne.glb", image: null, sortDate: "2025-03-29T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_iridescentdishwitholives", slug: "demo-iridescent-dish-with-olives", name: "Iridescent Dish With Olives", description: "Iridescent ceramic dish holding olives.", tags: ["food","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescentDishWithOlives/glTF-Binary/IridescentDishWithOlives.glb", image: null, sortDate: "2025-03-29T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_lantern", slug: "demo-lantern", name: "Lantern", description: "Traditional lantern with intricate metalwork — a Khronos PBR benchmark.", tags: ["object","metal","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Lantern/glTF-Binary/Lantern.glb", image: null, sortDate: "2025-03-29T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_lightvisibility", slug: "demo-light-visibility", name: "Light Visibility", description: "Light-source visibility flag test for KHR_lights_punctual.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/LightVisibility/glTF-Binary/LightVisibility.glb", image: null, sortDate: "2025-03-28T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_lightspunctuallamp", slug: "demo-lights-punctual-lamp", name: "Lights Punctual Lamp", description: "Lamp model wired up via KHR_lights_punctual — real point light source.", tags: ["object","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/LightsPunctualLamp/glTF-Binary/LightsPunctualLamp.glb", image: null, sortDate: "2025-03-28T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_materialsvariantsshoe", slug: "demo-materials-variants-shoe", name: "Materials Variants Shoe", description: "Shoe with material variants — swap colorways at runtime.", tags: ["fashion","shoe","variants"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MaterialsVariantsShoe/glTF-Binary/MaterialsVariantsShoe.glb", image: null, sortDate: "2025-03-28T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_metalroughspheres", slug: "demo-metal-rough-spheres", name: "Metal Rough Spheres", description: "Spheres demonstrating the full metallic-roughness range.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MetalRoughSpheres/glTF-Binary/MetalRoughSpheres.glb", image: null, sortDate: "2025-03-28T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_metalroughspheresnotextures", slug: "demo-metal-rough-spheres-no-textures", name: "Metal Rough Spheres No Textures", description: "Untextured metallic-roughness sphere grid.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MetalRoughSpheresNoTextures/glTF-Binary/MetalRoughSpheresNoTextures.glb", image: null, sortDate: "2025-03-28T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_morphprimitivestest", slug: "demo-morph-primitives-test", name: "Morph Primitives Test", description: "Morph target test for blend shapes on primitives.", tags: ["test","morph"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MorphPrimitivesTest/glTF-Binary/MorphPrimitivesTest.glb", image: null, sortDate: "2025-03-28T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_morphstresstest", slug: "demo-morph-stress-test", name: "Morph Stress Test", description: "Stress test for many simultaneous morph targets.", tags: ["test","morph"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MorphStressTest/glTF-Binary/MorphStressTest.glb", image: null, sortDate: "2025-03-28T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_multiuvtest", slug: "demo-multi-uvtest", name: "Multi UV Test", description: "Multi-UV-channel test for textures using TEXCOORD_1.", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MultiUVTest/glTF-Binary/MultiUVTest.glb", image: null, sortDate: "2025-03-28T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_negativescaletest", slug: "demo-negative-scale-test", name: "Negative Scale Test", description: "Negative scaling and winding-order test.", tags: ["test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/NegativeScaleTest/glTF-Binary/NegativeScaleTest.glb", image: null, sortDate: "2025-03-28T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_normaltangentmirrortest", slug: "demo-normal-tangent-mirror-test", name: "Normal Tangent Mirror Test", description: "Mirror-symmetry test for normal and tangent vectors.", tags: ["test","normals"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/NormalTangentMirrorTest/glTF-Binary/NormalTangentMirrorTest.glb", image: null, sortDate: "2025-03-28T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_normaltangenttest", slug: "demo-normal-tangent-test", name: "Normal Tangent Test", description: "Normal/tangent space correctness test.", tags: ["test","normals"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/NormalTangentTest/glTF-Binary/NormalTangentTest.glb", image: null, sortDate: "2025-03-28T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_orientationtest", slug: "demo-orientation-test", name: "Orientation Test", description: "Coordinate system orientation test for glTF importers.", tags: ["test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/OrientationTest/glTF-Binary/OrientationTest.glb", image: null, sortDate: "2025-03-28T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_playsetlighttest", slug: "demo-playset-light-test", name: "Playset Light Test", description: "Toy playset lighting test — multiple punctual lights interacting.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PlaysetLightTest/glTF-Binary/PlaysetLightTest.glb", image: null, sortDate: "2025-03-28T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_pointlightintensitytest", slug: "demo-point-light-intensity-test", name: "Point Light Intensity Test", description: "Point light intensity falloff test.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PointLightIntensityTest/glTF-Binary/PointLightIntensityTest.glb", image: null, sortDate: "2025-03-28T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_potofcoals", slug: "demo-pot-of-coals", name: "Pot Of Coals", description: "Glowing pot of coals demonstrating emissive strength.", tags: ["object","fire","emissive"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PotOfCoals/glTF-Binary/PotOfCoals.glb", image: null, sortDate: "2025-03-28T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_potofcoalsanimationpointer", slug: "demo-pot-of-coals-animation-pointer", name: "Pot Of Coals Animation Pointer", description: "Pot of coals with KHR_animation_pointer driving emissive flicker.", tags: ["object","fire","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PotOfCoalsAnimationPointer/glTF-Binary/PotOfCoalsAnimationPointer.glb", image: null, sortDate: "2025-03-28T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_recursiveskeletons", slug: "demo-recursive-skeletons", name: "Recursive Skeletons", description: "Stress test for deeply nested skeletal hierarchies.", tags: ["test","skinning"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/RecursiveSkeletons/glTF-Binary/RecursiveSkeletons.glb", image: null, sortDate: "2025-03-28T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_riggedfigure", slug: "demo-rigged-figure", name: "Rigged Figure", description: "Bare-bones rigged humanoid for testing skinning.", tags: ["humanoid","rigged","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/RiggedFigure/glTF-Binary/RiggedFigure.glb", image: null, sortDate: "2025-03-28T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_riggedsimple", slug: "demo-rigged-simple", name: "Rigged Simple", description: "Minimal rigged figure — the smallest possible skinned mesh.", tags: ["rigged","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/RiggedSimple/glTF-Binary/RiggedSimple.glb", image: null, sortDate: "2025-03-28T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_scatteringskull", slug: "demo-scattering-skull", name: "Scattering Skull", description: "Skull with subsurface scattering for translucent bone material.", tags: ["object","sss","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ScatteringSkull/glTF-Binary/ScatteringSkull.glb", image: null, sortDate: "2025-03-28T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_sheenchair", slug: "demo-sheen-chair", name: "Sheen Chair", description: "Armchair upholstered in sheen-fabric demonstrating grazing-angle highlights.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SheenChair/glTF-Binary/SheenChair.glb", image: null, sortDate: "2025-03-28T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_sheentestgrid", slug: "demo-sheen-test-grid", name: "Sheen Test Grid", description: "Sheen test grid sweeping roughness and color.", tags: ["test","material","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SheenTestGrid/glTF-Binary/SheenTestGrid.glb", image: null, sortDate: "2025-03-28T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_sheenwoodleathersofa", slug: "demo-sheen-wood-leather-sofa", name: "Sheen Wood Leather Sofa", description: "Sofa combining sheen fabric, leather, and wood — a multi-material reference.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SheenWoodLeatherSofa/glTF-Binary/SheenWoodLeatherSofa.glb", image: null, sortDate: "2025-03-28T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_simpleinstancing", slug: "demo-simple-instancing", name: "Simple Instancing", description: "EXT_mesh_gpu_instancing demonstration.", tags: ["test","instancing"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SimpleInstancing/glTF-Binary/SimpleInstancing.glb", image: null, sortDate: "2025-03-28T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_specglossvsmetalrough", slug: "demo-spec-gloss-vs-metal-rough", name: "Spec Gloss Vs Metal Rough", description: "Spec-gloss vs metallic-roughness workflow comparison.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SpecGlossVsMetalRough/glTF-Binary/SpecGlossVsMetalRough.glb", image: null, sortDate: "2025-03-27T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_specularsilkpouf", slug: "demo-specular-silk-pouf", name: "Specular Silk Pouf", description: "Silk pouf footstool with specular sheen.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SpecularSilkPouf/glTF-Binary/SpecularSilkPouf.glb", image: null, sortDate: "2025-03-27T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_speculartest", slug: "demo-specular-test", name: "Specular Test", description: "KHR_materials_specular extension test.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SpecularTest/glTF-Binary/SpecularTest.glb", image: null, sortDate: "2025-03-27T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_sunglasseskhronos", slug: "demo-sunglasses-khronos", name: "Sunglasses Khronos", description: "Aviator-style sunglasses with tinted transmission lenses and metal frame.", tags: ["fashion","object","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SunglassesKhronos/glTF-Binary/SunglassesKhronos.glb", image: null, sortDate: "2025-03-27T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_texturecoordinatetest", slug: "demo-texture-coordinate-test", name: "Texture Coordinate Test", description: "UV coordinate correctness test.", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TextureCoordinateTest/glTF-Binary/TextureCoordinateTest.glb", image: null, sortDate: "2025-03-27T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_textureencodingtest", slug: "demo-texture-encoding-test", name: "Texture Encoding Test", description: "Texture color-space encoding test (sRGB vs linear).", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TextureEncodingTest/glTF-Binary/TextureEncodingTest.glb", image: null, sortDate: "2025-03-27T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_texturelinearinterpolationtest", slug: "demo-texture-linear-interpolation-test", name: "Texture Linear Interpolation Test", description: "Linear texture interpolation test.", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TextureLinearInterpolationTest/glTF-Binary/TextureLinearInterpolationTest.glb", image: null, sortDate: "2025-03-27T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_texturesettingstest", slug: "demo-texture-settings-test", name: "Texture Settings Test", description: "Texture sampler settings test.", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TextureSettingsTest/glTF-Binary/TextureSettingsTest.glb", image: null, sortDate: "2025-03-27T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_texturetransformmultitest", slug: "demo-texture-transform-multi-test", name: "Texture Transform Multi Test", description: "KHR_texture_transform test with multiple offsets/scales/rotations.", tags: ["test","textures"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TextureTransformMultiTest/glTF-Binary/TextureTransformMultiTest.glb", image: null, sortDate: "2025-03-27T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_toycar", slug: "demo-toy-car", name: "Toy Car", description: "Stylized toy car with chunky proportions and shiny paint.", tags: ["vehicle","toy","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ToyCar/glTF-Binary/ToyCar.glb", image: null, sortDate: "2025-03-27T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_transmissionordertest", slug: "demo-transmission-order-test", name: "Transmission Order Test", description: "Render-order test for stacked transmissive materials.", tags: ["test","material","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TransmissionOrderTest/glTF-Binary/TransmissionOrderTest.glb", image: null, sortDate: "2025-03-27T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_transmissionroughnesstest", slug: "demo-transmission-roughness-test", name: "Transmission Roughness Test", description: "Transmission with varying roughness test.", tags: ["material","test","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TransmissionRoughnessTest/glTF-Binary/TransmissionRoughnessTest.glb", image: null, sortDate: "2025-03-27T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_transmissiontest", slug: "demo-transmission-test", name: "Transmission Test", description: "KHR_materials_transmission extension test.", tags: ["material","test","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TransmissionTest/glTF-Binary/TransmissionTest.glb", image: null, sortDate: "2025-03-27T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_transmissionthinwalltestgrid", slug: "demo-transmission-thinwall-test-grid", name: "Transmission Thinwall Test Grid", description: "Thin-wall transmission grid test.", tags: ["material","test","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/TransmissionThinwallTestGrid/glTF-Binary/TransmissionThinwallTestGrid.glb", image: null, sortDate: "2025-03-27T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_usdshaderballforgltf", slug: "demo-usdshader-ball-for-gltf", name: "USD Shader Ball For Gltf", description: "Pixar USD-compatible shader ball ported to glTF for cross-format material checks.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/USDShaderBallForGltf/glTF-Binary/USDShaderBallForGltf.glb", image: null, sortDate: "2025-03-27T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_unicode❤♻test", slug: "demo-unicode❤♻test", name: "Unicode❤♻Test", description: "Unicode glTF asset name test (the file name itself is the test).", tags: ["test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Unicode❤♻Test/glTF-Binary/Unicode❤♻Test.glb", image: null, sortDate: "2025-03-27T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_unlittest", slug: "demo-unlit-test", name: "Unlit Test", description: "KHR_materials_unlit extension test — flat shading.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/UnlitTest/glTF-Binary/UnlitTest.glb", image: null, sortDate: "2025-03-27T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_vertexcolortest", slug: "demo-vertex-color-test", name: "Vertex Color Test", description: "Per-vertex color test plane.", tags: ["test","colors"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/VertexColorTest/glTF-Binary/VertexColorTest.glb", image: null, sortDate: "2025-03-27T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_virtualcity", slug: "demo-virtual-city", name: "Virtual City", description: "Stylized low-poly city block — buildings, streets, props.", tags: ["scene","environment","urban"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/VirtualCity/glTF-Binary/VirtualCity.glb", image: null, sortDate: "2025-03-27T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_waterbottle", slug: "demo-water-bottle", name: "Water Bottle", description: "Water bottle with translucent plastic body and embossed label.", tags: ["object","pbr","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/WaterBottle/glTF-Binary/WaterBottle.glb", image: null, sortDate: "2025-03-27T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_k_xmpmetadataroundedcube", slug: "demo-xmp-metadata-rounded-cube", name: "Xmp Metadata Rounded Cube", description: "Rounded cube embedding XMP metadata for attribution.", tags: ["test","metadata"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/XmpMetadataRoundedCube/glTF-Binary/XmpMetadataRoundedCube.glb", image: null, sortDate: "2025-03-27T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
- demoItem({ id: "avatar_demo_t_flamingo", slug: "demo-flamingo", name: "Flamingo", description: "Pink flamingo in flight.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Flamingo.glb", image: null, sortDate: "2025-03-27T02:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_horse", slug: "demo-horse", name: "Horse", description: "Galloping horse with skeletal animation.", tags: ["animal","animated","rigged"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Horse.glb", image: null, sortDate: "2025-03-27T01:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_littlesttokyo", slug: "demo-littlesttokyo", name: "LittlestTokyo", description: "Animated Tokyo street scene by Glen Fox — cars driving, neon, atmosphere.", tags: ["scene","environment","urban","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/LittlestTokyo.glb", image: null, sortDate: "2025-03-27T00:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_michelle", slug: "demo-michelle", name: "Michelle", description: "Michelle character with Mixamo-compatible rig.", tags: ["humanoid","rigged","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Michelle.glb", image: null, sortDate: "2025-03-26T23:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_parrot", slug: "demo-parrot", name: "Parrot", description: "Flying parrot with wing-flap animation.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Parrot.glb", image: null, sortDate: "2025-03-26T22:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_primaryiondrive", slug: "demo-primaryiondrive", name: "PrimaryIonDrive", description: "Primary ion drive engine module with animated pulse.", tags: ["scifi","vehicle","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/PrimaryIonDrive.glb", image: null, sortDate: "2025-03-26T21:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_shaderball", slug: "demo-shaderball", name: "ShaderBall", description: "Shader ball — the standard material test sphere with reflective base.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShaderBall.glb", image: null, sortDate: "2025-03-26T20:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_shaderball2", slug: "demo-shaderball2", name: "ShaderBall2", description: "Alternate shader ball variant.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShaderBall2.glb", image: null, sortDate: "2025-03-26T19:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_shadowmappablemesh", slug: "demo-shadowmappablemesh", name: "ShadowmappableMesh", description: "Mesh with high-frequency detail for shadow-mapping tests.", tags: ["test","shadows"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShadowmappableMesh.glb", image: null, sortDate: "2025-03-26T18:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_soldier", slug: "demo-soldier-threejs", name: "Soldier", description: "Soldier character with walk, run, and idle animations — three.js classic.", tags: ["humanoid","rigged","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Soldier.glb", image: null, sortDate: "2025-03-26T17:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_stork", slug: "demo-stork", name: "Stork", description: "Stork mid-flight with wing animation.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Stork.glb", image: null, sortDate: "2025-03-26T16:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_xbot", slug: "demo-xbot", name: "Xbot", description: "X-Bot rigged humanoid robot, ready for retargeting.", tags: ["robot","rigged","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Xbot.glb", image: null, sortDate: "2025-03-26T15:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_bath-day", slug: "demo-bath-day", name: "Bath Day", description: "Bath day animated scene — quirky character moment.", tags: ["scene","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/bath_day.glb", image: null, sortDate: "2025-03-26T14:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_coffeemug", slug: "demo-coffeemug", name: "CoffeeMug", description: "Ceramic coffee mug.", tags: ["object","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/coffeeMug.glb", image: null, sortDate: "2025-03-26T13:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_coffeemat", slug: "demo-coffeemat", name: "Coffeemat", description: "Coffee machine with detailed dispenser.", tags: ["object","machine","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/coffeemat.glb", image: null, sortDate: "2025-03-26T12:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_collision-world", slug: "demo-collision-world", name: "Collision World", description: "Test scene with collision geometry.", tags: ["scene","environment","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/collision-world.glb", image: null, sortDate: "2025-03-26T11:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_dungeon-warkarma", slug: "demo-dungeon-warkarma", name: "Dungeon Warkarma", description: "Fantasy dungeon scene by Warkarma.", tags: ["scene","fantasy","environment"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/dungeon_warkarma.glb", image: null, sortDate: "2025-03-26T10:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_facecap", slug: "demo-facecap", name: "Facecap", description: "Face capture sample with blendshape animation.", tags: ["humanoid","face","animated","morph"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/facecap.glb", image: null, sortDate: "2025-03-26T09:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_ferrari", slug: "demo-ferrari", name: "Ferrari", description: "Detailed Ferrari with full PBR materials and accurate proportions.", tags: ["vehicle","car","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ferrari.glb", image: null, sortDate: "2025-03-26T08:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_gears", slug: "demo-gears", name: "Gears", description: "Interlocking gears with mechanical animation.", tags: ["object","mechanical","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/gears.glb", image: null, sortDate: "2025-03-26T07:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_godrays-demo", slug: "demo-godrays-demo", name: "Godrays Demo", description: "God rays / volumetric lighting demonstration scene.", tags: ["scene","lighting","demo"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/godrays_demo.glb", image: null, sortDate: "2025-03-26T06:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_kira", slug: "demo-kira", name: "Kira", description: "Kira character model.", tags: ["humanoid","character","rigged"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/kira.glb", image: null, sortDate: "2025-03-26T05:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_minimalistic-modern-bedroom", slug: "demo-minimalistic-modern-bedroom", name: "Minimalistic Modern Bedroom", description: "Minimalist modern bedroom interior.", tags: ["scene","interior","architecture"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/minimalistic_modern_bedroom.glb", image: null, sortDate: "2025-03-26T04:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_nemetona", slug: "demo-nemetona", name: "Nemetona", description: "Nemetona character bust.", tags: ["humanoid","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/nemetona.glb", image: null, sortDate: "2025-03-26T03:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_pool", slug: "demo-pool", name: "Pool", description: "Pool scene with water reflections.", tags: ["scene","water","environment"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/pool.glb", image: null, sortDate: "2025-03-26T02:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_readyplayer-me", slug: "demo-readyplayer-me", name: "Readyplayer.Me", description: "Ready Player Me avatar sample — humanoid character ready for VR/AR.", tags: ["humanoid","avatar","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/readyplayer.me.glb", image: null, sortDate: "2025-03-26T01:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_rolex", slug: "demo-rolex", name: "Rolex", description: "Detailed Rolex-style timepiece with metallic finish.", tags: ["object","watch","luxury","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/rolex.glb", image: null, sortDate: "2025-03-26T00:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_space-ship-hallway", slug: "demo-space-ship-hallway", name: "Space Ship Hallway", description: "Sci-fi spaceship corridor scene.", tags: ["scene","scifi","interior"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/space_ship_hallway.glb", image: null, sortDate: "2025-03-25T23:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_steampunk-camera", slug: "demo-steampunk-camera", name: "Steampunk Camera", description: "Steampunk-style camera with brass fittings and leather wrap.", tags: ["object","steampunk","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/steampunk_camera.glb", image: null, sortDate: "2025-03-25T22:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
- demoItem({ id: "avatar_demo_t_venice-mask", slug: "demo-venice-mask", name: "Venice Mask", description: "Ornate Venetian carnival mask with gold leaf detailing.", tags: ["object","mask","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/venice_mask.glb", image: null, sortDate: "2025-03-25T21:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_k_anisotropybarnlamp", slug: "demo-anisotropy-barn-lamp", name: "Anisotropy Barn Lamp", description: "Barn-style lamp with brushed-metal anisotropic shading on the housing.", tags: ["object","lighting","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AnisotropyBarnLamp/glTF-Binary/AnisotropyBarnLamp.glb", image: null, sortDate: "2025-03-31T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_antiquecamera", slug: "demo-antique-camera", name: "Antique Camera", description: "Vintage twin-lens reflex camera with leather wrap and chrome detailing.", tags: ["object","photography","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/AntiqueCamera/glTF-Binary/AntiqueCamera.glb", image: null, sortDate: "2025-03-31T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_avocado", slug: "demo-avocado", name: "Avocado", description: "A photorealistic avocado — a Khronos classic for testing physically-based rendering.", tags: ["food","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Avocado/glTF-Binary/Avocado.glb", image: null, sortDate: "2025-03-31T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_barramundifish", slug: "demo-barramundi-fish", name: "Barramundi Fish", description: "Detailed barramundi fish with realistic scales and PBR materials.", tags: ["animal","fish","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BarramundiFish/glTF-Binary/BarramundiFish.glb", image: null, sortDate: "2025-03-31T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_boombox", slug: "demo-boom-box", name: "Boom Box", description: "Retro boombox with intricate textures — a benchmark PBR asset.", tags: ["object","audio","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BoomBox/glTF-Binary/BoomBox.glb", image: null, sortDate: "2025-03-31T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_brainstem", slug: "demo-brain-stem", name: "Brain Stem", description: "Walking humanoid figure with skinned mesh and animations.", tags: ["humanoid","rigged","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/BrainStem/glTF-Binary/BrainStem.glb", image: null, sortDate: "2025-03-31T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_carconcept", slug: "demo-car-concept", name: "Car Concept", description: "Concept car with sculpted bodywork and clear-coat materials.", tags: ["vehicle","concept","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CarConcept/glTF-Binary/CarConcept.glb", image: null, sortDate: "2025-03-31T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_carbonfibre", slug: "demo-carbon-fibre", name: "Carbon Fibre", description: "Carbon-fibre weave material test — anisotropy and clear-coat.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CarbonFibre/glTF-Binary/CarbonFibre.glb", image: null, sortDate: "2025-03-31T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_cesiumman", slug: "demo-cesium-man", name: "Cesium Man", description: "The iconic Cesium Man — walking animation, fully rigged.", tags: ["humanoid","rigged","animated","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CesiumMan/glTF-Binary/CesiumMan.glb", image: null, sortDate: "2025-03-31T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_cesiummilktruck", slug: "demo-cesium-milk-truck", name: "Cesium Milk Truck", description: "Cesium Milk Truck rolling along — wheel rotation animation.", tags: ["vehicle","animated","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CesiumMilkTruck/glTF-Binary/CesiumMilkTruck.glb", image: null, sortDate: "2025-03-31T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_chairdamaskpurplegold", slug: "demo-chair-damask-purplegold", name: "Chair Damask Purplegold", description: "Ornate damask chair with gold leaf and patterned upholstery.", tags: ["furniture","pbr","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ChairDamaskPurplegold/glTF-Binary/ChairDamaskPurplegold.glb", image: null, sortDate: "2025-03-31T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_chronographwatch", slug: "demo-chronograph-watch", name: "Chronograph Watch", description: "Detailed chronograph wristwatch with metallic finish and glass face.", tags: ["object","pbr","metal"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ChronographWatch/glTF-Binary/ChronographWatch.glb", image: null, sortDate: "2025-03-31T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_clearcoatcarpaint", slug: "demo-clear-coat-car-paint", name: "Clear Coat Car Paint", description: "Clear-coat car paint material test under varied lighting.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ClearCoatCarPaint/glTF-Binary/ClearCoatCarPaint.glb", image: null, sortDate: "2025-03-31T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_clearcoatwicker", slug: "demo-clearcoat-wicker", name: "Clearcoat Wicker", description: "Wicker pattern with clear-coat layer.", tags: ["material","pbr","fabric"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ClearcoatWicker/glTF-Binary/ClearcoatWicker.glb", image: null, sortDate: "2025-03-31T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_commercialrefrigerator", slug: "demo-commercial-refrigerator", name: "Commercial Refrigerator", description: "Commercial glass-door refrigerator with transmission.", tags: ["object","commercial","glass"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CommercialRefrigerator/glTF-Binary/CommercialRefrigerator.glb", image: null, sortDate: "2025-03-31T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_damagedhelmet", slug: "demo-damaged-helmet", name: "Damaged Helmet", description: "Battle-worn sci-fi helmet — possibly the most-rendered glTF in history.", tags: ["object","armor","pbr","iconic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DamagedHelmet/glTF-Binary/DamagedHelmet.glb", image: null, sortDate: "2025-03-31T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_diffusetransmissionplant", slug: "demo-diffuse-transmission-plant", name: "Diffuse Transmission Plant", description: "Botanical leaves demonstrating diffuse transmission for thin foliage.", tags: ["plant","transmission","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DiffuseTransmissionPlant/glTF-Binary/DiffuseTransmissionPlant.glb", image: null, sortDate: "2025-03-31T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_diffusetransmissionteacup", slug: "demo-diffuse-transmission-teacup", name: "Diffuse Transmission Teacup", description: "Bone china teacup with translucent walls.", tags: ["object","transmission","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DiffuseTransmissionTeacup/glTF-Binary/DiffuseTransmissionTeacup.glb", image: null, sortDate: "2025-03-31T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_directionallight", slug: "demo-directional-light", name: "Directional Light", description: "Directional (sun) light reference scene with shadow-casting plane.", tags: ["test","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DirectionalLight/glTF-Binary/DirectionalLight.glb", image: null, sortDate: "2025-03-31T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_dragonattenuation", slug: "demo-dragon-attenuation", name: "Dragon Attenuation", description: "Glass dragon demonstrating volume attenuation and transmission.", tags: ["creature","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DragonAttenuation/glTF-Binary/DragonAttenuation.glb", image: null, sortDate: "2025-03-31T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_dragondispersion", slug: "demo-dragon-dispersion", name: "Dragon Dispersion", description: "Glass dragon with chromatic dispersion for prismatic light.", tags: ["creature","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/DragonDispersion/glTF-Binary/DragonDispersion.glb", image: null, sortDate: "2025-03-31T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_duck", slug: "demo-duck", name: "Duck", description: "The Khronos Duck — every 3D dev has met this duck.", tags: ["animal","iconic","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Duck/glTF-Binary/Duck.glb", image: null, sortDate: "2025-03-30T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_fox", slug: "demo-fox", name: "Fox", description: "Stylized fox with three baked animations — Survey, Walk, Run.", tags: ["animal","animated","rigged","iconic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Fox/glTF-Binary/Fox.glb", image: null, sortDate: "2025-03-30T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_glamvelvetsofa", slug: "demo-glam-velvet-sofa", name: "Glam Velvet Sofa", description: "Velvet sofa demonstrating sheen for fabric materials.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlamVelvetSofa/glTF-Binary/GlamVelvetSofa.glb", image: null, sortDate: "2025-03-30T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_glassbrokenwindow", slug: "demo-glass-broken-window", name: "Glass Broken Window", description: "Shattered window pane with refraction and transmission.", tags: ["object","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassBrokenWindow/glTF-Binary/GlassBrokenWindow.glb", image: null, sortDate: "2025-03-30T20:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_glasshurricanecandleholder", slug: "demo-glass-hurricane-candle-holder", name: "Glass Hurricane Candle Holder", description: "Hurricane candle holder with thick glass and a flickering candle.", tags: ["object","glass","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassHurricaneCandleHolder/glTF-Binary/GlassHurricaneCandleHolder.glb", image: null, sortDate: "2025-03-30T19:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_glassvaseflowers", slug: "demo-glass-vase-flowers", name: "Glass Vase Flowers", description: "Cut-glass vase with flowers — refraction through curved glass.", tags: ["object","glass","plant"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/GlassVaseFlowers/glTF-Binary/GlassVaseFlowers.glb", image: null, sortDate: "2025-03-30T18:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_iridescenceabalone", slug: "demo-iridescence-abalone", name: "Iridescence Abalone", description: "Abalone shell with natural iridescence.", tags: ["object","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceAbalone/glTF-Binary/IridescenceAbalone.glb", image: null, sortDate: "2025-03-30T17:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_iridescencelamp", slug: "demo-iridescence-lamp", name: "Iridescence Lamp", description: "Lamp shade with iridescent thin-film effect.", tags: ["object","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceLamp/glTF-Binary/IridescenceLamp.glb", image: null, sortDate: "2025-03-30T16:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_iridescencesuzanne", slug: "demo-iridescence-suzanne", name: "Iridescence Suzanne", description: "Blender Suzanne with iridescent thin-film material.", tags: ["classic","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescenceSuzanne/glTF-Binary/IridescenceSuzanne.glb", image: null, sortDate: "2025-03-30T15:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_iridescentdishwitholives", slug: "demo-iridescent-dish-with-olives", name: "Iridescent Dish With Olives", description: "Iridescent ceramic dish holding olives.", tags: ["food","pbr","iridescent"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/IridescentDishWithOlives/glTF-Binary/IridescentDishWithOlives.glb", image: null, sortDate: "2025-03-30T14:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_lantern", slug: "demo-lantern", name: "Lantern", description: "Traditional lantern with intricate metalwork — a Khronos PBR benchmark.", tags: ["object","metal","pbr","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/Lantern/glTF-Binary/Lantern.glb", image: null, sortDate: "2025-03-30T13:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_lightspunctuallamp", slug: "demo-lights-punctual-lamp", name: "Lights Punctual Lamp", description: "Lamp model wired up via KHR_lights_punctual — real point light source.", tags: ["object","lighting"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/LightsPunctualLamp/glTF-Binary/LightsPunctualLamp.glb", image: null, sortDate: "2025-03-30T12:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_materialsvariantsshoe", slug: "demo-materials-variants-shoe", name: "Materials Variants Shoe", description: "Shoe with material variants — swap colorways at runtime.", tags: ["fashion","shoe","variants"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MaterialsVariantsShoe/glTF-Binary/MaterialsVariantsShoe.glb", image: null, sortDate: "2025-03-30T11:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_metalroughspheres", slug: "demo-metal-rough-spheres", name: "Metal Rough Spheres", description: "Spheres demonstrating the full metallic-roughness range.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MetalRoughSpheres/glTF-Binary/MetalRoughSpheres.glb", image: null, sortDate: "2025-03-30T10:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_metalroughspheresnotextures", slug: "demo-metal-rough-spheres-no-textures", name: "Metal Rough Spheres No Textures", description: "Untextured metallic-roughness sphere grid.", tags: ["material","pbr","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/MetalRoughSpheresNoTextures/glTF-Binary/MetalRoughSpheresNoTextures.glb", image: null, sortDate: "2025-03-30T09:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_potofcoals", slug: "demo-pot-of-coals", name: "Pot Of Coals", description: "Glowing pot of coals demonstrating emissive strength.", tags: ["object","fire","emissive"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PotOfCoals/glTF-Binary/PotOfCoals.glb", image: null, sortDate: "2025-03-30T08:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_potofcoalsanimationpointer", slug: "demo-pot-of-coals-animation-pointer", name: "Pot Of Coals Animation Pointer", description: "Pot of coals with KHR_animation_pointer driving emissive flicker.", tags: ["object","fire","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/PotOfCoalsAnimationPointer/glTF-Binary/PotOfCoalsAnimationPointer.glb", image: null, sortDate: "2025-03-30T07:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_riggedfigure", slug: "demo-rigged-figure", name: "Rigged Figure", description: "Bare-bones rigged humanoid for testing skinning.", tags: ["humanoid","rigged","classic"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/RiggedFigure/glTF-Binary/RiggedFigure.glb", image: null, sortDate: "2025-03-30T06:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_riggedsimple", slug: "demo-rigged-simple", name: "Rigged Simple", description: "Minimal rigged figure — the smallest possible skinned mesh.", tags: ["rigged","test"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/RiggedSimple/glTF-Binary/RiggedSimple.glb", image: null, sortDate: "2025-03-30T05:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_scatteringskull", slug: "demo-scattering-skull", name: "Scattering Skull", description: "Skull with subsurface scattering for translucent bone material.", tags: ["object","sss","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ScatteringSkull/glTF-Binary/ScatteringSkull.glb", image: null, sortDate: "2025-03-30T04:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_sheenchair", slug: "demo-sheen-chair", name: "Sheen Chair", description: "Armchair upholstered in sheen-fabric demonstrating grazing-angle highlights.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SheenChair/glTF-Binary/SheenChair.glb", image: null, sortDate: "2025-03-30T03:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_sheenwoodleathersofa", slug: "demo-sheen-wood-leather-sofa", name: "Sheen Wood Leather Sofa", description: "Sofa combining sheen fabric, leather, and wood — a multi-material reference.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SheenWoodLeatherSofa/glTF-Binary/SheenWoodLeatherSofa.glb", image: null, sortDate: "2025-03-30T02:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_specularsilkpouf", slug: "demo-specular-silk-pouf", name: "Specular Silk Pouf", description: "Silk pouf footstool with specular sheen.", tags: ["furniture","fabric","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SpecularSilkPouf/glTF-Binary/SpecularSilkPouf.glb", image: null, sortDate: "2025-03-30T01:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_sunglasseskhronos", slug: "demo-sunglasses-khronos", name: "Sunglasses Khronos", description: "Aviator-style sunglasses with tinted transmission lenses and metal frame.", tags: ["fashion","object","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/SunglassesKhronos/glTF-Binary/SunglassesKhronos.glb", image: null, sortDate: "2025-03-30T00:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_toycar", slug: "demo-toy-car", name: "Toy Car", description: "Stylized toy car with chunky proportions and shiny paint.", tags: ["vehicle","toy","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/ToyCar/glTF-Binary/ToyCar.glb", image: null, sortDate: "2025-03-29T23:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_virtualcity", slug: "demo-virtual-city", name: "Virtual City", description: "Stylized low-poly city block — buildings, streets, props.", tags: ["scene","environment","urban"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/VirtualCity/glTF-Binary/VirtualCity.glb", image: null, sortDate: "2025-03-29T22:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_k_waterbottle", slug: "demo-water-bottle", name: "Water Bottle", description: "Water bottle with translucent plastic body and embossed label.", tags: ["object","pbr","transmission"], glbUrl: "https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/WaterBottle/glTF-Binary/WaterBottle.glb", image: null, sortDate: "2025-03-29T21:00:00.000Z", attribution: {"handle":"khronos","displayName":"Khronos Group","url":"https://github.com/KhronosGroup/glTF-Sample-Assets","license":"CC-BY 4.0"}, author: {"handle":"khronos","displayName":"Khronos Group","profileUrl":"https://github.com/KhronosGroup/glTF-Sample-Assets"} }),
+ demoItem({ id: "avatar_demo_t_flamingo", slug: "demo-flamingo", name: "Flamingo", description: "Pink flamingo in flight.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Flamingo.glb", image: null, sortDate: "2025-03-29T20:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_horse", slug: "demo-horse", name: "Horse", description: "Galloping horse with skeletal animation.", tags: ["animal","animated","rigged"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Horse.glb", image: null, sortDate: "2025-03-29T19:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_littlesttokyo", slug: "demo-littlesttokyo", name: "LittlestTokyo", description: "Animated Tokyo street scene by Glen Fox — cars driving, neon, atmosphere.", tags: ["scene","environment","urban","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/LittlestTokyo.glb", image: null, sortDate: "2025-03-29T18:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_michelle", slug: "demo-michelle", name: "Michelle", description: "Michelle character with Mixamo-compatible rig.", tags: ["humanoid","rigged","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Michelle.glb", image: null, sortDate: "2025-03-29T17:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_parrot", slug: "demo-parrot", name: "Parrot", description: "Flying parrot with wing-flap animation.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Parrot.glb", image: null, sortDate: "2025-03-29T16:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_primaryiondrive", slug: "demo-primaryiondrive", name: "PrimaryIonDrive", description: "Primary ion drive engine module with animated pulse.", tags: ["scifi","vehicle","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/PrimaryIonDrive.glb", image: null, sortDate: "2025-03-29T15:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_shaderball", slug: "demo-shaderball", name: "ShaderBall", description: "Shader ball — the standard material test sphere with reflective base.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShaderBall.glb", image: null, sortDate: "2025-03-29T14:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_shaderball2", slug: "demo-shaderball2", name: "ShaderBall2", description: "Alternate shader ball variant.", tags: ["material","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShaderBall2.glb", image: null, sortDate: "2025-03-29T13:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_shadowmappablemesh", slug: "demo-shadowmappablemesh", name: "ShadowmappableMesh", description: "Mesh with high-frequency detail for shadow-mapping tests.", tags: ["test","shadows"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ShadowmappableMesh.glb", image: null, sortDate: "2025-03-29T12:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_soldier", slug: "demo-soldier-threejs", name: "Soldier", description: "Soldier character with walk, run, and idle animations — three.js classic.", tags: ["humanoid","rigged","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Soldier.glb", image: null, sortDate: "2025-03-29T11:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_stork", slug: "demo-stork", name: "Stork", description: "Stork mid-flight with wing animation.", tags: ["animal","bird","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Stork.glb", image: null, sortDate: "2025-03-29T10:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_xbot", slug: "demo-xbot", name: "Xbot", description: "X-Bot rigged humanoid robot, ready for retargeting.", tags: ["robot","rigged","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Xbot.glb", image: null, sortDate: "2025-03-29T09:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_bath-day", slug: "demo-bath-day", name: "Bath Day", description: "Bath day animated scene — quirky character moment.", tags: ["scene","animated","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/bath_day.glb", image: null, sortDate: "2025-03-29T08:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_coffeemug", slug: "demo-coffeemug", name: "CoffeeMug", description: "Ceramic coffee mug.", tags: ["object","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/coffeeMug.glb", image: null, sortDate: "2025-03-29T07:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_coffeemat", slug: "demo-coffeemat", name: "Coffeemat", description: "Coffee machine with detailed dispenser.", tags: ["object","machine","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/coffeemat.glb", image: null, sortDate: "2025-03-29T06:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_collision-world", slug: "demo-collision-world", name: "Collision World", description: "Test scene with collision geometry.", tags: ["scene","environment","test"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/collision-world.glb", image: null, sortDate: "2025-03-29T05:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_dungeon-warkarma", slug: "demo-dungeon-warkarma", name: "Dungeon Warkarma", description: "Fantasy dungeon scene by Warkarma.", tags: ["scene","fantasy","environment"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/dungeon_warkarma.glb", image: null, sortDate: "2025-03-29T04:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_facecap", slug: "demo-facecap", name: "Facecap", description: "Face capture sample with blendshape animation.", tags: ["humanoid","face","animated","morph"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/facecap.glb", image: null, sortDate: "2025-03-29T03:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_ferrari", slug: "demo-ferrari", name: "Ferrari", description: "Detailed Ferrari with full PBR materials and accurate proportions.", tags: ["vehicle","car","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/ferrari.glb", image: null, sortDate: "2025-03-29T02:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_gears", slug: "demo-gears", name: "Gears", description: "Interlocking gears with mechanical animation.", tags: ["object","mechanical","animated"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/gears.glb", image: null, sortDate: "2025-03-29T01:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_godrays-demo", slug: "demo-godrays-demo", name: "Godrays Demo", description: "God rays / volumetric lighting demonstration scene.", tags: ["scene","lighting","demo"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/godrays_demo.glb", image: null, sortDate: "2025-03-29T00:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_kira", slug: "demo-kira", name: "Kira", description: "Kira character model.", tags: ["humanoid","character","rigged"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/kira.glb", image: null, sortDate: "2025-03-28T23:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_minimalistic-modern-bedroom", slug: "demo-minimalistic-modern-bedroom", name: "Minimalistic Modern Bedroom", description: "Minimalist modern bedroom interior.", tags: ["scene","interior","architecture"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/minimalistic_modern_bedroom.glb", image: null, sortDate: "2025-03-28T22:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_nemetona", slug: "demo-nemetona", name: "Nemetona", description: "Nemetona character bust.", tags: ["humanoid","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/nemetona.glb", image: null, sortDate: "2025-03-28T21:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_pool", slug: "demo-pool", name: "Pool", description: "Pool scene with water reflections.", tags: ["scene","water","environment"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/pool.glb", image: null, sortDate: "2025-03-28T20:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_readyplayer-me", slug: "demo-readyplayer-me", name: "Readyplayer.Me", description: "Ready Player Me avatar sample — humanoid character ready for VR/AR.", tags: ["humanoid","avatar","character"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/readyplayer.me.glb", image: null, sortDate: "2025-03-28T19:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_rolex", slug: "demo-rolex", name: "Rolex", description: "Detailed Rolex-style timepiece with metallic finish.", tags: ["object","watch","luxury","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/rolex.glb", image: null, sortDate: "2025-03-28T18:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_space-ship-hallway", slug: "demo-space-ship-hallway", name: "Space Ship Hallway", description: "Sci-fi spaceship corridor scene.", tags: ["scene","scifi","interior"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/space_ship_hallway.glb", image: null, sortDate: "2025-03-28T17:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_steampunk-camera", slug: "demo-steampunk-camera", name: "Steampunk Camera", description: "Steampunk-style camera with brass fittings and leather wrap.", tags: ["object","steampunk","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/steampunk_camera.glb", image: null, sortDate: "2025-03-28T16:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
+ demoItem({ id: "avatar_demo_t_venice-mask", slug: "demo-venice-mask", name: "Venice Mask", description: "Ornate Venetian carnival mask with gold leaf detailing.", tags: ["object","mask","pbr"], glbUrl: "https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/venice_mask.glb", image: null, sortDate: "2025-03-28T15:00:00.000Z", attribution: {"handle":"threejs","displayName":"three.js examples","url":"https://github.com/mrdoob/three.js","license":"MIT"}, author: {"handle":"threejs","displayName":"three.js examples","profileUrl":"https://github.com/mrdoob/three.js"} }),
];
diff --git a/api/_lib/migrations/2026-05-10-time-pass-columns.sql b/api/_lib/migrations/2026-05-10-time-pass-columns.sql
new file mode 100644
index 000000000..2f5ae8684
--- /dev/null
+++ b/api/_lib/migrations/2026-05-10-time-pass-columns.sql
@@ -0,0 +1,7 @@
+-- Migration: add time_pass_hours and time_pass_amount to agent_skill_prices (C3).
+-- Idempotent.
+begin;
+alter table agent_skill_prices
+ add column if not exists time_pass_hours integer,
+ add column if not exists time_pass_amount bigint;
+commit;
diff --git a/api/_lib/migrations/2026-05-10-withdrawal-error-message.sql b/api/_lib/migrations/2026-05-10-withdrawal-error-message.sql
new file mode 100644
index 000000000..0a3b99755
--- /dev/null
+++ b/api/_lib/migrations/2026-05-10-withdrawal-error-message.sql
@@ -0,0 +1,6 @@
+-- Migration: add error_message column to agent_withdrawals for failure details.
+-- Idempotent.
+begin;
+alter table agent_withdrawals
+ add column if not exists error_message text;
+commit;
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.js
index 806d8f9a6..1b06914e8 100644
--- a/api/_lib/rate-limit.js
+++ b/api/_lib/rate-limit.js
@@ -89,6 +89,12 @@ export const limits = {
// Skills marketplace browse — isolated bucket so traffic on other public endpoints
// can't starve the skills list. 60/min per IP.
skillsBrowse: (ip) => getLimiter('skills:browse', { limit: 60, window: '1 m' }).limit(ip),
+ // Marketplace agent preview chat — anonymous "try before fork" flow on the
+ // agent detail page. Strict per-IP and per-agent caps so one client can't
+ // drain LLM credits and one agent can't starve the global pool.
+ previewIp: (ip) => getLimiter('preview:ip', { limit: 30, window: '1 h' }).limit(ip),
+ previewAgent: (agentId) =>
+ getLimiter('preview:agent', { limit: 200, window: '1 h' }).limit(agentId),
widgetWrite: (userId) => getLimiter('widget:write', { limit: 60, window: '1 m' }).limit(userId),
widgetRead: (ip) => getLimiter('widget:read', { limit: 600, window: '1 m' }).limit(ip),
// Per-widget visitor chat. Limit is dynamic — one bucket per (widgetId, perMinute).
diff --git a/api/agents/[id]/skills-pricing.js b/api/agents/[id]/skills-pricing.js
index 62cfdc53a..38cef85f7 100644
--- a/api/agents/[id]/skills-pricing.js
+++ b/api/agents/[id]/skills-pricing.js
@@ -8,6 +8,9 @@ const priceSchema = z.object({
amount: z.number().int().min(1),
currency_mint: z.string().trim().min(1).max(100),
chain: z.string().trim().min(1).max(20),
+ trial_uses: z.number().int().min(0).max(10).default(0),
+ time_pass_hours: z.number().int().min(1).max(720).nullable().optional(),
+ time_pass_amount: z.number().int().min(1).nullable().optional(),
});
const pricingUpdateSchema = z.object({
@@ -63,13 +66,19 @@ async function handlePut(req, res, agentId) {
// Insert or update new prices
for (const p of prices) {
await tx`
- INSERT INTO agent_skill_prices (agent_id, skill, amount, currency_mint, chain, is_active)
- VALUES (${agentId}, ${p.skill}, ${p.amount}, ${p.currency_mint}, ${p.chain}, true)
+ INSERT INTO agent_skill_prices
+ (agent_id, skill, amount, currency_mint, chain, is_active, trial_uses, time_pass_hours, time_pass_amount)
+ VALUES
+ (${agentId}, ${p.skill}, ${p.amount}, ${p.currency_mint}, ${p.chain}, true,
+ ${p.trial_uses ?? 0}, ${p.time_pass_hours ?? null}, ${p.time_pass_amount ?? null})
ON CONFLICT (agent_id, skill) DO UPDATE SET
amount = EXCLUDED.amount,
currency_mint = EXCLUDED.currency_mint,
chain = EXCLUDED.chain,
is_active = true,
+ trial_uses = EXCLUDED.trial_uses,
+ time_pass_hours = EXCLUDED.time_pass_hours,
+ time_pass_amount = EXCLUDED.time_pass_amount,
updated_at = now()
`;
}
diff --git a/api/avatars/_actions.js b/api/avatars/_actions.js
index 52e519954..ae96ffa02 100644
--- a/api/avatars/_actions.js
+++ b/api/avatars/_actions.js
@@ -112,10 +112,155 @@ const handleRegenerateStatus = wrap(async (req, res) => {
return json(res, 200, response);
});
+// ── presign-thumbnail ─────────────────────────────────────────────────────────
+// Called by the browser after rendering a GLB preview via <model-viewer>.
+// The client captures toBlob() and uploads the PNG here, then PATCHes the
+// avatar record with the resulting thumbnail_key.
+
+const thumbnailPresignSchema = z.object({
+ avatar_id: z.string().uuid(),
+ size_bytes: z.number().int().min(1).max(2 * 1024 * 1024), // 2 MB max for a PNG thumb
+});
+
+const handlePresignThumbnail = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const userId = await resolvePresignUser(req, 'avatars:write');
+ if (!userId) return error(res, 401, 'unauthorized', 'sign in or provide a valid bearer token');
+
+ const body = parse(thumbnailPresignSchema, await readJson(req));
+
+ // Verify caller owns the avatar they're thumbnailing.
+ const rows = await (await import('../_lib/db.js')).sql`
+ select id, storage_key from avatars
+ where id = ${body.avatar_id} and owner_id = ${userId} and deleted_at is null
+ limit 1
+ `;
+ if (!rows[0]) return error(res, 404, 'not_found', 'avatar not found or not yours');
+
+ // Thumbnail key: same prefix as the GLB, different suffix.
+ const thumbKey = rows[0].storage_key.replace(/\.glb$/i, '') + '_thumb.jpg';
+ const uploadUrl = await presignUpload({ key: thumbKey, contentType: 'image/jpeg' });
+
+ return json(res, 200, {
+ thumb_key: thumbKey,
+ upload_url: uploadUrl,
+ method: 'PUT',
+ headers: { 'content-type': 'image/jpeg' },
+ expires_in: 300,
+ });
+});
+
+// ── auto-tag ──────────────────────────────────────────────────────────────────
+// Called after thumbnail upload; sends the poster to Claude vision for
+// auto-generated tags and a one-line description. Non-blocking — a failure
+// here must never fail the upload flow.
+
+const autoTagSchema = z.object({
+ avatar_id: z.string().uuid(),
+ thumb_key: z.string().min(1).max(512),
+});
+
+const AVATAR_TAG_PROMPT = `You are a 3D avatar classification assistant.
+Given a screenshot of a 3D avatar, respond with ONLY a JSON object:
+{
+ "tags": [3-6 tags from: humanoid, robot, animal, vehicle, stylized, realistic, anime, creature, character, abstract, military, fantasy, sci-fi, casual, formal],
+ "description": "One sentence describing this 3D avatar (20-60 words)."
+}
+Respond with nothing else — no markdown, no explanation.`;
+
+const handleAutoTag = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const userId = await resolvePresignUser(req, 'avatars:write');
+ if (!userId) return error(res, 401, 'unauthorized', 'sign in or provide a valid bearer token');
+
+ const body = parse(autoTagSchema, await readJson(req));
+
+ // Verify ownership.
+ const { sql } = await import('../_lib/db.js');
+ const rows = await sql`
+ select id, name, tags, description, thumbnail_key
+ from avatars where id = ${body.avatar_id} and owner_id = ${userId} and deleted_at is null
+ limit 1
+ `;
+ if (!rows[0]) return error(res, 404, 'not_found', 'avatar not found');
+
+ // Fetch the thumbnail from R2 for vision.
+ const { publicUrl } = await import('../_lib/r2.js');
+ const { env } = await import('../_lib/env.js');
+ const thumbUrl = publicUrl(body.thumb_key);
+
+ // Call Claude Haiku — cheapest, sufficient for image classification.
+ const anthropicRes = await fetch('https://api.anthropic.com/v1/messages', {
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json',
+ 'x-api-key': env.ANTHROPIC_API_KEY,
+ 'anthropic-version': '2023-06-01',
+ },
+ body: JSON.stringify({
+ model: 'claude-haiku-4-5-20251001',
+ max_tokens: 256,
+ messages: [
+ {
+ role: 'user',
+ content: [
+ { type: 'image', source: { type: 'url', url: thumbUrl } },
+ { type: 'text', text: AVATAR_TAG_PROMPT },
+ ],
+ },
+ ],
+ }),
+ });
+
+ if (!anthropicRes.ok) {
+ console.error('[auto-tag] anthropic error', await anthropicRes.text());
+ return json(res, 200, { ok: false, reason: 'vision_api_error' });
+ }
+
+ const result = await anthropicRes.json();
+ let parsed;
+ try {
+ const raw = result.content?.[0]?.text || '{}';
+ parsed = JSON.parse(raw.trim());
+ } catch {
+ return json(res, 200, { ok: false, reason: 'parse_error' });
+ }
+
+ const newTags = Array.isArray(parsed.tags) ? parsed.tags.slice(0, 6) : [];
+ const desc = typeof parsed.description === 'string' ? parsed.description.slice(0, 500) : '';
+
+ // Only write if the avatar still has no tags/description (don't overwrite manual ones).
+ const currentTags = rows[0].tags || [];
+ const currentDesc = rows[0].description || '';
+
+ const patch = {};
+ if (!currentTags.length && newTags.length) patch.tags = newTags;
+ if (!currentDesc && desc) patch.description = desc;
+ // Always write thumbnail_key if not set yet.
+ if (!rows[0].thumbnail_key) patch.thumbnail_key = body.thumb_key;
+
+ if (Object.keys(patch).length) {
+ await sql`
+ update avatars set
+ tags = coalesce(${patch.tags ?? null}::text[], tags),
+ description = coalesce(${patch.description ?? null}, description),
+ thumbnail_key = coalesce(${patch.thumbnail_key ?? null}, thumbnail_key),
+ updated_at = now()
+ where id = ${body.avatar_id} and owner_id = ${userId}
+ `;
+ }
+
+ return json(res, 200, { ok: true, tags: newTags, description: desc });
+});
+
// ── dispatcher ────────────────────────────────────────────────────────────────
const DISPATCH = {
presign: handlePresign,
+ 'presign-thumbnail': handlePresignThumbnail,
+ 'auto-tag': handleAutoTag,
public: handlePublic,
regenerate: handleRegenerate,
'regenerate-status': handleRegenerateStatus,
diff --git a/api/avatars/thumbnail.js b/api/avatars/thumbnail.js
new file mode 100644
index 000000000..a5d16f9b9
--- /dev/null
+++ b/api/avatars/thumbnail.js
@@ -0,0 +1,104 @@
+// POST /api/avatars/thumbnail — upload a PNG poster for an existing avatar.
+// Body: { avatar_id: uuid, png_base64: "data:image/png;base64,..." | "<raw base64>" }
+// The caller must own the avatar OR be an admin (for the backfill script).
+//
+// PNGs are stored under thumb/<avatarId>.png in R2 and the avatars row's
+// thumbnail_key is updated. The frontend then fetches via publicUrl() so the
+// browser sees a 50KB PNG instead of a 5MB GLB.
+
+import { sql } from '../_lib/db.js';
+import { getSessionUser, authenticateBearer, extractBearer, hasScope } from '../_lib/auth.js';
+import { putObject, deleteObject, publicUrl } from '../_lib/r2.js';
+import { cors, error, json, method, readJson, wrap } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+
+const MAX_PNG_BYTES = 1_500_000; // 1.5 MB max — generous for 1024² posters.
+const PNG_HEADER = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in or provide a valid bearer token');
+
+ const rl = await limits.upload(auth.userId);
+ if (!rl.success) return error(res, 429, 'rate_limited', 'thumbnail upload rate exceeded');
+
+ const body = await readJson(req).catch(() => null);
+ const avatarId = body?.avatar_id;
+ const pngB64 = body?.png_base64;
+
+ if (!avatarId || typeof avatarId !== 'string' || avatarId.length > 100) {
+ return error(res, 400, 'invalid_request', 'avatar_id required');
+ }
+ if (!pngB64 || typeof pngB64 !== 'string') {
+ return error(res, 400, 'invalid_request', 'png_base64 required');
+ }
+
+ // Strip an optional "data:image/png;base64," prefix.
+ const raw = pngB64.replace(/^data:image\/png;base64,/, '');
+ let buf;
+ try {
+ buf = Buffer.from(raw, 'base64');
+ } catch {
+ return error(res, 400, 'invalid_request', 'png_base64 not valid base64');
+ }
+ if (buf.length === 0 || buf.length > MAX_PNG_BYTES) {
+ return error(res, 413, 'too_large', `png must be 1..${MAX_PNG_BYTES} bytes`);
+ }
+ if (!buf.subarray(0, 8).equals(PNG_HEADER)) {
+ return error(res, 400, 'invalid_request', 'body is not a PNG');
+ }
+
+ // Look up the avatar; permit owner OR admin (admins are needed to backfill
+ // thumbnails for legacy avatars whose owners may be inactive).
+ const [row] = await sql`
+ SELECT a.id, a.owner_id, a.thumbnail_key, u.is_admin
+ FROM avatars a
+ LEFT JOIN users u ON u.id = ${auth.userId}
+ WHERE a.id = ${avatarId} AND a.deleted_at IS NULL
+ LIMIT 1
+ `;
+ if (!row) return error(res, 404, 'not_found', 'avatar not found');
+ const isOwner = row.owner_id === auth.userId;
+ const isAdmin = row.is_admin === true;
+ if (!isOwner && !isAdmin) return error(res, 403, 'forbidden', 'not your avatar');
+
+ const key = `thumb/${avatarId}.png`;
+ await putObject({
+ key,
+ body: buf,
+ contentType: 'image/png',
+ metadata: { 'avatar-id': avatarId, 'uploaded-by': auth.userId },
+ });
+
+ // If the avatar previously had a different thumbnail key, drop the old one.
+ if (row.thumbnail_key && row.thumbnail_key !== key) {
+ queueMicrotask(() => deleteObject(row.thumbnail_key).catch(() => {}));
+ }
+
+ await sql`
+ UPDATE avatars
+ SET thumbnail_key = ${key}, updated_at = now()
+ WHERE id = ${avatarId}
+ `;
+
+ return json(res, 200, {
+ data: {
+ avatar_id: avatarId,
+ thumbnail_key: key,
+ thumbnail_url: publicUrl(key),
+ bytes: buf.length,
+ },
+ });
+});
+
+async function resolveAuth(req) {
+ const session = await getSessionUser(req);
+ if (session) return { userId: session.id };
+ const bearer = await authenticateBearer(extractBearer(req));
+ if (!bearer) return null;
+ if (!hasScope(bearer.scope, 'avatars:write')) return null;
+ return { userId: bearer.userId };
+}
diff --git a/api/avatars/view.js b/api/avatars/view.js
new file mode 100644
index 000000000..5d6d5133c
--- /dev/null
+++ b/api/avatars/view.js
@@ -0,0 +1,34 @@
+// POST /api/avatars/view — increment view_count for a public avatar.
+// Accepts { avatar_id } in the JSON body. Auth is optional; the endpoint
+// rate-limits by IP to prevent trivial inflation.
+
+import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
+import { sql } from '../_lib/db.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ // One view per IP per avatar per 30 min — light throttle.
+ const ip = clientIp(req);
+ const rl = await limits.publicIp(ip);
+ if (!rl.success) return json(res, 200, { ok: false, reason: 'rate_limited' });
+
+ const body = await readJson(req).catch(() => null);
+ const avatarId = body?.avatar_id;
+ if (!avatarId || typeof avatarId !== 'string' || avatarId.length > 100) {
+ return error(res, 400, 'invalid_request', 'avatar_id required');
+ }
+
+ // Only count views for public avatars; silently ignore private/deleted.
+ await sql`
+ UPDATE avatars
+ SET view_count = coalesce(view_count, 0) + 1
+ WHERE id = ${avatarId}
+ AND visibility = 'public'
+ AND deleted_at IS NULL
+ `;
+
+ return json(res, 200, { ok: true });
+});
diff --git a/api/billing/receipts.js b/api/billing/receipts.js
new file mode 100644
index 000000000..c5309617f
--- /dev/null
+++ b/api/billing/receipts.js
@@ -0,0 +1,51 @@
+/**
+ * GET /api/billing/receipts?purchase_id=<uuid>
+ * Returns the signed receipt JSON for a confirmed purchase, auth-gated to the owning user.
+ */
+
+import { sql } from '../_lib/db.js';
+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
+import { cors, error, json, method, wrap } from '../_lib/http.js';
+import { clientIp, limits } from '../_lib/rate-limit.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const session = await getSessionUser(req);
+ const bearer = session ? null : await authenticateBearer(extractBearer(req));
+ const userId = session?.id || bearer?.userId;
+ if (!userId) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.widgetRead(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const params = new URL(req.url, 'http://x').searchParams;
+ const purchaseId = params.get('purchase_id');
+ if (!purchaseId) return error(res, 400, 'bad_request', 'purchase_id required');
+
+ // Verify ownership before returning receipt
+ const [purchase] = await sql`
+ SELECT id, user_id FROM skill_purchases
+ WHERE id = ${purchaseId}
+ `;
+ if (!purchase) return error(res, 404, 'not_found', 'purchase not found');
+ if (purchase.user_id !== userId) return error(res, 403, 'forbidden', 'not your purchase');
+
+ const [receipt] = await sql`
+ SELECT receipt_json, signature, created_at
+ FROM purchase_receipts
+ WHERE purchase_id = ${purchaseId}
+ `;
+
+ if (!receipt) return error(res, 404, 'not_found', 'receipt not found for this purchase');
+
+ return json(res, 200, {
+ data: {
+ purchase_id: purchaseId,
+ receipt: receipt.receipt_json,
+ signature: receipt.signature,
+ issued_at: receipt.created_at,
+ },
+ });
+});
diff --git a/api/billing/withdrawals/index.js b/api/billing/withdrawals/index.js
index 9b8a0fcc4..b2f2d6e9d 100644
--- a/api/billing/withdrawals/index.js
+++ b/api/billing/withdrawals/index.js
@@ -7,6 +7,7 @@ import { getSessionUser } from '../../_lib/auth.js';
import { cors, json, method, wrap, error, readJson } from '../../_lib/http.js';
import { parse } from '../../_lib/validate.js';
import { limits, clientIp } from '../../_lib/rate-limit.js';
+import { requireCsrf } from '../../_lib/csrf.js';
const postBody = z.object({
amount: z.number().int().positive(),
@@ -53,6 +54,9 @@ export default wrap(async (req, res) => {
}
// POST
+ const csrfOk = await requireCsrf(req, res, user.id);
+ if (!csrfOk) return;
+
const rlUser = await limits.withdrawalPerUser(user.id);
if (!rlUser.success) return error(res, 429, 'rate_limited', 'too many withdrawal requests');
diff --git a/api/creators/[id].js b/api/creators/[id].js
new file mode 100644
index 000000000..b0d31a380
--- /dev/null
+++ b/api/creators/[id].js
@@ -0,0 +1,120 @@
+/**
+ * GET /api/creators/:id
+ *
+ * Public creator profile keyed by user UUID. Returns the creator's display
+ * info plus their published marketplace agents and public avatars. Used by
+ * the marketplace creator-profile modal — clickable author names route here.
+ *
+ * Cached for a minute so popular creators don't hammer the DB on every modal
+ * open.
+ */
+
+import { sql } from '../_lib/db.js';
+import { cors, error, json, method, wrap } from '../_lib/http.js';
+import { publicUrl } from '../_lib/r2.js';
+import { clientIp, limits } from '../_lib/rate-limit.js';
+
+const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const id = String(req.query?.id || '').trim();
+ if (!UUID_RE.test(id)) return error(res, 404, 'not_found', 'creator not found');
+
+ const rl = await limits.publicIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const [user] = await sql`
+ SELECT id, display_name, username, avatar_url, created_at
+ FROM users
+ WHERE id = ${id} AND deleted_at IS NULL
+ LIMIT 1
+ `;
+ if (!user) return error(res, 404, 'not_found', 'creator not found');
+
+ const [agentRows, avatarRows, counts] = await Promise.all([
+ sql`
+ SELECT ai.id, ai.name, ai.description, ai.category, ai.tags, ai.avatar_id,
+ ai.forks_count, ai.views_count, ai.published_at, ai.created_at, ai.skills,
+ av.thumbnail_key,
+ EXISTS (
+ SELECT 1 FROM agent_skill_prices asp
+ WHERE asp.agent_id = ai.id AND asp.is_active = true
+ ) AS has_paid_skills
+ FROM agent_identities ai
+ LEFT JOIN avatars av ON av.id = ai.avatar_id AND av.deleted_at IS NULL
+ WHERE ai.user_id = ${user.id}
+ AND ai.is_published = true
+ AND ai.deleted_at IS NULL
+ ORDER BY ai.published_at DESC NULLS LAST
+ LIMIT 24
+ `,
+ sql`
+ SELECT id, slug, name, description, storage_key, thumbnail_key, tags, created_at
+ FROM avatars
+ WHERE owner_id = ${user.id}
+ AND visibility = 'public'
+ AND deleted_at IS NULL
+ ORDER BY created_at DESC
+ LIMIT 24
+ `,
+ sql`
+ SELECT
+ (SELECT count(*)::int FROM agent_identities WHERE user_id = ${user.id} AND is_published = true AND deleted_at IS NULL) AS agents_total,
+ (SELECT count(*)::int FROM avatars WHERE owner_id = ${user.id} AND visibility = 'public' AND deleted_at IS NULL) AS avatars_total,
+ (SELECT coalesce(sum(forks_count), 0)::int FROM agent_identities WHERE user_id = ${user.id} AND is_published = true AND deleted_at IS NULL) AS forks_total,
+ (SELECT coalesce(sum(views_count), 0)::int FROM agent_identities WHERE user_id = ${user.id} AND is_published = true AND deleted_at IS NULL) AS views_total
+ `,
+ ]);
+
+ const agents = agentRows.map((a) => ({
+ id: a.id,
+ name: a.name,
+ description: a.description,
+ category: a.category,
+ tags: a.tags || [],
+ thumbnail_url: a.thumbnail_key ? publicUrl(a.thumbnail_key) : null,
+ skills: a.skills || [],
+ forks_count: a.forks_count || 0,
+ views_count: a.views_count || 0,
+ published_at: a.published_at,
+ has_paid_skills: a.has_paid_skills || false,
+ }));
+
+ const avatars = avatarRows.map((a) => ({
+ id: a.id,
+ slug: a.slug,
+ name: a.name,
+ description: a.description,
+ thumbnail_url: a.thumbnail_key ? publicUrl(a.thumbnail_key) : null,
+ glb_url: a.storage_key ? publicUrl(a.storage_key) : null,
+ tags: a.tags || [],
+ created_at: a.created_at,
+ }));
+
+ const totals = counts[0] || {};
+
+ res.setHeader('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=300');
+ return json(res, 200, {
+ data: {
+ creator: {
+ id: user.id,
+ display_name: user.display_name || user.username || 'Anonymous',
+ username: user.username || null,
+ avatar_url: user.avatar_url || null,
+ profile_url: user.username ? `/@${user.username}` : `/creators/${user.id}`,
+ joined: user.created_at,
+ totals: {
+ agents: totals.agents_total || 0,
+ avatars: totals.avatars_total || 0,
+ forks: totals.forks_total || 0,
+ views: totals.views_total || 0,
+ },
+ },
+ agents,
+ avatars,
+ },
+ });
+});
diff --git a/api/cron/[name].js b/api/cron/[name].js
index 7c7a172b5..b36b8cca6 100644
--- a/api/cron/[name].js
+++ b/api/cron/[name].js
@@ -66,6 +66,7 @@ const HANDLERS = {
'solana-attestations-crawl': handleSolanaAttestationsCrawl,
'expire-pending-purchases': handleExpirePendingPurchases,
'cleanup-csrf-tokens': handleCleanupCsrfTokens,
+ 'process-withdrawals': handleProcessWithdrawals,
};
export default wrap(async (req, res) => {
@@ -2400,3 +2401,146 @@ async function handleCleanupCsrfTokens(req, res) {
const result = await sql`DELETE FROM csrf_tokens WHERE expires_at < now() RETURNING token`;
return json(res, 200, { deleted: result.length });
}
+
+// ═══════════════════════════════════════════════════════════════════════════
+// process-withdrawals — pick up pending Solana USDC withdrawals and execute
+// them from the treasury keypair. Runs hourly.
+// State machine: pending → processing → completed (with tx_signature) | failed (with error_message)
+// ═══════════════════════════════════════════════════════════════════════════
+
+const WITHDRAWALS_BATCH = 20;
+
+async function handleProcessWithdrawals(req, res) {
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS' })) return;
+
+ const auth = req.headers['authorization'] || '';
+ const cronSecret = env.CRON_SECRET;
+ const fromCron = req.headers['x-vercel-cron'] === '1';
+ if (!fromCron && cronSecret && auth !== `Bearer ${cronSecret}`) {
+ return error(res, 401, 'unauthorized', 'cron secret required');
+ }
+
+ const treasuryKeypair = process.env.TREASURY_KEYPAIR;
+ if (!treasuryKeypair) {
+ return json(res, 200, { skipped: true, reason: 'TREASURY_KEYPAIR not configured' });
+ }
+
+ const { transferSolanaUSDC } = await import('../_lib/solana-transfer.js');
+ const { insertNotification } = await import('../_lib/notify.js');
+
+ // Fetch pending Solana withdrawals, join user earnings to verify available balance
+ const pending = await sql`
+ SELECT
+ w.id,
+ w.user_id,
+ w.amount,
+ w.currency_mint,
+ w.to_address,
+ w.chain,
+ (
+ SELECT coalesce(sum(re.net_amount), 0)::bigint
+ FROM agent_revenue_events re
+ JOIN agent_identities ai ON ai.id = re.agent_id
+ WHERE ai.user_id = w.user_id AND re.currency_mint = w.currency_mint
+ ) -
+ (
+ SELECT coalesce(sum(w2.amount), 0)::bigint
+ FROM agent_withdrawals w2
+ WHERE w2.user_id = w.user_id
+ AND w2.id != w.id
+ AND w2.status IN ('pending', 'processing', 'completed')
+ AND w2.currency_mint = w.currency_mint
+ ) AS available
+ FROM agent_withdrawals w
+ WHERE w.status = 'pending' AND w.chain = 'solana'
+ ORDER BY w.created_at ASC
+ LIMIT ${WITHDRAWALS_BATCH}
+ `;
+
+ const report = { processed: 0, completed: 0, failed: 0, skipped: 0, errors: [] };
+
+ for (const w of pending) {
+ report.processed++;
+ const available = Number(w.available ?? 0);
+
+ // Skip if user doesn't have enough available balance
+ if (w.amount > available) {
+ await sql`
+ UPDATE agent_withdrawals
+ SET status = 'failed',
+ error_message = 'Insufficient referral balance at processing time',
+ updated_at = now()
+ WHERE id = ${w.id}
+ `;
+ insertNotification(w.user_id, 'withdrawal_failed', {
+ withdrawal_id: w.id,
+ amount: w.amount,
+ currency_mint: w.currency_mint,
+ reason: 'insufficient_balance',
+ });
+ report.failed++;
+ report.errors.push({ id: w.id, error: 'insufficient_balance' });
+ continue;
+ }
+
+ // Mark as processing atomically — only if still pending
+ const [claimed] = await sql`
+ UPDATE agent_withdrawals
+ SET status = 'processing', updated_at = now()
+ WHERE id = ${w.id} AND status = 'pending'
+ RETURNING id
+ `;
+ if (!claimed) {
+ report.skipped++;
+ continue;
+ }
+
+ try {
+ const sig = await transferSolanaUSDC({
+ fromWallet: treasuryKeypair,
+ toAddress: w.to_address,
+ amount: BigInt(w.amount),
+ mint: w.currency_mint,
+ });
+
+ await sql`
+ UPDATE agent_withdrawals
+ SET status = 'completed', tx_signature = ${sig}, updated_at = now()
+ WHERE id = ${w.id}
+ `;
+
+ // Deduct from referral_earnings_total (best-effort; earnings are tracked via revenue_events)
+ await sql`
+ UPDATE users
+ SET referral_earnings_total = greatest(0, coalesce(referral_earnings_total, 0) - ${w.amount})
+ WHERE id = ${w.user_id}
+ `.catch((e) => console.error('[process-withdrawals] referral deduct failed:', e.message));
+
+ insertNotification(w.user_id, 'withdrawal_completed', {
+ withdrawal_id: w.id,
+ amount: w.amount,
+ currency_mint: w.currency_mint,
+ tx_signature: sig,
+ });
+
+ report.completed++;
+ } catch (err) {
+ const msg = err.message || String(err);
+ await sql`
+ UPDATE agent_withdrawals
+ SET status = 'failed', error_message = ${msg}, updated_at = now()
+ WHERE id = ${w.id}
+ `;
+ insertNotification(w.user_id, 'withdrawal_failed', {
+ withdrawal_id: w.id,
+ amount: w.amount,
+ currency_mint: w.currency_mint,
+ reason: msg,
+ });
+ report.failed++;
+ report.errors.push({ id: w.id, error: msg });
+ }
+ }
+
+ return json(res, 200, { ok: true, ...report });
+}
diff --git a/api/explore.js b/api/explore.js
index c7d674276..a67ff3f16 100644
--- a/api/explore.js
+++ b/api/explore.js
@@ -82,6 +82,8 @@ export default wrap(async (req, res) => {
? await sql`
SELECT a.id, a.slug, a.name, a.description, a.storage_key, a.thumbnail_key,
a.tags, a.created_at, a.source,
+ coalesce(a.featured, false) AS featured,
+ coalesce(a.view_count, 0) AS view_count,
u.username AS owner_username,
u.display_name AS owner_display_name,
u.wallet_address AS owner_wallet
@@ -94,7 +96,7 @@ export default wrap(async (req, res) => {
OR coalesce(a.description,'') ILIKE ${'%' + q + '%'}
))
AND (${cursorDate ? cursorDate.toISOString() : null}::timestamptz IS NULL OR a.created_at < ${cursorDate ? cursorDate.toISOString() : null}::timestamptz)
- ORDER BY a.created_at DESC
+ ORDER BY coalesce(a.featured, false) DESC, a.created_at DESC
LIMIT ${(limit + 1) * 3}
`
: [];
@@ -147,6 +149,8 @@ export default wrap(async (req, res) => {
has3d: true,
tags: r.tags || [],
source: r.source || null,
+ featured: r.featured === true || r.featured === 't',
+ viewCount: Number(r.view_count) || 0,
createdAt: r.created_at,
viewerUrl: `/#model=${encodeURIComponent(glb)}`,
author: handle
diff --git a/api/marketplace/[action].js b/api/marketplace/[action].js
index 84f08ace9..65deb53d6 100644
--- a/api/marketplace/[action].js
+++ b/api/marketplace/[action].js
@@ -90,6 +90,7 @@ export default wrap(async (req, res) => {
if (sub === 'bookmark') return handleBookmark(req, res, id);
if (sub === 'publish') return handlePublish(req, res, id);
if (sub === 'view') return handleView(req, res, id);
+ if (sub === 'preview') return handlePreview(req, res, id);
return error(res, 404, 'not_found', 'unknown marketplace action');
}
@@ -336,6 +337,9 @@ async function handleDetail(req, res, id) {
const [row] = await sql`
SELECT a.*, u.display_name AS author_name, u.avatar_url AS author_avatar,
+ av.storage_key AS avatar_storage_key,
+ av.thumbnail_key AS avatar_thumbnail_key,
+ av.visibility AS avatar_visibility,
(SELECT count(*)::int FROM skill_purchases sp
WHERE sp.agent_id = a.id AND sp.status = 'confirmed') AS buyers_total,
(SELECT count(*)::int FROM skill_purchases sp
@@ -343,6 +347,7 @@ async function handleDetail(req, res, id) {
AND sp.confirmed_at > now() - interval '24 hours') AS buyers_24h
FROM agent_identities a
LEFT JOIN users u ON u.id = a.user_id
+ LEFT JOIN avatars av ON av.id = a.avatar_id AND av.deleted_at IS NULL
WHERE a.id = ${id} AND a.deleted_at IS NULL
`;
if (!row) return error(res, 404, 'not_found', 'agent not found');
@@ -386,6 +391,261 @@ async function handleDetail(req, res, id) {
);
}
+// ── Preview chat ───────────────────────────────────────────────────────────
+//
+// Anonymous-friendly "try before you fork" — POST a single user message, get
+// back an SSE stream of token chunks that come straight from the LLM provider.
+// Two rate-limit buckets in series:
+// 1. Per-IP: prevents one visitor from draining credits.
+// 2. Per-agent: prevents one popular agent from starving the global pool.
+//
+// History is capped at 8 turns; only the agent's published system_prompt is
+// used (no viewer tools, no admin context). Provider is whichever is
+// configured via env, in fallback order: anthropic → openrouter → groq → openai.
+
+const PREVIEW_PROVIDERS = {
+ anthropic: {
+ envKey: 'ANTHROPIC_API_KEY',
+ url: 'https://api.anthropic.com/v1/messages',
+ defaultModel: 'claude-haiku-4-5-20251001',
+ style: 'anthropic',
+ extraHeaders: { 'anthropic-version': '2023-06-01' },
+ },
+ openrouter: {
+ envKey: 'OPENROUTER_API_KEY',
+ url: 'https://openrouter.ai/api/v1/chat/completions',
+ defaultModel: 'meta-llama/llama-3.3-70b-instruct:free',
+ style: 'openai',
+ extraHeaders: {
+ 'HTTP-Referer': 'https://three.ws',
+ 'X-Title': 'three.ws marketplace',
+ },
+ },
+ groq: {
+ envKey: 'GROQ_API_KEY',
+ url: 'https://api.groq.com/openai/v1/chat/completions',
+ defaultModel: 'llama-3.3-70b-versatile',
+ style: 'openai',
+ },
+ openai: {
+ envKey: 'OPENAI_API_KEY',
+ url: 'https://api.openai.com/v1/chat/completions',
+ defaultModel: 'gpt-4o-mini',
+ style: 'openai',
+ },
+};
+
+const previewBody = z.object({
+ message: z.string().trim().min(1).max(2000),
+ history: z
+ .array(
+ z.object({
+ role: z.enum(['user', 'assistant']),
+ content: z.string().min(1).max(2000),
+ }),
+ )
+ .max(8)
+ .default([]),
+});
+
+async function handlePreview(req, res, id) {
+ if (cors(req, res, { methods: 'POST,OPTIONS' })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const ip = clientIp(req);
+ const ipRl = await limits.previewIp(ip);
+ if (!ipRl.success) return error(res, 429, 'rate_limited', 'too many preview messages — try again later');
+ const agentRl = await limits.previewAgent(id);
+ if (!agentRl.success) return error(res, 429, 'rate_limited', 'this agent is at capacity right now');
+
+ const raw = await readJson(req).catch(() => null);
+ if (!raw) return error(res, 400, 'validation_error', 'request body required');
+ let body;
+ try {
+ body = previewBody.parse(raw);
+ } catch (err) {
+ return error(res, 400, 'validation_error', err.errors?.[0]?.message || 'invalid body');
+ }
+
+ const [agent] = await sql`
+ SELECT id, name, greeting, system_prompt, persona_prompt, is_published, deleted_at
+ FROM agent_identities
+ WHERE id = ${id}
+ LIMIT 1
+ `;
+ if (!agent || agent.deleted_at || !agent.is_published) {
+ return error(res, 404, 'not_found', 'agent not found or not published');
+ }
+
+ const route = pickPreviewProvider();
+ if (!route) return error(res, 503, 'preview_unavailable', 'no preview provider configured');
+
+ const baseSystem = (agent.system_prompt || agent.persona_prompt || '').trim();
+ const systemPrompt = baseSystem
+ ? `${baseSystem}\n\nReply concisely. Keep responses to 1–4 sentences. No markdown formatting, no headers, no lists. Stay in character as ${agent.name || 'this agent'}.`
+ : `You are ${agent.name || 'a community agent'}. Reply concisely in 1–4 sentences in plain text. No markdown.`;
+
+ const history = body.history.map((m) => ({ role: m.role, content: m.content }));
+ history.push({ role: 'user', content: body.message });
+
+ let upstream;
+ try {
+ upstream = await fetch(route.url, {
+ method: 'POST',
+ headers: route.headers,
+ body: JSON.stringify(route.buildPayload({ systemPrompt, history })),
+ });
+ } catch {
+ return error(res, 502, 'upstream_unavailable', 'preview backend unreachable');
+ }
+
+ if (!upstream.ok) {
+ const text = await upstream.text().catch(() => '');
+ if (process.env.DEBUG === 'true') {
+ console.warn(`[preview:${route.name}]`, upstream.status, text.slice(0, 400));
+ }
+ return error(res, 502, 'upstream_error', `preview backend returned ${upstream.status}`);
+ }
+
+ res.writeHead(200, {
+ 'Content-Type': 'text/event-stream; charset=utf-8',
+ 'Cache-Control': 'no-cache, no-transform',
+ 'X-Accel-Buffering': 'no',
+ 'Connection': 'keep-alive',
+ });
+ const sendSSE = (obj) => res.write(`data: ${JSON.stringify(obj)}\n\n`);
+ sendSSE({ type: 'open', model: route.model, provider: route.name });
+
+ const started = Date.now();
+ const out = route.style === 'anthropic'
+ ? await streamAnthropicPreview(upstream, sendSSE)
+ : await streamOpenAIPreview(upstream, sendSSE);
+
+ if (out.error) {
+ sendSSE({ type: 'error', code: 'stream_error', message: 'stream interrupted' });
+ res.end();
+ return;
+ }
+
+ sendSSE({
+ type: 'done',
+ reply: out.reply.trim(),
+ model: route.model,
+ provider: route.name,
+ latencyMs: Date.now() - started,
+ });
+ res.end();
+}
+
+function pickPreviewProvider() {
+ const order = ['anthropic', 'openrouter', 'groq', 'openai'];
+ for (const name of order) {
+ const cfg = PREVIEW_PROVIDERS[name];
+ const key = process.env[cfg.envKey];
+ if (!key) continue;
+ const model = process.env.PREVIEW_MODEL || cfg.defaultModel;
+ if (cfg.style === 'anthropic') {
+ return {
+ name,
+ model,
+ url: cfg.url,
+ style: 'anthropic',
+ headers: {
+ 'x-api-key': key,
+ 'content-type': 'application/json',
+ ...(cfg.extraHeaders || {}),
+ },
+ buildPayload: ({ systemPrompt, history }) => ({
+ model,
+ max_tokens: 512,
+ system: systemPrompt,
+ messages: history,
+ stream: true,
+ }),
+ };
+ }
+ return {
+ name,
+ model,
+ url: cfg.url,
+ style: 'openai',
+ headers: {
+ Authorization: `Bearer ${key}`,
+ 'Content-Type': 'application/json',
+ ...(cfg.extraHeaders || {}),
+ },
+ buildPayload: ({ systemPrompt, history }) => ({
+ model,
+ max_tokens: 512,
+ messages: [{ role: 'system', content: systemPrompt }, ...history],
+ stream: true,
+ }),
+ };
+ }
+ return null;
+}
+
+async function streamAnthropicPreview(upstream, sendSSE) {
+ const reader = upstream.body.getReader();
+ const decoder = new TextDecoder();
+ let buf = '';
+ let reply = '';
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) break;
+ buf += decoder.decode(value, { stream: true });
+ const lines = buf.split('\n');
+ buf = lines.pop();
+ for (const line of lines) {
+ if (!line.startsWith('data: ')) continue;
+ const raw = line.slice(6).trim();
+ if (!raw) continue;
+ let evt;
+ try { evt = JSON.parse(raw); } catch { continue; }
+ if (evt.type === 'content_block_delta' && evt.delta?.type === 'text_delta') {
+ reply += evt.delta.text;
+ sendSSE({ type: 'chunk', text: evt.delta.text });
+ }
+ }
+ }
+ } catch (err) {
+ return { error: err, reply };
+ }
+ return { reply };
+}
+
+async function streamOpenAIPreview(upstream, sendSSE) {
+ const reader = upstream.body.getReader();
+ const decoder = new TextDecoder();
+ let buf = '';
+ let reply = '';
+ try {
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) break;
+ buf += decoder.decode(value, { stream: true });
+ const lines = buf.split('\n');
+ buf = lines.pop();
+ for (const line of lines) {
+ if (!line.startsWith('data: ')) continue;
+ const raw = line.slice(6).trim();
+ if (!raw || raw === '[DONE]') continue;
+ let evt;
+ try { evt = JSON.parse(raw); } catch { continue; }
+ const text = evt.choices?.[0]?.delta?.content;
+ if (text) {
+ reply += text;
+ sendSSE({ type: 'chunk', text });
+ }
+ }
+ }
+ } catch (err) {
+ return { error: err, reply };
+ }
+ return { reply };
+}
+
// ── Versions ───────────────────────────────────────────────────────────────
async function handleVersions(req, res, id) {
@@ -604,6 +864,7 @@ async function handleView(req, res, id) {
// ── Shaping ────────────────────────────────────────────────────────────────
function toCard(row) {
+ const avatarPublic = !row.avatar_visibility || row.avatar_visibility === 'public' || row.avatar_visibility === 'unlisted';
return {
id: row.id,
name: row.name,
@@ -612,6 +873,7 @@ function toCard(row) {
tags: row.tags || [],
avatar_id: row.avatar_id,
thumbnail_url: row.thumbnail_key ? publicUrl(row.thumbnail_key) : null,
+ avatar_glb_url: row.avatar_storage_key && avatarPublic ? publicUrl(row.avatar_storage_key) : null,
author_id: row.user_id,
skills: row.skills || [],
forks_count: row.forks_count || 0,
diff --git a/api/marketplace/purchase.js b/api/marketplace/purchase.js
index dabc9d5e7..52943da06 100644
--- a/api/marketplace/purchase.js
+++ b/api/marketplace/purchase.js
@@ -74,13 +74,16 @@ async function handleCreate(req, res) {
const body = await readJson(req).catch(() => null);
const agentId = body?.agent_id;
const skill = typeof body?.skill === 'string' ? body.skill.trim() : null;
+ const durationHours = Number.isInteger(body?.duration_hours) && body.duration_hours > 0
+ ? Math.min(body.duration_hours, 720)
+ : null;
if (!agentId || !skill) {
return error(res, 400, 'validation_error', 'agent_id and skill required');
}
// Look up the active price for this skill on this agent.
const [price] = await sql`
- SELECT amount, currency_mint, chain, mint_decimals, trial_uses
+ SELECT amount, currency_mint, chain, mint_decimals, trial_uses, time_pass_hours, time_pass_amount
FROM agent_skill_prices
WHERE agent_id = ${agentId} AND skill = ${skill} AND is_active = true
`;
diff --git a/api/marketplace/start-trial.js b/api/marketplace/start-trial.js
new file mode 100644
index 000000000..a21241fdc
--- /dev/null
+++ b/api/marketplace/start-trial.js
@@ -0,0 +1,108 @@
+/**
+ * POST /api/marketplace/start-trial
+ * Body: { agent_id, skill }
+ *
+ * Checks the skill has trial_uses > 0 on agent_skill_prices.
+ * Inserts a skill_purchases row with status='trial', kind='trial', no payment.
+ * Rate-limit: one trial per (user, agent, skill).
+ */
+
+import { z } from 'zod';
+import crypto from 'node:crypto';
+import { sql } from '../_lib/db.js';
+import { getSessionUser } from '../_lib/auth.js';
+import { cors, json, method, wrap, error, readJson } from '../_lib/http.js';
+import { parse } from '../_lib/validate.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { requireCsrf } from '../_lib/csrf.js';
+
+const bodySchema = z.object({
+ agent_id: z.string().uuid(),
+ skill: z.string().trim().min(1).max(100),
+});
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const csrfOk = await requireCsrf(req, res, user.id);
+ if (!csrfOk) return;
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const body = parse(bodySchema, await readJson(req));
+ const { agent_id, skill } = body;
+
+ // Verify agent exists
+ const [agent] = await sql`
+ SELECT id FROM agent_identities WHERE id = ${agent_id} AND deleted_at IS NULL
+ `;
+ if (!agent) return error(res, 404, 'not_found', 'agent not found');
+
+ // Check skill has trial_uses > 0
+ const [price] = await sql`
+ SELECT skill, trial_uses, amount, currency_mint, chain
+ FROM agent_skill_prices
+ WHERE agent_id = ${agent_id} AND skill = ${skill} AND is_active = true
+ `;
+ if (!price) return error(res, 404, 'not_found', 'skill not found or not priced');
+ if ((price.trial_uses || 0) <= 0) {
+ return error(res, 422, 'no_trials', 'this skill does not offer free trials');
+ }
+
+ // Check for existing active (confirmed or trial) purchase — one per (user, agent, skill)
+ const [existing] = await sql`
+ SELECT id, status, trial_remaining
+ FROM skill_purchases
+ WHERE user_id = ${user.id} AND agent_id = ${agent_id} AND skill = ${skill}
+ AND status IN ('confirmed', 'trial')
+ LIMIT 1
+ `;
+ if (existing) {
+ if (existing.status === 'confirmed') {
+ return error(res, 409, 'already_owned', 'you already own this skill');
+ }
+ // Active trial — return current state
+ return json(res, 200, {
+ data: {
+ trial_remaining: existing.trial_remaining,
+ reference: null,
+ already_trialing: true,
+ },
+ });
+ }
+
+ // Check rate-limit: one trial attempt per (user, agent, skill) — look at any prior trial row
+ const [priorTrial] = await sql`
+ SELECT id FROM skill_purchases
+ WHERE user_id = ${user.id} AND agent_id = ${agent_id} AND skill = ${skill}
+ AND kind = 'trial'
+ LIMIT 1
+ `;
+ if (priorTrial) {
+ return error(res, 409, 'trial_used', 'you have already used the trial for this skill');
+ }
+
+ const reference = crypto.randomBytes(32).toString('hex');
+
+ const [purchase] = await sql`
+ INSERT INTO skill_purchases
+ (user_id, agent_id, skill, status, kind, reference, amount, currency_mint, chain, trial_remaining)
+ VALUES
+ (${user.id}, ${agent_id}, ${skill}, 'trial', 'trial', ${reference},
+ ${price.amount}, ${price.currency_mint}, ${price.chain}, ${price.trial_uses})
+ RETURNING id, trial_remaining, reference, created_at
+ `;
+
+ return json(res, 201, {
+ data: {
+ trial_remaining: purchase.trial_remaining,
+ reference: purchase.reference,
+ purchase_id: purchase.id,
+ },
+ });
+});
diff --git a/api/marketplace/theme.js b/api/marketplace/theme.js
new file mode 100644
index 000000000..5db89ef55
--- /dev/null
+++ b/api/marketplace/theme.js
@@ -0,0 +1,32 @@
+// GET /api/marketplace/theme — returns the currently active marketplace theme,
+// or null if none. Themes are curated manually via the marketplace_themes table.
+
+import { sql } from '../_lib/db.js';
+import { cors, json, method, wrap } from '../_lib/http.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rows = await sql`
+ SELECT id, title, blurb, tag, starts_at, ends_at
+ FROM marketplace_themes
+ WHERE starts_at <= now() AND ends_at >= now()
+ ORDER BY created_at DESC
+ LIMIT 1
+ `;
+
+ const theme = rows[0]
+ ? {
+ id: rows[0].id,
+ title: rows[0].title,
+ blurb: rows[0].blurb || '',
+ tag: rows[0].tag || null,
+ startsAt: rows[0].starts_at,
+ endsAt: rows[0].ends_at,
+ }
+ : null;
+
+ res.setHeader('cache-control', 'public, max-age=300, s-maxage=300, stale-while-revalidate=900');
+ return json(res, 200, { data: { theme } });
+});
diff --git a/api/pump/[action].js b/api/pump/[action].js
index d5e53d4fa..217c2984d 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -1211,16 +1211,33 @@ async function handleByAgent(req, res) {
if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
const url = new URL(req.url, `http://${req.headers.host}`);
- const agentId = url.searchParams.get('agent_id');
- if (!agentId) return error(res, 400, 'validation_error', 'agent_id required');
+ const agentId = url.searchParams.get('agent_id');
+ const avatarId = url.searchParams.get('avatar_id');
+ if (!agentId && !avatarId)
+ return error(res, 400, 'validation_error', 'agent_id or avatar_id required');
- const [row] = await sql`
- select id, mint, network, name, symbol, buyback_bps, agent_authority,
- metadata_uri, sharing_config, created_at
- from pump_agent_mints
- where agent_id=${agentId}
- order by created_at desc limit 1
- `;
+ let row;
+ if (agentId) {
+ [row] = await sql`
+ select pam.id, pam.mint, pam.network, pam.name, pam.symbol,
+ pam.buyback_bps, pam.agent_authority, pam.metadata_uri,
+ pam.sharing_config, pam.created_at
+ from pump_agent_mints pam
+ where pam.agent_id=${agentId}
+ order by pam.created_at desc limit 1
+ `;
+ } else {
+ [row] = await sql`
+ select pam.id, pam.mint, pam.network, pam.name, pam.symbol,
+ pam.buyback_bps, pam.agent_authority, pam.metadata_uri,
+ pam.sharing_config, pam.created_at
+ from pump_agent_mints pam
+ join agent_identities ai
+ on ai.id = pam.agent_id and ai.deleted_at is null
+ where ai.avatar_id=${avatarId}
+ order by pam.created_at desc limit 1
+ `;
+ }
if (!row) return json(res, 200, { data: null });
const [stats] = await sql`
diff --git a/api/users/me/purchased-skills.js b/api/users/me/purchased-skills.js
index d08596589..f3b31a122 100644
--- a/api/users/me/purchased-skills.js
+++ b/api/users/me/purchased-skills.js
@@ -21,10 +21,26 @@ export default wrap(async (req, res) => {
if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
const purchases = await sql`
- SELECT agent_id, skill, amount, currency_mint, chain, tx_signature, confirmed_at
- FROM skill_purchases
- WHERE user_id = ${userId} AND status = 'confirmed'
- ORDER BY confirmed_at DESC
+ SELECT
+ sp.id,
+ sp.agent_id,
+ sp.skill,
+ sp.status,
+ sp.kind,
+ sp.amount,
+ sp.currency_mint,
+ sp.chain,
+ sp.tx_signature,
+ sp.confirmed_at,
+ sp.valid_until,
+ sp.trial_remaining,
+ sp.created_at,
+ ai.name AS agent_name,
+ ai.thumbnail_url AS agent_thumbnail
+ FROM skill_purchases sp
+ LEFT JOIN agent_identities ai ON ai.id = sp.agent_id
+ WHERE sp.user_id = ${userId} AND sp.status IN ('confirmed', 'trial')
+ ORDER BY sp.confirmed_at DESC NULLS LAST, sp.created_at DESC
`;
return json(res, 200, { data: { purchases } });
diff --git a/marketplace-v2.css b/marketplace-v2.css
new file mode 100644
index 000000000..c511106fb
--- /dev/null
+++ b/marketplace-v2.css
@@ -0,0 +1,415 @@
+/* Marketplace v2 — chat preview, creator modal, detail 3D avatar, mobile.
+ * Loaded as a separate file so inline-style linting doesn't compete with edits. */
+
+/* ── Detail header 3D avatar ──────────────────────────────────────────── */
+.market-detail-avatar {
+ position: relative;
+ overflow: hidden;
+}
+.market-detail-avatar model-viewer {
+ width: 100%;
+ height: 100%;
+ --poster-color: transparent;
+ background: transparent;
+}
+.market-detail-avatar .d-avatar-fallback {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ height: 100%;
+}
+.market-detail-avatar.has-img {
+ background-size: cover;
+ background-position: center;
+}
+.market-detail-avatar.has-img .d-avatar-fallback {
+ display: none;
+}
+.market-detail-avatar.has-3d {
+ background: radial-gradient(circle at 50% 60%, rgba(125, 211, 252, 0.06), transparent 70%),
+ linear-gradient(180deg, #050505, #0d0d0d);
+}
+.market-detail-avatar.has-3d .d-avatar-fallback {
+ display: none;
+}
+.market-author-btn {
+ background: none;
+ border: 0;
+ color: inherit;
+ font: inherit;
+ padding: 0;
+ cursor: pointer;
+ text-decoration: underline;
+ text-decoration-color: rgba(255, 255, 255, 0.18);
+ text-underline-offset: 3px;
+ transition: text-decoration-color 0.15s ease, color 0.15s ease;
+}
+.market-author-btn:hover {
+ text-decoration-color: #fafafa;
+ color: #fafafa;
+}
+
+/* ── Live chat preview on agent detail ─────────────────────────────────── */
+.market-preview-card {
+ margin-top: 16px;
+ background: linear-gradient(180deg, #0e0e10, #0a0a0a);
+ border: 1px solid #1f1f1f;
+ border-radius: 16px;
+ padding: 18px;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+}
+.market-preview-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: baseline;
+ gap: 12px;
+ flex-wrap: wrap;
+}
+.market-preview-hint {
+ color: #71717a;
+ font-size: 12px;
+}
+.market-preview-thread {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ min-height: 64px;
+ max-height: 360px;
+ overflow-y: auto;
+ padding-right: 4px;
+}
+.market-preview-thread:empty::before {
+ content: 'The agent will reply here. Try "What can you do?"';
+ color: #52525b;
+ font-size: 13px;
+ font-style: italic;
+ display: block;
+ padding: 8px 12px;
+}
+.market-preview-msg {
+ display: flex;
+ gap: 8px;
+ align-items: flex-start;
+}
+.market-preview-msg.user {
+ flex-direction: row-reverse;
+}
+.market-preview-bubble {
+ background: #161616;
+ border: 1px solid #222;
+ border-radius: 12px;
+ padding: 10px 14px;
+ font-size: 14px;
+ line-height: 1.5;
+ color: #f4f4f5;
+ white-space: pre-wrap;
+ word-break: break-word;
+ max-width: 80%;
+}
+.market-preview-msg.user .market-preview-bubble {
+ background: #fafafa;
+ color: #0a0a0a;
+ border-color: #fafafa;
+}
+.market-preview-msg.assistant .market-preview-bubble {
+ background: #131316;
+}
+.market-preview-bubble.streaming::after {
+ content: '▌';
+ display: inline-block;
+ margin-left: 2px;
+ animation: mk-cursor-blink 0.9s infinite;
+ color: #7dd3fc;
+}
+@keyframes mk-cursor-blink {
+ 0%, 49% { opacity: 1; }
+ 50%, 100% { opacity: 0; }
+}
+.market-preview-form {
+ display: flex;
+ gap: 8px;
+}
+.market-preview-input {
+ flex: 1;
+ background: #0d0d0f;
+ border: 1px solid #2a2a2a;
+ border-radius: 10px;
+ padding: 10px 14px;
+ color: #fafafa;
+ font-size: 14px;
+ font-family: inherit;
+}
+.market-preview-input:focus {
+ outline: none;
+ border-color: #4a4a4a;
+}
+.market-preview-send {
+ background: #fafafa;
+ color: #0a0a0a;
+ border: 0;
+ padding: 10px 18px;
+ border-radius: 10px;
+ font-weight: 600;
+ cursor: pointer;
+ font-size: 13px;
+}
+.market-preview-send:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+}
+.market-preview-send:hover:not(:disabled) {
+ transform: translateY(-1px);
+}
+.market-preview-footer {
+ font-size: 11px;
+ color: #52525b;
+ min-height: 14px;
+}
+.market-preview-footer.err {
+ color: #f87171;
+}
+
+/* ── Creator profile modal ─────────────────────────────────────────────── */
+.creator-modal-overlay {
+ position: fixed;
+ inset: 0;
+ background: rgba(0, 0, 0, 0.78);
+ backdrop-filter: blur(6px);
+ z-index: 200;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 24px;
+ opacity: 0;
+ transition: opacity 0.2s ease;
+}
+.creator-modal-overlay.show {
+ opacity: 1;
+}
+.creator-modal {
+ background: #0d0d0d;
+ border: 1px solid #1f1f1f;
+ border-radius: 18px;
+ width: min(900px, 100%);
+ max-height: 90vh;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
+ position: relative;
+}
+.creator-modal-close {
+ position: absolute;
+ top: 12px;
+ right: 14px;
+ background: rgba(0, 0, 0, 0.4);
+ border: 1px solid #1f1f1f;
+ color: #fafafa;
+ width: 30px;
+ height: 30px;
+ border-radius: 50%;
+ cursor: pointer;
+ font-size: 18px;
+ line-height: 1;
+ z-index: 2;
+}
+.creator-modal-head {
+ display: flex;
+ gap: 18px;
+ align-items: center;
+ padding: 24px 26px 18px;
+ border-bottom: 1px solid #1a1a1a;
+}
+.creator-modal-avatar {
+ width: 64px;
+ height: 64px;
+ border-radius: 50%;
+ background: #1a1a1a center/cover no-repeat;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-family: 'Space Grotesk', sans-serif;
+ font-weight: 700;
+ font-size: 24px;
+ color: #fafafa;
+ flex: 0 0 auto;
+ border: 1px solid #2a2a2a;
+}
+.creator-modal-meta {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-width: 0;
+ flex: 1;
+}
+.creator-modal-eyebrow {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 10px;
+ letter-spacing: 0.18em;
+ text-transform: uppercase;
+ color: #7dd3fc;
+ font-weight: 600;
+}
+.creator-modal-title {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 22px;
+ font-weight: 700;
+ color: #fafafa;
+ margin: 0;
+ line-height: 1.2;
+}
+.creator-modal-handle {
+ color: #a1a1aa;
+ font-size: 13px;
+}
+.creator-modal-stats {
+ display: flex;
+ gap: 16px;
+ margin-top: 6px;
+ font-size: 12px;
+ color: #a1a1aa;
+ flex-wrap: wrap;
+}
+.creator-modal-stats strong {
+ color: #fafafa;
+ font-family: 'Space Grotesk', sans-serif;
+ font-weight: 700;
+ margin-right: 4px;
+}
+.creator-modal-body {
+ flex: 1;
+ overflow-y: auto;
+ padding: 18px 26px 26px;
+ display: flex;
+ flex-direction: column;
+ gap: 24px;
+}
+.creator-modal-sectiontitle {
+ font-size: 14px;
+ font-weight: 600;
+ color: #fafafa;
+ margin: 0 0 12px;
+}
+.creator-modal-sectiontitle .muted {
+ color: #71717a;
+ font-weight: 500;
+ font-size: 12px;
+ margin-left: 6px;
+}
+.creator-modal-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
+ gap: 12px;
+}
+.creator-mini-card {
+ background: #111;
+ border: 1px solid #1f1f1f;
+ border-radius: 12px;
+ padding: 12px;
+ cursor: pointer;
+ transition: border-color 0.15s ease, transform 0.15s ease;
+}
+.creator-mini-card:hover {
+ border-color: #2a2a2a;
+ transform: translateY(-1px);
+}
+.creator-mini-card .thumb {
+ aspect-ratio: 1 / 1;
+ border-radius: 8px;
+ background: #050505 center/cover no-repeat;
+ margin-bottom: 8px;
+ border: 1px solid #1a1a1a;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: rgba(255, 255, 255, 0.18);
+ font-size: 28px;
+}
+.creator-mini-card .name {
+ font-size: 13px;
+ font-weight: 600;
+ color: #fafafa;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.creator-mini-card .meta {
+ font-size: 11px;
+ color: #a1a1aa;
+ margin-top: 4px;
+}
+
+/* ── Mobile responsive ─────────────────────────────────────────────────── */
+.market-sidebar-toggle {
+ display: none;
+ position: fixed;
+ top: 14px;
+ left: 14px;
+ z-index: 50;
+ background: #111;
+ border: 1px solid #2a2a2a;
+ color: #fafafa;
+ width: 38px;
+ height: 38px;
+ border-radius: 10px;
+ cursor: pointer;
+ font-size: 18px;
+ line-height: 1;
+}
+.market-sidebar-backdrop {
+ position: fixed;
+ inset: 0;
+ background: rgba(0, 0, 0, 0.6);
+ z-index: 40;
+ display: none;
+}
+body.market-sidebar-open .market-sidebar-backdrop {
+ display: block;
+}
+@media (max-width: 880px) {
+ body.market-page {
+ grid-template-columns: 1fr;
+ }
+ .market-sidebar {
+ position: fixed;
+ top: 0;
+ left: -260px;
+ width: 240px;
+ height: 100vh;
+ background: #0a0a0a;
+ z-index: 45;
+ transition: left 0.2s ease;
+ }
+ body.market-sidebar-open .market-sidebar {
+ left: 0;
+ }
+ .market-sidebar-toggle {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .market-topbar {
+ padding-left: 64px;
+ flex-wrap: wrap;
+ gap: 8px;
+ }
+ .market-hero {
+ margin: 16px 12px 0;
+ padding: 20px;
+ }
+ .market-grid {
+ padding: 0 12px;
+ }
+ .market-body {
+ padding: 0;
+ }
+ .creator-modal {
+ max-height: 95vh;
+ }
+ .creator-modal-grid {
+ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
+ }
+}
diff --git a/marketplace.css b/marketplace.css
index 233827ff9..129452a2c 100644
--- a/marketplace.css
+++ b/marketplace.css
@@ -191,11 +191,75 @@ body.market-page {
.market-grid {
padding: 18px 24px 80px;
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
- gap: 16px;
+ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
+ gap: 14px;
align-content: start;
}
+/* ── Category chips row ─────────────────────────────────────── */
+.market-cat-chips {
+ display: flex;
+ gap: 6px;
+ padding: 8px 24px 2px;
+ overflow-x: auto;
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+ flex-shrink: 0;
+}
+.market-cat-chips::-webkit-scrollbar { display: none; }
+.market-cat-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 5px 12px;
+ border-radius: 999px;
+ border: 1px solid var(--mk-border);
+ background: var(--mk-panel);
+ color: var(--mk-text-2);
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 0.15s, background 0.15s, color 0.15s;
+ flex-shrink: 0;
+}
+.market-cat-chip:hover {
+ border-color: var(--mk-border-2);
+ color: var(--mk-text);
+}
+.market-cat-chip.active {
+ background: var(--mk-text);
+ color: var(--mk-bg);
+ border-color: var(--mk-text);
+}
+.market-cat-chip .cat-chip-count {
+ font-size: 10px;
+ opacity: 0.6;
+ font-weight: 600;
+}
+
+/* ── Infinite scroll sentinel ─────────────────────────────── */
+.market-scroll-sentinel {
+ height: 1px;
+ grid-column: 1 / -1;
+}
+.market-loadmore-spinner {
+ grid-column: 1 / -1;
+ display: flex;
+ justify-content: center;
+ padding: 16px;
+}
+.market-loadmore-spinner::after {
+ content: '';
+ width: 20px;
+ height: 20px;
+ border: 2px solid var(--mk-border-2);
+ border-top-color: var(--mk-text-2);
+ border-radius: 50%;
+ animation: mk-spin 0.7s linear infinite;
+}
+@keyframes mk-spin { to { transform: rotate(360deg); } }
+
.market-card-agent {
background: var(--mk-panel);
border: 1px solid var(--mk-border);
@@ -1602,19 +1666,65 @@ body.market-page {
position: relative;
overflow: hidden;
}
+.market-card-avatar .thumb {
+ position: relative;
+ overflow: hidden;
+ background: #0a0a0c;
+}
+
+/* Shimmer that shows while the GLB streams in */
+.market-card-avatar .thumb::before {
+ content: '';
+ position: absolute;
+ inset: 0;
+ background: linear-gradient(
+ 110deg,
+ transparent 20%,
+ rgba(255,255,255,0.04) 50%,
+ transparent 80%
+ );
+ background-size: 200% 100%;
+ animation: mv-shimmer 1.6s infinite;
+ z-index: 1;
+ pointer-events: none;
+ transition: opacity 0.4s ease;
+}
+.market-card-avatar.mv-loaded .thumb::before { opacity: 0; }
+
+@keyframes mv-shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+}
+
.market-card-avatar .thumb model-viewer {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
background: transparent;
- --poster-color: transparent;
+ --poster-color: #0a0a0c;
opacity: 0;
- transition: opacity 0.3s ease;
+ transition: opacity 0.4s ease;
+ z-index: 0;
}
-.market-card-avatar:hover .thumb model-viewer {
+/* Fade in when model has loaded (JS adds .mv-loaded) */
+.market-card-avatar.mv-loaded .thumb model-viewer {
opacity: 1;
}
+
+/* Featured: first card spans 2 columns + 2 rows for a spotlight effect */
+.market-card-avatar--featured {
+ grid-column: span 2;
+ grid-row: span 2;
+}
+.market-card-avatar--featured .thumb {
+ aspect-ratio: unset;
+ min-height: 320px;
+}
+@media (max-width: 600px) {
+ .market-card-avatar--featured { grid-column: span 1; grid-row: span 1; }
+ .market-card-avatar--featured .thumb { min-height: 0; }
+}
.market-card-avatar .thumb-badge {
position: absolute;
top: 8px;
@@ -1636,6 +1746,47 @@ body.market-page {
opacity: 1;
}
+/* ── Tag filter banner ──────────────────────────────────────── */
+
+.market-tag-banner {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 10px 24px;
+ border-bottom: 1px solid var(--mk-border);
+ background: rgba(125, 211, 252, 0.04);
+ font-size: 12px;
+ color: var(--mk-text-2);
+}
+.market-tag-banner-label {
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ font-size: 10px;
+ color: var(--mk-text-3);
+}
+.market-tag-banner-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ background: rgba(125, 211, 252, 0.12);
+ border: 1px solid rgba(125, 211, 252, 0.3);
+ color: #7dd3fc;
+ padding: 4px 10px;
+ border-radius: 999px;
+ font-size: 12px;
+ font-weight: 600;
+}
+.market-tag-banner-clear {
+ background: transparent;
+ border: 0;
+ color: rgba(125, 211, 252, 0.7);
+ cursor: pointer;
+ font-size: 12px;
+ padding: 0 2px;
+ line-height: 1;
+}
+.market-tag-banner-clear:hover { color: #fff; }
+
/* ── My Agents / Skills tab heads ───────────────────────────── */
.market-topbar {
diff --git a/marketplace.html b/marketplace.html
index 52abc5dde..0a3a854ca 100644
--- a/marketplace.html
+++ b/marketplace.html
@@ -17,6 +17,7 @@
<link rel="stylesheet" href="footer.css" />
<link rel="stylesheet" href="marketplace.css" />
<link rel="stylesheet" href="marketplace-skills.css" />
+ <link rel="stylesheet" href="marketplace-v2.css" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"
rel="stylesheet"
@@ -391,6 +392,139 @@
margin-bottom: 14px;
}
+ /* ── Weekly theme strip ───────────────────────────────────────── */
+ .market-theme-strip {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ margin: 14px 24px 0;
+ padding: 10px 16px;
+ background: linear-gradient(90deg, rgba(168, 85, 247, 0.1), rgba(125, 211, 252, 0.06) 60%, transparent);
+ border: 1px solid rgba(168, 85, 247, 0.18);
+ border-radius: 12px;
+ font-size: 13px;
+ color: #d4d4d8;
+ flex-wrap: wrap;
+ }
+ .market-theme-strip .market-theme-eyebrow {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 10px;
+ letter-spacing: 0.2em;
+ text-transform: uppercase;
+ color: #c4b5fd;
+ font-weight: 700;
+ }
+ .market-theme-strip .market-theme-title {
+ color: #fafafa;
+ font-weight: 700;
+ font-size: 14px;
+ }
+ .market-theme-strip .market-theme-blurb {
+ color: #a1a1aa;
+ flex: 1;
+ min-width: 200px;
+ }
+ .market-theme-strip .market-theme-cta {
+ background: rgba(168, 85, 247, 0.18);
+ color: #f5f3ff;
+ border: 1px solid rgba(168, 85, 247, 0.3);
+ border-radius: 8px;
+ padding: 6px 12px;
+ font-size: 12px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 0.15s ease;
+ }
+ .market-theme-strip .market-theme-cta:hover {
+ background: rgba(168, 85, 247, 0.3);
+ }
+
+ /* ── Onchain card variants ────────────────────────────────────── */
+ .market-card-avatar.onchain {
+ background: linear-gradient(180deg, #0c0d10, #0a0a0a);
+ }
+ .market-card-avatar.onchain .avatar-pill.onchain {
+ background: rgba(168, 85, 247, 0.12);
+ color: #c4b5fd;
+ }
+ .market-card-avatar.onchain .card-chain {
+ font-family: 'Space Grotesk', sans-serif;
+ letter-spacing: 0.04em;
+ color: #c4b5fd;
+ font-weight: 600;
+ font-size: 11px;
+ text-transform: uppercase;
+ }
+ .onchain-x402 {
+ background: rgba(125, 211, 252, 0.12);
+ color: #7dd3fc;
+ padding: 2px 8px;
+ border-radius: 999px;
+ font-size: 10px;
+ font-weight: 700;
+ letter-spacing: 0.04em;
+ }
+
+ /* Onchain count chip (shown next to "Onchain" filter button) */
+ .market-chip .chip-count {
+ background: rgba(255, 255, 255, 0.08);
+ color: inherit;
+ padding: 1px 6px;
+ margin-left: 4px;
+ border-radius: 999px;
+ font-size: 10px;
+ font-weight: 600;
+ }
+ .market-chip.active .chip-count {
+ background: rgba(0, 0, 0, 0.15);
+ }
+
+ /* Tag pills become hover-clickable buttons (filter search by tag). */
+ .market-card-avatar .card-tags .tag-pill {
+ cursor: pointer;
+ font-family: inherit;
+ transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
+ }
+ .market-card-avatar .card-tags .tag-pill:hover {
+ background: rgba(125, 211, 252, 0.18);
+ border-color: rgba(125, 211, 252, 0.4);
+ color: #fafafa;
+ }
+
+ /* Featured-curated badge over the avatar thumbnail (gold star, top-left) */
+ .market-card-avatar.featured {
+ border-color: rgba(253, 224, 71, 0.25);
+ box-shadow: 0 0 0 1px rgba(253, 224, 71, 0.05);
+ }
+ .market-card-avatar .card-featured-badge {
+ position: absolute;
+ top: 8px;
+ left: 8px;
+ z-index: 2;
+ width: 22px;
+ height: 22px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ background: rgba(253, 224, 71, 0.18);
+ color: #fde047;
+ border: 1px solid rgba(253, 224, 71, 0.3);
+ border-radius: 50%;
+ font-size: 12px;
+ backdrop-filter: blur(4px);
+ pointer-events: none;
+ }
+ /* View-count pill in the byline (subtle, low-contrast). */
+ .market-card-avatar .byline .stat-pill.views {
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: 999px;
+ padding: 1px 7px;
+ font-size: 10px;
+ color: #a1a1aa;
+ font-weight: 500;
+ }
+
/* ── Avatar card details: byline, tags, footer cta ──────────── */
.market-card-avatar .byline {
display: flex;
@@ -876,6 +1010,7 @@
<a href="/marketplace?tab=skills" data-nav="skills"><span class="ico">≡</span> <span>Skills</span></a>
<a href="/dashboard" data-nav="model"><span class="ico">◉</span> <span>Model</span></a>
<a href="/marketplace?tab=mine" data-nav="mine"><span class="ico">◱</span> <span>My Agents</span></a>
+ <a href="/marketplace?tab=purchases" data-nav="purchases"><span class="ico">✓</span> <span>My Purchases</span></a>
</nav>
<button class="market-submit-btn market-sidebar-submit" id="market-submit-btn">+ Submit Agent</button>
</aside>
@@ -892,6 +1027,13 @@
<!-- Discovery view -->
<section class="market-discovery" id="market-discovery">
+ <!-- Weekly curated theme strip (loads from /api/marketplace/theme) -->
+ <aside class="market-theme-strip" id="market-theme-strip" hidden>
+ <span class="market-theme-eyebrow">This week</span>
+ <strong class="market-theme-title" id="market-theme-title">—</strong>
+ <span class="market-theme-blurb" id="market-theme-blurb">—</span>
+ <button class="market-theme-cta" id="market-theme-cta" hidden>Browse →</button>
+ </aside>
<!-- Live 3D hero carousel -->
<section class="market-hero" id="market-hero" hidden aria-label="Featured 3D avatars">
<div class="market-hero-stage" id="market-hero-stage"></div>
@@ -919,6 +1061,7 @@
<button class="market-chip active" data-filter="all" role="tab">All</button>
<button class="market-chip" data-filter="agents" role="tab">Agents</button>
<button class="market-chip" data-filter="avatars" role="tab">Avatars</button>
+ <button class="market-chip" data-filter="onchain" role="tab">Onchain <span class="chip-count" id="chip-count-onchain"></span></button>
</div>
<select id="market-sort" class="market-sort">
<option value="recommended">Recommended</option>
@@ -930,8 +1073,12 @@
<div class="wallet-adapter-button-container"></div>
</header>
+ <div class="market-cat-chips" id="market-cat-chips" role="navigation" aria-label="Categories"></div>
+
+ <div class="market-tag-banner" id="market-tag-banner" role="status" hidden></div>
+
<div class="market-grid" id="market-grid"></div>
- <div class="market-loadmore">
+ <div class="market-loadmore" id="market-loadmore-row" hidden>
<button id="market-loadmore" hidden>Load more</button>
</div>
</section>
@@ -940,11 +1087,11 @@
<section class="market-detail" id="market-detail" hidden>
<button class="market-back" id="market-back" aria-label="Back">←</button>
<div class="market-detail-head">
- <div class="market-detail-avatar" id="d-avatar">▣</div>
+ <div class="market-detail-avatar" id="d-avatar"><span class="d-avatar-fallback">▣</span></div>
<div class="market-detail-meta">
<h1 id="d-name">—</h1>
<div class="market-detail-author">
- <span id="d-author">—</span>
+ <button type="button" id="d-author" class="market-author-btn">—</button>
<span class="dot">·</span>
<span id="d-published">—</span>
<span id="d-forks-pill" class="forks-pill" hidden></span>
@@ -972,9 +1119,24 @@
<h3>What can you do with this Agent?</h3>
<p id="d-overview">—</p>
</div>
- <h2 class="market-section-title">Agent Demo</h2>
- <div class="market-demo">
- <div class="market-demo-bubble" id="d-greeting">—</div>
+ <div class="market-preview-card" id="d-preview-card">
+ <div class="market-preview-head">
+ <h2 class="market-section-title" style="margin:0">Try it now</h2>
+ <span class="market-preview-hint">Send a message — no fork required</span>
+ </div>
+ <div class="market-preview-thread" id="d-preview-thread" aria-live="polite"></div>
+ <form class="market-preview-form" id="d-preview-form" autocomplete="off">
+ <input
+ type="text"
+ id="d-preview-input"
+ class="market-preview-input"
+ placeholder="Ask this agent anything…"
+ maxlength="2000"
+ required
+ />
+ <button type="submit" class="market-preview-send" id="d-preview-send">Send</button>
+ </form>
+ <div class="market-preview-footer" id="d-preview-footer"></div>
</div>
</div>
@@ -1031,6 +1193,19 @@
</div>
</section>
+ <!-- My Purchases tab -->
+ <section class="market-purchases" id="market-purchases" hidden>
+ <header class="market-topbar">
+ <div class="market-mine-head">
+ <h2 class="market-section-heading">My Purchases</h2>
+ <span class="market-mine-sub" id="purchases-subtitle"></span>
+ </div>
+ </header>
+ <div class="market-mine-body">
+ <div class="market-grid" id="purchases-grid"></div>
+ </div>
+ </section>
+
<!-- Skills tab -->
<section class="market-skills-section" id="market-skills-section" hidden>
<header class="market-topbar">
@@ -1203,6 +1378,40 @@
</div>
</div>
+ <!-- Creator Profile Modal -->
+ <div class="creator-modal-overlay" id="creator-modal-overlay" hidden aria-modal="true" role="dialog" aria-labelledby="creator-modal-title">
+ <div class="creator-modal" role="document">
+ <button class="creator-modal-close" id="creator-modal-close" aria-label="Close">×</button>
+ <header class="creator-modal-head">
+ <div class="creator-modal-avatar" id="creator-modal-avatar"></div>
+ <div class="creator-modal-meta">
+ <div class="creator-modal-eyebrow">Creator profile</div>
+ <h2 class="creator-modal-title" id="creator-modal-title">—</h2>
+ <div class="creator-modal-handle" id="creator-modal-handle"></div>
+ <div class="creator-modal-stats" id="creator-modal-stats"></div>
+ </div>
+ </header>
+ <div class="creator-modal-body">
+ <section>
+ <h3 class="creator-modal-sectiontitle">Published agents <span id="creator-agents-count" class="muted"></span></h3>
+ <div class="creator-modal-grid" id="creator-agents-grid">
+ <div class="market-empty">Loading…</div>
+ </div>
+ </section>
+ <section>
+ <h3 class="creator-modal-sectiontitle">Public avatars <span id="creator-avatars-count" class="muted"></span></h3>
+ <div class="creator-modal-grid" id="creator-avatars-grid">
+ <div class="market-empty">Loading…</div>
+ </div>
+ </section>
+ </div>
+ </div>
+ </div>
+
+ <!-- Mobile sidebar backdrop + toggle -->
+ <button class="market-sidebar-toggle" id="market-sidebar-toggle" aria-label="Open menu" hidden>☰</button>
+ <div class="market-sidebar-backdrop" id="market-sidebar-backdrop" hidden></div>
+
<!-- Payment Modal -->
<div class="market-modal-overlay" id="payment-modal-overlay" hidden aria-modal="true" role="dialog" aria-labelledby="payment-modal-title">
<div class="market-modal">
diff --git a/migrations/20260510000000_avatars_featured_views.sql b/migrations/20260510000000_avatars_featured_views.sql
new file mode 100644
index 000000000..f9f651ad8
--- /dev/null
+++ b/migrations/20260510000000_avatars_featured_views.sql
@@ -0,0 +1,37 @@
+-- Add featured flag and view counter to avatars table.
+-- featured = true surfaces the avatar at the top of the hero carousel and
+-- community grid. Curated manually by admins via direct SQL or a future
+-- admin panel.
+-- view_count is incremented by the /api/avatars/view endpoint on each
+-- unique page view; used for "popular" sort order.
+
+ALTER TABLE avatars
+ ADD COLUMN IF NOT EXISTS featured boolean NOT NULL DEFAULT false,
+ ADD COLUMN IF NOT EXISTS view_count bigint NOT NULL DEFAULT 0;
+
+-- Index so ORDER BY featured DESC, created_at DESC is fast.
+CREATE INDEX IF NOT EXISTS idx_avatars_featured ON avatars (featured DESC, created_at DESC)
+ WHERE deleted_at IS NULL AND visibility = 'public';
+
+-- Seed the featured flag for the curated showcase avatars (matched by slug
+-- prefix so new uploads don't accidentally get featured by sharing a name).
+UPDATE avatars
+SET featured = true
+WHERE deleted_at IS NULL
+ AND visibility = 'public'
+ AND (
+ name ILIKE 'CZ'
+ OR name ILIKE 'LittlestTokyo'
+ OR name ILIKE 'Soldier%'
+ OR name ILIKE 'Robot%Expressive'
+ OR name ILIKE 'Floating%Character'
+ OR name ILIKE 'Stork'
+ OR name ILIKE 'Parrot'
+ OR name ILIKE 'Horse'
+ OR name ILIKE 'Flamingo'
+ OR name ILIKE 'Xbot'
+ OR name ILIKE 'Michelle'
+ OR name ILIKE 'Fox'
+ OR name ILIKE 'CesiumMan'
+ OR name ILIKE 'BrainStem'
+ );
diff --git a/migrations/20260510010000_marketplace_themes.sql b/migrations/20260510010000_marketplace_themes.sql
new file mode 100644
index 000000000..373de56ed
--- /dev/null
+++ b/migrations/20260510010000_marketplace_themes.sql
@@ -0,0 +1,30 @@
+-- Weekly themes for the marketplace hero ("This week: cyberpunk", etc.).
+-- Each theme covers a date range; the active theme is the one whose range
+-- contains now(). Curated manually by admins via direct SQL or a future
+-- admin panel. Multiple overlapping themes are allowed; the most recently
+-- created one wins.
+
+CREATE TABLE IF NOT EXISTS marketplace_themes (
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
+ title text NOT NULL,
+ blurb text,
+ tag text, -- avatar/agent tag to filter by
+ starts_at timestamptz NOT NULL DEFAULT now(),
+ ends_at timestamptz NOT NULL,
+ created_at timestamptz NOT NULL DEFAULT now(),
+ created_by uuid REFERENCES users(id) ON DELETE SET NULL
+);
+
+CREATE INDEX IF NOT EXISTS idx_marketplace_themes_active
+ ON marketplace_themes (starts_at DESC, ends_at DESC);
+
+-- Seed an opening theme so the banner has content to display today.
+INSERT INTO marketplace_themes (title, blurb, tag, starts_at, ends_at)
+VALUES (
+ 'Community Spotlight',
+ 'Real 3D avatars built by the community this week. Click any to fork into your own agent.',
+ NULL,
+ now() - interval '1 day',
+ now() + interval '7 days'
+)
+ON CONFLICT DO NOTHING;
diff --git a/public/marketplace.css b/public/marketplace.css
index 233827ff9..129452a2c 100644
--- a/public/marketplace.css
+++ b/public/marketplace.css
@@ -191,11 +191,75 @@ body.market-page {
.market-grid {
padding: 18px 24px 80px;
display: grid;
- grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
- gap: 16px;
+ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
+ gap: 14px;
align-content: start;
}
+/* ── Category chips row ─────────────────────────────────────── */
+.market-cat-chips {
+ display: flex;
+ gap: 6px;
+ padding: 8px 24px 2px;
+ overflow-x: auto;
+ scrollbar-width: none;
+ -ms-overflow-style: none;
+ flex-shrink: 0;
+}
+.market-cat-chips::-webkit-scrollbar { display: none; }
+.market-cat-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 5px 12px;
+ border-radius: 999px;
+ border: 1px solid var(--mk-border);
+ background: var(--mk-panel);
+ color: var(--mk-text-2);
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: border-color 0.15s, background 0.15s, color 0.15s;
+ flex-shrink: 0;
+}
+.market-cat-chip:hover {
+ border-color: var(--mk-border-2);
+ color: var(--mk-text);
+}
+.market-cat-chip.active {
+ background: var(--mk-text);
+ color: var(--mk-bg);
+ border-color: var(--mk-text);
+}
+.market-cat-chip .cat-chip-count {
+ font-size: 10px;
+ opacity: 0.6;
+ font-weight: 600;
+}
+
+/* ── Infinite scroll sentinel ─────────────────────────────── */
+.market-scroll-sentinel {
+ height: 1px;
+ grid-column: 1 / -1;
+}
+.market-loadmore-spinner {
+ grid-column: 1 / -1;
+ display: flex;
+ justify-content: center;
+ padding: 16px;
+}
+.market-loadmore-spinner::after {
+ content: '';
+ width: 20px;
+ height: 20px;
+ border: 2px solid var(--mk-border-2);
+ border-top-color: var(--mk-text-2);
+ border-radius: 50%;
+ animation: mk-spin 0.7s linear infinite;
+}
+@keyframes mk-spin { to { transform: rotate(360deg); } }
+
.market-card-agent {
background: var(--mk-panel);
border: 1px solid var(--mk-border);
@@ -1602,19 +1666,65 @@ body.market-page {
position: relative;
overflow: hidden;
}
+.market-card-avatar .thumb {
+ position: relative;
+ overflow: hidden;
+ background: #0a0a0c;
+}
+
+/* Shimmer that shows while the GLB streams in */
+.market-card-avatar .thumb::before {
+ content: '';
+ position: absolute;
+ inset: 0;
+ background: linear-gradient(
+ 110deg,
+ transparent 20%,
+ rgba(255,255,255,0.04) 50%,
+ transparent 80%
+ );
+ background-size: 200% 100%;
+ animation: mv-shimmer 1.6s infinite;
+ z-index: 1;
+ pointer-events: none;
+ transition: opacity 0.4s ease;
+}
+.market-card-avatar.mv-loaded .thumb::before { opacity: 0; }
+
+@keyframes mv-shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+}
+
.market-card-avatar .thumb model-viewer {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
background: transparent;
- --poster-color: transparent;
+ --poster-color: #0a0a0c;
opacity: 0;
- transition: opacity 0.3s ease;
+ transition: opacity 0.4s ease;
+ z-index: 0;
}
-.market-card-avatar:hover .thumb model-viewer {
+/* Fade in when model has loaded (JS adds .mv-loaded) */
+.market-card-avatar.mv-loaded .thumb model-viewer {
opacity: 1;
}
+
+/* Featured: first card spans 2 columns + 2 rows for a spotlight effect */
+.market-card-avatar--featured {
+ grid-column: span 2;
+ grid-row: span 2;
+}
+.market-card-avatar--featured .thumb {
+ aspect-ratio: unset;
+ min-height: 320px;
+}
+@media (max-width: 600px) {
+ .market-card-avatar--featured { grid-column: span 1; grid-row: span 1; }
+ .market-card-avatar--featured .thumb { min-height: 0; }
+}
.market-card-avatar .thumb-badge {
position: absolute;
top: 8px;
@@ -1636,6 +1746,47 @@ body.market-page {
opacity: 1;
}
+/* ── Tag filter banner ──────────────────────────────────────── */
+
+.market-tag-banner {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 10px 24px;
+ border-bottom: 1px solid var(--mk-border);
+ background: rgba(125, 211, 252, 0.04);
+ font-size: 12px;
+ color: var(--mk-text-2);
+}
+.market-tag-banner-label {
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ font-size: 10px;
+ color: var(--mk-text-3);
+}
+.market-tag-banner-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ background: rgba(125, 211, 252, 0.12);
+ border: 1px solid rgba(125, 211, 252, 0.3);
+ color: #7dd3fc;
+ padding: 4px 10px;
+ border-radius: 999px;
+ font-size: 12px;
+ font-weight: 600;
+}
+.market-tag-banner-clear {
+ background: transparent;
+ border: 0;
+ color: rgba(125, 211, 252, 0.7);
+ cursor: pointer;
+ font-size: 12px;
+ padding: 0 2px;
+ line-height: 1;
+}
+.market-tag-banner-clear:hover { color: #fff; }
+
/* ── My Agents / Skills tab heads ───────────────────────────── */
.market-topbar {
diff --git a/public/nav.html b/public/nav.html
index 4c6cd3a9b..d9929e475 100644
--- a/public/nav.html
+++ b/public/nav.html
@@ -1,5 +1,17 @@
<nav class="home-nav" aria-label="Primary">
- <ul class="nav-root" role="menubar">
+ <button
+ type="button"
+ class="nav-burger"
+ id="home-nav-burger"
+ aria-label="Toggle menu"
+ aria-expanded="false"
+ aria-controls="home-nav-root"
+ >
+ <span class="nav-burger-bar"></span>
+ <span class="nav-burger-bar"></span>
+ <span class="nav-burger-bar"></span>
+ </button>
+ <ul class="nav-root" id="home-nav-root" role="menubar">
<li class="nav-item nav-has-menu" role="none">
<button
type="button"
@@ -31,7 +43,17 @@
</li>
</ul>
</li>
- <li role="none"><a href="/discover" role="menuitem">Discover</a></li>
+ <li class="nav-item" role="none">
+ <a href="/pay" class="nav-link-with-badge" role="menuitem"
+ >Pay<span class="nav-badge">NEW</span></a
+ >
+ </li>
+ <li class="nav-item" role="none">
+ <a href="/marketplace" role="menuitem">Marketplace</a>
+ </li>
+ <li class="nav-item" role="none">
+ <a href="/discover" role="menuitem">Discover</a>
+ </li>
<li class="nav-item nav-has-menu" role="none">
<button
type="button"
@@ -40,21 +62,27 @@
aria-expanded="false"
role="menuitem"
>
- Solana<span class="nav-caret" aria-hidden="true">▾</span>
+ Crypto<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>
+ <ul class="nav-menu" role="menu" aria-label="Crypto">
<li role="none">
<a href="/pumpfun" role="menuitem"
><span class="nav-mi-title">Pump.fun stream</span
><span class="nav-mi-sub">Mint agent tokens</span></a
>
</li>
+ <li role="none">
+ <a href="/pump-live" role="menuitem"
+ ><span class="nav-mi-title">Live launches</span
+ ><span class="nav-mi-sub">Real-time mint feed</span></a
+ >
+ </li>
+ <li role="none">
+ <a href="/pump-dashboard" role="menuitem"
+ ><span class="nav-mi-title">Pump Dashboard</span
+ ><span class="nav-mi-sub">Watches · scanner · quotes</span></a
+ >
+ </li>
<li role="none">
<a href="/vanity-wallet" role="menuitem"
><span class="nav-mi-title">Vanity wallet</span
@@ -73,18 +101,6 @@
><span class="nav-mi-sub">DCA + subscriptions</span></a
>
</li>
- <li role="none">
- <a href="/pump-live.html" role="menuitem"
- ><span class="nav-mi-title">Live launches</span
- ><span class="nav-mi-sub">Real-time mint feed</span></a
- >
- </li>
- <li role="none">
- <a href="/pump-dashboard.html" role="menuitem"
- ><span class="nav-mi-title">Pump Dashboard</span
- ><span class="nav-mi-sub">Watches · scanner · quotes</span></a
- >
- </li>
<li role="none">
<a href="/docs#solana" role="menuitem"
><span class="nav-mi-title">Solana SDK</span
@@ -130,11 +146,37 @@
</li>
</ul>
</li>
- <li class="nav-item" role="none"><a href="/marketplace.html" role="menuitem">Marketplace</a></li>
- <li class="nav-item" role="none"><a href="/chat" role="menuitem">Chat</a></li>
- <li class="nav-item" role="none">
+ <li class="nav-item nav-has-menu" role="none">
+ <button
+ type="button"
+ class="nav-trigger"
+ aria-haspopup="true"
+ aria-expanded="false"
+ role="menuitem"
+ >
+ Learn<span class="nav-caret" aria-hidden="true">▾</span>
+ </button>
+ <ul class="nav-menu" role="menu" aria-label="Learn">
+ <li role="none">
+ <a href="/chat" role="menuitem"
+ ><span class="nav-mi-title">Chat</span
+ ><span class="nav-mi-sub">Talk to your agent</span></a
+ >
+ </li>
+ <li role="none">
+ <a href="/tutorials" role="menuitem"
+ ><span class="nav-mi-title">Tutorials</span
+ ><span class="nav-mi-sub">Step-by-step guides</span></a
+ >
+ </li>
+ <li role="none">
+ <a href="/docs" role="menuitem"
+ ><span class="nav-mi-title">Docs</span
+ ><span class="nav-mi-sub">SDKs + API reference</span></a
+ >
+ </li>
+ </ul>
</li>
- <li class="nav-item" role="none"><a href="/tutorials.html" role="menuitem">Tutorials</a></li>
<li class="nav-item" id="home-nav-my-agents-li" role="none" hidden>
<a href="/my-agents" id="home-nav-my-agents" role="menuitem">My Agents</a>
</li>
@@ -147,4 +189,4 @@
>
</li>
</ul>
-</nav>
\ No newline at end of file
+</nav>
diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.js
index abb4cd81c..608b0a760 100644
--- a/public/studio/launch-panel.js
+++ b/public/studio/launch-panel.js
@@ -1,20 +1,21 @@
-// Launch panel for the studio right column.
-// Self-contained: handles wallet detection, SOL balance, metadata upload,
-// on-chain signing, confirmation, and success display — no separate modal.
+// Launch panel — self-contained token launch experience for /studio.
+// Handles: existing-token check, wallet events + balance auto-refresh,
+// metadata upload, on-chain signing, confirmation polling with timeout
+// escape hatch, and success display.
//
-// Exported pure functions (keep for tests):
-// validateLaunchForm(fields) → { ok, errors }
-// handleLaunchSubmit(fields, onSubmit) → { ok, errors? }
+// Exported pure functions (tested):
+// validateLaunchForm(fields) → { ok, errors }
+// handleLaunchSubmit(f, cb) → { ok, errors? }
//
-// DOM entry point:
-// mountLaunchPanel(container, { getAvatar, getUser }) → { avatarChanged, teardown }
+// DOM entry:
+// mountLaunchPanel(el, { getAvatar, getUser }) → { avatarChanged, teardown }
-// ── Pure validation (tested) ────────────────────────────────────────────────
+// ── Pure validation ─────────────────────────────────────────────────────────
export function validateLaunchForm({ name, symbol, description, initialBuy } = {}) {
const errors = {};
- if (!name?.trim()) errors.name = 'Token name is required';
- if (!symbol?.trim()) errors.symbol = 'Symbol is required';
+ if (!name?.trim()) errors.name = 'Token name is required';
+ if (!symbol?.trim()) errors.symbol = 'Symbol is required';
if (!description?.trim()) errors.description = 'Description is required';
if (initialBuy !== '' && initialBuy != null) {
const n = Number(initialBuy);
@@ -30,22 +31,19 @@ export function handleLaunchSubmit(fields, onSubmit) {
return { ok: true };
}
-// ── Utilities ───────────────────────────────────────────────────────────────
+// ── Utilities ────────────────────────────────────────────────────────────────
-function esc(s) {
- return String(s ?? '').replace(/[&<>"']/g, (c) =>
+const esc = (s) =>
+ String(s ?? '').replace(/[&<>"']/g, (c) =>
({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
);
-}
-function toSymbol(name) {
- return (name || '').toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 8) || 'AGENT';
-}
+const toSymbol = (name) =>
+ (name || '').toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 8) || 'AGENT';
-function shortenAddr(addr) {
- if (!addr || addr.length < 10) return addr || '';
- return addr.slice(0, 4) + '…' + addr.slice(-4);
-}
+const shortenAddr = (a) => (!a || a.length < 10 ? a || '' : a.slice(0, 4) + '…' + a.slice(-4));
+
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
function detectWallet() {
if (typeof window === 'undefined') return null;
@@ -55,7 +53,7 @@ function detectWallet() {
function fileToDataUrl(file) {
return new Promise((res, rej) => {
const reader = new FileReader();
- reader.onload = (e) => res(e.target.result);
+ reader.onload = (e) => res(e.target.result);
reader.onerror = rej;
reader.readAsDataURL(file);
});
@@ -64,234 +62,293 @@ function fileToDataUrl(file) {
function friendlyError(msg) {
const m = String(msg || '');
if (/user rejected|rejected the request/i.test(m)) return 'Wallet signing cancelled.';
- if (/0x1\b/.test(m) || /insufficient.*sol/i.test(m) || /insufficient lamports/i.test(m))
- return 'Transaction failed — not enough SOL for fees and rent. Fund your wallet and try again.';
- if (/wallet.*not.*found|no.*wallet.*detected/i.test(m))
+ if (/0x1\b/.test(m) || /insufficient.*lamports|insufficient.*sol/i.test(m))
+ return 'Not enough SOL — fund your wallet and try again.';
+ if (/wallet.*not.*found|no.*wallet/i.test(m))
return 'No Solana wallet detected. Install Phantom or Backpack.';
+ if (/429|rate.limit/i.test(m)) return 'Too many requests — wait a moment and try again.';
return m;
}
-// pump.fun create fee + mint account rent (estimate; actual may vary slightly)
-const PUMP_BASE_COST_SOL = 0.022;
-
-// ── CSS ─────────────────────────────────────────────────────────────────────
-
-const LP_STYLES = `
-.lp { display: flex; flex-direction: column; gap: 0.9rem; }
-.lp-empty { text-align: center; padding: 2.5rem 1rem; color: rgba(255,255,255,0.3);
- font-size: 0.85rem; line-height: 1.7; }
-.lp-empty a { color: rgba(164,240,188,0.7); text-decoration: none; }
-.lp-empty a:hover { color: #a4f0bc; }
-
-/* Token card — image + name/symbol */
-.lp-card {
- display: flex; gap: 0.8rem; align-items: flex-start;
- padding: 0.85rem; border-radius: 12px;
- background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07);
- transition: border-color 0.2s;
-}
-.lp-card:focus-within { border-color: rgba(255,255,255,0.14); }
-
-/* Image drop zone */
-.lp-img-zone {
- flex-shrink: 0; width: 78px; height: 78px; border-radius: 11px;
- border: 2px dashed rgba(255,255,255,0.14); cursor: pointer;
- overflow: hidden; display: flex; align-items: center; justify-content: center;
- background: rgba(255,255,255,0.03); position: relative; transition: all 0.2s;
-}
-.lp-img-zone:hover, .lp-img-zone.dragover { border-color: rgba(164,240,188,0.5); background: rgba(164,240,188,0.05); }
-.lp-img-zone img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
-.lp-img-ph { font-size: 0.62rem; color: rgba(255,255,255,0.28); text-align: center; line-height: 1.5; padding: 0.25rem; pointer-events: none; }
-.lp-img-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
-
-/* Name + symbol inline in card */
-.lp-card-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; padding-top: 0.1rem; }
-.lp-iname {
- width: 100%; font-size: 0.97rem; font-weight: 600;
- background: transparent; border: none; border-bottom: 1px solid rgba(255,255,255,0.09);
- color: #fff; padding: 0 0 0.28rem; outline: none; transition: border-color 0.15s;
-}
-.lp-iname:focus { border-bottom-color: rgba(255,255,255,0.28); }
-.lp-iname::placeholder { color: rgba(255,255,255,0.2); font-weight: 400; }
-.lp-isymbol {
- width: 100%; font-size: 0.8rem; background: transparent; border: none;
- color: #a4f0bc; padding: 0; outline: none;
- font-family: ui-monospace, monospace; letter-spacing: 0.05em;
-}
-.lp-isymbol::placeholder { color: rgba(164,240,188,0.28); }
-.lp-img-hint { font-size: 0.6rem; color: rgba(255,255,255,0.2); margin-top: 0.3rem; }
-
-/* Standard fields */
-.lp label { font-size: 0.72rem; color: rgba(255,255,255,0.4); display: block; margin-bottom: 0.22rem; }
-.lp textarea, .lp-number {
- width: 100%; padding: 0.5rem 0.7rem; border-radius: 8px; outline: none;
- background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
- color: #fff; font-size: 0.85rem; font-family: inherit; box-sizing: border-box;
- transition: border-color 0.15s;
-}
-.lp textarea { resize: vertical; }
-.lp textarea:focus, .lp-number:focus { border-color: rgba(255,255,255,0.2); }
-.lp-number::-webkit-inner-spin-button { opacity: 0.4; }
-
-/* Two-column row */
-.lp-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
-
-/* Buyback slider */
-.lp-slider-head { display: flex; justify-content: space-between; align-items: baseline; }
-.lp-bps-val { font-size: 0.78rem; color: #a4f0bc; font-weight: 500; }
-.lp-slider { width: 100%; accent-color: #a4f0bc; margin-top: 0.4rem; cursor: pointer; }
-.lp-slider-hint { font-size: 0.62rem; color: rgba(255,255,255,0.22); margin-top: 0.18rem; }
+const PUMP_BASE_COST = 0.022; // pump.fun fee + mint rent (estimate)
+const SOLSCAN = (sig, net = 'mainnet') =>
+ `https://solscan.io/tx/${sig}${net === 'devnet' ? '?cluster=devnet' : ''}`;
+const PUMP_URL = (mint) => `https://pump.fun/coin/${mint}`;
+
+// ── CSS ──────────────────────────────────────────────────────────────────────
+
+const LP_CSS = `
+.lp{display:flex;flex-direction:column;gap:.9rem}
+.lp-empty{text-align:center;padding:2.5rem 1rem;color:rgba(255,255,255,.3);font-size:.85rem;line-height:1.7}
+.lp-empty a{color:rgba(164,240,188,.7);text-decoration:none}
+.lp-empty a:hover{color:#a4f0bc}
+
+/* Existing-token card */
+.lp-existing{display:flex;flex-direction:column;gap:.75rem}
+.lp-ex-head{display:flex;align-items:center;gap:.55rem;font-size:.72rem;color:#a4f0bc;font-weight:500;letter-spacing:.03em}
+.lp-ex-dot{width:7px;height:7px;border-radius:50%;background:#a4f0bc;box-shadow:0 0 6px rgba(164,240,188,.45)}
+.lp-ex-card{display:flex;gap:.75rem;align-items:center;padding:.85rem;border-radius:12px;
+ background:rgba(164,240,188,.04);border:1px solid rgba(164,240,188,.14)}
+.lp-ex-thumb{width:52px;height:52px;border-radius:9px;object-fit:cover;flex-shrink:0;
+ border:1px solid rgba(164,240,188,.2)}
+.lp-ex-thumb-ph{width:52px;height:52px;border-radius:9px;background:rgba(164,240,188,.08);
+ display:flex;align-items:center;justify-content:center;font-size:1.4rem;flex-shrink:0}
+.lp-ex-info{flex:1;min-width:0}
+.lp-ex-sym{font-size:1rem;font-weight:700;color:#fff;letter-spacing:-.01em}
+.lp-ex-name{font-size:.75rem;color:rgba(255,255,255,.45);margin-top:.08rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+.lp-ex-since{font-size:.65rem;color:rgba(255,255,255,.3);margin-top:.3rem}
+.lp-ex-stats{display:grid;grid-template-columns:1fr 1fr;gap:.4rem}
+.lp-ex-stat{background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.06);border-radius:8px;
+ padding:.45rem .6rem}
+.lp-ex-stat-n{font-size:.92rem;font-weight:600;color:#fff}
+.lp-ex-stat-l{font-size:.62rem;color:rgba(255,255,255,.4);margin-top:.05rem}
+.lp-ex-mint{display:flex;align-items:center;gap:.5rem;padding:.45rem .65rem;border-radius:8px;
+ background:rgba(255,255,255,.03);font-family:ui-monospace,monospace;font-size:.73rem;color:rgba(255,255,255,.55)}
+.lp-ex-mint span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.lp-ex-links{display:flex;gap:.45rem;flex-wrap:wrap}
+.lp-ex-link{padding:.36rem .65rem;border-radius:7px;font-size:.77rem;text-decoration:none;
+ background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);color:rgba(255,255,255,.75);transition:all .15s}
+.lp-ex-link:hover{background:rgba(255,255,255,.1);color:#fff}
+.lp-ex-new{width:100%;padding:.42rem;border-radius:7px;cursor:pointer;background:transparent;
+ border:1px solid rgba(255,255,255,.07);color:rgba(255,255,255,.32);font-size:.77rem}
+.lp-ex-new:hover{color:rgba(255,255,255,.62);border-color:rgba(255,255,255,.16)}
+
+/* Checking spinner */
+.lp-checking{display:flex;align-items:center;gap:.55rem;padding:.65rem .75rem;border-radius:10px;
+ background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.06);
+ font-size:.78rem;color:rgba(255,255,255,.38)}
+@keyframes lp-spin{to{transform:rotate(360deg)}}
+.lp-spin{width:14px;height:14px;border:2px solid rgba(255,255,255,.12);border-top-color:rgba(255,255,255,.5);
+ border-radius:50%;animation:lp-spin .8s linear infinite;flex-shrink:0}
+
+/* Launch form token card */
+.lp-card{display:flex;gap:.8rem;align-items:flex-start;padding:.85rem;border-radius:12px;
+ background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.07);transition:border-color .2s}
+.lp-card:focus-within{border-color:rgba(255,255,255,.14)}
+.lp-img-zone{flex-shrink:0;width:78px;height:78px;border-radius:11px;border:2px dashed rgba(255,255,255,.14);
+ cursor:pointer;overflow:hidden;display:flex;align-items:center;justify-content:center;
+ background:rgba(255,255,255,.03);position:relative;transition:all .2s}
+.lp-img-zone:hover,.lp-img-zone.dragover{border-color:rgba(164,240,188,.5);background:rgba(164,240,188,.05)}
+.lp-img-zone img{width:100%;height:100%;object-fit:cover;border-radius:9px}
+.lp-img-ph{font-size:.62rem;color:rgba(255,255,255,.28);text-align:center;line-height:1.5;padding:.25rem;pointer-events:none}
+.lp-img-file{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
+.lp-card-fields{flex:1;min-width:0;display:flex;flex-direction:column;gap:.35rem;padding-top:.1rem}
+.lp-iname{width:100%;font-size:.97rem;font-weight:600;background:transparent;border:none;
+ border-bottom:1px solid rgba(255,255,255,.09);color:#fff;padding:0 0 .28rem;outline:none;transition:border-color .15s}
+.lp-iname:focus{border-bottom-color:rgba(255,255,255,.28)}
+.lp-iname::placeholder{color:rgba(255,255,255,.2);font-weight:400}
+.lp-isymbol{width:100%;font-size:.8rem;background:transparent;border:none;color:#a4f0bc;
+ padding:0;outline:none;font-family:ui-monospace,monospace;letter-spacing:.05em}
+.lp-isymbol::placeholder{color:rgba(164,240,188,.28)}
+.lp-img-hint{font-size:.6rem;color:rgba(255,255,255,.2);margin-top:.3rem}
+
+.lp label{font-size:.72rem;color:rgba(255,255,255,.4);display:block;margin-bottom:.22rem}
+.lp textarea,.lp-number{width:100%;padding:.5rem .7rem;border-radius:8px;outline:none;
+ background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.08);
+ color:#fff;font-size:.85rem;font-family:inherit;box-sizing:border-box;transition:border-color .15s}
+.lp textarea{resize:vertical}
+.lp textarea:focus,.lp-number:focus{border-color:rgba(255,255,255,.2)}
+.lp-number::-webkit-inner-spin-button{opacity:.4}
+.lp-2col{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}
+.lp-slider-head{display:flex;justify-content:space-between;align-items:baseline}
+.lp-bps-val{font-size:.78rem;color:#a4f0bc;font-weight:500}
+.lp-slider{width:100%;accent-color:#a4f0bc;margin-top:.4rem;cursor:pointer}
+.lp-slider-hint{font-size:.62rem;color:rgba(255,255,255,.22);margin-top:.18rem}
/* Wallet bar */
-.lp-wallet {
- display: flex; align-items: center; gap: 0.55rem; padding: 0.58rem 0.8rem;
- background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07);
- border-radius: 10px; font-size: 0.78rem;
-}
-.lp-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: background 0.3s; }
-.lp-dot.on { background: #a4f0bc; box-shadow: 0 0 6px rgba(164,240,188,0.45); }
-.lp-dot.off { background: rgba(255,255,255,0.18); }
-.lp-wallet-info { flex: 1; min-width: 0; }
-.lp-wallet-addr { color: rgba(255,255,255,0.75); }
-.lp-wallet-bal { color: rgba(255,255,255,0.42); margin-left: 0.4rem; font-size: 0.73rem; }
-.lp-wallet-cost { display: block; font-size: 0.69rem; margin-top: 0.1rem; }
-.lp-wallet-cost.ok { color: #a4f0bc; }
-.lp-wallet-cost.warn { color: #f6b3b3; }
-.lp-wallet-cost.dim { color: rgba(255,255,255,0.3); }
-.lp-wallet-none { flex: 1; color: rgba(255,255,255,0.32); }
-.lp-wbtn {
- padding: 0.28rem 0.65rem; border-radius: 6px; cursor: pointer; flex-shrink: 0;
- background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
- color: rgba(255,255,255,0.78); font-size: 0.72rem; white-space: nowrap;
- transition: background 0.15s;
-}
-.lp-wbtn:hover { background: rgba(255,255,255,0.13); }
-.lp-wbtn.ghost { opacity: 0.4; font-size: 0.65rem; }
+.lp-wallet{display:flex;align-items:center;gap:.55rem;padding:.58rem .8rem;
+ background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.07);border-radius:10px;font-size:.78rem}
+.lp-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0;transition:background .3s}
+.lp-dot.on{background:#a4f0bc;box-shadow:0 0 6px rgba(164,240,188,.45)}
+.lp-dot.off{background:rgba(255,255,255,.18)}
+.lp-wallet-info{flex:1;min-width:0}
+.lp-wallet-addr{color:rgba(255,255,255,.75)}
+.lp-wallet-bal{color:rgba(255,255,255,.42);margin-left:.4rem;font-size:.73rem}
+.lp-wallet-cost{display:block;font-size:.69rem;margin-top:.1rem}
+.lp-wallet-cost.ok{color:#a4f0bc}
+.lp-wallet-cost.warn{color:#f6b3b3}
+.lp-wallet-cost.dim{color:rgba(255,255,255,.3)}
+.lp-wallet-none{flex:1;color:rgba(255,255,255,.32)}
+.lp-wbtn{padding:.28rem .65rem;border-radius:6px;cursor:pointer;flex-shrink:0;
+ background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.1);
+ color:rgba(255,255,255,.78);font-size:.72rem;white-space:nowrap;transition:background .15s}
+.lp-wbtn:hover{background:rgba(255,255,255,.13)}
+.lp-wbtn.ghost{opacity:.4;font-size:.65rem}
/* Launch button */
-.lp-launch {
- width: 100%; padding: 0.8rem 1rem; border-radius: 10px; cursor: pointer;
- background: linear-gradient(135deg, rgba(120,200,140,0.22), rgba(60,140,100,0.14));
- border: 1px solid rgba(120,200,140,0.42); color: #c6f0d6;
- font-size: 0.94rem; font-weight: 600; letter-spacing: -0.01em;
- transition: all 0.15s; line-height: 1;
-}
-.lp-launch:hover:not([disabled]) {
- background: linear-gradient(135deg, rgba(120,200,140,0.33), rgba(60,140,100,0.22));
- border-color: rgba(120,200,140,0.65); color: #d8f5e2;
-}
-.lp-launch[disabled] { opacity: 0.38; cursor: not-allowed; }
-.lp-launch.busy { opacity: 0.72; cursor: wait; }
-.lp-phase { font-size: 0.7rem; color: rgba(255,255,255,0.35); text-align: center; min-height: 1.1em; margin-top: 0.15rem; }
-.lp-err {
- font-size: 0.78rem; color: #f6b3b3; padding: 0.55rem 0.75rem; line-height: 1.5;
- border-radius: 8px; background: rgba(246,179,179,0.07); border: 1px solid rgba(246,179,179,0.18);
-}
-.lp-err-retry { margin-top: 0.35rem; font-size: 0.72rem; color: rgba(255,255,255,0.35); }
-
-/* ── Success state ─────────────────────────────────── */
-.lp-ok { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; text-align: center; }
-.lp-ok-thumb { width: 82px; height: 82px; border-radius: 50%; object-fit: cover;
- border: 2px solid rgba(164,240,188,0.4); }
-.lp-ok-thumb-ph { width: 82px; height: 82px; border-radius: 50%;
- background: rgba(164,240,188,0.08); border: 2px solid rgba(164,240,188,0.2);
- display: flex; align-items: center; justify-content: center; font-size: 2.2rem; }
-.lp-ok-title { font-size: 1.3rem; font-weight: 700; color: #a4f0bc; letter-spacing: -0.02em; margin: 0; }
-.lp-ok-sub { font-size: 0.78rem; color: rgba(255,255,255,0.38); margin: -0.45rem 0 0; }
-.lp-ok-mint {
- display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
- background: rgba(255,255,255,0.04); border-radius: 8px; width: 100%;
- font-family: ui-monospace, monospace; font-size: 0.75rem; color: rgba(255,255,255,0.6);
-}
-.lp-ok-mint span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.lp-copy { padding: 0.2rem 0.5rem; border-radius: 5px; cursor: pointer; flex-shrink: 0;
- background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
- color: rgba(255,255,255,0.65); font-size: 0.7rem; white-space: nowrap; }
-.lp-copy:hover { background: rgba(255,255,255,0.15); }
-.lp-ok-links { display: flex; gap: 0.45rem; justify-content: center; flex-wrap: wrap; width: 100%; }
-.lp-ext { padding: 0.38rem 0.7rem; border-radius: 7px; font-size: 0.78rem; text-decoration: none;
- background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
- color: rgba(255,255,255,0.78); transition: all 0.15s; }
-.lp-ext:hover { background: rgba(255,255,255,0.11); color: #fff; }
-.lp-share { width: 100%; padding: 0.55rem 0.9rem; border-radius: 8px; cursor: pointer;
- background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
- color: rgba(255,255,255,0.65); font-size: 0.8rem; }
-.lp-share:hover { background: rgba(255,255,255,0.09); color: rgba(255,255,255,0.92); }
-.lp-again { width: 100%; padding: 0.42rem; border-radius: 7px; cursor: pointer;
- background: transparent; border: 1px solid rgba(255,255,255,0.07);
- color: rgba(255,255,255,0.32); font-size: 0.77rem; }
-.lp-again:hover { color: rgba(255,255,255,0.62); border-color: rgba(255,255,255,0.16); }
+.lp-launch{width:100%;padding:.8rem 1rem;border-radius:10px;cursor:pointer;
+ background:linear-gradient(135deg,rgba(120,200,140,.22),rgba(60,140,100,.14));
+ border:1px solid rgba(120,200,140,.42);color:#c6f0d6;
+ font-size:.94rem;font-weight:600;letter-spacing:-.01em;transition:all .15s;line-height:1}
+.lp-launch:hover:not([disabled]){background:linear-gradient(135deg,rgba(120,200,140,.33),rgba(60,140,100,.22));
+ border-color:rgba(120,200,140,.65);color:#d8f5e2}
+.lp-launch[disabled]{opacity:.38;cursor:not-allowed}
+.lp-launch.busy{opacity:.72;cursor:wait}
+.lp-phase{font-size:.7rem;color:rgba(255,255,255,.35);text-align:center;min-height:1.1em;margin-top:.15rem}
+.lp-err{font-size:.78rem;color:#f6b3b3;padding:.55rem .75rem;line-height:1.5;
+ border-radius:8px;background:rgba(246,179,179,.07);border:1px solid rgba(246,179,179,.18)}
+.lp-err-sub{font-size:.7rem;color:rgba(255,255,255,.3);margin-top:.3rem}
+
+/* Confirmation timeout escape hatch */
+.lp-timeout{display:flex;flex-direction:column;gap:.7rem;padding:.85rem;border-radius:12px;
+ background:rgba(246,200,100,.05);border:1px solid rgba(246,200,100,.18)}
+.lp-timeout-title{font-size:.85rem;font-weight:600;color:rgba(246,220,130,.9)}
+.lp-timeout-body{font-size:.78rem;color:rgba(255,255,255,.55);line-height:1.55}
+.lp-timeout-sig{font-family:ui-monospace,monospace;font-size:.7rem;color:rgba(255,255,255,.4);
+ word-break:break-all;padding:.4rem .55rem;background:rgba(255,255,255,.04);border-radius:6px}
+.lp-timeout-btns{display:flex;gap:.5rem;flex-wrap:wrap}
+.lp-tbtn{padding:.42rem .8rem;border-radius:8px;cursor:pointer;font-size:.8rem;transition:all .15s}
+.lp-tbtn.primary{background:rgba(164,240,188,.14);border:1px solid rgba(164,240,188,.3);color:#c8f0d8}
+.lp-tbtn.primary:hover{background:rgba(164,240,188,.22)}
+.lp-tbtn.ghost{background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);color:rgba(255,255,255,.6)}
+.lp-tbtn.ghost:hover{background:rgba(255,255,255,.1)}
+
+/* Success */
+.lp-ok{display:flex;flex-direction:column;align-items:center;gap:.85rem;text-align:center}
+.lp-ok-thumb{width:82px;height:82px;border-radius:50%;object-fit:cover;border:2px solid rgba(164,240,188,.4)}
+.lp-ok-thumb-ph{width:82px;height:82px;border-radius:50%;background:rgba(164,240,188,.08);
+ border:2px solid rgba(164,240,188,.2);display:flex;align-items:center;justify-content:center;font-size:2.2rem}
+.lp-ok-title{font-size:1.3rem;font-weight:700;color:#a4f0bc;letter-spacing:-.02em;margin:0}
+.lp-ok-sub{font-size:.78rem;color:rgba(255,255,255,.38);margin:-.45rem 0 0}
+.lp-ok-mint{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;
+ background:rgba(255,255,255,.04);border-radius:8px;width:100%;
+ font-family:ui-monospace,monospace;font-size:.75rem;color:rgba(255,255,255,.6)}
+.lp-ok-mint span{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.lp-copy{padding:.2rem .5rem;border-radius:5px;cursor:pointer;flex-shrink:0;
+ background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.12);
+ color:rgba(255,255,255,.65);font-size:.7rem;white-space:nowrap}
+.lp-copy:hover{background:rgba(255,255,255,.15)}
+.lp-ok-links{display:flex;gap:.45rem;justify-content:center;flex-wrap:wrap;width:100%}
+.lp-ext{padding:.38rem .7rem;border-radius:7px;font-size:.78rem;text-decoration:none;
+ background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);
+ color:rgba(255,255,255,.78);transition:all .15s}
+.lp-ext:hover{background:rgba(255,255,255,.11);color:#fff}
+.lp-share{width:100%;padding:.55rem .9rem;border-radius:8px;cursor:pointer;
+ background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);
+ color:rgba(255,255,255,.65);font-size:.8rem}
+.lp-share:hover{background:rgba(255,255,255,.09);color:rgba(255,255,255,.92)}
+.lp-again{width:100%;padding:.42rem;border-radius:7px;cursor:pointer;background:transparent;
+ border:1px solid rgba(255,255,255,.07);color:rgba(255,255,255,.32);font-size:.77rem}
+.lp-again:hover{color:rgba(255,255,255,.62);border-color:rgba(255,255,255,.16)}
`;
-let _stylesInjected = false;
-function injectStyles() {
- if (_stylesInjected || typeof document === 'undefined') return;
- _stylesInjected = true;
+let _cssInjected = false;
+function injectCss() {
+ if (_cssInjected || typeof document === 'undefined') return;
+ _cssInjected = true;
const el = document.createElement('style');
- el.textContent = LP_STYLES;
+ el.textContent = LP_CSS;
document.head.appendChild(el);
}
-// ── Mount ────────────────────────────────────────────────────────────────────
+// ── Mount ─────────────────────────────────────────────────────────────────────
const DEMO_ID = '__demo__';
export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
- injectStyles();
+ injectCss();
+
+ let av = null;
- let av = null; // current avatar object
+ // ── State ──────────────────────────────────────────────────────────────
- // All mutable UI + launch state in one flat object
let s = {
- // form (seeded from avatar on mount / avatar change)
- name: '',
- symbol: '',
- description: '',
- initialBuy: '0',
- buybackBps: 500,
- imageFile: null,
- imagePreviewUrl: null, // data URL of custom image; falls back to av.thumbnail_url
- _symbolEdited: false, // user manually typed a symbol
+ // form
+ name: '', symbol: '', description: '',
+ initialBuy: '0', buybackBps: 500,
+ imageFile: null, imagePreviewUrl: null,
+ _symbolEdited: false,
// wallet
- walletAddr: null,
- solBalance: null,
+ walletAddr: null, solBalance: null,
- // launch state machine
- phase: 'idle', // idle | building | signing | confirming | success | error
- phaseLabel: '',
+ // existing token (checked on avatar change)
+ checkingMint: false,
+ existingMint: null, // { mint, name, symbol, network, metadata_uri, stats, burns }
+ forceNew: false, // user clicked "launch another token" despite existing
+
+ // launch phases: idle | building | signing | confirming | confirm-timeout | success | error
+ phase: 'idle', phaseLabel: '',
errorMsg: '',
- // results
- mint: null,
- resolvedAgentId: null,
+ // success
+ mint: null, resolvedAgentId: null,
+
+ // timeout escape hatch
+ pendingConfirm: null, // { prepId, sig, network }
// metadata cache
- _metaUrl: null,
- _metaKey: null, // `name|symbol|description` the cached URL was built for
+ _metaUrl: null, _metaKey: null,
};
- // ── Helpers ────────────────────────────────────────────────────────────
+ // ── Cleanup registry ───────────────────────────────────────────────────
+
+ let _balanceInterval = null;
+ const _walletListeners = []; // [{ wallet, event, fn }]
- function estimatedCost() {
- return PUMP_BASE_COST_SOL + Math.max(0, parseFloat(s.initialBuy) || 0);
+ function cleanup() {
+ if (_balanceInterval) { clearInterval(_balanceInterval); _balanceInterval = null; }
+ for (const { wallet, event, fn } of _walletListeners) {
+ try { wallet.off?.(event, fn); } catch { /* ignore */ }
+ }
+ _walletListeners.length = 0;
}
- function formValid() {
- return s.name.trim() && s.symbol.trim() && s.description.trim();
+ // ── Existing token check ───────────────────────────────────────────────
+
+ async function checkExistingMint(avatar) {
+ if (!avatar || avatar.id === DEMO_ID) { s.existingMint = null; s.checkingMint = false; return; }
+ s.checkingMint = true;
+ render();
+ try {
+ const param = avatar.agent_id
+ ? `agent_id=${encodeURIComponent(avatar.agent_id)}`
+ : `avatar_id=${encodeURIComponent(avatar.id)}`;
+ const res = await fetch(`/api/pump/by-agent?${param}`, { credentials: 'include' });
+ if (res.ok) {
+ const { data } = await res.json();
+ s.existingMint = data || null;
+ }
+ } catch { /* best-effort */ }
+ s.checkingMint = false;
+ render();
}
- // ── Wallet ─────────────────────────────────────────────────────────────
+ // ── Wallet management ──────────────────────────────────────────────────
+
+ function subscribeWalletEvents(wallet) {
+ if (!wallet?.on) return;
+
+ const onAccountsChanged = (accounts) => {
+ const acc = Array.isArray(accounts) ? accounts[0] : accounts;
+ const addr = acc?.toBase58?.() || (typeof acc === 'string' ? acc : null);
+ if (!addr) { disconnectWallet(); return; }
+ if (addr === s.walletAddr) return;
+ s.walletAddr = addr;
+ s.solBalance = null;
+ render();
+ fetchBalance(addr);
+ };
+
+ const onDisconnect = () => disconnectWallet();
+
+ wallet.on('accountsChanged', onAccountsChanged);
+ wallet.on('disconnect', onDisconnect);
+ _walletListeners.push(
+ { wallet, event: 'accountsChanged', fn: onAccountsChanged },
+ { wallet, event: 'disconnect', fn: onDisconnect },
+ );
+ }
async function tryAutoConnect() {
const w = detectWallet();
if (!w?.isConnected || !w.publicKey) return;
const addr = w.publicKey.toBase58?.() || w.publicKey.toString?.();
- if (addr && addr !== s.walletAddr) {
- s.walletAddr = addr;
- render();
- fetchBalance(addr);
- }
+ if (!addr || addr === s.walletAddr) return;
+ s.walletAddr = addr;
+ render();
+ subscribeWalletEvents(w);
+ startBalancePoll(addr);
}
async function connectWallet() {
@@ -303,28 +360,33 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
if (!addr) return;
s.walletAddr = addr;
render();
- fetchBalance(addr);
+ subscribeWalletEvents(w);
+ startBalancePoll(addr);
} catch { /* user dismissed */ }
}
+ function disconnectWallet() {
+ s.walletAddr = null; s.solBalance = null;
+ if (_balanceInterval) { clearInterval(_balanceInterval); _balanceInterval = null; }
+ render();
+ }
+
async function fetchBalance(addr) {
try {
const { Connection, PublicKey } = await import('https://esm.sh/@solana/[email protected]');
const conn = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
s.solBalance = (await conn.getBalance(new PublicKey(addr))) / 1e9;
- } catch {
- s.solBalance = null;
- }
+ } catch { s.solBalance = null; }
render();
}
- function disconnectWallet() {
- s.walletAddr = null;
- s.solBalance = null;
- render();
+ function startBalancePoll(addr) {
+ if (_balanceInterval) clearInterval(_balanceInterval);
+ fetchBalance(addr);
+ _balanceInterval = setInterval(() => { if (s.walletAddr) fetchBalance(s.walletAddr); }, 30_000);
}
- // ── Image ──────────────────────────────────────────────────────────────
+ // ── Image handling ─────────────────────────────────────────────────────
function handleImageFile(file) {
if (!file?.type.startsWith('image/')) return;
@@ -333,64 +395,70 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
const reader = new FileReader();
reader.onload = (e) => {
s.imagePreviewUrl = e.target.result;
- // Update img zone in-place without full re-render
const zone = container.querySelector('.lp-img-zone');
- if (zone) {
- const old = zone.querySelector('img, .lp-img-ph');
- if (old) old.remove();
- const img = document.createElement('img');
- img.src = s.imagePreviewUrl;
- img.alt = '';
- zone.insertBefore(img, zone.firstChild);
- }
+ if (!zone) return;
+ const old = zone.querySelector('img, .lp-img-ph');
+ if (old) old.remove();
+ const img = document.createElement('img');
+ img.src = s.imagePreviewUrl; img.alt = '';
+ zone.insertBefore(img, zone.firstChild);
};
reader.readAsDataURL(file);
}
+ // ── Confirmation polling with timeout ──────────────────────────────────
+
+ async function pollConfirmation(conn, sig, timeoutMs = 75_000) {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ const { value } = await conn.getSignatureStatuses([sig], { searchTransactionHistory: true });
+ const status = value?.[0];
+ if (status) {
+ if (status.err) throw new Error(`On-chain error: ${JSON.stringify(status.err)}`);
+ if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized')
+ return status;
+ }
+ await sleep(2000);
+ }
+ const err = new Error('Confirmation timeout — your transaction may still confirm.');
+ err.code = 'CONFIRM_TIMEOUT';
+ throw err;
+ }
+
// ── Launch ─────────────────────────────────────────────────────────────
async function launch() {
if (!formValid() || !s.walletAddr || s.phase !== 'idle') return;
if (!av || av.id === DEMO_ID) return;
-
s.errorMsg = '';
try {
- // 1. Build / reuse metadata
- s.phase = 'building';
- s.phaseLabel = 'Uploading metadata…';
- render();
+ // 1 ── Build / reuse metadata
+ s.phase = 'building'; s.phaseLabel = 'Uploading metadata…'; render();
- const nameTrim = s.name.trim();
- const symTrim = s.symbol.trim();
- const descTrim = s.description.trim();
- const metaKey = `${nameTrim}|${symTrim}|${descTrim}|${!!s.imageFile}`;
+ const nameTrim = s.name.trim(), symTrim = s.symbol.trim(), descTrim = s.description.trim();
+ const metaKey = `${nameTrim}|${symTrim}|${descTrim}|${!!s.imageFile}`;
if (s._metaKey !== metaKey || !s._metaUrl) {
let imageDataUrl = null;
if (s.imageFile) imageDataUrl = await fileToDataUrl(s.imageFile);
-
const mr = await fetch('/api/pump/build-metadata', {
- method: 'POST',
+ method: 'POST', credentials: 'include',
headers: { 'content-type': 'application/json' },
- credentials: 'include',
body: JSON.stringify({
name: nameTrim, symbol: symTrim, description: descTrim,
- ...(av.id ? { avatar_id: av.id } : {}),
- ...(av.agent_id ? { agent_id: av.agent_id } : {}),
+ ...(av.id ? { avatar_id: av.id } : {}),
+ ...(av.agent_id ? { agent_id: av.agent_id } : {}),
...(imageDataUrl ? { image_data_url: imageDataUrl } : {}),
}),
});
if (!mr.ok) throw new Error(`Metadata build failed (${mr.status})`);
const md = await mr.json();
- s._metaUrl = md.metadata_url;
- s._metaKey = metaKey;
+ s._metaUrl = md.metadata_url; s._metaKey = metaKey;
}
- // 2. Prep transaction (wallet must sign)
- s.phase = 'signing';
- s.phaseLabel = 'Sign in your wallet…';
- render();
+ // 2 ── Prep transaction
+ s.phase = 'signing'; s.phaseLabel = 'Sign in your wallet…'; render();
const w = detectWallet();
if (!w) throw new Error('No Solana wallet detected. Install Phantom or Backpack.');
@@ -399,9 +467,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
if (!payer) throw new Error('Could not read wallet public key.');
const pr = await fetch('/api/pump/launch-prep', {
- method: 'POST',
+ method: 'POST', credentials: 'include',
headers: { 'content-type': 'application/json' },
- credentials: 'include',
body: JSON.stringify({
...(av.agent_id ? { agent_id: av.agent_id } : { avatar_id: av.id }),
wallet_address: payer,
@@ -415,232 +482,325 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
if (prep.error) throw new Error(prep.error_description || prep.error);
s.resolvedAgentId = prep.agent_id;
- // 3. Deserialize, co-sign mint keypair, send to wallet
+ // 3 ── Sign
const { VersionedTransaction, Keypair, Connection } =
await import('https://esm.sh/@solana/[email protected]');
-
const tx = VersionedTransaction.deserialize(
Uint8Array.from(atob(prep.tx_base64), (c) => c.charCodeAt(0)),
);
if (prep.mint_secret_key_b64) {
- const mintKp = Keypair.fromSecretKey(
+ tx.sign([Keypair.fromSecretKey(
Uint8Array.from(atob(prep.mint_secret_key_b64), (c) => c.charCodeAt(0)),
- );
- tx.sign([mintKp]);
+ )]);
}
const signed = await w.signTransaction(tx);
- // 4. Send + confirm
- s.phase = 'confirming';
- s.phaseLabel = 'Confirming on-chain…';
- render();
+ // 4 ── Send + poll confirmation (75s timeout)
+ s.phase = 'confirming'; s.phaseLabel = 'Confirming on-chain…'; render();
const conn = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
- const sig = await conn.sendRawTransaction(signed.serialize(), { skipPreflight: false });
- await conn.confirmTransaction(sig, 'confirmed');
-
- const cr = await fetch('/api/pump/launch-confirm', {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- credentials: 'include',
- body: JSON.stringify({ prep_id: prep.prep_id, tx_signature: sig }),
- });
- const confirmed = await cr.json();
- if (confirmed.error) throw new Error(confirmed.error_description || confirmed.error);
+ const sig = await conn.sendRawTransaction(signed.serialize(), { skipPreflight: false });
+
+ try {
+ await pollConfirmation(conn, sig);
+ } catch (confErr) {
+ if (confErr.code === 'CONFIRM_TIMEOUT') {
+ s.phase = 'confirm-timeout';
+ s.pendingConfirm = { prepId: prep.prep_id, sig, network: 'mainnet' };
+ render(); return;
+ }
+ throw confErr;
+ }
- s.mint = prep.mint;
- s.phase = 'success';
- render();
+ await finalizeConfirm(prep.prep_id, sig);
} catch (e) {
s.errorMsg = friendlyError(e.message || String(e));
- s.phase = 'error';
- render();
+ s.phase = 'error'; render();
}
}
+ // Called after confirmed on-chain (normal path or escape-hatch path)
+ async function finalizeConfirm(prepId, sig) {
+ const cr = await fetch('/api/pump/launch-confirm', {
+ method: 'POST', credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ prep_id: prepId, tx_signature: sig }),
+ });
+ const confirmed = await cr.json();
+ if (confirmed.error) throw new Error(confirmed.error_description || confirmed.error);
+
+ // Extract mint from what we already know (stored in pendingConfirm or parent scope)
+ // The server echoes pump_agent_mint which has the mint address
+ const mintAddr = confirmed.pump_agent_mint?.mint || s.pendingConfirm?.mint || null;
+ if (mintAddr) s.mint = mintAddr;
+ s.phase = 'success'; s.pendingConfirm = null;
+ render();
+ }
+
+ // ── Helpers ────────────────────────────────────────────────────────────
+
+ const estimatedCost = () => PUMP_BASE_COST + Math.max(0, parseFloat(s.initialBuy) || 0);
+ const formValid = () => s.name.trim() && s.symbol.trim() && s.description.trim();
+
// ── Render ─────────────────────────────────────────────────────────────
function render() {
- if (!av || av.id === DEMO_ID) { renderEmpty(); return; }
- if (s.phase === 'success') { renderSuccess(); return; }
+ if (!av || av.id === DEMO_ID) { renderEmpty(); return; }
+ if (s.checkingMint) { renderChecking(); return; }
+ if (s.existingMint && !s.forceNew) { renderExisting(); return; }
+ if (s.phase === 'success') { renderSuccess(); return; }
+ if (s.phase === 'confirm-timeout') { renderTimeout(); return; }
renderForm();
}
function renderEmpty() {
- container.innerHTML = `
- <div class="lp">
- <div class="lp-empty">
- Select one of your own avatars from the left panel<br>to launch a token.
- <br><br>
- <a href="/dashboard/avatars" target="_blank" rel="noopener">Upload an avatar →</a>
+ container.innerHTML = `<div class="lp">
+ <div class="lp-empty">Select one of your own avatars from the left panel to launch a token.<br><br>
+ <a href="/dashboard/avatars" target="_blank" rel="noopener">Upload an avatar →</a>
+ </div></div>`;
+ }
+
+ function renderChecking() {
+ container.innerHTML = `<div class="lp">
+ <div class="lp-checking"><div class="lp-spin"></div>Checking for existing token…</div>
+ </div>`;
+ }
+
+ function renderExisting() {
+ const m = s.existingMint;
+ const st = m.stats || {};
+ const thumbSrc = av?.thumbnail_url;
+ const since = m.created_at
+ ? new Date(m.created_at).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })
+ : '';
+ const payments = st.confirmed_payments || 0;
+ const payers = st.unique_payers || 0;
+ const mintShort = m.mint ? m.mint.slice(0, 6) + '…' + m.mint.slice(-6) : '';
+
+ container.innerHTML = `<div class="lp"><div class="lp-existing">
+ <div class="lp-ex-head"><div class="lp-ex-dot"></div>Token already launched</div>
+ <div class="lp-ex-card">
+ ${thumbSrc
+ ? `<img class="lp-ex-thumb" src="${esc(thumbSrc)}" alt="" />`
+ : `<div class="lp-ex-thumb-ph">🪙</div>`}
+ <div class="lp-ex-info">
+ <div class="lp-ex-sym">$${esc(m.symbol || '')}</div>
+ <div class="lp-ex-name">${esc(m.name || '')}</div>
+ ${since ? `<div class="lp-ex-since">Launched ${since}</div>` : ''}
</div>
- </div>`;
+ </div>
+ ${(payments > 0 || payers > 0) ? `
+ <div class="lp-ex-stats">
+ <div class="lp-ex-stat">
+ <div class="lp-ex-stat-n">${payments}</div>
+ <div class="lp-ex-stat-l">Payments received</div>
+ </div>
+ <div class="lp-ex-stat">
+ <div class="lp-ex-stat-n">${payers}</div>
+ <div class="lp-ex-stat-l">Unique payers</div>
+ </div>
+ </div>` : ''}
+ <div class="lp-ex-mint">
+ <span title="${esc(m.mint || '')}">${mintShort}</span>
+ <button class="lp-copy" id="lp-ex-copy">Copy</button>
+ </div>
+ <div class="lp-ex-links">
+ <a class="lp-ex-link" href="${esc(PUMP_URL(m.mint))}" target="_blank" rel="noopener">pump.fun ↗</a>
+ <a class="lp-ex-link" href="https://solscan.io/token/${esc(m.mint)}" target="_blank" rel="noopener">Solscan ↗</a>
+ ${s.resolvedAgentId || av?.agent_id
+ ? `<a class="lp-ex-link" href="/agent/${esc(s.resolvedAgentId || av.agent_id)}">Agent page ↗</a>`
+ : ''}
+ </div>
+ <button class="lp-ex-new" id="lp-force-new">Launch a new token for this avatar</button>
+ </div></div>`;
+
+ container.querySelector('#lp-ex-copy')?.addEventListener('click', (e) => {
+ navigator.clipboard?.writeText(m.mint || '').catch(() => {});
+ e.currentTarget.textContent = 'Copied!';
+ setTimeout(() => { e.currentTarget.textContent = 'Copy'; }, 1500);
+ });
+ container.querySelector('#lp-force-new')?.addEventListener('click', () => {
+ s.forceNew = true; render();
+ });
+ }
+
+ function renderTimeout() {
+ const pc = s.pendingConfirm || {};
+ const solscanUrl = pc.sig ? SOLSCAN(pc.sig, pc.network) : null;
+ container.innerHTML = `<div class="lp"><div class="lp-timeout">
+ <div class="lp-timeout-title">⏱ Taking longer than expected</div>
+ <div class="lp-timeout-body">
+ Your transaction was sent and may confirm shortly — Solana sometimes takes a few minutes during peak load.
+ Check Solscan to see the status, then click <strong>Finalize</strong> once it confirms.
+ </div>
+ ${pc.sig ? `<div class="lp-timeout-sig">${esc(pc.sig)}</div>` : ''}
+ <div class="lp-timeout-btns">
+ ${solscanUrl ? `<a class="lp-tbtn ghost" href="${esc(solscanUrl)}" target="_blank" rel="noopener">View on Solscan ↗</a>` : ''}
+ <button class="lp-tbtn primary" id="lp-finalize">Finalize once confirmed</button>
+ <button class="lp-tbtn ghost" id="lp-restart">Start over</button>
+ </div>
+ </div></div>`;
+
+ container.querySelector('#lp-finalize')?.addEventListener('click', async () => {
+ const btn = container.querySelector('#lp-finalize');
+ if (btn) { btn.disabled = true; btn.textContent = 'Checking…'; }
+ try {
+ if (!s.pendingConfirm) return;
+ // One more on-chain check before finalizing
+ const { Connection } = await import('https://esm.sh/@solana/[email protected]');
+ const conn = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
+ const { value } = await conn.getSignatureStatuses([s.pendingConfirm.sig], { searchTransactionHistory: true });
+ const st = value?.[0];
+ if (!st) {
+ if (btn) { btn.disabled = false; btn.textContent = 'Finalize once confirmed'; }
+ const note = container.querySelector('.lp-timeout-body');
+ if (note) note.textContent = 'Not confirmed yet — check Solscan and try again in a moment.';
+ return;
+ }
+ if (st.err) throw new Error(`On-chain error: ${JSON.stringify(st.err)}`);
+ await finalizeConfirm(s.pendingConfirm.prepId, s.pendingConfirm.sig);
+ } catch (e) {
+ s.errorMsg = friendlyError(e.message || String(e));
+ s.phase = 'error'; s.pendingConfirm = null; render();
+ }
+ });
+
+ container.querySelector('#lp-restart')?.addEventListener('click', () => {
+ s.phase = 'idle'; s.pendingConfirm = null; s.errorMsg = ''; render();
+ });
}
function renderForm() {
const busy = s.phase !== 'idle' && s.phase !== 'error';
const dis = busy ? 'disabled' : '';
-
- // Wallet bar
- const w = detectWallet();
+ const w = detectWallet();
const cost = estimatedCost();
+
let walletHtml;
if (!w) {
- walletHtml = `
- <div class="lp-wallet">
- <div class="lp-dot off"></div>
- <span class="lp-wallet-none">No Solana wallet found</span>
- <button class="lp-wbtn" id="lp-install">Install Phantom ↗</button>
- </div>`;
+ walletHtml = `<div class="lp-wallet">
+ <div class="lp-dot off"></div>
+ <span class="lp-wallet-none">No Solana wallet found</span>
+ <button class="lp-wbtn" id="lp-install">Install Phantom ↗</button>
+ </div>`;
} else if (!s.walletAddr) {
- walletHtml = `
- <div class="lp-wallet">
- <div class="lp-dot off"></div>
- <span class="lp-wallet-none">Wallet not connected</span>
- <button class="lp-wbtn" id="lp-connect">Connect</button>
- </div>`;
+ walletHtml = `<div class="lp-wallet">
+ <div class="lp-dot off"></div>
+ <span class="lp-wallet-none">Wallet not connected</span>
+ <button class="lp-wbtn" id="lp-connect">Connect</button>
+ </div>`;
} else {
const hasEnough = s.solBalance !== null && s.solBalance >= cost;
- const costCls = s.solBalance === null ? 'dim' : hasEnough ? 'ok' : 'warn';
+ const cls = s.solBalance === null ? 'dim' : hasEnough ? 'ok' : 'warn';
const costTxt = s.solBalance === null
? `Est. cost ~${cost.toFixed(3)} SOL`
: hasEnough
? `~${cost.toFixed(3)} SOL required · ${s.solBalance.toFixed(3)} available ✓`
: `Need ~${cost.toFixed(3)} SOL · ${s.solBalance.toFixed(3)} in wallet`;
- walletHtml = `
- <div class="lp-wallet">
- <div class="lp-dot on"></div>
- <div class="lp-wallet-info">
- <span class="lp-wallet-addr">${shortenAddr(s.walletAddr)}</span>
- ${s.solBalance !== null ? `<span class="lp-wallet-bal">${s.solBalance.toFixed(3)} SOL</span>` : ''}
- <span class="lp-wallet-cost ${costCls}">${costTxt}</span>
- </div>
- <button class="lp-wbtn ghost" id="lp-disc" title="Disconnect">✕</button>
- </div>`;
+ walletHtml = `<div class="lp-wallet">
+ <div class="lp-dot on"></div>
+ <div class="lp-wallet-info">
+ <span class="lp-wallet-addr">${shortenAddr(s.walletAddr)}</span>
+ ${s.solBalance !== null ? `<span class="lp-wallet-bal">${s.solBalance.toFixed(3)} SOL</span>` : ''}
+ <span class="lp-wallet-cost ${cls}">${costTxt}</span>
+ </div>
+ <button class="lp-wbtn ghost" id="lp-disc" title="Disconnect">✕</button>
+ </div>`;
}
- // Launch button
let btnText, btnDis;
- if (busy) {
- btnText = s.phaseLabel || 'Working…'; btnDis = true;
- } else if (!formValid()) {
- btnText = 'Fill in name, symbol &amp; description'; btnDis = true;
- } else if (!s.walletAddr) {
- btnText = 'Connect wallet to launch'; btnDis = true;
- } else {
- btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')}`; btnDis = false;
- }
+ if (busy) { btnText = s.phaseLabel || 'Working…'; btnDis = true; }
+ else if (!formValid()) { btnText = 'Fill in name, symbol &amp; description'; btnDis = true; }
+ else if (!s.walletAddr){ btnText = 'Connect wallet to launch'; btnDis = true; }
+ else { btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')}`; btnDis = false; }
- // Image preview
const imgSrc = s.imagePreviewUrl || av?.thumbnail_url;
- container.innerHTML = `
- <div class="lp">
- <div class="lp-card">
- <div class="lp-img-zone" id="lp-zone">
- ${imgSrc ? `<img src="${esc(imgSrc)}" alt="" />` : `<div class="lp-img-ph">Drop image<br>or click</div>`}
- <input type="file" class="lp-img-file" id="lp-img" accept="image/*" ${dis} />
- </div>
- <div class="lp-card-fields">
- <input class="lp-iname" id="lp-name" type="text" maxlength="32"
- placeholder="Token name" value="${esc(s.name)}" ${dis} />
- <input class="lp-isymbol" id="lp-sym" type="text" maxlength="10"
- placeholder="SYMBOL" value="${esc(s.symbol)}" ${dis} />
- <div class="lp-img-hint">Click image to replace · drag &amp; drop</div>
- </div>
+ container.innerHTML = `<div class="lp">
+ <div class="lp-card">
+ <div class="lp-img-zone" id="lp-zone">
+ ${imgSrc ? `<img src="${esc(imgSrc)}" alt="" />` : `<div class="lp-img-ph">Drop image<br>or click</div>`}
+ <input type="file" class="lp-img-file" id="lp-img" accept="image/*" ${dis} />
</div>
-
+ <div class="lp-card-fields">
+ <input class="lp-iname" id="lp-name" type="text" maxlength="32"
+ placeholder="Token name" value="${esc(s.name)}" ${dis} />
+ <input class="lp-isymbol" id="lp-sym" type="text" maxlength="10"
+ placeholder="SYMBOL" value="${esc(s.symbol)}" ${dis} />
+ <div class="lp-img-hint">Click image to replace · drag &amp; drop</div>
+ </div>
+ </div>
+ <div>
+ <label for="lp-desc">Description</label>
+ <textarea id="lp-desc" rows="3" maxlength="500"
+ placeholder="What does this agent do?" ${dis}>${esc(s.description)}</textarea>
+ </div>
+ <div class="lp-2col">
<div>
- <label for="lp-desc">Description</label>
- <textarea id="lp-desc" rows="3" maxlength="500"
- placeholder="What does this agent do?" ${dis}>${esc(s.description)}</textarea>
+ <label for="lp-buy">Initial buy (SOL)</label>
+ <input class="lp-number" id="lp-buy" type="number" min="0" max="50" step="0.001"
+ value="${esc(s.initialBuy)}" ${dis} />
</div>
-
- <div class="lp-2col">
- <div>
- <label for="lp-buy">Initial buy (SOL)</label>
- <input class="lp-number" id="lp-buy" type="number"
- min="0" max="50" step="0.001" value="${esc(s.initialBuy)}" ${dis} />
- </div>
- <div>
- <div class="lp-slider-head">
- <label>Buyback share</label>
- <span class="lp-bps-val" id="lp-bps-val">${(s.buybackBps / 100).toFixed(1)}%</span>
- </div>
- <input type="range" class="lp-slider" id="lp-bps"
- min="0" max="5000" step="50" value="${s.buybackBps}" ${dis} />
- <div class="lp-slider-hint">Of agent revenue burned back</div>
+ <div>
+ <div class="lp-slider-head">
+ <label>Buyback share</label>
+ <span class="lp-bps-val" id="lp-bps-val">${(s.buybackBps / 100).toFixed(1)}%</span>
</div>
+ <input type="range" class="lp-slider" id="lp-bps"
+ min="0" max="5000" step="50" value="${s.buybackBps}" ${dis} />
+ <div class="lp-slider-hint">Of agent revenue burned back</div>
</div>
-
- ${walletHtml}
-
- ${s.phase === 'error' ? `
- <div class="lp-err">${esc(s.errorMsg)}
- <div class="lp-err-retry">Fix the issue above and try again.</div>
- </div>` : ''}
-
- <button class="lp-launch${busy ? ' busy' : ''}" id="lp-go" ${btnDis ? 'disabled' : ''}>
- ${btnText}
- </button>
- ${busy ? `<div class="lp-phase">${esc(s.phaseLabel)}</div>` : ''}
- </div>`;
+ </div>
+ ${walletHtml}
+ ${s.phase === 'error' ? `<div class="lp-err">${esc(s.errorMsg)}<div class="lp-err-sub">Fix the issue above and try again.</div></div>` : ''}
+ <button class="lp-launch${busy ? ' busy' : ''}" id="lp-go" ${btnDis ? 'disabled' : ''}>${btnText}</button>
+ ${busy ? `<div class="lp-phase">${esc(s.phaseLabel)}</div>` : ''}
+ </div>`;
wireForm();
}
function renderSuccess() {
- const imgSrc = s.imagePreviewUrl || av?.thumbnail_url;
- const mint = s.mint || '';
+ const imgSrc = s.imagePreviewUrl || av?.thumbnail_url;
+ const mint = s.mint || '';
const mintShort = mint ? mint.slice(0, 6) + '…' + mint.slice(-6) : '';
- const sym = s.symbol.trim() || 'TOKEN';
- const pumpUrl = `https://pump.fun/coin/${mint}`;
- const scanUrl = `https://solscan.io/token/${mint}`;
- const agentUrl = s.resolvedAgentId ? `/agent/${s.resolvedAgentId}` : null;
- const shareText = `Just launched $${sym} on pump.fun 🎉 Built with three.ws\n${pumpUrl}`;
-
- container.innerHTML = `
- <div class="lp">
- <div class="lp-ok">
- ${imgSrc
- ? `<img class="lp-ok-thumb" src="${esc(imgSrc)}" alt="" />`
- : `<div class="lp-ok-thumb-ph">🪙</div>`}
- <p class="lp-ok-title">$${esc(sym)} is live!</p>
- <p class="lp-ok-sub">Your token is live on pump.fun</p>
-
- <div class="lp-ok-mint">
- <span title="${esc(mint)}">${mintShort}</span>
- <button class="lp-copy" id="lp-copy-mint">Copy</button>
- </div>
-
- <div class="lp-ok-links">
- <a class="lp-ext" href="${esc(pumpUrl)}" target="_blank" rel="noopener">pump.fun ↗</a>
- <a class="lp-ext" href="${esc(scanUrl)}" target="_blank" rel="noopener">Solscan ↗</a>
- ${agentUrl ? `<a class="lp-ext" href="${esc(agentUrl)}">Agent page ↗</a>` : ''}
- </div>
-
- <button class="lp-share" id="lp-share">📋 Copy launch announcement</button>
- <button class="lp-again" id="lp-again">Launch another token</button>
- </div>
- </div>`;
-
- function copyBtn(id, text, resetText) {
+ const sym = s.symbol.trim() || 'TOKEN';
+ const agentId = s.resolvedAgentId || av?.agent_id;
+ const shareText = `Just launched $${sym} on pump.fun 🎉 Built with three.ws\n${PUMP_URL(mint)}`;
+
+ container.innerHTML = `<div class="lp"><div class="lp-ok">
+ ${imgSrc ? `<img class="lp-ok-thumb" src="${esc(imgSrc)}" alt="" />` : `<div class="lp-ok-thumb-ph">🪙</div>`}
+ <p class="lp-ok-title">$${esc(sym)} is live!</p>
+ <p class="lp-ok-sub">Your token is live on pump.fun</p>
+ <div class="lp-ok-mint">
+ <span title="${esc(mint)}">${mintShort}</span>
+ <button class="lp-copy" id="lp-copy-mint">Copy</button>
+ </div>
+ <div class="lp-ok-links">
+ <a class="lp-ext" href="${esc(PUMP_URL(mint))}" target="_blank" rel="noopener">pump.fun ↗</a>
+ <a class="lp-ext" href="https://solscan.io/token/${esc(mint)}" target="_blank" rel="noopener">Solscan ↗</a>
+ ${agentId ? `<a class="lp-ext" href="/agent/${esc(agentId)}">Agent page ↗</a>` : ''}
+ </div>
+ <button class="lp-share" id="lp-share">📋 Copy launch announcement</button>
+ <button class="lp-again" id="lp-again">Launch another token</button>
+ </div></div>`;
+
+ const copyBtn = (id, text) => {
container.querySelector(id)?.addEventListener('click', (e) => {
navigator.clipboard?.writeText(text).catch(() => {});
- const btn = e.currentTarget;
- const orig = btn.textContent;
- btn.textContent = resetText;
+ const btn = e.currentTarget, orig = btn.textContent;
+ btn.textContent = '✓ Copied';
setTimeout(() => { btn.textContent = orig; }, 1800);
});
- }
- copyBtn('#lp-copy-mint', mint, 'Copied!');
- copyBtn('#lp-share', shareText, '✓ Copied to clipboard');
-
+ };
+ copyBtn('#lp-copy-mint', mint);
+ copyBtn('#lp-share', shareText);
container.querySelector('#lp-again')?.addEventListener('click', () => {
s.phase = 'idle'; s.mint = null; s.errorMsg = '';
s.imageFile = null; s.imagePreviewUrl = null;
s._metaUrl = null; s._metaKey = null;
+ s.existingMint = null; s.forceNew = false;
render();
});
}
@@ -648,65 +808,44 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
function wireForm() {
const q = (sel) => container.querySelector(sel);
- // Image
- q('#lp-zone')?.addEventListener('dragover', (e) => {
- e.preventDefault(); q('#lp-zone')?.classList.add('dragover');
- });
- q('#lp-zone')?.addEventListener('dragleave', () => q('#lp-zone')?.classList.remove('dragover'));
- q('#lp-zone')?.addEventListener('drop', (e) => {
- e.preventDefault(); q('#lp-zone')?.classList.remove('dragover');
- handleImageFile(e.dataTransfer?.files?.[0]);
- });
+ q('#lp-zone')?.addEventListener('dragover', (e) => { e.preventDefault(); q('#lp-zone')?.classList.add('dragover'); });
+ q('#lp-zone')?.addEventListener('dragleave', () => q('#lp-zone')?.classList.remove('dragover'));
+ q('#lp-zone')?.addEventListener('drop', (e) => { e.preventDefault(); q('#lp-zone')?.classList.remove('dragover'); handleImageFile(e.dataTransfer?.files?.[0]); });
q('#lp-img')?.addEventListener('change', (e) => handleImageFile(e.target.files?.[0]));
- // Name → auto-derive symbol
q('#lp-name')?.addEventListener('input', (e) => {
s.name = e.target.value;
if (!s._symbolEdited) {
s.symbol = toSymbol(s.name);
- const symEl = q('#lp-sym');
- if (symEl) symEl.value = s.symbol;
+ const se = q('#lp-sym'); if (se) se.value = s.symbol;
}
});
-
- // Symbol (force uppercase/alphanumeric)
q('#lp-sym')?.addEventListener('input', (e) => {
const raw = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 10);
- e.target.value = raw;
- s.symbol = raw;
- s._symbolEdited = true;
+ e.target.value = raw; s.symbol = raw; s._symbolEdited = true;
});
-
q('#lp-desc')?.addEventListener('input', (e) => { s.description = e.target.value; });
- // Initial buy — update cost display inline without full re-render
q('#lp-buy')?.addEventListener('input', (e) => {
s.initialBuy = e.target.value;
- const costEl = container.querySelector('.lp-wallet-cost');
- if (!costEl || !s.walletAddr) return;
- const cost = estimatedCost();
- const ok = s.solBalance !== null && s.solBalance >= cost;
- costEl.className = `lp-wallet-cost ${s.solBalance === null ? 'dim' : ok ? 'ok' : 'warn'}`;
- costEl.textContent = s.solBalance === null
+ const ce = container.querySelector('.lp-wallet-cost');
+ if (!ce || !s.walletAddr) return;
+ const cost = estimatedCost(), ok = s.solBalance !== null && s.solBalance >= cost;
+ ce.className = `lp-wallet-cost ${s.solBalance === null ? 'dim' : ok ? 'ok' : 'warn'}`;
+ ce.textContent = s.solBalance === null
? `Est. cost ~${cost.toFixed(3)} SOL`
: ok
? `~${cost.toFixed(3)} SOL required · ${s.solBalance.toFixed(3)} available ✓`
: `Need ~${cost.toFixed(3)} SOL · ${s.solBalance.toFixed(3)} in wallet`;
});
-
- // Buyback slider — update value label inline
q('#lp-bps')?.addEventListener('input', (e) => {
s.buybackBps = parseInt(e.target.value, 10);
- const v = q('#lp-bps-val');
- if (v) v.textContent = `${(s.buybackBps / 100).toFixed(1)}%`;
+ const v = q('#lp-bps-val'); if (v) v.textContent = `${(s.buybackBps / 100).toFixed(1)}%`;
});
- // Wallet
q('#lp-install')?.addEventListener('click', () => window.open('https://phantom.app/', '_blank', 'noopener'));
q('#lp-connect')?.addEventListener('click', connectWallet);
q('#lp-disc')?.addEventListener('click', disconnectWallet);
-
- // Launch
q('#lp-go')?.addEventListener('click', launch);
}
@@ -714,27 +853,33 @@ export function mountLaunchPanel(container, { getAvatar, getUser } = {}) {
function avatarChanged() {
av = getAvatar?.() || null;
+ s.forceNew = false;
+ s._metaUrl = null; s._metaKey = null;
+
if (av && av.id !== DEMO_ID) {
- if (!s.name) s.name = av.name || '';
- if (!s._symbolEdited) s.symbol = toSymbol(s.name);
- if (!s.description) s.description = av.description || '';
+ if (!s.name) s.name = av.name || '';
+ if (!s._symbolEdited) s.symbol = toSymbol(s.name);
+ if (!s.description) s.description = av.description || '';
}
- // Invalidate metadata cache on avatar change
- s._metaUrl = null; s._metaKey = null;
- render();
+
+ checkExistingMint(av); // async — updates state and re-renders when done
}
// ── Boot ────────────────────────────────────────────────────────────────
av = getAvatar?.() || null;
if (av && av.id !== DEMO_ID) {
- s.name = av.name || '';
+ s.name = av.name || '';
s.symbol = toSymbol(s.name);
s.description = av.description || '';
}
render();
- setTimeout(tryAutoConnect, 250); // check for already-connected wallet
+ setTimeout(tryAutoConnect, 250);
+ if (av && av.id !== DEMO_ID) checkExistingMint(av);
- return { avatarChanged, teardown() { container.innerHTML = ''; } };
+ return {
+ avatarChanged,
+ teardown() { cleanup(); container.innerHTML = ''; },
+ };
}
diff --git a/scripts/backfill-avatar-thumbnails.mjs b/scripts/backfill-avatar-thumbnails.mjs
new file mode 100644
index 000000000..3eacfaed7
--- /dev/null
+++ b/scripts/backfill-avatar-thumbnails.mjs
@@ -0,0 +1,134 @@
+#!/usr/bin/env node
+/**
+ * Backfill PNG thumbnails for public avatars that don't have one yet.
+ *
+ * Renders each avatar's GLB in a headless Chromium via model-viewer,
+ * captures a 1024×1024 PNG, and POSTs it to /api/avatars/thumbnail
+ * (which uploads to R2 and updates the avatars row).
+ *
+ * Usage:
+ * ADMIN_BEARER=<token> ORIGIN=https://three.ws \
+ * node scripts/backfill-avatar-thumbnails.mjs
+ *
+ * The bearer token must have avatars:write scope and belong to a user with
+ * is_admin=true (so it can update other users' avatars). Pass --limit=N to
+ * cap how many avatars are processed in a single run; default 25.
+ *
+ * Each avatar takes ~4-6s to render. Run nightly or after large imports.
+ */
+
+import { chromium } from 'playwright';
+
+const ORIGIN = process.env.ORIGIN || 'https://three.ws';
+const ADMIN_BEARER = process.env.ADMIN_BEARER;
+const LIMIT = Number(process.argv.find((a) => a.startsWith('--limit='))?.split('=')[1]) || 25;
+const VIEWPORT = 1024;
+
+if (!ADMIN_BEARER) {
+ console.error('ADMIN_BEARER env var required (must have avatars:write scope on an admin account).');
+ process.exit(1);
+}
+
+const VIEWER_HTML = `<!doctype html>
+<html><head><meta charset="utf-8">
+<style>
+ html,body { margin:0; padding:0; background: transparent; width:${VIEWPORT}px; height:${VIEWPORT}px; }
+ model-viewer { width:100%; height:100%; --poster-color: transparent; background: transparent; }
+</style>
+<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>
+</head>
+<body>
+ <model-viewer id="mv" interaction-prompt="none" exposure="1.05" shadow-intensity="0.7" tone-mapping="aces"></model-viewer>
+</body></html>`;
+
+async function fetchAvatarsNeedingThumbs() {
+ const url = `${ORIGIN}/api/avatars/public?limit=200`;
+ const r = await fetch(url);
+ if (!r.ok) throw new Error(`fetch ${url}: HTTP ${r.status}`);
+ const j = await r.json();
+ return (j.avatars || []).filter((a) => !a.thumbnail_url && a.model_url);
+}
+
+async function captureAvatar(page, glbUrl) {
+ await page.evaluate(async (src) => {
+ const mv = document.getElementById('mv');
+ mv.setAttribute('src', src);
+ await new Promise((res, rej) => {
+ const t = setTimeout(() => rej(new Error('model-viewer load timeout')), 20000);
+ mv.addEventListener('load', () => { clearTimeout(t); res(); }, { once: true });
+ mv.addEventListener('error', (e) => { clearTimeout(t); rej(new Error('load error')); }, { once: true });
+ });
+ // Frame and one extra render tick to let the camera settle.
+ mv.cameraOrbit = '0deg 75deg auto';
+ mv.fieldOfView = '30deg';
+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
+ }, glbUrl);
+
+ const dataUrl = await page.evaluate(async () => {
+ const mv = document.getElementById('mv');
+ const blob = await mv.toBlob({ idealAspect: true, mimeType: 'image/png' });
+ return await new Promise((res) => {
+ const fr = new FileReader();
+ fr.onloadend = () => res(fr.result);
+ fr.readAsDataURL(blob);
+ });
+ });
+ return dataUrl;
+}
+
+async function uploadThumbnail(avatarId, pngDataUrl) {
+ const r = await fetch(`${ORIGIN}/api/avatars/thumbnail`, {
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json',
+ authorization: `Bearer ${ADMIN_BEARER}`,
+ },
+ body: JSON.stringify({ avatar_id: avatarId, png_base64: pngDataUrl }),
+ });
+ if (!r.ok) {
+ const text = await r.text().catch(() => '');
+ throw new Error(`upload ${avatarId}: HTTP ${r.status} ${text.slice(0, 200)}`);
+ }
+ return r.json();
+}
+
+async function main() {
+ console.log(`[backfill] origin=${ORIGIN} limit=${LIMIT}`);
+ const todo = (await fetchAvatarsNeedingThumbs()).slice(0, LIMIT);
+ console.log(`[backfill] ${todo.length} avatar(s) need thumbnails`);
+ if (!todo.length) return;
+
+ const browser = await chromium.launch();
+ const ctx = await browser.newContext({
+ viewport: { width: VIEWPORT, height: VIEWPORT },
+ deviceScaleFactor: 1,
+ });
+ const page = await ctx.newPage();
+ await page.setContent(VIEWER_HTML, { waitUntil: 'load' });
+ // Wait for model-viewer custom element to be defined.
+ await page.waitForFunction(() => !!customElements.get('model-viewer'));
+
+ let okCount = 0;
+ let failCount = 0;
+ for (const a of todo) {
+ const tag = `${a.id} (${a.name || a.slug || '?'})`;
+ try {
+ console.log(`[backfill] rendering ${tag}…`);
+ const dataUrl = await captureAvatar(page, a.model_url);
+ const result = await uploadThumbnail(a.id, dataUrl);
+ console.log(`[backfill] ✓ ${tag} → ${result?.data?.thumbnail_url} (${result?.data?.bytes} bytes)`);
+ okCount++;
+ } catch (err) {
+ console.error(`[backfill] ✗ ${tag}: ${err.message}`);
+ failCount++;
+ }
+ }
+
+ await browser.close();
+ console.log(`[backfill] done — ${okCount} ok, ${failCount} failed`);
+}
+
+main().catch((err) => {
+ console.error('[backfill] fatal:', err);
+ process.exit(1);
+});
diff --git a/scripts/gen-demo-avatars.mjs b/scripts/gen-demo-avatars.mjs
index 7fc8d1151..bdfe9d7b3 100644
--- a/scripts/gen-demo-avatars.mjs
+++ b/scripts/gen-demo-avatars.mjs
@@ -258,9 +258,34 @@ for (const m of ON_DISK) {
});
}
+// Filters out pure technical fixtures from the marketplace catalogue. The
+// Khronos asset repo includes many "compare X / X test / animation pointer"
+// assets meant for renderer conformance — they'd dilute a marketplace meant
+// for showcasing characters and curated objects. We keep them in the source
+// list so the generator stays close to upstream, but skip them here.
+function isReferenceFixture(name, meta) {
+ if (/^Compare/i.test(name)) return true;
+ if (/Test$|TestGrid$/i.test(name)) return true;
+ if (/^Animated(Cube|Triangle|ColorsCube|MorphCube)$/i.test(name)) return true;
+ if (/^(Box|Cube|Triangle|Simple|Primitive|Recursive|MultiUV|Cameras|Negative|Mirror|Orientation|Texture(Coord|Encoding|LinearInterp|Settings|Transform)|Vertex|Interpolation|XmpMetadata|CubeVisibility|LightVisibility|MeshPrimitive|UnicodeFile|Unicode)/i.test(name)) return true;
+ if (/AnimationPointer/i.test(name) && !/Lamp|PotOfCoals/i.test(name)) return true;
+ // Drop entries whose tags consist entirely of {test, primitive, material} with
+ // no aesthetic descriptor — pure reference grids.
+ const tagSet = new Set(meta.tags);
+ const filler = ['test', 'material', 'primitive', 'normals', 'metadata', 'colors'];
+ const hasShowcase = meta.tags.some((t) => !filler.includes(t));
+ if (!hasShowcase) return true;
+ return false;
+}
+
// Khronos
+let dropped = 0;
for (const name of KHRONOS) {
const meta = KHRONOS_META[name] || classifyByName(name);
+ if (isReferenceFixture(name, meta)) {
+ dropped += 1;
+ continue;
+ }
const slug = 'demo-' + name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
addItem({
id: `avatar_demo_k_${name.toLowerCase()}`,
@@ -347,3 +372,4 @@ ${lines.join('\n')}
const target = path.join(HERE, '..', 'api', '_lib', 'demo-avatars.js');
fs.writeFileSync(target, file);
console.log('wrote', lines.length, 'demo entries to', target);
+console.log('dropped', dropped, 'reference/test fixtures');
diff --git a/src/account.js b/src/account.js
index 431b659f1..69a970f77 100644
--- a/src/account.js
+++ b/src/account.js
@@ -133,7 +133,89 @@ export async function saveRemoteGlbToAccount(source, meta = {}) {
source: meta.source || 'upload',
source_meta: sourceMeta,
});
- return created.avatar;
+ const avatar = created.avatar;
+
+ // Fire-and-forget thumbnail + auto-tag pipeline. Doesn't block the caller.
+ // Uses a hidden off-screen model-viewer to render the GLB, captures a JPEG
+ // poster, uploads to R2, and calls Claude Haiku for tags + description.
+ captureAndTagAvatar(avatar.id, presign.storage_key).catch((err) => {
+ console.warn('[account] thumbnail/auto-tag pipeline failed silently', err?.message);
+ });
+
+ return avatar;
+}
+
+async function captureAndTagAvatar(avatarId, storageKey) {
+ // Resolve the public GLB URL from the storage key.
+ const glbUrl = storageKey.startsWith('http')
+ ? storageKey
+ : `${location.origin}/api/avatars/${avatarId}?url=1`;
+
+ // We need the actual R2 public URL. Get it from the avatar record.
+ let publicGlb;
+ try {
+ const r = await apiFetch(`/api/avatars/${avatarId}`);
+ if (!r.ok) return;
+ const j = await r.json();
+ publicGlb = j.avatar?.url || j.avatar?.model_url;
+ if (!publicGlb) return;
+ } catch { return; }
+
+ // Render in a tiny off-screen model-viewer element.
+ const mv = document.createElement('model-viewer');
+ mv.setAttribute('src', publicGlb);
+ mv.setAttribute('camera-orbit', '0deg 75deg 105%');
+ mv.setAttribute('exposure', '1');
+ mv.setAttribute('shadow-intensity', '0.6');
+ mv.setAttribute('tone-mapping', 'aces');
+ mv.style.cssText = 'position:fixed;left:-9999px;top:-9999px;width:512px;height:512px;opacity:0;pointer-events:none;';
+ document.body.appendChild(mv);
+
+ await new Promise((resolve, reject) => {
+ const timeout = setTimeout(() => reject(new Error('model-viewer load timeout')), 25_000);
+ mv.addEventListener('load', () => { clearTimeout(timeout); resolve(); }, { once: true });
+ mv.addEventListener('error', () => { clearTimeout(timeout); reject(new Error('model-viewer load error')); }, { once: true });
+ });
+
+ // Give the renderer one frame to paint.
+ await new Promise((r) => requestAnimationFrame(r));
+ await new Promise((r) => requestAnimationFrame(r));
+
+ // Capture poster as JPEG blob.
+ let thumbBlob;
+ try {
+ thumbBlob = await mv.toBlob({ mimeType: 'image/jpeg', qualityArgument: 0.82 });
+ } finally {
+ document.body.removeChild(mv);
+ }
+ if (!thumbBlob || thumbBlob.size < 500) return;
+
+ // Get a presigned upload URL for the thumbnail.
+ const presignRes = await postJson('/api/avatars/presign-thumbnail', {
+ avatar_id: avatarId,
+ size_bytes: thumbBlob.size,
+ });
+
+ // Upload the JPEG to R2.
+ const putRes = await fetch(presignRes.upload_url, {
+ method: 'PUT',
+ headers: { 'content-type': 'image/jpeg' },
+ body: thumbBlob,
+ });
+ if (!putRes.ok) throw new Error(`thumbnail R2 upload failed: ${putRes.status}`);
+
+ // Patch the avatar to store the thumbnail_key, then auto-tag via Claude vision.
+ await apiFetch(`/api/avatars/${avatarId}`, {
+ method: 'PATCH',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ thumbnail_key: presignRes.thumb_key }),
+ });
+
+ // Auto-tag (non-fatal — Claude vision call).
+ await postJson('/api/avatars/auto-tag', {
+ avatar_id: avatarId,
+ thumb_key: presignRes.thumb_key,
+ });
}
async function postJson(path, body) {
diff --git a/src/agent-edit.js b/src/agent-edit.js
index 7042872bd..607387c0f 100644
--- a/src/agent-edit.js
+++ b/src/agent-edit.js
@@ -1,13 +1,24 @@
const API_BASE = '/api';
-const agentId = new URLSearchParams(location.search).get('id');
+const params = new URLSearchParams(location.search);
+const agentId = params.get('id');
+
+// Avatar handoff from marketplace modal ("Start an agent with this avatar")
+const initAvatarId = params.get('avatar_id') || null;
+const initAvatarGlb = params.get('avatar_glb') || null;
+const initAvatarName = params.get('avatar_name') || null;
const $ = (id) => document.getElementById(id);
let agentData = null;
async function loadAgent() {
+ // No existing agent ID — create a fresh one pre-loaded with the avatar.
if (!agentId) {
- showError('No agent ID provided.');
+ if (initAvatarId || initAvatarGlb) {
+ await createAgentFromAvatar();
+ } else {
+ showError('No agent ID provided.');
+ }
return;
}
try {
@@ -21,6 +32,77 @@ async function loadAgent() {
}
}
+async function createAgentFromAvatar() {
+ showLoading('Creating agent…');
+ try {
+ // 1. Create a new agent.
+ const name = initAvatarName ? `${initAvatarName} Agent` : 'My Agent';
+ const createRes = await fetch(`${API_BASE}/agents`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ name }),
+ });
+ if (!createRes.ok) {
+ const j = await createRes.json().catch(() => ({}));
+ if (createRes.status === 401) {
+ sessionStorage.setItem('login_redirect', location.href);
+ location.replace('/login');
+ return;
+ }
+ throw new Error(j.error_description || `HTTP ${createRes.status}`);
+ }
+ const { agent } = await createRes.json();
+
+ // 2. Attach the avatar if we have an ID (already in the user's account).
+ if (initAvatarId) {
+ const patchRes = await fetch(`${API_BASE}/agents/${agent.id}`, {
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ avatar_id: initAvatarId }),
+ });
+ if (!patchRes.ok) {
+ // Non-fatal — agent was created, avatar link just didn't stick.
+ console.warn('[agent-edit] avatar attach failed', patchRes.status);
+ }
+ }
+
+ // 3. Replace URL so the page now "owns" this agent ID without re-creating
+ // on back-nav, then load normally.
+ history.replaceState({}, '', `/agent-edit.html?id=${agent.id}`);
+ agentData = agent;
+ // Seed a helpful prompt based on the avatar name.
+ if (initAvatarName) {
+ agentData.name = name;
+ agentData.system_prompt = agentData.system_prompt ||
+ `You are ${initAvatarName}, a 3D avatar agent. Be helpful and engaging.`;
+ }
+ render();
+ showBanner(`Agent created from "${initAvatarName || 'avatar'}" — fill in the details below.`);
+ } catch (err) {
+ showError(err.message);
+ }
+}
+
+function showLoading(msg) {
+ const el = $('loading');
+ if (el) { el.hidden = false; el.textContent = msg; }
+}
+
+function showBanner(msg) {
+ let el = $('avatar-origin-banner');
+ if (!el) {
+ el = document.createElement('div');
+ el.id = 'avatar-origin-banner';
+ el.style.cssText =
+ 'padding:10px 20px;background:rgba(125,211,252,.1);border-bottom:1px solid rgba(125,211,252,.25);' +
+ 'color:#7dd3fc;font-size:13px;font-weight:500;';
+ document.body.prepend(el);
+ }
+ el.textContent = msg;
+}
+
function render() {
$('loading').hidden = true;
$('panel-persona').classList.add('active');
@@ -56,6 +138,7 @@ function renderMonetization() {
const price = skillPrices[skillName];
const isPaid = !!price;
const amount = isPaid ? (price.amount / 1e6).toFixed(2) : '';
+ const trialUses = isPaid ? (price.trial_uses ?? 0) : 0;
return `
<div class="skill-item" data-skill-name="${escapeHtml(skillName)}">
@@ -65,9 +148,13 @@ function renderMonetization() {
<input type="checkbox" class="price-toggle" ${isPaid ? 'checked' : ''}>
<span class="slider"></span>
</label>
- <div class="price-input-wrapper" style="display: ${isPaid ? 'flex' : 'none'};">
+ <div class="price-input-wrapper" style="display: ${isPaid ? 'flex' : 'none'}; align-items:center; gap:8px;">
<input type="number" class="price-input" min="0" step="0.01" placeholder="0.50" value="${amount}">
<span>USDC</span>
+ <label style="font-size:12px;color:#a1a1aa;margin-left:8px;white-space:nowrap">
+ Free trials:
+ <input type="number" class="trial-uses-input" min="0" max="10" step="1" placeholder="0" value="${trialUses}" style="width:52px;margin-left:4px">
+ </label>
</div>
</div>
</div>
@@ -192,11 +279,14 @@ $('monetization-save').addEventListener('click', async () => {
const input = item.querySelector('.price-input');
if (toggle.checked && input.value) {
+ const trialInput = item.querySelector('.trial-uses-input');
+ const trialUses = trialInput ? Math.max(0, Math.min(10, parseInt(trialInput.value || '0', 10) || 0)) : 0;
prices.push({
skill,
amount: Math.round(parseFloat(input.value) * 1e6),
currency_mint: USDC_MINT,
chain: 'solana',
+ trial_uses: trialUses,
});
}
});
diff --git a/src/avatar-page.js b/src/avatar-page.js
index cdfb51702..9b03b363c 100644
--- a/src/avatar-page.js
+++ b/src/avatar-page.js
@@ -100,32 +100,42 @@ async function fetchPlugins() {
return j?.data?.items || [];
}
-// Skills are derived from a curated catalogue + any agent-defined skills
-// surfaced through marketplace. For the avatar studio we expose a stable
-// catalog of capabilities the user can attach to give the avatar behavior.
+// Skill catalogue. Every entry here is wired to something real:
+// - tts → POST /api/tts/edge (Microsoft Edge TTS, free, no API key)
+// - stt → window.SpeechRecognition (Web Speech API, browser-native)
+// - memory → localStorage chat history per avatar
+// - animate-* → triggers a clip in the loaded GLB (only enabled if the GLB
+// actually contains a clip with that name)
+// - wallet → opens /pay (USDC tip flow already shipped)
+// - identity → opens the ERC-8004 register flow
+// Everything else (image gen, web search, lip sync) was speculative and has
+// been removed until there's a real backend behind it.
const SKILL_CATALOG = [
- { id: 'wave', name: 'Wave hello', desc: 'Greet the visitor with a wave gesture' },
- { id: 'idle-anim', name: 'Idle animation', desc: 'Subtle breathing/sway loop when not chatting' },
- { id: 'lip-sync', name: 'Lip sync', desc: 'Mouth animation synced to TTS responses' },
- { id: 'face-track', name: 'Face camera', desc: 'Avatar head tracks the cursor / camera' },
- { id: 'memory', name: 'Conversation memory', desc: 'Remember chat history across page loads' },
- { id: 'voice-tts', name: 'Voice (TTS)', desc: 'Speak responses out loud with synthesized voice' },
- { id: 'voice-stt', name: 'Voice input', desc: 'Listen to the user via microphone (speech-to-text)' },
- { id: 'web-search', name: 'Web search', desc: 'Look up information online during chat' },
- { id: 'image-gen', name: 'Image generation', desc: 'Generate images on request' },
- { id: 'pump-feed', name: 'Pump.fun feed', desc: 'Real-time data on new Solana token launches' },
- { id: 'wallet-pay', name: 'Wallet payments', desc: 'Accept USDC tips via Solana Pay' },
- { id: 'erc8004', name: 'ERC-8004 identity', desc: 'On-chain agent identity for cross-app reputation' },
+ { id: 'tts', name: 'Voice replies (TTS)', desc: 'Speak each chat reply out loud using Microsoft Edge Neural TTS.' },
+ { id: 'stt', name: 'Voice input (STT)', desc: 'Press the mic in the chat box to dictate via the browser Web Speech API.' },
+ { id: 'memory', name: 'Conversation memory', desc: 'Persist chat history across reloads (per-avatar, in this browser).' },
+ { id: 'animate-wave', name: 'Wave animation', desc: 'Play a wave-style clip when the conversation starts. Requires a matching clip in the GLB.', requiresClip: ['wave', 'wavehello', 'hi'] },
+ { id: 'animate-idle', name: 'Auto-play idle', desc: 'Loop the idle animation between replies. Requires an idle clip in the GLB.', requiresClip: ['idle', 'breathing', 'breath'] },
+ { id: 'wallet', name: 'Accept USDC tips', desc: 'Open the Solana Pay flow so visitors can tip this avatar.' },
+ { id: 'identity', name: 'ERC-8004 identity', desc: 'Register an on-chain agent identity for cross-app reputation.' },
];
async function fetchSkills() {
- return SKILL_CATALOG;
+ return SKILL_CATALOG.map((s) => {
+ if (!s.requiresClip) return { ...s, available: true };
+ const has = s.requiresClip.some((c) =>
+ [...availableAnimations].some((name) => name.includes(c)),
+ );
+ return { ...s, available: has };
+ });
}
// ── Render ────────────────────────────────────────────────────────────
function renderShell(glbUrl) {
- const tagsHtml = (avatar.tags || []).map((t) => `<span class="av-tag">${esc(t)}</span>`).join('');
+ const tagsHtml = (avatar.tags || [])
+ .map((t) => `<a class="av-tag" href="/marketplace?tag=${encodeURIComponent(t)}">${esc(t)}</a>`)
+ .join('');
const author = avatar.author || avatar.attribution;
const byLine = author?.handle
? author.profileUrl || author.url
@@ -432,30 +442,77 @@ async function loadSkills() {
function renderSkillRow(s) {
const on = attachedSkills.has(s.id);
- return `<div class="av-row">
+ const disabled = s.available === false;
+ const action = disabled
+ ? `<button class="av-row-action" disabled title="No matching animation clip in this GLB">Unavailable</button>`
+ : `<button class="av-row-action${on ? ' active' : ''}" data-skill="${esc(s.id)}">${on ? 'Attached' : 'Attach'}</button>`;
+ return `<div class="av-row${disabled ? ' av-row-disabled' : ''}">
<div class="av-row-main">
<p class="av-row-title">${esc(s.name)}</p>
<p class="av-row-sub">${esc(s.desc)}</p>
</div>
- <button class="av-row-action${on ? ' active' : ''}" data-skill="${esc(s.id)}">
- ${on ? 'Attached' : 'Attach'}
- </button>
+ ${action}
</div>`;
}
-function toggleSkill(id) {
- if (attachedSkills.has(id)) attachedSkills.delete(id);
+async function toggleSkill(id) {
+ const wasOn = attachedSkills.has(id);
+ if (wasOn) attachedSkills.delete(id);
else attachedSkills.add(id);
saveAttached();
- loadSkills();
+ await loadSkills();
const overview = $('av-overview');
if (overview) {
- // re-render attached pills in the overview panel
const existing = overview.querySelector('.av-attached');
if (existing) existing.remove();
const html = renderAttached();
if (html) overview.insertAdjacentHTML('beforeend', html);
}
+
+ // Side effects on attach/detach for skills that act immediately:
+ if (!wasOn) {
+ switch (id) {
+ case 'memory':
+ // Re-hydrate stored chat history into the panel.
+ hydrateChatHistory();
+ break;
+ case 'animate-wave':
+ playClipByHint(['wave', 'wavehello', 'hi']);
+ break;
+ case 'animate-idle':
+ playClipByHint(['idle', 'breathing', 'breath'], { loop: true });
+ break;
+ case 'wallet':
+ window.open('/pay', '_blank', 'noopener');
+ break;
+ case 'identity':
+ window.open('/dashboard', '_blank', 'noopener');
+ break;
+ }
+ }
+}
+
+// ── Animation triggers ───────────────────────────────────────────────
+//
+// model-viewer surfaces playback through `availableAnimations` (array of
+// clip names) + `animationName` setter + `play()/pause()` methods. We use
+// only those public APIs — no scene-graph reach-in.
+
+function playClipByHint(hints, { loop = false } = {}) {
+ const viewer = $('av-viewer');
+ if (!viewer) return;
+ const clips = viewer.availableAnimations || [];
+ if (!clips.length) return;
+ const lower = clips.map((n) => n.toLowerCase());
+ let idx = -1;
+ for (const hint of hints) {
+ idx = lower.findIndex((n) => n.includes(hint));
+ if (idx !== -1) break;
+ }
+ if (idx === -1) return;
+ viewer.animationName = clips[idx];
+ viewer.autoplay = true;
+ if (typeof viewer.play === 'function') viewer.play({ repetitions: loop ? Infinity : 1 });
}
// ── Plugins panel ─────────────────────────────────────────────────────
@@ -538,8 +595,12 @@ function bindChat() {
const form = $('av-chat-form');
const input = $('av-chat-input');
const send = $('av-chat-send');
+ const mic = $('av-chat-mic');
if (!form || !input || !send) return;
+ // Persistent memory (memory skill): replay stored history on first paint.
+ if (attachedSkills.has('memory')) hydrateChatHistory();
+
input.addEventListener('input', () => {
input.style.height = 'auto';
input.style.height = Math.min(input.scrollHeight, 120) + 'px';
@@ -558,6 +619,102 @@ function bindChat() {
input.style.height = 'auto';
await sendChatMessage(text);
});
+
+ // Mic button → Web Speech API STT. Hidden if the browser doesn't support it.
+ const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
+ if (mic && SR) {
+ const rec = new SR();
+ rec.continuous = false;
+ rec.interimResults = false;
+ rec.lang = 'en-US';
+ let listening = false;
+ mic.addEventListener('click', () => {
+ if (!attachedSkills.has('stt')) {
+ alert('Attach the "Voice input" skill first (Skills tab).');
+ return;
+ }
+ if (listening) { rec.stop(); return; }
+ try { rec.start(); listening = true; mic.classList.add('listening'); }
+ catch (err) { console.warn('[avatar] STT start', err.message); }
+ });
+ rec.onresult = (e) => {
+ const text = e.results[0]?.[0]?.transcript;
+ if (text) input.value = (input.value ? input.value + ' ' : '') + text;
+ input.dispatchEvent(new Event('input'));
+ input.focus();
+ };
+ rec.onend = () => { listening = false; mic.classList.remove('listening'); };
+ rec.onerror = () => { listening = false; mic.classList.remove('listening'); };
+ } else if (mic) {
+ mic.hidden = true; // unsupported browser — hide rather than show a dead button
+ }
+}
+
+// ── Persistent chat memory ───────────────────────────────────────────
+
+const MEMORY_KEY_PREFIX = 'avatar_chat_v1:';
+function memoryKey() { return MEMORY_KEY_PREFIX + (avatar?.id || avatarId); }
+
+function hydrateChatHistory() {
+ if (!attachedSkills.has('memory')) return;
+ try {
+ const raw = localStorage.getItem(memoryKey());
+ if (!raw) return;
+ const stored = JSON.parse(raw);
+ if (!Array.isArray(stored) || stored.length === 0) return;
+ chatHistory = stored.slice(-40); // cap so we don't blow context
+ const log = $('av-chat-log');
+ if (!log) return;
+ log.querySelector('.av-chat-empty')?.remove();
+ // Re-render the conversation from the persisted history.
+ const existing = log.querySelectorAll('.av-chat-msg');
+ existing.forEach((n) => n.remove());
+ for (const m of chatHistory) appendChatMessage(m.role, m.content);
+ } catch (err) {
+ console.warn('[avatar] memory hydrate failed', err.message);
+ }
+}
+
+function persistChatHistory() {
+ if (!attachedSkills.has('memory')) return;
+ try {
+ localStorage.setItem(memoryKey(), JSON.stringify(chatHistory.slice(-40)));
+ } catch {
+ // quota exceeded — drop oldest half and retry
+ try {
+ localStorage.setItem(memoryKey(), JSON.stringify(chatHistory.slice(-10)));
+ } catch {/* give up */}
+ }
+}
+
+// ── TTS playback ─────────────────────────────────────────────────────
+//
+// Hits the existing /api/tts/edge endpoint (Microsoft Edge Neural voices,
+// no API key required, R2-cached server-side). Returns audio/mpeg which we
+// play through a single shared Audio element.
+
+let ttsAudio = null;
+async function speakReply(text) {
+ if (!attachedSkills.has('tts')) return;
+ if (!text || !text.trim()) return;
+ try {
+ // Stop any prior playback so consecutive replies don't overlap.
+ if (ttsAudio) { ttsAudio.pause(); ttsAudio = null; }
+ const r = await fetch('/api/tts/edge', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ voice: 'en-US-AriaNeural', text: text.slice(0, 1500) }),
+ });
+ if (!r.ok) throw new Error(`TTS failed (${r.status})`);
+ const blob = await r.blob();
+ const url = URL.createObjectURL(blob);
+ ttsAudio = new Audio(url);
+ ttsAudio.onended = () => { URL.revokeObjectURL(url); ttsAudio = null; };
+ await ttsAudio.play();
+ } catch (err) {
+ console.warn('[avatar] TTS playback failed', err.message);
+ }
}
async function sendChatMessage(text) {
@@ -569,6 +726,12 @@ async function sendChatMessage(text) {
const empty = log.querySelector('.av-chat-empty');
if (empty) empty.remove();
+ // Wave on the very first user message of the session, if the avatar has
+ // a wave clip and the wave skill is attached.
+ if (chatHistory.length === 0 && attachedSkills.has('animate-wave')) {
+ playClipByHint(['wave', 'wavehello', 'hi']);
+ }
+
chatHistory.push({ role: 'user', content: text });
appendChatMessage('user', text);
@@ -622,6 +785,9 @@ async function sendChatMessage(text) {
}
}
chatHistory.push({ role: 'assistant', content: acc });
+ persistChatHistory();
+ // Speak the assistant's full reply (TTS skill).
+ if (acc) speakReply(acc);
} catch (err) {
assistantNode.textContent = acc || `⚠ ${err.message}`;
console.error('[avatar] chat', err);
@@ -692,68 +858,49 @@ async function loadRelated() {
// ── Model measurement ─────────────────────────────────────────────────
async function measureModel(glbUrl) {
- // Real file size via HEAD. Polygon counts come from the loaded model-viewer
- // scene graph (when 3DOM is available — gracefully skipped otherwise).
+ // Stable approach: parse the GLB binary header ourselves (range-fetched,
+ // JSON chunk only — usually under 100 KB). No model-viewer internals,
+ // no THREE.js, no scene-graph walking. Survives library upgrades.
+ let stats;
try {
- const r = await fetch(glbUrl, { method: 'HEAD' });
- const len = r.headers.get('content-length');
- if (len) {
- const bytes = Number(len);
- const mb = (bytes / 1_048_576).toFixed(1);
- $('av-size').textContent = `${mb} MB`;
- $('av-size-item').hidden = false;
- }
- } catch {
- // non-fatal
+ const { fetchGlbStats } = await import('./lib/glb-stats.js');
+ stats = await fetchGlbStats(glbUrl);
+ } catch (err) {
+ console.warn('[avatar] glb stats parse failed', err.message);
+ return;
}
- const viewer = $('av-viewer');
- if (!viewer) return;
- const onLoad = async () => {
- try {
- // model-viewer 3DOM gives us the loaded scene graph.
- const stats = await viewer.requestUpdate?.();
- void stats;
- const model = viewer.model || viewer.scene;
- if (!model) return;
- let verts = 0;
- let tris = 0;
- let mats = new Set();
- for (const mesh of model.materials || []) mats.add(mesh.name || mesh.id);
- // Fall back to walking the THREE scene if exposed
- const scene = viewer[Symbol.for('scene')] || viewer.scene;
- const root = scene?.modelContainer || scene;
- if (root && typeof root.traverse === 'function') {
- root.traverse((node) => {
- if (node.isMesh && node.geometry) {
- const pos = node.geometry.attributes?.position?.count;
- if (pos) verts += pos;
- const idx = node.geometry.index?.count;
- if (idx) tris += idx / 3;
- else if (pos) tris += pos / 3;
- if (node.material?.name) mats.add(node.material.name);
- }
- });
- }
- if (verts > 0) {
- $('av-vert').textContent = verts.toLocaleString();
- $('av-vert-item').hidden = false;
- }
- if (tris > 0) {
- $('av-tri').textContent = Math.round(tris).toLocaleString();
- $('av-tri-item').hidden = false;
- }
- if (mats.size > 0) {
- $('av-mat').textContent = mats.size;
- $('av-mat-item').hidden = false;
- }
- } catch {
- // non-fatal
- }
- };
- viewer.addEventListener('load', onLoad, { once: true });
+ if (stats.sizeBytes) {
+ const mb = (stats.sizeBytes / 1_048_576).toFixed(1);
+ $('av-size').textContent = `${mb} MB`;
+ $('av-size-item').hidden = false;
+ }
+ if (stats.vertices > 0) {
+ $('av-vert').textContent = stats.vertices.toLocaleString();
+ $('av-vert-item').hidden = false;
+ }
+ if (stats.triangles > 0) {
+ $('av-tri').textContent = stats.triangles.toLocaleString();
+ $('av-tri-item').hidden = false;
+ }
+ if (stats.materials > 0) {
+ $('av-mat').textContent = stats.materials;
+ $('av-mat-item').hidden = false;
+ }
+
+ // Animation clip names → expose to the skills panel so we can wire animation
+ // triggers (e.g. wave skill) to clips that actually exist in this GLB.
+ if (stats.animationNames?.length) {
+ availableAnimations = new Set(stats.animationNames.map((n) => n.toLowerCase()));
+ // Re-render the skills list so disabled/enabled state reflects what
+ // the GLB can actually do.
+ const skillsList = $('av-skills-list');
+ if (skillsList && !skillsList.querySelector('.av-list-loading')) loadSkills();
+ }
}
+let availableAnimations = new Set();
+
// ── OG meta ───────────────────────────────────────────────────────────
function updateOg() {
diff --git a/src/lib/glb-stats.js b/src/lib/glb-stats.js
new file mode 100644
index 000000000..7530b7a68
--- /dev/null
+++ b/src/lib/glb-stats.js
@@ -0,0 +1,152 @@
+/**
+ * Parse stats from a GLB (binary glTF) file using only the structured JSON
+ * chunk — no THREE.js, no model-viewer internals, no full scene
+ * reconstruction. We download the file with a Range request first to grab
+ * the JSON header, falling back to a full fetch if the server doesn't
+ * honor ranges.
+ *
+ * Returns: { sizeBytes, vertices, triangles, materials, animations, nodes,
+ * meshes, primitives, hasMorphTargets, extensionsUsed }
+ *
+ * GLB layout (spec https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#binary-gltf-layout):
+ * bytes 0..3 magic "glTF" (0x46546C67 little-endian)
+ * bytes 4..7 version uint32 (== 2)
+ * bytes 8..11 length uint32 — total size of the file
+ * bytes 12..15 chunk0Length uint32
+ * bytes 16..19 chunk0Type "JSON" (0x4E4F534A)
+ * bytes 20.. JSON payload
+ * ... subsequent chunks (BIN)
+ *
+ * For stats we only need the JSON. accessor.count gives vertex/index counts;
+ * primitive.indices/.attributes.POSITION resolve to those accessors.
+ */
+
+const MAGIC = 0x46546c67; // 'glTF'
+const JSON_CHUNK_TYPE = 0x4e4f534a; // 'JSON'
+
+const u32 = (view, offset) => view.getUint32(offset, true);
+
+export async function fetchGlbStats(url, { signal, maxBytes = 4 * 1024 * 1024 } = {}) {
+ // Step 1: HEAD for accurate size.
+ let sizeBytes = null;
+ try {
+ const headRes = await fetch(url, { method: 'HEAD', signal });
+ const len = headRes.headers.get('content-length');
+ if (len) sizeBytes = Number(len);
+ } catch {
+ // non-fatal — sizeBytes stays null
+ }
+
+ // Step 2: Range-fetch the first ~256 KB (enough to contain the GLB header
+ // and the JSON chunk for the vast majority of models). If the JSON chunk
+ // is bigger than our window we widen below.
+ let firstWindow = Math.min(256 * 1024, sizeBytes ?? 256 * 1024);
+ let buf = await fetchRange(url, 0, firstWindow - 1, { signal });
+ if (!buf) {
+ // Server doesn't support ranges — fall back to full fetch with a cap.
+ const fullRes = await fetch(url, { signal });
+ if (!fullRes.ok) throw new Error(`HTTP ${fullRes.status}`);
+ const ab = await fullRes.arrayBuffer();
+ buf = ab.slice(0, Math.min(ab.byteLength, maxBytes));
+ if (!sizeBytes) sizeBytes = ab.byteLength;
+ }
+
+ const view = new DataView(buf);
+ if (view.byteLength < 20) throw new Error('GLB header truncated');
+ if (u32(view, 0) !== MAGIC) throw new Error('Not a GLB');
+ if (u32(view, 4) !== 2) throw new Error(`Unsupported GLB version ${u32(view, 4)}`);
+ if (!sizeBytes) sizeBytes = u32(view, 8);
+
+ const chunk0Length = u32(view, 12);
+ const chunk0Type = u32(view, 16);
+ if (chunk0Type !== JSON_CHUNK_TYPE) throw new Error('First GLB chunk is not JSON');
+
+ let jsonStart = 20;
+ let jsonEnd = jsonStart + chunk0Length;
+ if (jsonEnd > buf.byteLength) {
+ // JSON chunk is larger than first window — widen to cover it.
+ const need = Math.min(jsonEnd, maxBytes);
+ buf = await fetchRange(url, 0, need - 1, { signal });
+ if (!buf) throw new Error('Cannot read JSON chunk');
+ }
+
+ const jsonBytes = new Uint8Array(buf, jsonStart, chunk0Length);
+ const jsonStr = new TextDecoder('utf-8').decode(jsonBytes);
+ const gltf = JSON.parse(jsonStr);
+
+ return analyseGltfJson(gltf, { sizeBytes });
+}
+
+function analyseGltfJson(gltf, { sizeBytes }) {
+ const accessors = gltf.accessors || [];
+ const meshes = gltf.meshes || [];
+ const materials = gltf.materials || [];
+ const animations = gltf.animations || [];
+ const nodes = gltf.nodes || [];
+
+ let vertices = 0;
+ let triangles = 0;
+ let primitives = 0;
+ let hasMorphTargets = false;
+
+ for (const mesh of meshes) {
+ for (const prim of mesh.primitives || []) {
+ primitives += 1;
+ const posIdx = prim.attributes?.POSITION;
+ if (Number.isInteger(posIdx) && accessors[posIdx]) {
+ vertices += accessors[posIdx].count || 0;
+ }
+ const idxIdx = prim.indices;
+ if (Number.isInteger(idxIdx) && accessors[idxIdx]) {
+ const count = accessors[idxIdx].count || 0;
+ const mode = prim.mode == null ? 4 : prim.mode; // 4 = TRIANGLES (default)
+ triangles += primitiveTriangleCount(mode, count);
+ } else if (Number.isInteger(posIdx) && accessors[posIdx]) {
+ const count = accessors[posIdx].count || 0;
+ const mode = prim.mode == null ? 4 : prim.mode;
+ triangles += primitiveTriangleCount(mode, count);
+ }
+ if (prim.targets && prim.targets.length > 0) hasMorphTargets = true;
+ }
+ }
+
+ return {
+ sizeBytes,
+ vertices,
+ triangles: Math.round(triangles),
+ materials: materials.length,
+ animations: animations.length,
+ animationNames: animations.map((a) => a.name).filter(Boolean),
+ nodes: nodes.length,
+ meshes: meshes.length,
+ primitives,
+ hasMorphTargets,
+ extensionsUsed: gltf.extensionsUsed || [],
+ };
+}
+
+function primitiveTriangleCount(mode, indexCount) {
+ switch (mode) {
+ case 0: return 0; // POINTS
+ case 1: case 2: case 3: return 0; // LINES variants
+ case 4: return indexCount / 3; // TRIANGLES
+ case 5: case 6: return Math.max(0, indexCount - 2); // TRIANGLE_STRIP / FAN
+ default: return 0;
+ }
+}
+
+async function fetchRange(url, start, end, { signal } = {}) {
+ try {
+ const res = await fetch(url, {
+ signal,
+ headers: { Range: `bytes=${start}-${end}` },
+ });
+ // 206 = partial content (range honoured). Some CDNs respond 200 with the
+ // full file — that's fine, we just use what we asked for in the slice.
+ if (res.status !== 206 && res.status !== 200) return null;
+ const ab = await res.arrayBuffer();
+ return ab;
+ } catch {
+ return null;
+ }
+}
diff --git a/src/marketplace.js b/src/marketplace.js
index b91abf2bb..00ac5bceb 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -45,17 +45,22 @@ const CATEGORY_LABELS = {
const state = {
category: null, // null = Discover (all)
q: '',
+ tag: null, // ?tag=humanoid → filter all cards to entries containing this tag
sort: 'recommended',
- filter: 'all', // all | agents | avatars
+ filter: 'all', // all | agents | avatars | onchain
cursor: null,
items: [],
loading: false,
publicAvatars: [],
publicAvatarsLoaded: false,
+ onchainItems: [],
+ onchainCursor: null,
+ onchainLoaded: false,
featured: [],
heroIndex: 0,
heroTimer: null,
stats: null,
+ theme: null,
};
const WIP_DISMISS_KEY = 'marketplace_wip_dismissed_v1';
@@ -66,6 +71,7 @@ const els = {
detail: $('market-detail'),
tools: $('market-tools'),
cats: $('market-cats'),
+ catChips: $('market-cat-chips'),
grid: $('market-grid'),
search: $('market-search'),
sortSel: $('market-sort'),
@@ -78,12 +84,15 @@ const els = {
function readRoute() {
const m = location.pathname.match(/^\/marketplace\/agents\/([^/]+)/);
if (m) return { view: 'detail', id: m[1] };
- const tab = new URLSearchParams(location.search).get('tab');
- if (tab === 'tools') return { view: 'tools' };
- if (tab === 'skills') return { view: 'skills' };
- if (tab === 'mine') return { view: 'mine' };
- if (tab === 'avatars') return { view: 'list', filter: 'avatars' };
- return { view: 'list' };
+ const params = new URLSearchParams(location.search);
+ const tab = params.get('tab');
+ const tag = (params.get('tag') || '').trim().toLowerCase().slice(0, 40) || null;
+ if (tab === 'tools') return { view: 'tools', tag };
+ if (tab === 'skills') return { view: 'skills', tag };
+ if (tab === 'mine') return { view: 'mine', tag };
+ if (tab === 'purchases') return { view: 'purchases', tag };
+ if (tab === 'avatars') return { view: 'list', filter: 'avatars', tag };
+ return { view: 'list', tag };
}
function navTo(path, replace = false) {
@@ -97,10 +106,104 @@ window.addEventListener('popstate', render);
// ── List view ─────────────────────────────────────────────────────────────
+// ── Poster cache (IndexedDB) ──────────────────────────────────────────────
+// Caches captured model-viewer poster images client-side so subsequent page
+// loads show instant thumbnails instead of the shimmer.
+
+const _POSTER_DB = 'mv-poster-cache-v1';
+const _POSTER_STORE = 'posters';
+let _dbPromise = null;
+
+function _openDb() {
+ if (_dbPromise) return _dbPromise;
+ _dbPromise = new Promise((resolve, reject) => {
+ const req = indexedDB.open(_POSTER_DB, 1);
+ req.onupgradeneeded = (e) => e.target.result.createObjectStore(_POSTER_STORE);
+ req.onsuccess = (e) => resolve(e.target.result);
+ req.onerror = () => { _dbPromise = null; reject(req.error); };
+ });
+ return _dbPromise;
+}
+
+async function _posterGet(key) {
+ try {
+ const db = await _openDb();
+ return await new Promise((resolve) => {
+ const tx = db.transaction(_POSTER_STORE, 'readonly');
+ const req = tx.objectStore(_POSTER_STORE).get(key);
+ req.onsuccess = () => resolve(req.result || null);
+ req.onerror = () => resolve(null);
+ });
+ } catch { return null; }
+}
+
+async function _posterSet(key, blob) {
+ try {
+ const db = await _openDb();
+ await new Promise((resolve) => {
+ const tx = db.transaction(_POSTER_STORE, 'readwrite');
+ tx.objectStore(_POSTER_STORE).put(blob, key);
+ tx.oncomplete = resolve;
+ tx.onerror = resolve;
+ });
+ } catch {}
+}
+
+/**
+ * After renderGrid() sets innerHTML, run this to:
+ * 1. Apply cached poster blobs (instant thumbnails on repeat visits).
+ * 2. Attach load-listener to capture + cache poster on first visit.
+ * 3. Add .mv-loaded class when model loads (triggers CSS shimmer-off + fade-in).
+ */
+async function attachModelViewerBehavior() {
+ const cards = els.grid.querySelectorAll('.market-card-avatar');
+ for (const card of cards) {
+ const mv = card.querySelector('model-viewer');
+ if (!mv) continue;
+ const src = mv.getAttribute('src');
+ if (!src) continue;
+
+ // Apply cached poster immediately (sync path via already-resolved db).
+ const cached = await _posterGet(src);
+ if (cached) {
+ mv.setAttribute('poster', URL.createObjectURL(cached));
+ }
+
+ const onLoad = async () => {
+ card.classList.add('mv-loaded');
+ if (!cached) {
+ try {
+ const blob = await mv.generatePosterBlob({ idealAspect: true });
+ if (blob) await _posterSet(src, blob);
+ } catch {}
+ }
+ };
+ mv.addEventListener('load', onLoad, { once: true });
+ // model-viewer fires 'poster-dismissed' when it transitions from poster → 3D.
+ mv.addEventListener('poster-dismissed', () => card.classList.add('mv-loaded'), { once: true });
+ }
+}
+
+// ── Infinite scroll ───────────────────────────────────────────────────────
+
+let _infiniteObserver = null;
+
+function _setupInfiniteScroll() {
+ if (_infiniteObserver) { _infiniteObserver.disconnect(); _infiniteObserver = null; }
+ const sentinel = els.grid.querySelector('.market-scroll-sentinel');
+ if (!sentinel) return;
+ _infiniteObserver = new IntersectionObserver((entries) => {
+ if (entries[0]?.isIntersecting && !state.loading && state.cursor) {
+ loadList(false);
+ }
+ }, { rootMargin: '200px' });
+ _infiniteObserver.observe(sentinel);
+}
+// ── Category chips row ────────────────────────────────────────────────────
async function loadCategories() {
- if (!els.cats) return;
+ if (!els.cats && !els.catChips) return;
try {
const r = await fetch(`${API}/marketplace/categories`);
const j = await r.json();
@@ -110,18 +213,56 @@ async function loadCategories() {
}
}
+function renderCategoryChips(data) {
+ if (!els.catChips) return;
+ const total = data?.total || 0;
+ const counts = Object.fromEntries((data?.categories || []).map((cat) => [cat.slug, cat.count]));
+ const chips = [
+ { slug: null, label: 'All', count: total },
+ ...Object.keys(CATEGORY_LABELS)
+ .map((slug) => ({ slug, label: CATEGORY_LABELS[slug], count: counts[slug] || 0 }))
+ .filter((c) => c.count > 0),
+ ];
+ els.catChips.innerHTML = chips.map((c) => {
+ const active = (c.slug === null && !state.category) || state.category === c.slug;
+ return `<button class="market-cat-chip${active ? ' active' : ''}" data-cat="${c.slug ?? ''}" type="button">
+ ${escapeHtml(c.label)}
+ <span class="cat-chip-count">${c.count}</span>
+ </button>`;
+ }).join('');
+ els.catChips.querySelectorAll('.market-cat-chip').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ const slug = btn.dataset.cat || null;
+ state.category = slug;
+ state.cursor = null;
+ loadList(true);
+ highlightCategoryChips();
+ });
+ });
+}
+
+function highlightCategoryChips() {
+ if (!els.catChips) return;
+ els.catChips.querySelectorAll('.market-cat-chip').forEach((btn) => {
+ const slug = btn.dataset.cat || null;
+ btn.classList.toggle('active', slug === state.category || (slug === null && !state.category));
+ });
+}
+
function renderCategories(data) {
+ renderCategoryChips(data);
if (!els.cats) return;
const total = data?.total || 0;
const counts = Object.fromEntries((data?.categories || []).map((cat) => [cat.slug, cat.count]));
+ // Hide categories with 0 published agents — they're noise. Keep "Discover" and
+ // "All" pinned, and keep the currently-selected category visible even at 0.
+ const populated = Object.keys(CATEGORY_LABELS)
+ .map((slug) => ({ slug, label: CATEGORY_LABELS[slug], count: counts[slug] || 0 }))
+ .filter((row) => row.count > 0 || state.category === row.slug);
const rows = [
{ slug: null, label: 'Discover', count: null, head: true },
{ slug: 'all', label: 'All', count: total },
- ...Object.keys(CATEGORY_LABELS).map((slug) => ({
- slug,
- label: CATEGORY_LABELS[slug],
- count: counts[slug] || 0,
- })),
+ ...populated,
];
els.cats.innerHTML = rows
.map((r) => {
@@ -191,6 +332,7 @@ async function loadList(reset = false) {
if (reset) {
loadPublicAvatars();
loadFeatured();
+ loadOnchainAgents(true);
}
}
@@ -224,11 +366,89 @@ async function loadPublicAvatars() {
state.stats = j?.totals || state.stats;
renderGrid();
renderHeroStats();
+ updateOnchainChipCount();
} catch (err) {
console.error('[marketplace] public avatars', err);
}
}
+// ── Onchain ERC-8004 agents (102k+ in DB) ────────────────────────────────
+
+async function loadOnchainAgents(reset = false) {
+ if (reset) {
+ state.onchainItems = [];
+ state.onchainCursor = null;
+ state.onchainLoaded = false;
+ }
+ try {
+ const url = new URL(`${API}/explore`, location.origin);
+ url.searchParams.set('source', 'onchain');
+ url.searchParams.set('only3d', '1');
+ url.searchParams.set('limit', '60');
+ if (state.q) url.searchParams.set('q', state.q);
+ if (state.onchainCursor) url.searchParams.set('cursor', state.onchainCursor);
+ const r = await fetch(url);
+ if (!r.ok) return;
+ const j = await r.json();
+ const items = (j?.items || []).filter((it) => it.kind === 'onchain' && it.glbUrl);
+ state.onchainItems = reset ? items : [...state.onchainItems, ...items];
+ state.onchainCursor = j?.nextCursor || null;
+ state.onchainLoaded = true;
+ if (state.filter === 'onchain' || state.filter === 'all') renderGrid();
+ updateOnchainChipCount();
+ } catch (err) {
+ console.error('[marketplace] onchain', err);
+ }
+}
+
+function updateOnchainChipCount() {
+ const el = $('chip-count-onchain');
+ if (!el) return;
+ const total = state.stats?.onchain;
+ if (!total) {
+ el.textContent = '';
+ return;
+ }
+ el.textContent = fmtNumber(total);
+}
+
+// ── Weekly theme strip ───────────────────────────────────────────────────
+
+async function loadTheme() {
+ try {
+ const r = await fetch(`${API}/marketplace/theme`);
+ if (!r.ok) return;
+ const j = await r.json();
+ const theme = j?.data?.theme;
+ if (!theme) return;
+ state.theme = theme;
+ renderTheme();
+ } catch (err) {
+ console.error('[marketplace] theme', err);
+ }
+}
+
+function renderTheme() {
+ const strip = $('market-theme-strip');
+ if (!strip || !state.theme) return;
+ $('market-theme-title').textContent = state.theme.title;
+ $('market-theme-blurb').textContent = state.theme.blurb || '';
+ const cta = $('market-theme-cta');
+ if (state.theme.tag) {
+ cta.hidden = false;
+ cta.textContent = `Browse #${state.theme.tag} →`;
+ cta.onclick = () => {
+ els.search.value = state.theme.tag;
+ state.q = state.theme.tag;
+ loadList(true);
+ window.scrollTo({ top: 0, behavior: 'smooth' });
+ };
+ } else {
+ cta.hidden = true;
+ }
+ strip.hidden = false;
+}
+
// ── Featured hero (rotating 3D showcase) ─────────────────────────────────
async function loadFeatured() {
@@ -418,7 +638,7 @@ function initWipBanner() {
}
}
-// ── Filter chips (All / Agents / Avatars) ────────────────────────────────
+// ── Filter chips (All / Agents / Avatars / Onchain) ──────────────────────
function bindFilterChips() {
const chips = document.querySelectorAll('#market-filter-chips .market-chip');
@@ -427,10 +647,10 @@ function bindFilterChips() {
chips.forEach((c) => c.classList.remove('active'));
chip.classList.add('active');
state.filter = chip.dataset.filter || 'all';
- // Hero showcases community avatars; hide it when filter is agents-only.
+ // Hero showcases community avatars; hide it for non-avatar filters.
const hero = $('market-hero');
if (hero) {
- if (state.filter === 'agents') {
+ if (state.filter === 'agents' || state.filter === 'onchain') {
hero.hidden = true;
stopHeroAutoplay();
} else if (state.featured.length) {
@@ -438,25 +658,69 @@ function bindFilterChips() {
startHeroAutoplay();
}
}
+ if (state.filter === 'onchain' && !state.onchainLoaded) {
+ loadOnchainAgents(true);
+ }
renderGrid();
});
});
}
+function renderTagBanner() {
+ const banner = $('market-tag-banner');
+ if (!banner) return;
+ if (!state.tag) {
+ banner.hidden = true;
+ banner.innerHTML = '';
+ return;
+ }
+ banner.hidden = false;
+ banner.innerHTML = `
+ <span class="market-tag-banner-label">Filtering by tag</span>
+ <span class="market-tag-banner-chip">
+ ${escapeHtml(state.tag)}
+ <button class="market-tag-banner-clear" aria-label="Clear tag filter" type="button">✕</button>
+ </span>`;
+ banner.querySelector('.market-tag-banner-clear')?.addEventListener('click', () => {
+ navTo('/marketplace');
+ });
+}
+
function renderGrid() {
- const showAgents = state.filter !== 'avatars';
- const showAvatars = state.filter !== 'agents' && !state.category;
- const agentItems = showAgents ? state.items : [];
- const avatars = showAvatars ? state.publicAvatars : [];
+ const showAgents = state.filter === 'all' || state.filter === 'agents';
+ const showAvatars = (state.filter === 'all' || state.filter === 'avatars') && !state.category;
+ const showOnchain = state.filter === 'all' || state.filter === 'onchain';
+ let agentItems = showAgents ? state.items : [];
+ let avatars = showAvatars ? state.publicAvatars : [];
+ let onchain = showOnchain ? state.onchainItems : [];
+
+ // Tag filter (?tag=humanoid) — case-insensitive exact-match on the .tags array
+ if (state.tag) {
+ const t = state.tag;
+ const matches = (arr) =>
+ Array.isArray(arr) && arr.some((x) => String(x).toLowerCase() === t);
+ agentItems = agentItems.filter((a) => matches(a.tags));
+ avatars = avatars.filter((a) => matches(a.tags));
+ onchain = onchain.filter((a) => matches(a.tags));
+ }
+
+ renderTagBanner();
- if (!agentItems.length && !avatars.length) {
+ const totalCards = agentItems.length + avatars.length + onchain.length;
+
+ if (!totalCards) {
let msg;
- if (!state.publicAvatarsLoaded && !state.items.length) {
+ const stillLoading =
+ (!state.publicAvatarsLoaded && state.filter !== 'agents' && state.filter !== 'onchain') ||
+ (!state.onchainLoaded && state.filter === 'onchain');
+ if (stillLoading) {
msg = renderSkeletons(8);
} else if (state.filter === 'agents') {
msg = '<div class="market-empty">No agents published yet. Be the first.</div>';
} else if (state.filter === 'avatars') {
msg = '<div class="market-empty">No public avatars match your search.</div>';
+ } else if (state.filter === 'onchain') {
+ msg = '<div class="market-empty">No onchain agents match your search.</div>';
} else {
msg = '<div class="market-empty">Nothing here yet — try a different search.</div>';
}
@@ -467,19 +731,45 @@ function renderGrid() {
let html = '';
if (agentItems.length) {
- if (state.filter === 'all' && avatars.length) {
+ if (state.filter === 'all' && (avatars.length || onchain.length)) {
html += `<div class="market-grid-section-title">Agents <span class="count">${agentItems.length}</span></div>`;
}
html += agentItems.map(renderCard).join('');
}
if (avatars.length) {
- if (state.filter === 'all' && agentItems.length) {
+ if (state.filter === 'all' && (agentItems.length || onchain.length)) {
html += `<div class="market-grid-section-title">Community Avatars <span class="count">${avatars.length} public</span></div>`;
}
- html += avatars.map(renderAvatarCard).join('');
+ // First avatar gets the featured spotlight (2×2) when avatars lead the grid.
+ const isLeading = !agentItems.length && !onchain.length;
+ html += avatars.map((a, i) => renderAvatarCard(a, isLeading && i === 0)).join('');
+ }
+ if (onchain.length) {
+ if (state.filter === 'all' && (agentItems.length || avatars.length)) {
+ const more = state.stats?.onchain ? `<span class="count">${fmtNumber(state.stats.onchain)} total</span>` : '';
+ html += `<div class="market-grid-section-title">Onchain Agents ${more}</div>`;
+ }
+ html += onchain.map(renderOnchainCard).join('');
+ }
+
+ // Infinite scroll sentinel — observed below to auto-fetch next page.
+ const hasMore =
+ (state.filter === 'all' && (state.cursor || state.onchainCursor)) ||
+ (state.filter === 'agents' && state.cursor) ||
+ (state.filter === 'onchain' && state.onchainCursor);
+ if (hasMore) {
+ html += '<div class="market-scroll-sentinel" aria-hidden="true"></div>';
+ html += '<div class="market-loadmore-spinner" aria-label="Loading more…"></div>';
}
+
els.grid.innerHTML = html;
+ // Poster cache + shimmer-off for model-viewers.
+ attachModelViewerBehavior();
+
+ // Kick off infinite scroll observation.
+ if (hasMore) _setupInfiniteScroll();
+
els.grid.querySelectorAll('[data-id]').forEach((card) => {
card.addEventListener('click', () => navTo(`/marketplace/agents/${card.dataset.id}`));
});
@@ -492,7 +782,80 @@ function renderGrid() {
if (avatar) openAvatarModal(avatar);
});
});
- els.loadMore.hidden = !state.cursor;
+ els.grid.querySelectorAll('[data-onchain-href]').forEach((card) => {
+ card.addEventListener('click', (e) => {
+ if (e.target.closest('a')) return;
+ const href = card.dataset.onchainHref;
+ if (href) location.href = href;
+ });
+ });
+
+ // Tag pills inside cards navigate to ?tag=X so the URL is shareable and
+ // browser back/forward works. render() picks up state.tag from the route.
+ els.grid.querySelectorAll('[data-tag]').forEach((pill) => {
+ pill.addEventListener('click', (e) => {
+ e.stopPropagation();
+ const tag = pill.dataset.tag;
+ if (!tag) return;
+ navTo(`/marketplace?tag=${encodeURIComponent(tag)}`);
+ });
+ });
+
+ // Hide the legacy load-more button — infinite scroll handles it.
+ els.loadMore.hidden = true;
+
+ observeCardModelViewers();
+}
+
+// ── 3D card performance: pause off-screen model-viewers ──────────────────
+//
+// Each <model-viewer> runs a continuous requestAnimationFrame loop while
+// auto-rotate is set, regardless of whether the card is on screen. With
+// 60+ cards in the grid that adds up to dropped frames on mid-tier devices.
+// Solution: an IntersectionObserver toggles the `auto-rotate` attribute as
+// each card enters/leaves the viewport. When detached, the model-viewer
+// stops rendering entirely (model-viewer halts its raf when no rotate/no
+// camera motion). We don't tear down the WebGL context — it's expensive
+// to re-init — but pausing rotation drops GPU usage to ~0 for off-screen
+// cards.
+
+let cardObserver = null;
+function observeCardModelViewers() {
+ if (typeof IntersectionObserver === 'undefined') {
+ // Browser without IntersectionObserver: eagerly promote data-src so
+ // the cards still render. Acceptable fallback for ancient browsers.
+ document.querySelectorAll('model-viewer[data-src]').forEach((mv) => {
+ mv.setAttribute('src', mv.dataset.src);
+ mv.setAttribute('auto-rotate', '');
+ });
+ return;
+ }
+ if (!cardObserver) {
+ cardObserver = new IntersectionObserver(
+ (entries) => {
+ for (const entry of entries) {
+ const mv = entry.target;
+ if (entry.isIntersecting) {
+ // Lazy promote data-src → src on first intersect (fires the GLB download).
+ if (mv.dataset.src && !mv.getAttribute('src')) {
+ mv.setAttribute('src', mv.dataset.src);
+ delete mv.dataset.src;
+ }
+ if (mv.dataset.shouldRotate !== '0') mv.setAttribute('auto-rotate', '');
+ } else {
+ // Suspend rotation off-screen so model-viewer halts its raf loop.
+ mv.removeAttribute('auto-rotate');
+ }
+ }
+ },
+ { rootMargin: '200px 0px', threshold: 0.01 },
+ );
+ }
+ document.querySelectorAll('.market-card-avatar model-viewer, .market-grid model-viewer').forEach((mv) => {
+ if (mv.dataset.observed) return;
+ mv.dataset.observed = '1';
+ cardObserver.observe(mv);
+ });
}
// ── Avatar detail modal ──────────────────────────────────────────────────
@@ -518,34 +881,77 @@ function openAvatarModal(avatar) {
mv.setAttribute('exposure', '1.05');
mv.setAttribute('shadow-intensity', '0.7');
mv.setAttribute('tone-mapping', 'aces');
+ if (avatar.image) mv.setAttribute('poster', avatar.image);
+ mv.style.cssText = 'opacity:0;transition:opacity .3s ease;';
stage.appendChild(mv);
+ const progressEl = Object.assign(document.createElement('div'), { className: 'modal-load-progress' });
+ progressEl.innerHTML = '<div class="modal-load-bar-wrap"><div class="modal-load-bar" id="modal-load-bar"></div></div><span class="modal-load-label">Loading 3D…</span>';
+ stage.insertBefore(progressEl, mv);
+ mv.addEventListener('progress', (e) => {
+ const bar = document.getElementById('modal-load-bar');
+ if (bar) bar.style.width = Math.round((e.detail?.totalProgress || 0) * 100) + '%';
+ });
+ mv.addEventListener('load', () => { progressEl.remove(); mv.style.opacity = '1'; }, { once: true });
+
$('avatar-modal-title').textContent = avatar.name || 'Untitled avatar';
$('avatar-modal-desc').textContent =
- avatar.description ||
- 'A 3D avatar published to the community. You can use it as the visual identity for a new agent.';
+ avatar.description || 'A 3D avatar published to the community. Use it as the face of a new AI agent.';
+
+ let authorEl = document.getElementById('avatar-modal-author');
+ if (avatar.author?.handle) {
+ if (!authorEl) {
+ authorEl = Object.assign(document.createElement('p'), { id: 'avatar-modal-author', className: 'avatar-modal-author' });
+ $('avatar-modal-desc')?.insertAdjacentElement('afterend', authorEl);
+ }
+ authorEl.innerHTML = avatar.author.profileUrl
+ ? `by <a href="${escapeHtml(avatar.author.profileUrl)}" rel="author">${escapeHtml(avatar.author.displayName || avatar.author.handle)}</a>`
+ : `by ${escapeHtml(avatar.author.displayName || avatar.author.handle)}`;
+ } else if (authorEl) { authorEl.textContent = ''; }
const meta = $('avatar-modal-meta');
const pills = [];
+ if (avatar.featured) pills.push('<span class="stat-pill featured-badge">⭐ Featured</span>');
+ if (Number(avatar.viewCount) > 0) pills.push(`<span class="stat-pill">⊙ ${fmtNumber(avatar.viewCount)} views</span>`);
if (avatar.createdAt) pills.push(`<span class="stat-pill">${escapeHtml(liveTime(avatar.createdAt))}</span>`);
- if (avatar.has3d !== false) pills.push('<span class="stat-pill">3D · GLB</span>');
- (avatar.tags || []).slice(0, 4).forEach((t) => {
- pills.push(`<span class="stat-pill">#${escapeHtml(t)}</span>`);
+ pills.push('<span class="stat-pill">3D · GLB</span>');
+ (avatar.tags || []).slice(0, 5).forEach((t) => {
+ pills.push(`<button type="button" class="stat-pill tag-pill" data-tag="${escapeHtml(t)}" style="cursor:pointer">#${escapeHtml(t)}</button>`);
});
meta.innerHTML = pills.join('');
+ meta.querySelectorAll('[data-tag]').forEach((btn) => {
+ btn.addEventListener('click', () => { closeAvatarModal(); navTo(`/marketplace?tag=${encodeURIComponent(btn.dataset.tag)}`); });
+ });
- const view = $('avatar-modal-view');
- if (view) {
- view.href = avatar.viewerUrl || (avatar.glbUrl ? `/#model=${encodeURIComponent(avatar.glbUrl)}` : '#');
+ const bm = getAvatarBookmarks().has(avatar.avatarId || '');
+ const bmBtn = $('avatar-modal-bookmark');
+ if (bmBtn) {
+ bmBtn.classList.toggle('active', bm);
+ bmBtn.setAttribute('aria-pressed', String(bm));
+ bmBtn.onclick = () => {
+ const now = toggleAvatarBookmark(avatar.avatarId || '');
+ bmBtn.classList.toggle('active', now);
+ bmBtn.setAttribute('aria-pressed', String(now));
+ };
}
+
+ const view = $('avatar-modal-view');
+ if (view) view.href = avatar.viewerUrl || (avatar.glbUrl ? `/#model=${encodeURIComponent(avatar.glbUrl)}` : '#');
const dl = $('avatar-modal-download');
- if (dl) {
- dl.href = avatar.glbUrl || '#';
- dl.download = (avatar.slug || avatar.avatarId || 'avatar') + '.glb';
- }
+ if (dl) { dl.href = avatar.glbUrl || '#'; dl.download = (avatar.slug || avatar.avatarId || 'avatar') + '.glb'; }
overlay.hidden = false;
requestAnimationFrame(() => overlay.classList.add('show'));
+
+ // Fire-and-forget view tracking — server rate-limits per IP/avatar so safe to call on every open.
+ if (avatar.avatarId && !String(avatar.avatarId).startsWith('avatar_demo_')) {
+ fetch(`${API}/avatars/view`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ avatar_id: avatar.avatarId }),
+ keepalive: true,
+ }).catch(() => {});
+ }
}
function closeAvatarModal() {
@@ -564,6 +970,24 @@ function closeAvatarModal() {
}, 200);
}
+// ── Avatar bookmarks (localStorage) ─────────────────────────────────────
+
+const AVATAR_BOOKMARKS_KEY = 'mk_avatar_bm_v1';
+function getAvatarBookmarks() {
+ try { return new Set(JSON.parse(localStorage.getItem(AVATAR_BOOKMARKS_KEY) || '[]')); }
+ catch { return new Set(); }
+}
+function toggleAvatarBookmark(avatarId) {
+ const set = getAvatarBookmarks();
+ if (set.has(avatarId)) set.delete(avatarId); else set.add(avatarId);
+ try { localStorage.setItem(AVATAR_BOOKMARKS_KEY, JSON.stringify([...set])); } catch {}
+ document.querySelectorAll(`[data-avatar-id="${avatarId}"] .card-heart`).forEach((btn) => {
+ btn.classList.toggle('active', set.has(avatarId));
+ btn.setAttribute('aria-pressed', String(set.has(avatarId)));
+ });
+ return set.has(avatarId);
+}
+
async function startAgentFromAvatar() {
if (!activeAvatar) return;
const params = new URLSearchParams({ avatar_id: activeAvatar.avatarId || '' });
@@ -676,6 +1100,129 @@ function renderSkillCard(s) {
</div>`;
}
+
+// ── My Purchases tab ─────────────────────────────────────────────────────
+
+const purchasesState = { loaded: false, loading: false, items: [] };
+
+async function loadPurchases(force = false) {
+ if (purchasesState.loading) return;
+ if (purchasesState.loaded && !force) return renderPurchasesGrid();
+ purchasesState.loading = true;
+ const grid = $('purchases-grid');
+ if (grid) grid.innerHTML = renderSkeletons(4);
+ try {
+ const r = await fetch(`${API}/users/me/purchased-skills`, { credentials: 'include' });
+ if (r.status === 401) {
+ if (grid) grid.innerHTML = `<div class="market-empty-cta">
+ <h3>Sign in to see your purchases</h3>
+ <p>Your unlocked skills and trial access will appear here.</p>
+ <button id="purchases-signin">Sign in</button>
+ </div>`;
+ $('purchases-signin')?.addEventListener('click', () => {
+ location.href = `/login?next=${encodeURIComponent(location.pathname + location.search)}`;
+ });
+ purchasesState.loading = false;
+ return;
+ }
+ const j = await r.json().catch(() => ({}));
+ purchasesState.items = j?.data?.purchases || [];
+ purchasesState.loaded = true;
+ } catch (err) {
+ console.error('[marketplace] purchases load', err);
+ } finally {
+ purchasesState.loading = false;
+ }
+ renderPurchasesGrid();
+}
+
+function renderPurchasesGrid() {
+ const grid = $('purchases-grid');
+ const sub = $('purchases-subtitle');
+ if (!grid) return;
+ if (sub) {
+ sub.textContent = purchasesState.items.length
+ ? `${purchasesState.items.length} ${purchasesState.items.length === 1 ? 'purchase' : 'purchases'}`
+ : '';
+ }
+ if (!purchasesState.items.length) {
+ grid.innerHTML = `<div class="market-empty-cta">
+ <h3>No purchases yet</h3>
+ <p>Skills you purchase or trial access you unlock will appear here.</p>
+ <button id="purchases-browse">Browse Skills</button>
+ </div>`;
+ $('purchases-browse')?.addEventListener('click', () => navTo('/marketplace?tab=skills'));
+ return;
+ }
+ grid.innerHTML = purchasesState.items.map(renderPurchaseCard).join('');
+ grid.querySelectorAll('[data-purchase-agent]').forEach((card) => {
+ card.addEventListener('click', (e) => {
+ if (e.target.closest('.receipt-btn')) return;
+ navTo(`/marketplace/agents/${card.dataset.purchaseAgent}`);
+ });
+ });
+ grid.querySelectorAll('.receipt-btn').forEach((btn) => {
+ btn.addEventListener('click', (e) => {
+ e.stopPropagation();
+ downloadReceipt(btn.dataset.purchaseId);
+ });
+ });
+}
+
+function renderPurchaseCard(p) {
+ const agentName = escapeHtml(p.agent_name || 'Unknown Agent');
+ const skill = escapeHtml(p.skill);
+ const date = p.confirmed_at ? formatDate(p.confirmed_at) : formatDate(p.created_at);
+ const chainBadge = `<span class="stat-pill">${escapeHtml(p.chain || 'solana')}</span>`;
+ const isTrial = p.kind === 'trial' || p.status === 'trial';
+ const kindBadge = isTrial
+ ? `<span class="stat-pill" style="color:#86efac">Trial${p.trial_remaining != null ? ` (${p.trial_remaining} left)` : ''}</span>`
+ : `<span class="stat-pill" style="color:#7dd3fc">Owned</span>`;
+ const hasReceipt = !isTrial;
+ const thumb = p.agent_thumbnail
+ ? `<div class="avatar avatar-img" style="background-image:url('${escapeHtml(p.agent_thumbnail)}');width:36px;height:36px;border-radius:8px;flex-shrink:0"></div>`
+ : `<div class="avatar" style="width:36px;height:36px;border-radius:8px;flex-shrink:0;display:flex;align-items:center;justify-content:center;background:#1a1a1a;font-size:16px">${escapeHtml(initial(p.agent_name || '?'))}</div>`;
+ return `<div class="market-card-agent" data-purchase-agent="${escapeHtml(p.agent_id)}" style="cursor:pointer">
+ <div class="head">
+ ${thumb}
+ <div style="min-width:0;flex:1">
+ <div class="title">${agentName}</div>
+ <div class="author">${skill}</div>
+ </div>
+ </div>
+ <div class="stats">
+ ${kindBadge}
+ ${chainBadge}
+ <span class="stat-pill">${escapeHtml(date)}</span>
+ </div>
+ <div class="footer" style="justify-content:flex-end">
+ ${hasReceipt ? `<button class="btn-secondary receipt-btn" data-purchase-id="${escapeHtml(p.id)}" style="font-size:11px;padding:4px 10px">Receipt</button>` : ''}
+ <span class="open-cta">View agent →</span>
+ </div>
+ </div>`;
+}
+
+async function downloadReceipt(purchaseId) {
+ try {
+ const r = await fetch(`${API}/billing/receipts?purchase_id=${encodeURIComponent(purchaseId)}`, { credentials: 'include' });
+ if (!r.ok) {
+ const j = await r.json().catch(() => ({}));
+ alert(j.error_description || 'Receipt not available');
+ return;
+ }
+ const j = await r.json();
+ const blob = new Blob([JSON.stringify(j.data, null, 2)], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `receipt-${purchaseId.slice(0, 8)}.json`;
+ a.click();
+ URL.revokeObjectURL(url);
+ } catch (err) {
+ alert('Download failed: ' + err.message);
+ }
+}
+
// ── My Agents tab ────────────────────────────────────────────────────────
const mineState = { loaded: false, loading: false, items: [] };
@@ -744,7 +1291,7 @@ function renderSkeletons(n) {
return cards;
}
-function renderAvatarCard(a) {
+function renderAvatarCard(a, spotlight = false) {
const name = escapeHtml(a.name || 'Untitled avatar');
const desc = escapeHtml(a.description || '');
const when = a.createdAt ? liveTime(a.createdAt) : '';
@@ -756,15 +1303,19 @@ function renderAvatarCard(a) {
: `<span class="card-author muted">Anonymous</span>`;
const tags = (a.tags || []).slice(0, 3);
const tagPills = tags.length
- ? `<div class="card-tags">${tags.map((t) => `<span class="tag-pill">${escapeHtml(t)}</span>`).join('')}</div>`
+ ? `<div class="card-tags">${tags.map((t) => `<button type="button" class="tag-pill" data-tag="${escapeHtml(t)}" title="Filter by ${escapeHtml(t)}">${escapeHtml(t)}</button>`).join('')}</div>`
: '';
+ // Lazy GLB load: don't set `src` until the card scrolls into view (handled
+ // by observeCardModelViewers below). Each <model-viewer> instance still
+ // allocates a WebGL context, so we also stash the URL in `data-src` and
+ // the observer promotes it to `src` on intersect — no GLB download, no
+ // scene parse, no animation loop until the card is actually on screen.
const preview = a.image
? `<img src="${escapeHtml(a.image)}" alt="${name}" loading="lazy" decoding="async" />`
: a.glbUrl
? `<model-viewer
- src="${escapeHtml(a.glbUrl)}"
+ data-src="${escapeHtml(a.glbUrl)}"
alt="${name}"
- auto-rotate
rotation-per-second="14deg"
interaction-prompt="none"
disable-zoom
@@ -774,14 +1325,18 @@ function renderAvatarCard(a) {
shadow-intensity="0.4"
tone-mapping="aces"
loading="lazy"
- reveal="auto"
+ reveal="manual"
></model-viewer>`
: `<div class="thumb-fallback">◉</div>`;
- return `<div class="market-card-avatar" data-avatar-id="${escapeHtml(a.avatarId || '')}">
- <div class="thumb">${preview}</div>
+ const isSpotlight = spotlight || a.featured;
+ const spotlightBadge = isSpotlight ? '<span class="card-featured-badge" title="Spotlight">★</span>' : '';
+ const views = Number(a.viewCount) > 0 ? `<span class="stat-pill views" title="${a.viewCount} views">⊙ ${fmtNumber(a.viewCount)}</span>` : '';
+ const cardClasses = ['market-card-avatar', isSpotlight && 'market-card-avatar--featured'].filter(Boolean).join(' ');
+ return `<div class="${cardClasses}" data-avatar-id="${escapeHtml(a.avatarId || '')}">
+ <div class="thumb">${spotlightBadge}${preview}</div>
<div class="body">
<div class="title">${name}</div>
- <div class="byline">${authorLine}${when ? `<span class="dot">·</span><span class="when">${escapeHtml(when)}</span>` : ''}</div>
+ <div class="byline">${authorLine}${when ? `<span class="dot">·</span><span class="when">${escapeHtml(when)}</span>` : ''}${views ? `<span class="dot">·</span>${views}` : ''}</div>
${desc ? `<div class="desc">${desc}</div>` : ''}
${tagPills}
<div class="footer">
@@ -828,6 +1383,52 @@ function renderCard(a) {
</div>`;
}
+// ERC-8004 onchain agents — rendered as cards with chain badges, link to viewer.
+function renderOnchainCard(a) {
+ const name = escapeHtml(a.name || `Agent #${a.agentId}`);
+ const desc = escapeHtml(a.description || '');
+ const when = a.registeredAt ? liveTime(a.registeredAt) : '';
+ const chain = escapeHtml(a.chainShortName || a.chainName || `Chain ${a.chainId}`);
+ const ownerShort = a.ownerShort || '';
+ const x402 = a.x402Support ? `<span class="onchain-x402" title="Accepts x402 micropayments">x402</span>` : '';
+ const href = a.viewerUrl || a.tokenExplorerUrl || '#';
+ const preview = a.image
+ ? `<img src="${escapeHtml(a.image)}" alt="${name}" loading="lazy" decoding="async" />`
+ : a.glbUrl
+ ? `<model-viewer
+ src="${escapeHtml(a.glbUrl)}"
+ alt="${name}"
+ auto-rotate
+ rotation-per-second="14deg"
+ interaction-prompt="none"
+ disable-zoom
+ disable-pan
+ disable-tap
+ exposure="1"
+ shadow-intensity="0.4"
+ tone-mapping="aces"
+ loading="lazy"
+ reveal="auto"
+ ></model-viewer>`
+ : `<div class="thumb-fallback">⬡</div>`;
+ return `<div class="market-card-avatar onchain" data-onchain-href="${escapeHtml(href)}">
+ <div class="thumb">${preview}</div>
+ <div class="body">
+ <div class="title">${name}</div>
+ <div class="byline">
+ <span class="card-chain">${chain}</span>
+ ${ownerShort ? `<span class="dot">·</span><span class="card-author muted">${escapeHtml(ownerShort)}</span>` : ''}
+ ${when ? `<span class="dot">·</span><span class="when">${escapeHtml(when)}</span>` : ''}
+ </div>
+ ${desc ? `<div class="desc">${desc}</div>` : ''}
+ <div class="footer">
+ <span class="avatar-pill onchain">ERC-8004</span>
+ <span class="open-cta">${x402 || 'View →'}</span>
+ </div>
+ </div>
+ </div>`;
+}
+
// ── Detail view ───────────────────────────────────────────────────────────
let detailState = null;
@@ -929,7 +1530,8 @@ function renderDetailError(msg) {
$('d-published').textContent = '';
$('d-overview').textContent = '';
$('d-overview-side').textContent = '';
- $('d-greeting').textContent = '';
+ const thread = $('d-preview-thread');
+ if (thread) thread.innerHTML = '';
}
function renderDetail(a, bookmarked) {
@@ -938,24 +1540,28 @@ function renderDetail(a, bookmarked) {
const views = a.views_count ?? a.views ?? 0;
const forks = a.forks_count ?? a.forks ?? 0;
$('d-name').textContent = a.name || 'Untitled';
- const avEl = $('d-avatar');
- if (a.thumbnail_url) {
- avEl.style.backgroundImage = `url('${a.thumbnail_url}')`;
- avEl.style.backgroundSize = 'cover';
- avEl.style.backgroundPosition = 'center';
- avEl.textContent = '';
+ renderDetailAvatar(a);
+
+ const authorBtn = $('d-author');
+ authorBtn.textContent = author;
+ if (a.author_id) {
+ authorBtn.dataset.creatorId = a.author_id;
+ authorBtn.disabled = false;
+ authorBtn.style.cursor = 'pointer';
+ authorBtn.style.textDecoration = '';
} else {
- avEl.style.backgroundImage = '';
- avEl.textContent = initial(a.name);
+ delete authorBtn.dataset.creatorId;
+ authorBtn.disabled = true;
+ authorBtn.style.cursor = 'default';
+ authorBtn.style.textDecoration = 'none';
}
- $('d-author').textContent = author;
$('d-published').textContent = published ? formatDate(published) : '';
$('d-category').textContent = CATEGORY_LABELS[a.category] || a.category || 'General';
$('d-views').textContent = `⊙ ${fmtNumber(views)}`;
$('d-overview').textContent = a.description || '';
$('d-overview-side').textContent = a.description || '';
- $('d-greeting').textContent = a.greeting || `Hello! I am ${a.name}. How can I help you today?`;
$('d-profile').textContent = a.system_prompt || a.prompt || '(No profile yet.)';
+ startPreviewSession(a);
$('d-bookmark').classList.toggle('on', bookmarked);
$('d-bookmark').textContent = bookmarked ? '★' : '☆';
@@ -982,22 +1588,27 @@ function renderDetail(a, bookmarked) {
const name = typeof s === 'string' ? s : (s.name || '');
const price = skillPrices[name];
const purchaseKey = `${a.id}:${name}`;
-
+
let badge;
if (purchasedSkills.has(purchaseKey)) {
badge = `<span class="price-badge price-owned">✓ Owned</span>`;
} else if (price) {
const priceInUSDC = (price.amount / 1e6).toFixed(2);
+ const trialUses = price.trial_uses || 0;
+ const trialBtn = trialUses > 0
+ ? `<button class="trial-btn" data-skill-name="${escapeHtml(name)}" data-agent-id="${a.id}" data-trial-uses="${trialUses}">Try free (${trialUses} left)</button>`
+ : '';
badge = `<span class="price-badge price-paid">${priceInUSDC} USDC</span>` +
- `<button class="purchase-btn" data-skill-name="${escapeHtml(name)}" data-agent-id="${a.id}">Purchase</button>`;
+ `<button class="purchase-btn" data-skill-name="${escapeHtml(name)}" data-agent-id="${a.id}">Purchase</button>` +
+ trialBtn;
} else {
badge = `<span class="price-badge price-free">Free</span>`;
}
-
+
return `<div class="skill-row">
- <span class="skill-name">${escapeHtml(name)}</span>
- ${badge}
- </div>`;
+ <span class="skill-name">${escapeHtml(name)}</span>
+ ${badge}
+ </div>`;
}).join('')
: '<div>This Agent has no skills defined.</div>';
@@ -1139,7 +1750,16 @@ function bindEvents() {
state.sort = e.target.value;
loadList(true);
});
- els.loadMore.addEventListener('click', () => loadList(false));
+ els.loadMore.addEventListener('click', () => {
+ // Load whichever list has a cursor; onchain owns its own pagination cursor.
+ if (state.filter === 'onchain' && state.onchainCursor) {
+ loadOnchainAgents(false);
+ } else if (state.cursor) {
+ loadList(false);
+ } else if (state.onchainCursor) {
+ loadOnchainAgents(false);
+ }
+ });
els.back.addEventListener('click', () => navTo('/marketplace'));
$('d-fork').addEventListener('click', fork);
$('d-bookmark').addEventListener('click', toggleBookmark);
@@ -1160,6 +1780,11 @@ function bindEvents() {
const agentId = e.target.dataset.agentId;
if (agentId && skillName) await openPurchaseFlow(agentId, skillName);
}
+ if (e.target.matches('.trial-btn')) {
+ const skillName = e.target.dataset.skillName;
+ const agentId = e.target.dataset.agentId;
+ if (agentId && skillName) await openTrialFlow(agentId, skillName, e.target);
+ }
});
$('payment-modal-close')?.addEventListener('click', closePaymentModal);
@@ -1454,6 +2079,41 @@ function shortMintLabel(mint) {
return mint.slice(0, 4) + '…';
}
+
+async function openTrialFlow(agentId, skill, btn) {
+ if (!detailState?.agent || detailState.agent.id !== agentId) {
+ alert('Agent not loaded; refresh and try again.');
+ return;
+ }
+ if (btn) {
+ btn.disabled = true;
+ btn.textContent = 'Starting trial…';
+ }
+ try {
+ const r = await apiPostWithCsrf('/api/marketplace/start-trial', { agent_id: agentId, skill });
+ const j = await r.json().catch(() => ({}));
+ if (!r.ok) {
+ if (j.error === 'already_owned') {
+ alert('You already own this skill.');
+ } else if (j.error === 'trial_used') {
+ alert('You have already used the trial for this skill.');
+ } else {
+ alert(j.error_description || j.error || 'Failed to start trial');
+ }
+ return;
+ }
+ await fetchUserPurchases();
+ loadDetail(agentId);
+ } catch (err) {
+ alert(err.message || 'Failed to start trial');
+ } finally {
+ if (btn) {
+ btn.disabled = false;
+ btn.textContent = `Try free`;
+ }
+ }
+}
+
async function openPurchaseFlow(agentId, skill) {
if (!detailState?.agent || detailState.agent.id !== agentId) {
alert('Agent not loaded; refresh and try again.');
@@ -1663,7 +2323,8 @@ function render() {
(nav === 'avatars' && r.view === 'list' && r.filter === 'avatars') ||
(nav === 'tools' && r.view === 'tools') ||
(nav === 'skills' && r.view === 'skills') ||
- (nav === 'mine' && r.view === 'mine');
+ (nav === 'mine' && r.view === 'mine') ||
+ (nav === 'purchases' && r.view === 'purchases');
a.classList.toggle('active', active);
});
@@ -1677,8 +2338,16 @@ function render() {
if (state.publicAvatarsLoaded) renderGrid();
}
+ // Route-driven tag filter — re-render whenever ?tag= changes.
+ const newTag = r.tag ?? null;
+ if (newTag !== state.tag) {
+ state.tag = newTag;
+ renderGrid();
+ }
+
const skillsSec = $('market-skills-section');
const mineSec = $('market-mine');
+ const purchasesSec = $('market-purchases');
const discovery = els.discovery;
const tools = els.tools;
const detail = els.detail;
@@ -1691,12 +2360,14 @@ function render() {
setHidden(tools, true);
setHidden(skillsSec, true);
setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
setHidden(detail, false);
} else if (r.view === 'tools') {
setHidden(detail, true);
setHidden(discovery, true);
setHidden(skillsSec, true);
setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
setHidden(tools, false);
if (!pluginState.loaded) loadPlugins(true);
} else if (r.view === 'skills') {
@@ -1704,6 +2375,7 @@ function render() {
setHidden(discovery, true);
setHidden(tools, true);
setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
setHidden(skillsSec, false);
loadSkillsTab();
} else if (r.view === 'mine') {
@@ -1711,13 +2383,23 @@ function render() {
setHidden(discovery, true);
setHidden(tools, true);
setHidden(skillsSec, true);
+ setHidden(purchasesSec, true);
setHidden(mineSec, false);
loadMine();
+ } else if (r.view === 'purchases') {
+ setHidden(detail, true);
+ setHidden(discovery, true);
+ setHidden(tools, true);
+ setHidden(skillsSec, true);
+ setHidden(mineSec, true);
+ setHidden(purchasesSec, false);
+ loadPurchases();
} else {
setHidden(detail, true);
setHidden(tools, true);
setHidden(skillsSec, true);
setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
setHidden(discovery, false);
}
}
@@ -1726,6 +2408,7 @@ function init() {
bindEvents();
loadCategories();
loadList(true);
+ loadTheme();
initPlugins();
initWalletAdapter();
fetchUserPurchases();
diff --git a/vercel.json b/vercel.json
index 967053425..0e813a3c7 100644
--- a/vercel.json
+++ b/vercel.json
@@ -104,6 +104,10 @@
"src": "/api/billing/withdraw",
"dest": "/api/billing/withdraw"
},
+ {
+ "src": "/api/billing/receipts",
+ "dest": "/api/billing/receipts"
+ },
{
"src": "/api/newsletter/subscribe",
"dest": "/api/newsletter-subscribe"
@@ -256,6 +260,10 @@
"src": "/api/marketplace/agents/([^/]+)/([^/]+)",
"dest": "/api/marketplace/[action]?action=agents&id=$1&sub=$2"
},
+ {
+ "src": "/api/marketplace/start-trial",
+ "dest": "/api/marketplace/start-trial"
+ },
{
"src": "/api/marketplace/purchase/([^/]+)/confirm",
"dest": "/api/marketplace/purchase?reference=$1&op=confirm"
@@ -592,6 +600,20 @@
"src": "/api/avatars/presign",
"dest": "/api/avatars/[id]"
},
+ {
+ "src": "/api/avatars/view",
+ "dest": "/api/avatars/view"
+ },
+
+ {
+ "src": "/api/avatars/presign-thumbnail",
+ "dest": "/api/avatars/[id]"
+ },
+ {
+ "src": "/api/avatars/auto-tag",
+ "dest": "/api/avatars/[id]"
+ },
+
{
"src": "/api/avatars/public",
"dest": "/api/avatars/[id]"
@@ -1164,6 +1186,10 @@
"path": "/api/cron/cleanup-csrf-tokens",
"schedule": "17 * * * *"
},
+ {
+ "path": "/api/cron/process-withdrawals",
+ "schedule": "0 * * * *"
+ },
{
"path": "/api/cron/erc8004-crawl",
"schedule": "*/15 * * * *"