Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
import { describe, it, expect } from 'vitest';
import {
buildModelName,
buildDescription,
buildTags,
promptDenyMatch,
showcaseLink,
DENY_SQL_PATTERN,
GLB_MAX_BYTES,
} from '../api/_lib/sketchfab.js';
describe('buildModelName', () => {
it('title-cases the first clause and strips the leading article', () => {
expect(buildModelName('a crystal dragon, perched on obsidian')).toBe('Crystal Dragon');
});
it('never exceeds the 48-char Sketchfab name limit and cuts on a word boundary', () => {
const name = buildModelName(
'an intricately detailed victorian steampunk locomotive with brass fittings everywhere',
);
expect(name.length).toBeLessThanOrEqual(48);
expect(name.endsWith(' ')).toBe(false);
// A word-boundary cut never ends mid-word relative to the source.
expect(name).toBe('Intricately Detailed Victorian Steampunk');
});
it('falls back sanely on empty input', () => {
expect(buildModelName('')).toBe('3D Model');
});
// The image-to-3D route stores its own name as the prompt. The accepted tier
// filters that sentinel out in SQL, but board winners and top-voted models skip
// the prompt-quality heuristics on purpose, so the sentinel reached the public
// name and the official account was one run away from publishing "Image-To-3d".
it('names a placeholder-prompt model from its category, not the placeholder', () => {
expect(buildModelName('image-to-3d', 'sci-fi vehicle')).toBe('Forged Sci-Fi Vehicle');
expect(buildModelName('Image-To-3D', 'avatar')).toBe('Forged Avatar');
expect(buildModelName('untitled', 'prop')).toBe('Forged Prop');
});
it('falls back to the generic name when a placeholder prompt has no useful category', () => {
expect(buildModelName('image-to-3d')).toBe('3D Model');
expect(buildModelName('image-to-3d', null)).toBe('3D Model');
// The live candidate that exposed this sat in the forge's catch-all bucket;
// "Forged Other" would have been no better a public name than the sentinel.
expect(buildModelName('image-to-3d', 'other')).toBe('3D Model');
expect(buildModelName('image-to-3d', 'Uncategorized')).toBe('3D Model');
});
it('leaves a real prompt that merely contains the placeholder words alone', () => {
expect(buildModelName('image-to-3d scanner rig on a tripod')).toBe(
'Image-To-3d Scanner Rig On A Tripod',
);
expect(buildModelName('test tube rack', 'lab')).toBe('Test Tube Rack');
});
});
describe('buildTags', () => {
it('always includes the AI disclosure tag first', () => {
expect(buildTags()[0]).toBe('createdwithai');
});
it('keeps the descriptive ai-generated tag for search', () => {
expect(buildTags()).toContain('ai-generated');
});
it('appends the model category as a slug', () => {
expect(buildTags('Sci-Fi Vehicle')).toContain('sci-fi-vehicle');
});
it('does not duplicate a category that matches a base tag', () => {
const tags = buildTags('threews');
expect(tags.filter((t) => t === 'threews')).toHaveLength(1);
});
});
describe('buildDescription', () => {
const base = { prompt: 'a crystal dragon', creationId: 'abc-123', source: 'board_winner' };
it('carries the prompt, AI disclosure, and both UTM backlinks', () => {
const desc = buildDescription(base);
expect(desc).toContain('Prompt: "a crystal dragon"');
expect(desc).toContain('AI-generated');
expect(desc).toContain('/forge/share/abc-123?utm_source=sketchfab');
expect(desc).toContain('/forge?utm_source=sketchfab');
expect(desc).toContain('utm_campaign=showcase');
});
it('names the curation source', () => {
expect(buildDescription(base)).toContain('Forge-Off winner');
expect(buildDescription({ ...base, source: 'top_voted' })).toContain('top-voted');
expect(buildDescription({ ...base, source: 'accepted' })).toContain('Curated pick');
});
it('clamps a huge prompt without ever losing the backlinks', () => {
const desc = buildDescription({ ...base, prompt: 'x'.repeat(5000) });
expect(desc.length).toBeLessThanOrEqual(1024);
expect(desc).toContain('/forge/share/abc-123?utm_source=sketchfab');
expect(desc).toContain('utm_campaign=showcase');
});
});
describe('showcaseLink', () => {
it('appends UTM params with ? on a bare path and & when a query exists', () => {
expect(showcaseLink('/forge')).toMatch(/\/forge\?utm_source=sketchfab/);
expect(showcaseLink('/viewer?src=x')).toMatch(/\/viewer\?src=x&utm_source=sketchfab/);
});
});
describe('promptDenyMatch (brand-safety gate)', () => {
it('blocks firearm and explicit prompts on word boundaries', () => {
expect(promptDenyMatch('Glock with a switch')).toBe('glock');
expect(promptDenyMatch('a futuristic RIFLE on a stand')).toBe('rifle');
expect(promptDenyMatch('nude figure study')).toBe('nude');
});
it('does not block safe prompts, including substring lookalikes', () => {
expect(promptDenyMatch('a crystal dragon')).toBeNull();
expect(promptDenyMatch('sussex county cottage')).toBeNull();
expect(promptDenyMatch('gunmetal grey sports car')).toBeNull();
});
it('keeps the SQL pattern in sync with the same term list', () => {
expect(DENY_SQL_PATTERN).toContain('glock');
expect(DENY_SQL_PATTERN).toMatch(/^\\m\(/);
});
});
describe('GLB_MAX_BYTES', () => {
it('stays under the Sketchfab basic-plan 50 MB cap', () => {
expect(GLB_MAX_BYTES).toBeLessThan(50 * 1024 * 1024);
});
});