--- name: "advanced-visualization" description: "Build responsive, accessible calculators, comparisons, charts, and simulations with the sandbox contract." allowed-tools: [] --- # Interactive answer implementation Use this guidance after choosing a custom UI because it helps the task. Follow Jev’s renderer and visualization decision. A2UI handles basic tables; this sandbox handles charts, diagrams and custom interaction. Do not turn every answer into a dashboard. Use multiple sections when needed, including headings, assumptions, units, sources, and instructions inside the UI. ## Streaming and execution For generateSandboxedUi emit initialHeight, placeholderMessages, css, html, jsFunctions, jsExpressions in that exact order. The placeholder remains until css is complete; put all styles in the css parameter. Keep html meaningful before scripts run. jsFunctions holds named declarations; jsExpressions holds small synchronous invocations. There is no API to append expressions to prior calls. No localStorage, sessionStorage, cookies, IndexedDB, same-origin fetch, parent DOM, or invented service endpoints. The pre-injected importmap supports bare imports for three, gsap, d3, and chart.js. jsFunctions/jsExpressions are classic scripts; top-level await is invalid. Import inside an async function and handle failure: ```js async function setupScene() { const THREE = await import('three'); const { OrbitControls } = await import( "three/examples/jsm/controls/OrbitControls.js" ); // Create geometry, materials, lights, camera, controls, and a responsive renderer. } function showSetupError() { document.getElementById("status").textContent = "The visual could not load. Please retry."; } ``` A jsExpression can invoke `setupScene().catch(showSetupError);`. The html must include an initially readable explanation and an element with id="status". A `