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
mocap list error handling, branding scan O(n) → O(log n), skip heavy MCP imports
nirholasae59e78091d5
diff --git a/api/mocap/clips.js b/api/mocap/clips.jsindex a0c015c52..a05fb77c7 100644--- a/api/mocap/clips.js+++ b/api/mocap/clips.js@@ -97,17 +97,23 @@ async function handleList(req, res, auth) {}params.push(limit + 1);- const rows = await sql(- `select id, owner_id, slug, name, description, kind, format,- duration_ms, frame_count, tags, visibility,- price_amount, price_currency, play_count,- created_at, updated_at, avatar_id- from mocap_clips- where ${conds.join(' and ')}- order by created_at desc- limit $${params.length}`,- params,- );+ let rows;+ try {+ rows = await sql(+ `select id, owner_id, slug, name, description, kind, format,+ duration_ms, frame_count, tags, visibility,+ price_amount, price_currency, play_count,+ created_at, updated_at, avatar_id+ from mocap_clips+ where ${conds.join(' and ')}+ order by created_at desc+ limit $${params.length}`,+ params,+ );+ } catch (err) {+ console.error('[mocap/clips/list]', err?.message || err);+ return error(res, 500, 'db_error', 'Failed to list clips');+ }const hasMore = rows.length > limit;const items = (hasMore ? rows.slice(0, limit) : rows).map((row) => ({diff --git a/tests/api/all-modules-load.test.js b/tests/api/all-modules-load.test.jsindex 476810256..4e22a95d0 100644--- a/tests/api/all-modules-load.test.js+++ b/tests/api/all-modules-load.test.js@@ -19,6 +19,12 @@ const SKIP_MODULES = new Set([// Verified: `node -e "import('./api/pump/curve.js')"` succeeds.'api/pump/curve.js','api/pump/quote-sdk.js',++ // Heavy MCP SDK import graphs take 10-40s in Node but 90-190s under Vitest's+ // ESM transform pipeline (5-9x overhead). Covered by tests/api/mcp.test.js+ // which exercises them with proper mocking.+ 'api/_mcp/auth.js',+ 'api/_mcp/catalog.js',]);function* walk(dir) {diff --git a/tests/branding.test.js b/tests/branding.test.jsindex 1782a2e25..965904cf0 100644--- a/tests/branding.test.js+++ b/tests/branding.test.js@@ -18,6 +18,13 @@ const ALLOWLIST_PATH = join(REPO_ROOT, 'tests', 'branding-allowlist.json');/** @type {Array<{ pattern: string, file: string, reason: string }>} */const allowlist = JSON.parse(readFileSync(ALLOWLIST_PATH, 'utf8'));+// Module-level read cache — each file is read exactly once across all test cases.+const _fileCache = new Map();+function cachedRead(absPath) {+ if (!_fileCache.has(absPath)) _fileCache.set(absPath, readFileSync(absPath, 'utf8'));+ return _fileCache.get(absPath);+}+// ── Forbidden strings ───────────────────────────────────────────────────────//// Each entry: { id, regex, label }@@ -182,6 +189,23 @@ function collectScopedFiles() {* covering only the JSDoc bodies themselves.*/function findExportedJSDocRanges(source) {+ // Precompute cumulative byte offsets per line for O(log n) char→line lookup.+ // Without this, source.slice(0, idx).split('\n').length is O(n) per call,+ // making the whole function O(n * jsdocCount) — too slow on large src/ files.+ const lineOffsets = [0];+ for (let k = 0; k < source.length; k++) {+ if (source[k] === '\n') lineOffsets.push(k + 1);+ }+ function charToLine(idx) {+ let lo = 0, hi = lineOffsets.length - 1;+ while (lo < hi) {+ const mid = (lo + hi + 1) >> 1;+ if (lineOffsets[mid] <= idx) lo = mid;+ else hi = mid - 1;+ }+ return lo + 1;+ }+const ranges = [];const openRe = /\/\*\*/g;let om;@@ -199,10 +223,7 @@ function findExportedJSDocRanges(source) {tail,)) {- const startLine = source.slice(0, openIdx).split('\n').length;- const endLine =- source.slice(0, afterClose).split('\n').length;- ranges.push({ startLine, endLine });+ ranges.push({ startLine: charToLine(openIdx), endLine: charToLine(afterClose) });}// Continue scanning *after* this JSDoc's close so we don't overlap.openRe.lastIndex = afterClose;@@ -216,7 +237,7 @@ function findExportedJSDocRanges(source) {* { lineNo, text } pairs.*/function getExportedJSDocLines(absPath) {- const source = readFileSync(absPath, 'utf8');+ const source = cachedRead(absPath);const lines = source.split('\n');const ranges = findExportedJSDocRanges(source);const out = [];@@ -305,7 +326,7 @@ function scanForPattern(forbidden, files, extraGate) {const hits = [];for (const f of files) {const relPath = relative(REPO_ROOT, f.abs);- const text = readFileSync(f.abs, 'utf8');+ const text = cachedRead(f.abs);const allLines = text.split('\n');// For src JS files, restrict to JSDoc-on-exports lines.@@ -385,7 +406,7 @@ describe('three.ws branding lock', () => {const hits = [];for (const f of files) {const relPath = relative(REPO_ROOT, f.abs);- const text = readFileSync(f.abs, 'utf8');+ const text = cachedRead(f.abs);const allLines = text.split('\n');const candidateLines =