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.

feat: implement bounded-concurrency map for efficient RPC calls and add session capture script for live data

fudjia76fd4922c48f
diff --git a/robinhood/hood-api/Dockerfile b/robinhood/hood-api/Dockerfile
new file mode 100644
index 000000000..824d028ce
--- /dev/null
+++ b/robinhood/hood-api/Dockerfile
@@ -0,0 +1,26 @@
+# syntax=docker/dockerfile:1
+
+# ---- deps + build ----
+FROM node:22-slim AS build
+WORKDIR /app
+COPY package.json package-lock.json ./
+# Assumes `hoodchain` is published to npm (see README "Local development" for
+# the pre-publish alternative — a monorepo-context build that installs the
+# sibling SDK from source instead of the registry).
+RUN npm install --omit=dev
+COPY tsconfig.json ./
+COPY src ./src
+COPY scripts ./scripts
+RUN npm run build
+
+# ---- runtime (distroless, no shell, no package manager) ----
+FROM gcr.io/distroless/nodejs22-debian12 AS runtime
+WORKDIR /app
+ENV NODE_ENV=production
+# Cloud Run / most PaaS inject PORT; the app reads it via env.ts (default 8787).
+ENV PORT=8080
+COPY --from=build /app/dist ./dist
+COPY --from=build /app/node_modules ./node_modules
+COPY --from=build /app/package.json ./package.json
+EXPOSE 8080
+CMD ["dist/src/index.js"]
diff --git a/robinhood/hood-cli/scripts/capture-session.mjs b/robinhood/hood-cli/scripts/capture-session.mjs
new file mode 100644
index 000000000..d2d36d50d
--- /dev/null
+++ b/robinhood/hood-cli/scripts/capture-session.mjs
@@ -0,0 +1,73 @@
+#!/usr/bin/env node
+/**
+ * Capture a REAL terminal session against live Robinhood Chain mainnet data
+ * and write it to docs/session.json. The docs landing page's typewriter
+ * animation replays this file verbatim — it is never hand-authored output.
+ *
+ * Run: npm run build && npm run capture
+ */
+import { spawnSync } from 'node:child_process'
+import { writeFileSync, mkdtempSync, rmSync, existsSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const root = join(here, '..')
+const bin = join(root, 'dist', 'cli.js')
+
+if (!existsSync(bin)) {
+ console.error(`dist/cli.js not found — run "npm run build" first.`)
+ process.exit(1)
+}
+
+const workDir = mkdtempSync(join(tmpdir(), 'hood-cli-capture-'))
+const env = { ...process.env, HOOD_CONFIG_DIR: join(workDir, 'config'), FORCE_COLOR: '1' }
+
+const SCRIPT = [
+ { prompt: 'hood price AAPL', args: ['price', 'AAPL'] },
+ { prompt: 'hood stocks --sort premium --dex --limit 6', args: ['stocks', '--sort', 'premium', '--dex', '--limit', '6'] },
+ { prompt: 'hood launches --lookback 2000000 --limit 5 --names', args: ['launches', '--lookback', '2000000', '--limit', '5', '--names'] },
+ {
+ prompt: 'hood portfolio 0x9701fb0aDe1E269c8f64Ec0C7b3cfADB31A13A52',
+ args: ['portfolio', '0x9701fb0aDe1E269c8f64Ec0C7b3cfADB31A13A52'],
+ },
+ { prompt: 'hood swap --sell USDG --buy WETH --amount 250', args: ['swap', '--sell', 'USDG', '--buy', 'WETH', '--amount', '250'] },
+ {
+ prompt: 'hood tx 0x870a3bee3070f10e3c4f34271cfde70fd5aa0dc2eade6f07d01ae6c9a00285bd',
+ args: ['tx', '0x870a3bee3070f10e3c4f34271cfde70fd5aa0dc2eade6f07d01ae6c9a00285bd'],
+ },
+]
+
+console.log(`Capturing ${SCRIPT.length} real commands against Robinhood Chain mainnet…\n`)
+
+const frames = []
+for (const step of SCRIPT) {
+ process.stdout.write(`$ ${step.prompt}\n`)
+ const proc = spawnSync('node', [bin, ...step.args], { env, encoding: 'utf8', timeout: 60_000 })
+ if (proc.status !== 0) {
+ console.error(`\n✗ capture failed for "${step.prompt}" (exit ${proc.status})\n${proc.stderr}`)
+ rmSync(workDir, { recursive: true, force: true })
+ process.exit(1)
+ }
+ process.stdout.write(proc.stdout)
+ frames.push({ prompt: step.prompt, output: proc.stdout.replace(/\n$/, '') })
+}
+
+rmSync(workDir, { recursive: true, force: true })
+
+const outPath = join(root, 'docs', 'session.json')
+writeFileSync(
+ outPath,
+ JSON.stringify(
+ {
+ capturedAt: new Date().toISOString(),
+ chain: 'Robinhood Chain mainnet (4663)',
+ frames,
+ },
+ null,
+ 2,
+ ) + '\n',
+)
+
+console.log(`\n✓ Wrote ${frames.length} real frames to ${outPath}`)
diff --git a/robinhood/hood-cli/src/ui/ansi.ts b/robinhood/hood-cli/src/ui/ansi.ts
index 66b6ee2d6..8e3771fb9 100644
--- a/robinhood/hood-cli/src/ui/ansi.ts
+++ b/robinhood/hood-cli/src/ui/ansi.ts
@@ -1,13 +1,17 @@
/**
* Chalk-free ANSI styling. Small, dependency-free, and TTY-aware.
*
- * Colour is enabled only when stdout is a TTY, `NO_COLOR` is unset, and the
+ * Colour is enabled when stdout is a TTY, `NO_COLOR` is unset, and the
* terminal is not `dumb`. `--no-color` (or a non-TTY pipe) forces plain text,
- * so `hood ... --json | jq` and log files stay clean.
+ * so `hood ... --json | jq` and log files stay clean. `FORCE_COLOR=1`
+ * overrides the TTY check (the same convention chalk/supports-color use) —
+ * used by the docs session-capture script to record a colourised transcript
+ * from a piped subprocess.
*/
-let colorEnabled =
- !!process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb'
+let colorEnabled = process.env.FORCE_COLOR
+ ? process.env.FORCE_COLOR !== '0'
+ : !!process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb'
/** Force colour on or off (wired to the global `--no-color` flag). */
export function setColorEnabled(enabled: boolean): void {
diff --git a/workers/robinhood-feed/src/feed.js b/workers/robinhood-feed/src/feed.js
index 9a7f5d7a4..b3a336e2b 100644
--- a/workers/robinhood-feed/src/feed.js
+++ b/workers/robinhood-feed/src/feed.js
@@ -43,6 +43,20 @@ const ODYSSEY_FACTORIES = [
ODYSSEY_ADDRESSES.instantFactory,
];
+// Bounded-concurrency map — a backfill of hundreds of launches each needing a
+// metadata multicall must not run one-at-a-time (minutes of dead sequential
+// RPC latency) nor all-at-once (a request storm against a public RPC).
+async function mapLimit(items, limit, fn) {
+ let i = 0;
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
+ while (i < items.length) {
+ const idx = i++;
+ await fn(items[idx], idx);
+ }
+ });
+ await Promise.all(workers);
+}
+
/**
* Start the firehose.
* @param {(ev: { kind: 'launch'|'trade'|'graduation'|'status', data: object }) => void} onEvent
@@ -190,15 +204,20 @@ export function startFirehose(onEvent) {
}
// ── cold-start backfill: register existing pools + seed the replay buffer ───
+ //
+ // getRecentLaunches over a wide window can return hundreds of launches; the
+ // replay buffer only ever surfaces the newest `bufferLimit`, so fully
+ // resolving metadata for the rest is wasted RPC work that would otherwise
+ // serialize cold start for minutes. Every discovered pool is still tracked
+ // (cheap, synchronous) so live Uniswap swaps on older NOXA coins are caught;
+ // only the newest slice gets the full emit (metadata + ETH price + buffer).
async function backfill() {
try {
const launches = await getRecentLaunches(hood, { lookbackBlocks: config.backfillBlocks });
- // Oldest-first so the newest launch lands on top of the replay buffer.
- for (const l of launches) {
- if (l.pool) trackPool(l.pool, l.token);
- await emitLaunch(l);
- }
- onEvent({ kind: 'status', data: { level: 'info', src: 'backfill', launches: launches.length } });
+ for (const l of launches) if (l.pool) trackPool(l.pool, l.token);
+ const toEmit = launches.slice(-config.bufferLimit); // oldest-first input → newest last
+ await mapLimit(toEmit, 8, (l) => emitLaunch(l));
+ onEvent({ kind: 'status', data: { level: 'info', src: 'backfill', launches: launches.length, emitted: toEmit.length } });
} catch (err) {
onEvent({ kind: 'status', data: { level: 'warn', src: 'backfill', message: err?.message } });
}