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
fix(examples): write the index atomically and stop the test clobbering shared state
nirholasa36efe88b473
diff --git a/robinhood/robinhood-chain-examples/docs/index.html b/robinhood/robinhood-chain-examples/docs/index.htmlindex f0d7bb8b6..9ba48825c 100644--- a/robinhood/robinhood-chain-examples/docs/index.html+++ b/robinhood/robinhood-chain-examples/docs/index.html@@ -15,13 +15,13 @@</div><div class="wrap"><h1>Robinhood Chain Examples</h1>-<p class="hero-sub">14 small, runnable projects for Robinhood Chain (mainnet 4663 / testnet 46630) —+<p class="hero-sub">14 small, runnable projects for Robinhood Chain (mainnet 4663 / testnet 46630):from a raw viem read to a live dashboard, a Telegram bot, and a paper trader. Every read below is real.</p><div class="embed-frame"><iframe src="embed/07-live-price-webpage.html" title="Live Robinhood Chain Stock Token prices" loading="lazy"></iframe><div class="embed-label">- <span>Example 07, running live — client-side JSON-RPC, no backend.</span>+ <span>Example 07, running live, client-side JSON-RPC, no backend.</span><a href="examples/07-live-price-webpage/index.html">How it works →</a></div></div>@@ -46,7 +46,7 @@ from a raw viem read to a live dashboard, a Telegram bot, and a paper trader. Ev<div class="num">01</div><div class="title">Read a stock price</div><div class="concept">viem only, no SDK</div>- <div class="proves">Robinhood Chain is a normal EVM L2 — viem ships its chain def, Chainlink feeds are a plain readContract.</div>+ <div class="proves">Robinhood Chain is a normal EVM L2: viem ships its chain def, Chainlink feeds are a plain readContract.</div><span class="badge Beginner">Beginner</span></a><a class="card" href="examples/02-stock-price-sdk/index.html">@@ -81,14 +81,14 @@ from a raw viem read to a live dashboard, a Telegram bot, and a paper trader. Ev<div class="num">06</div><div class="title">Sequencer firehose</div><div class="concept">Raw Nitro feed decoding</div>- <div class="proves">Transactions are visible ~100–300ms before they hit RPC, straight off the public feed socket.</div>+ <div class="proves">Transactions are visible ~100-300ms before they hit RPC, straight off the public feed socket.</div><span class="badge Advanced">Advanced</span></a><a class="card" href="examples/07-live-price-webpage/index.html"><div class="num">07</div><div class="title">Live price webpage</div><div class="concept">Client-side JSON-RPC</div>- <div class="proves">Read-only chain calls work from a static page — no backend, no build step, live on this gallery below.</div>+ <div class="proves">Read-only chain calls work from a static page with no backend, no build step, live on this gallery below.</div><span class="badge Beginner">Beginner</span></a><a class="card" href="examples/08-portfolio-dashboard/index.html">@@ -137,7 +137,7 @@ from a raw viem read to a live dashboard, a Telegram bot, and a paper trader. Ev<div class="num">14</div><div class="title">Agent paper trader</div><div class="concept">Strategy loop, simulated</div>- <div class="proves">A strategy loop is just getQuote on a timer — real execution slots in later without a rewrite.</div>+ <div class="proves">A strategy loop is just getQuote on a timer, and real execution slots in later without a rewrite.</div><span class="badge Intermediate">Intermediate</span></a></div>diff --git a/robinhood/robinhood-chain-examples/tools/build-docs.mjs b/robinhood/robinhood-chain-examples/tools/build-docs.mjsindex 277860dc7..22f24ef64 100644--- a/robinhood/robinhood-chain-examples/tools/build-docs.mjs+++ b/robinhood/robinhood-chain-examples/tools/build-docs.mjs@@ -1,6 +1,6 @@/*** Build-time docs generator. Renders every example's README.md to static- * HTML with syntax highlighting (marked + highlight.js, both server-side —+ * HTML with syntax highlighting (marked + highlight.js, both server-side,* no client-side markdown fetching), builds the gallery landing page from* the shared manifest, and copies example 07's self-contained page into* docs/ so it runs live, embedded, on GitHub Pages.@@ -139,7 +139,7 @@ async function buildGallery() {const num = String(i + 1).padStart(2, '0')const badge = ex.blocked ? '<span class="badge blocked">blocked</span>' : `<span class="badge ${ex.difficulty}">${ex.difficulty}</span>`const proves = ex.blocked- ? `Blocked on: <code>${ex.blocked}</code> (not built yet — see the README for the gap).`+ ? `Blocked on: <code>${ex.blocked}</code> (not built yet, see the README for the gap).`: ex.provesreturn `<a class="card" href="examples/${ex.id}/index.html"><div class="num">${num}</div>@@ -152,13 +152,13 @@ async function buildGallery() {const body = `<h1>Robinhood Chain Examples</h1>-<p class="hero-sub">14 small, runnable projects for Robinhood Chain (mainnet 4663 / testnet 46630) —+<p class="hero-sub">14 small, runnable projects for Robinhood Chain (mainnet 4663 / testnet 46630):from a raw viem read to a live dashboard, a Telegram bot, and a paper trader. Every read below is real.</p><div class="embed-frame"><iframe src="embed/07-live-price-webpage.html" title="Live Robinhood Chain Stock Token prices" loading="lazy"></iframe><div class="embed-label">- <span>Example 07, running live — client-side JSON-RPC, no backend.</span>+ <span>Example 07, running live, client-side JSON-RPC, no backend.</span><a href="examples/07-live-price-webpage/index.html">How it works →</a></div></div>diff --git a/robinhood/robinhood-chain-examples/tools/manifest.mjs b/robinhood/robinhood-chain-examples/tools/manifest.mjsindex 6f380b38e..e9b488e8c 100644--- a/robinhood/robinhood-chain-examples/tools/manifest.mjs+++ b/robinhood/robinhood-chain-examples/tools/manifest.mjs@@ -1,17 +1,17 @@// Shared example metadata for the docs gallery build.export const EXAMPLES = [- { id: '01-read-stock-price', title: 'Read a stock price', concept: 'viem only, no SDK', difficulty: 'Beginner', proves: 'Robinhood Chain is a normal EVM L2 — viem ships its chain def, Chainlink feeds are a plain readContract.' },+ { id: '01-read-stock-price', title: 'Read a stock price', concept: 'viem only, no SDK', difficulty: 'Beginner', proves: 'Robinhood Chain is a normal EVM L2: viem ships its chain def, Chainlink feeds are a plain readContract.' },{ id: '02-stock-price-sdk', title: 'Stock price with the SDK', concept: 'hoodchain basics', difficulty: 'Beginner', proves: 'hoodchain collapses example 01 to 3 lines and covers all 95 registry tokens.' },{ id: '03-portfolio-valuation', title: 'Portfolio valuation', concept: 'ERC-8056 multiplier math', difficulty: 'Intermediate', proves: 'The correct way to value Stock Token holdings without double-counting corporate actions.' },{ id: '04-swap-memecoin', title: 'Swap a token', concept: 'Uniswap v3 quote + execute', difficulty: 'Intermediate', proves: 'One code path quotes and (with a funded key) executes swaps on testnet and mainnet alike.' },{ id: '05-watch-launches', title: 'Watch launches', concept: 'NOXA + Odyssey event streams', difficulty: 'Intermediate', proves: 'Two different launchpad contract shapes decode into one Launch type.' },- { id: '06-firehose', title: 'Sequencer firehose', concept: 'Raw Nitro feed decoding', difficulty: 'Advanced', proves: 'Transactions are visible ~100–300ms before they hit RPC, straight off the public feed socket.' },- { id: '07-live-price-webpage', title: 'Live price webpage', concept: 'Client-side JSON-RPC', difficulty: 'Beginner', proves: 'Read-only chain calls work from a static page — no backend, no build step, live on this gallery below.' },+ { id: '06-firehose', title: 'Sequencer firehose', concept: 'Raw Nitro feed decoding', difficulty: 'Advanced', proves: 'Transactions are visible ~100-300ms before they hit RPC, straight off the public feed socket.' },+ { id: '07-live-price-webpage', title: 'Live price webpage', concept: 'Client-side JSON-RPC', difficulty: 'Beginner', proves: 'Read-only chain calls work from a static page with no backend, no build step, live on this gallery below.' },{ id: '08-portfolio-dashboard', title: 'Portfolio dashboard', concept: 'React + polling hook', difficulty: 'Intermediate', proves: 'A production-shaped dashboard (loading/empty/error states) is a thin wrapper over example 03.' },{ id: '09-x402-paid-api-call', title: 'Pay for an API call', concept: 'x402 client', difficulty: 'Advanced', proves: 'USDG has no EIP-2612 permit, so the gasless rail is EIP-3009 transferWithAuthorization: the payer signs, the server broadcasts.' },{ id: '10-x402-sell-your-api', title: 'Sell your API', concept: 'x402 server middleware', difficulty: 'Advanced', proves: 'Monetizing an endpoint is middleware, not architecture: one paywall() call, and a free route sits beside the paid one.' },{ id: '11-mcp-agent-session', title: 'MCP agent session', concept: 'Model Context Protocol', difficulty: 'Advanced', proves: 'The SDK, an MCP server, and an agent host are three layers over one chain, and read-only tools never share a process with spending ones.' },{ id: '12-telegram-price-bot', title: 'Telegram price bot', concept: 'grammY + hoodchain', difficulty: 'Intermediate', proves: 'A full user-facing bot is ~70 lines once the SDK does the chain work.' },{ id: '13-launch-a-coin-testnet', title: 'Launch a coin (testnet)', concept: 'Launchpad direct rail', difficulty: 'Advanced', proves: 'A launch is a pipeline, not a transaction: screening, ticker uniqueness, artwork, caps and a live preflight all clear before any ETH moves.' },- { id: '14-agent-paper-trader', title: 'Agent paper trader', concept: 'Strategy loop, simulated', difficulty: 'Intermediate', proves: 'A strategy loop is just getQuote on a timer — real execution slots in later without a rewrite.' },+ { id: '14-agent-paper-trader', title: 'Agent paper trader', concept: 'Strategy loop, simulated', difficulty: 'Intermediate', proves: 'A strategy loop is just getQuote on a timer, and real execution slots in later without a rewrite.' },]diff --git a/scripts/build-examples-index.mjs b/scripts/build-examples-index.mjsindex 7e274e843..bcc07968d 100644--- a/scripts/build-examples-index.mjs+++ b/scripts/build-examples-index.mjs@@ -17,10 +17,20 @@// command or URL that runs it. Descriptions come from the example's own README// or an HTML <title>/comment, never from a hand-kept list here.-import { readFileSync, writeFileSync, readdirSync, existsSync, statSync } from 'node:fs';+import { readFileSync, writeFileSync, readdirSync, existsSync, statSync, renameSync } from 'node:fs';import { join, relative, basename, dirname } from 'node:path';import { fileURLToPath } from 'node:url';+// Write through a temp file in the same directory, then rename. rename(2) is+// atomic on the same filesystem, so a reader (the page, a test, another agent+// in this shared worktree) always sees either the old file or the new one,+// never a half-written one.+function writeAtomic(path, contents) {+ const tmp = `${path}.tmp-${process.pid}`;+ writeFileSync(tmp, contents);+ renameSync(tmp, path);+}+const root = join(dirname(fileURLToPath(import.meta.url)), '..');const OUT = join(root, 'data/examples.json');@@ -275,7 +285,7 @@ const payload = {examples: entries,};-writeFileSync(OUT, `${JSON.stringify(payload, null, '\t')}\n`);+writeAtomic(OUT, `${JSON.stringify(payload, null, '\t')}\n`);// Mirror the same index into docs/examples.md between markers, so the doc's// inventory is regenerated rather than hand-kept. Everything outside the@@ -352,7 +362,7 @@ if (handWritten(next) < handWritten(doc)) {`would shrink from ${handWritten(doc)} to ${handWritten(next)} characters.`,);}-writeFileSync(DOC, next.endsWith('\n') ? next : `${next}\n`);+writeAtomic(DOC, next.endsWith('\n') ? next : `${next}\n`);console.log(`wrote data/examples.json + docs/examples.md index: ${payload.counts.total} examples ` +diff --git a/tests/examples-index.test.js b/tests/examples-index.test.jsindex a4a4c616c..05b52987d 100644--- a/tests/examples-index.test.js+++ b/tests/examples-index.test.js@@ -26,14 +26,20 @@ function handWrittenPart(text) {}describe('examples index generator', () => {- let original;+ // Running the generator rewrites two files other tests read (and other+ // agents share this worktree), so snapshot and restore both. The generator+ // itself writes atomically, so a concurrent reader never sees a torn file.+ let originalDoc;+ let originalJson;beforeEach(() => {- original = readFileSync(DOC, 'utf8');+ originalDoc = readFileSync(DOC, 'utf8');+ originalJson = existsSync(JSON_OUT) ? readFileSync(JSON_OUT, 'utf8') : null;});afterEach(() => {- writeFileSync(DOC, original);+ writeFileSync(DOC, originalDoc);+ if (originalJson !== null) writeFileSync(JSON_OUT, originalJson);});it('emits a machine-readable index whose entries all exist on disk', () => {