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
test(voice): repair the agent-voice suite against the BYOK key resolution it never mocked
nirholas4c95e61cf9c2
diff --git a/prompts/swarm-100/docs-batch-05.md b/prompts/swarm-100/docs-batch-05.mddeleted file mode 100644index 76b146069..000000000--- a/prompts/swarm-100/docs-batch-05.md+++ /dev/null@@ -1,100 +0,0 @@-# Docs audit batch 05: /docs/mocap-studio through /docs/genesis--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Confirm each path below still exists in data/pages.json; a path that was- removed there is out of scope (note it in the report, skip it).-2. Start (or reuse) the local dev server: npm run dev (vite, port 3000).-3. Probe production for each path:-- for p in /docs/mocap-studio /docs/selfie-to-avatar /docs/voice-lab /docs/lipsync /docs/talking-avatar-video /docs/galaxy /docs/ar-studio /docs/genesis; do printf '%s ' "$p"; curl -so /dev/null -w '%{http_code}\n' "https://three.ws$p"; done--## Task: audit this batch of docs pages, then fix everything found--Pages in this batch:--- /docs/mocap-studio ("Docs · Mocap Studio")-- /docs/selfie-to-avatar ("Docs · Selfie to Avatar")-- /docs/voice-lab ("Docs · Voice Lab")-- /docs/lipsync ("Docs · Lipsync")-- /docs/talking-avatar-video ("Docs · Talking Avatar Video")-- /docs/galaxy ("Docs · Agent Galaxy")-- /docs/ar-studio ("Docs · AR Studio")-- /docs/genesis ("Docs · Instant Agent Genesis")--For every page, in a real headless browser against localhost:--1. HTTP 200, zero console errors, zero unhandled failed requests.-2. Every link on the page resolves (internal paths exist in the route table;- anchors have targets). Fix or remove dead ones.-3. Content accuracy: the page documents current behavior. Spot-check its claims against the code it describes; where it names a command, run the command; where it shows a code sample, the sample must actually run. Fix stale claims in the same change.-4. Title tag and meta description present and specific.-5. Fix defects at their root and re-run until clean.--## Definition of done--- [ ] Every page in the batch loads locally with HTTP 200 and zero console- errors.-- [ ] Zero dead links across the batch.-- [ ] Every named command and code sample on these pages verified runnable, or corrected.-- [ ] Title and meta description verified on every page.-- [ ] npm run check:rules -- --paths <touched files> exits 0; npm test passes- if you touched code.-- [ ] Production status per page recorded in the report.--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |-| Playwright browser missing | npx playwright install chromium |-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |--## Close out (required)--1. Verify every Definition of done line with the actual command output in- front of you. Never claim a line you did not verify.-2. Commit with explicit paths and a subject that describes the diff (house- style: type(scope): what changed and why a reader cares).-3. Delete this prompt file in that same commit:-- git rm prompts/swarm-100/docs-batch-05.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/tests/api/agents-voice.test.js b/tests/api/agents-voice.test.jsindex f8fa1b4f6..1085951f2 100644--- a/tests/api/agents-voice.test.js+++ b/tests/api/agents-voice.test.js@@ -14,6 +14,10 @@ vi.mock('../../api/_lib/zauth.js', () => ({ instrument: () => false, drain: asynvi.mock('../../api/_lib/sentry.js', () => ({ captureException: () => {} }));vi.mock('../../api/_lib/csrf.js', () => ({ requireCsrf: vi.fn(async () => true) }));+// The stand-in for ELEVENLABS_API_KEY. Only its presence matters: no test+// asserts on the value, and no request leaves the process.+const PLATFORM_ELEVEN_KEY = 'test-platform-eleven-key';+// ── Shared mutable state ──────────────────────────────────────────────────────const state = {session: null,@@ -28,6 +32,10 @@ const state = {cloneThrowErr: null,rateLimitOk: true,creditsShort: false,+ // Encrypted ElevenLabs key stored on the agent owner, keyed by provider slug.+ // Null in every test here: these cover the platform lane, and the BYOK lane+ // has its own coverage.+ ownerProviderKeys: null,sqlQueue: [],};@@ -58,6 +66,16 @@ vi.mock('../../api/_lib/db.js', () => ({.replace(/\s+/g, ' ').trim();+ // The BYOK key lookup (api/_lib/agent-voice-key.js) runs alongside the+ // voice queries but is not part of any test's ordered expectation, so it+ // is answered here rather than allowed to consume a queued row and shift+ // every later result by one.+ if (q.startsWith('select') && q.includes('provider_keys') && q.includes('from users')) {+ return Promise.resolve(+ state.ownerProviderKeys ? [{ provider_keys: state.ownerProviderKeys }] : [],+ );+ }+if (state.sqlQueue.length) {const next = state.sqlQueue.shift();if (next instanceof Error) return Promise.reject(next);@@ -80,8 +98,23 @@ vi.mock('../../api/_lib/db.js', () => ({}));// ── ElevenLabs mock ───────────────────────────────────────────────────────────+// api/_lib/agent-voice-key.js imports elevenApiKey + resolveElevenKey from this+// module, so the factory has to export them even though the handler itself does+// not: vi.mock replaces the module for every importer in the graph, and a+// missing export makes that transitive import throw instead of resolving.vi.mock('../../api/_lib/elevenlabs.js', () => ({isConfigured: vi.fn(() => state.elevenConfigured),+ elevenApiKey: vi.fn(() => (state.elevenConfigured ? PLATFORM_ELEVEN_KEY : null)),+ // Mirrors the real precedence: a well-formed x-eleven-key header is BYOK and+ // wins, otherwise the platform key serves the request (or nothing does).+ resolveElevenKey: vi.fn((req) => {+ const raw = req?.headers?.['x-eleven-key'];+ const userKey = typeof raw === 'string' ? raw.trim() : '';+ if (userKey && userKey.length <= 256 && /^[\x21-\x7e]+$/.test(userKey)) {+ return { apiKey: userKey, byok: true };+ }+ return { apiKey: state.elevenConfigured ? PLATFORM_ELEVEN_KEY : null, byok: false };+ }),listVoices: vi.fn(async () => ({ voices: state.voices, cached: false })),createClonedVoice: vi.fn(async () => {if (state.cloneThrows)@@ -436,7 +469,11 @@ describe('POST /api/agents/:id/voice/clone', () => {];const { status } = await invoke('POST', VALID_AUDIO, { action: 'clone' });expect(status).toBe(500);- expect(vi.mocked(deleteVoice)).toHaveBeenCalledWith('cloned-1');+ // The rollback deletes on the same account the clone was created on, so+ // the credential travels with the call.+ expect(vi.mocked(deleteVoice)).toHaveBeenCalledWith('cloned-1', {+ apiKey: PLATFORM_ELEVEN_KEY,+ });expect(refundCreditsMock).toHaveBeenCalledWith(expect.objectContaining({ action: 'voice.clone', amountUsd: 0.5 }),);@@ -487,6 +524,10 @@ describe('DELETE /api/agents/:id/voice', () => {[],];await invoke('DELETE');- expect(vi.mocked(deleteVoice)).toHaveBeenCalledWith('my-clone');+ // A clone only exists inside the account that made it, so freeing the slot+ // has to name that account's key, not just the voice id.+ expect(vi.mocked(deleteVoice)).toHaveBeenCalledWith('my-clone', {+ apiKey: PLATFORM_ELEVEN_KEY,+ });});});