Skip to content

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.

chore(model-viewer): pin the cookbook pages to the single shipped build

nirholas86a1e7240a25
diff --git a/public/cookbook/self-correcting-3d/index.html b/public/cookbook/self-correcting-3d/index.html
index 70a7acb1a..14af9d9b5 100644
--- a/public/cookbook/self-correcting-3d/index.html
+++ b/public/cookbook/self-correcting-3d/index.html
@@ -8218,7 +8218,7 @@ grid; static views still see the models.</p>
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
-<div class="highlight hl-ipython3"><pre><span></span><span class="n">_MV</span> <span class="o">=</span> <span class="s2">"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js"</span>
+<div class="highlight hl-ipython3"><pre><span></span><span class="n">_MV</span> <span class="o">=</span> <span class="s2">"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"</span>
<span class="n">_CSS</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2">.twg{--panel:#141821;--line:#232838;--txt:#e7e9f0;--muted:#8b93a7;--accent:#8b7bf7;</span>
<span class="s2"> background:radial-gradient(1100px 380px at 18</span><span class="si">% -20%</span><span class="s2">,#1a1f2e 0%,#0b0d12 62%);</span>
@@ -8439,7 +8439,7 @@ the batch. Every model below was generated live by this cell.</p>
padding:3px 9px;border-radius:999px;transition:.15s;}
.twg .links a:hover{color:var(--txt);border-color:var(--accent);}
</style>
-<script src="https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js" type="module"></script>
+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>
<div class="head">
<span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling">// three.ws × function calling</span>
<h3 data-i18n="cookbook_index.a_wizard_s_study">A wizard's study</h3><p class="sub" data-i18n="cookbook_index.four_props_one_sentence_each_generated_on">Four props, one sentence each, generated on the free three.ws draft lane and rendered inline. Drag to orbit; tap AR on a phone.</p>
@@ -8756,7 +8756,7 @@ If you want:
padding:3px 9px;border-radius:999px;transition:.15s;}
.twg .links a:hover{color:var(--txt);border-color:var(--accent);}
</style>
-<script src="https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js" type="module"></script>
+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>
<div class="head">
<span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_2">// three.ws × function calling</span>
<h3 data-i18n="cookbook_index.a_windowsill_of_houseplants">A windowsill of houseplants</h3><p class="sub" data-i18n="cookbook_index.designed_and_built_by_the_model_from">Designed and built by the model from a single-line brief.</p>
@@ -9323,7 +9323,7 @@ human.</p>
padding:3px 9px;border-radius:999px;transition:.15s;}
.twg .links a:hover{color:var(--txt);border-color:var(--accent);}
</style>
-<script src="https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js" type="module"></script>
+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>
<div class="head">
<span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_3">// three.ws × function calling</span>
<h3 data-i18n="cookbook_index.a_windowsill_of_houseplants_after_qa">A windowsill of houseplants, after QA</h3><p class="sub" data-i18n="cookbook_index.every_prop_was_inspected_by_the_model">Every prop was inspected by the model; failures were rebuilt from the critic's own revised prompt.</p>
@@ -9526,7 +9526,7 @@ If you want variations (e.g., more weathering, different color palette, high-pol
padding:3px 9px;border-radius:999px;transition:.15s;}
.twg .links a:hover{color:var(--txt);border-color:var(--accent);}
</style>
-<script src="https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js" type="module"></script>
+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>
<div class="head">
<span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_4">// three.ws × function calling</span>
<h3 data-i18n="cookbook_index.a_deep_sea_explorer_s_cabin">A deep-sea explorer's cabin</h3><p class="sub" data-i18n="cookbook_index.art_directed_built_inspected_and_repaired_by">Art-directed, built, inspected, and repaired by the model from one sentence. Drag to orbit; tap AR on a phone.</p>
diff --git a/public/cookbook/text_to_3d_with_function_calling.ipynb b/public/cookbook/text_to_3d_with_function_calling.ipynb
index f17bf22e7..ecf508b05 100644
--- a/public/cookbook/text_to_3d_with_function_calling.ipynb
+++ b/public/cookbook/text_to_3d_with_function_calling.ipynb
@@ -357,7 +357,7 @@
"metadata": {},
"outputs": [],
"source": [
- "_MV = \"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js\"\n",
+ "_MV = \"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"\n",
"_CSS = \"\"\"\n",
".twg{--panel:#141821;--line:#232838;--txt:#e7e9f0;--muted:#8b93a7;--accent:#8b7bf7;\n",
" background:radial-gradient(1100px 380px at 18% -20%,#1a1f2e 0%,#0b0d12 62%);\n",
@@ -536,7 +536,7 @@
" padding:3px 9px;border-radius:999px;transition:.15s;}\n",
".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n",
"</style>\n",
- " <script type=\"module\" src=\"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js\"></script>\n",
+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",
" <div class=\"head\">\n",
" <span class=\"eyebrow\">// three.ws &times; function calling</span>\n",
" <h3>A wizard&#x27;s study</h3><p class=\"sub\">Four props, one sentence each, generated on the free three.ws draft lane and rendered inline. Drag to orbit; tap AR on a phone.</p>\n",
@@ -860,7 +860,7 @@
" padding:3px 9px;border-radius:999px;transition:.15s;}\n",
".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n",
"</style>\n",
- " <script type=\"module\" src=\"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js\"></script>\n",
+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",
" <div class=\"head\">\n",
" <span class=\"eyebrow\">// three.ws &times; function calling</span>\n",
" <h3>A windowsill of houseplants</h3><p class=\"sub\">Designed and built by the model from a single-line brief.</p>\n",
@@ -1340,7 +1340,7 @@
" padding:3px 9px;border-radius:999px;transition:.15s;}\n",
".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n",
"</style>\n",
- " <script type=\"module\" src=\"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js\"></script>\n",
+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",
" <div class=\"head\">\n",
" <span class=\"eyebrow\">// three.ws &times; function calling</span>\n",
" <h3>A windowsill of houseplants, after QA</h3><p class=\"sub\">Every prop was inspected by the model; failures were rebuilt from the critic&#x27;s own revised prompt.</p>\n",
@@ -1568,7 +1568,7 @@
" padding:3px 9px;border-radius:999px;transition:.15s;}\n",
".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n",
"</style>\n",
- " <script type=\"module\" src=\"https://unpkg.com/@google/model-viewer@^3.5.0/dist/model-viewer.min.js\"></script>\n",
+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",
" <div class=\"head\">\n",
" <span class=\"eyebrow\">// three.ws &times; function calling</span>\n",
" <h3>A deep-sea explorer&#x27;s cabin</h3><p class=\"sub\">Art-directed, built, inspected, and repaired by the model from one sentence. Drag to orbit; tap AR on a phone.</p>\n",
diff --git a/scripts/check-model-viewer-version.mjs b/scripts/check-model-viewer-version.mjs
index f1c35a2cb..c3b08ee17 100755
--- a/scripts/check-model-viewer-version.mjs
+++ b/scripts/check-model-viewer-version.mjs
@@ -31,8 +31,17 @@ import { execFileSync } from 'node:child_process';
const VENDORED = 'pages/ibm/vendor/model-viewer.min.js';
// Both URL shapes in use: Google's hosted path form and the npm CDN form.
+//
+// The version is captured as "everything up to the next path separator or
+// quote", NOT as \d+\.\d+\.\d+, so a semver RANGE is caught rather than
+// skipped. An earlier digits-only pattern silently ignored
+// `@google/model-viewer@^3.5.0` on the published cookbook page, which therefore
+// served 3.5.0 to real visitors for as long as the guard reported the tree
+// clean. A range is never a valid pin here anyway: the whole point is that every
+// surface loads one identical build, and `^3.5.0` resolves to whatever the CDN
+// last published. Anything that is not exactly the pinned version now fails.
const URL_RE =
- /(?:ajax\.googleapis\.com\/ajax\/libs\/model-viewer\/(\d+\.\d+\.\d+)|@google\/model-viewer@(\d+\.\d+\.\d+))/g;
+ /(?:ajax\.googleapis\.com\/ajax\/libs\/model-viewer\/([^/"'`\s]+)|@google\/model-viewer@([^/"'`\s]+))/g;
// Integrity is read per <script> TAG, never from a character window around the
// URL: pages routinely load model-viewer next to another SRI-pinned CDN script
// (highlight.js on /tutorial), and a window wide enough to reach the attribute
@@ -50,7 +59,21 @@ const SCANNED = /\.(js|mjs|cjs|jsx|ts|tsx|html|htm|md|json|svelte|vue|py|ipynb)$
// (a deliberately wrong version the harness writes to a temp file
// and expects us to reject). Reading it back as a real reference
// would make the guard fail on its own proof, forever.
-const SKIPPED = [/\/_generated\//, /\.min\.js$/, /^node_modules\//, /(^|\/)guards\.json$/];
+// this file the guard's own source spells the URL shapes it looks for, so
+// scanning itself would report its own regex as a reference.
+const SKIPPED = [
+ /\/_generated\//,
+ /\.min\.js$/,
+ /^node_modules\//,
+ /(^|\/)guards\.json$/,
+ /(^|\/)check-model-viewer-version\.mjs$/,
+];
+
+// A reference whose version is a template interpolation (`@google/model-viewer@
+// ${VERSION}`) IS the single-sourcing this guard exists to encourage: the value
+// comes from one constant. Read past it rather than reporting "${VERSION}" as a
+// rogue sixth version.
+const INTERPOLATED = /^\$\{/;
function trackedFiles() {
const listed = (args) => execFileSync('git', args, { encoding: 'utf8', maxBuffer: 1 << 28 }).split('\n');
@@ -81,6 +104,7 @@ for (const file of trackedFiles()) {
for (const match of text.matchAll(URL_RE)) {
const version = match[1] || match[2];
+ if (INTERPOLATED.test(version)) continue;
refs += 1;
if (!versions.has(version)) versions.set(version, new Set());
versions.get(version).add(file);
@@ -91,6 +115,7 @@ for (const file of trackedFiles()) {
const url = URL_RE.exec(tag);
if (!url) continue;
const version = url[1] || url[2];
+ if (INTERPOLATED.test(version)) continue;
const integrity = tag.match(INTEGRITY_RE)?.[1];
if (!integrity) continue;
if (!integrities.has(version)) integrities.set(version, new Map());