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
feat(studio): enhance AR functionality with device-aware links and update responses
nirholasd3cff34aecab
diff --git a/api/3d/studio.js b/api/3d/studio.jsindex 9c3e880b2..4438607d1 100644--- a/api/3d/studio.js+++ b/api/3d/studio.js@@ -227,7 +227,7 @@ async function poll(req, res, jobId, title) {} catch {// A transient network blip on the self-call is not a job failure — tell the// caller it's still pending so its poll loop retries.- return json(res, 200, shapePoll({ status: 'running' }, base, jobId));+ return json(res, 200, shapePoll({ status: 'running' }, base, jobId, title));}const data = await upstream.json().catch(() => ({}));@@ -241,10 +241,10 @@ async function poll(req, res, jobId, title) {}if (!upstream.ok) {// Upstream hiccup mid-poll — keep the job alive as pending so the loop retries.- return json(res, 200, shapePoll({ status: 'running' }, base, jobId));+ return json(res, 200, shapePoll({ status: 'running' }, base, jobId, title));}- return json(res, 200, shapePoll(data, base, jobId));+ return json(res, 200, shapePoll(data, base, jobId, title));}export default wrap(async (req, res) => {@@ -258,7 +258,8 @@ export default wrap(async (req, res) => {if (!jobId) {return error(res, 400, 'missing_job', 'Pass ?job=<id> to poll a generation, or POST { prompt } to start one.');}- return poll(req, res, jobId);+ const title = (url.searchParams.get('title') || '').trim().slice(0, 120);+ return poll(req, res, jobId, title);});// The free NIM draft often finishes inside the submit window; startForge waits updiff --git a/api/_mcp-studio/component.js b/api/_mcp-studio/component.jsindex 6a3f12e3b..d346a44d6 100644--- a/api/_mcp-studio/component.js+++ b/api/_mcp-studio/component.js@@ -108,6 +108,8 @@ export const COMPONENT_HTML = `<!doctype html>a.btn:hover, button.btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.28); }a.btn:active, button.btn:active { transform: translateY(1px); }a.btn:focus-visible, button.btn:focus-visible { outline: 2px solid #6ea8fe; outline-offset: 2px; }+ a.btn.ar { color: #0b0c10; font-weight: 700; background: #6ea8fe; border-color: transparent; }+ a.btn.ar:hover { background: #83b5ff; border-color: transparent; }.hidden { display: none !important; }</style></head>@@ -142,6 +144,7 @@ export const COMPONENT_HTML = `<!doctype html><span id="kind" class="chip">model</span><span id="prompt" class="prompt"></span><div class="actions">+ <a id="arlink" class="btn ar hidden" target="_blank" rel="noopener noreferrer">View in your space</a><a id="open" class="btn" target="_blank" rel="noopener noreferrer">Open viewer</a><a id="download" class="btn" download>Download GLB</a></div>@@ -160,6 +163,7 @@ export const COMPONENT_HTML = `<!doctype html>var kindEl = document.getElementById('kind');var openEl = document.getElementById('open');var downloadEl = document.getElementById('download');+ var arEl = document.getElementById('arlink');var versionsEl = document.getElementById('versions');// Tracks whether the next model-viewer 'load' is a fresh render (show the@@ -220,6 +224,7 @@ export const COMPONENT_HTML = `<!doctype html>chip.classList.add('active');openEl.href = v.viewerUrl || v.glbUrl;downloadEl.href = v.glbUrl;+ if (v.arUrl) { arEl.href = v.arUrl; arEl.classList.remove('hidden'); }if (v.instruction) { promptEl.textContent = v.instruction; promptEl.title = v.instruction; }swapTo(v.glbUrl);});@@ -248,6 +253,11 @@ export const COMPONENT_HTML = `<!doctype html>else { promptEl.textContent = ''; }openEl.href = out.viewerUrl || glb;downloadEl.href = glb;+ // Device-aware AR launch (/api/ar): the same one-tap "place it in your+ // home" flow the forge site uses. ChatGPT opens it in the system browser,+ // where iPhone enters Quick Look and Android enters Scene Viewer.+ if (out.arUrl) { arEl.href = out.arUrl; arEl.classList.remove('hidden'); }+ else { arEl.classList.add('hidden'); }bar.classList.remove('hidden');renderVersions(out.lineage, glb);}diff --git a/api/_mcp-studio/tools.js b/api/_mcp-studio/tools.jsindex 7eacb965b..8bcfdbb58 100644--- a/api/_mcp-studio/tools.js+++ b/api/_mcp-studio/tools.js@@ -86,7 +86,9 @@ function ok({ glbUrl, base, kind, prompt, rigged }) {content: [{type: 'text',- text: `Generated a ${label} (GLB). View it: ${structured.viewerUrl}\nDownload: ${glbUrl}`,+ text:+ `Generated a ${label} (GLB). View it: ${structured.viewerUrl}\n` ++ `Place it in your room (AR, open on a phone): ${aUrl}\nDownload: ${glbUrl}`,},],structuredContent: structured,@@ -109,19 +111,22 @@ function toolError(message) {function refineOk({ glbUrl, base, prompt, instruction, lineage, activeIndex }) {glbUrl = firstPartyGlbUrl(glbUrl, base);const vUrl = viewerUrl(base, glbUrl);+ const aUrl = arLaunchUrl(base, glbUrl, instruction || prompt);const structured = {kind: 'refined model',glbUrl,viewerUrl: vUrl,+ arUrl: aUrl,format: 'glb',...(prompt ? { prompt } : {}),...(instruction ? { instruction } : {}),// Version chips swap GLBs inside the same sandboxed iframe, so every- // lineage URL needs the CDN form too.- lineage: summarizeLineage(lineage, activeIndex).map((v) => ({- ...v,- glbUrl: firstPartyGlbUrl(v.glbUrl, base),- })),+ // lineage URL needs the CDN form too — and its own AR launch link so the+ // Place-in-AR button tracks the selected version.+ lineage: summarizeLineage(lineage, activeIndex).map((v) => {+ const vGlb = firstPartyGlbUrl(v.glbUrl, base);+ return { ...v, glbUrl: vGlb, arUrl: arLaunchUrl(base, vGlb, v.instruction || prompt) };+ }),activeIndex,// Conformant Spatial MCP artifact (specs/SPATIAL_MCP.md) for the refined model.spatial: buildSpatialArtifact({ glbUrl, kind: 'model', viewerUrl: vUrl, prompt: prompt || undefined, title: instruction || undefined }),@@ -131,7 +136,9 @@ function refineOk({ glbUrl, base, prompt, instruction, lineage, activeIndex }) {content: [{type: 'text',- text: `Refined the model (v${versionNo}: "${instruction}"). View it: ${structured.viewerUrl}\nDownload: ${glbUrl}`,+ text:+ `Refined the model (v${versionNo}: "${instruction}"). View it: ${structured.viewerUrl}\n` ++ `Place it in your room (AR, open on a phone): ${aUrl}\nDownload: ${glbUrl}`,},],structuredContent: structured,