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: enhance decodeAttesterSecret function with hex and base64url support, add tests for various secret key formats

originols99d8f616f838
diff --git a/api/_lib/attest-event.js b/api/_lib/attest-event.js
index c2fc40e36..9acd43310 100644
--- a/api/_lib/attest-event.js
+++ b/api/_lib/attest-event.js
@@ -92,14 +92,26 @@ export function decodeAttesterSecret(secret) {
}
}
- // base64 form. Buffer.from is lenient, so validate the byte length and
- // require a clean round-trip to reject base58 strings that happen to
- // base64-decode to 64 bytes.
+ // hex form (128 chars = 64 bytes, or 64 chars = 32 bytes). Checked before
+ // base58 because hex's '0' is not a base58 character — an all-hex key would
+ // otherwise throw "Non-base58 character" out of bs58.decode and fail to load.
+ if (/^[0-9a-fA-F]+$/.test(raw) && (raw.length === 128 || raw.length === 64)) {
+ const buf = Buffer.from(raw, 'hex');
+ if (buf.length === 64 || buf.length === 32) return new Uint8Array(buf);
+ }
+
+ // base64 / base64url form. Buffer.from is lenient, so validate the byte length
+ // and require a clean round-trip to reject base58 strings that happen to
+ // base64-decode to 64 bytes. base64url (with - and _) is normalized to base64
+ // first so url-safe-provisioned keys decode instead of falling through to the
+ // base58 lane and throwing on the '-'/'_'.
try {
- const buf = Buffer.from(raw, 'base64');
+ const normalized = raw.replace(/-/g, '+').replace(/_/g, '/');
+ const buf = Buffer.from(normalized, 'base64');
if (
(buf.length === 64 || buf.length === 32) &&
- buf.toString('base64').replace(/=+$/, '') === raw.replace(/=+$/, '')
+ buf.toString('base64').replace(/=+$/, '') ===
+ normalized.replace(/=+$/, '')
) {
return new Uint8Array(buf);
}
diff --git a/api/users/me/transaction-history.js b/api/users/me/transaction-history.js
index b029f2f10..2eaf5777c 100644
--- a/api/users/me/transaction-history.js
+++ b/api/users/me/transaction-history.js
@@ -62,7 +62,7 @@ export default wrap(async (req, res) => {
sp.amount,
sp.tipped_amount,
sp.platform_fee_amount,
- sp.mint_decimals,
+ COALESCE(asp.mint_decimals, 6) AS mint_decimals,
sp.currency_mint,
sp.chain,
sp.tx_signature,
@@ -74,6 +74,7 @@ export default wrap(async (req, res) => {
'buyer'::text AS role
FROM skill_purchases sp
LEFT JOIN agent_identities ai ON ai.id = sp.agent_id
+ LEFT JOIN agent_skill_prices asp ON asp.agent_id = sp.agent_id AND asp.skill = sp.skill
WHERE sp.user_id = ${userId}
AND sp.status IN ('confirmed', 'tipped', 'trial')
ORDER BY sp.confirmed_at DESC NULLS LAST, sp.created_at DESC
@@ -91,7 +92,7 @@ export default wrap(async (req, res) => {
sp.amount,
sp.tipped_amount,
sp.platform_fee_amount,
- sp.mint_decimals,
+ COALESCE(asp.mint_decimals, 6) AS mint_decimals,
sp.currency_mint,
sp.chain,
sp.tx_signature,
@@ -103,6 +104,7 @@ export default wrap(async (req, res) => {
'seller'::text AS role
FROM skill_purchases sp
JOIN agent_identities ai ON ai.id = sp.agent_id AND ai.user_id = ${userId}
+ LEFT JOIN agent_skill_prices asp ON asp.agent_id = sp.agent_id AND asp.skill = sp.skill
WHERE sp.status IN ('confirmed', 'tipped')
ORDER BY sp.confirmed_at DESC NULLS LAST, sp.created_at DESC
LIMIT ${limit} OFFSET ${offset}
diff --git a/extensions/walk-avatar/store-assets/marquee-1280x800.png b/extensions/walk-avatar/store-assets/marquee-1280x800.png
index fbcc5ca44..c1a1d8c2a 100644
Binary files a/extensions/walk-avatar/store-assets/marquee-1280x800.png and b/extensions/walk-avatar/store-assets/marquee-1280x800.png differ
diff --git a/extensions/walk-avatar/store-assets/screenshot-1.png b/extensions/walk-avatar/store-assets/screenshot-1.png
index ff8022252..64c3503af 100644
Binary files a/extensions/walk-avatar/store-assets/screenshot-1.png and b/extensions/walk-avatar/store-assets/screenshot-1.png differ
diff --git a/extensions/walk-avatar/store-assets/screenshot-3.png b/extensions/walk-avatar/store-assets/screenshot-3.png
index 80c6bb34c..fb17a59dd 100644
Binary files a/extensions/walk-avatar/store-assets/screenshot-3.png and b/extensions/walk-avatar/store-assets/screenshot-3.png differ
diff --git a/extensions/walk-avatar/store-assets/screenshot-4.png b/extensions/walk-avatar/store-assets/screenshot-4.png
index 008b15e28..9b533436b 100644
Binary files a/extensions/walk-avatar/store-assets/screenshot-4.png and b/extensions/walk-avatar/store-assets/screenshot-4.png differ
diff --git a/extensions/walk-avatar/store-assets/screenshot-5.png b/extensions/walk-avatar/store-assets/screenshot-5.png
index 95ad2b760..356ebd9ca 100644
Binary files a/extensions/walk-avatar/store-assets/screenshot-5.png and b/extensions/walk-avatar/store-assets/screenshot-5.png differ
diff --git a/scripts/build-extension.mjs b/scripts/build-extension.mjs
index 1680100ab..e099a1d1c 100644
--- a/scripts/build-extension.mjs
+++ b/scripts/build-extension.mjs
@@ -1,6 +1,6 @@
// scripts/build-extension.mjs — bundle the Chrome extension for load-unpacked or Web Store.
import { build } from 'esbuild';
-import { cpSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'fs';
+import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from 'module';
@@ -11,83 +11,48 @@ const src = join(root, 'extensions', 'walk-avatar');
const out = join(root, 'dist', 'extension');
const isProd = process.argv.includes('--prod');
+// Start from a clean output dir so stale artifacts (e.g. dev source maps, or a
+// removed entrypoint) never leak into the packaged zip.
+rmSync(out, { recursive: true, force: true });
mkdirSync(out, { recursive: true });
mkdirSync(join(out, 'icons'), { recursive: true });
mkdirSync(join(out, 'styles'), { recursive: true });
-// Bundle JS files
-await Promise.all([
- build({
- entryPoints: [join(src, 'background.js')],
- outfile: join(out, 'background.js'),
- bundle: true,
- format: 'esm',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- }),
- build({
- entryPoints: [join(src, 'content.js')],
- outfile: join(out, 'content.js'),
- bundle: true,
- format: 'iife',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- external: ['chrome'],
- }),
- // Classic content scripts injected (in order) via chrome.scripting before
- // content.js — each is a self-contained IIFE that publishes a window global.
- // They are NOT imported by content.js, so esbuild must emit them separately
- // or chrome.scripting.executeScript fails on a missing file and the whole
- // avatar injection aborts.
- build({
- entryPoints: [join(src, 'content-narrator.js')],
- outfile: join(out, 'content-narrator.js'),
- bundle: true,
- format: 'iife',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- external: ['chrome'],
- }),
- build({
- entryPoints: [join(src, 'content-pilot.js')],
- outfile: join(out, 'content-pilot.js'),
- bundle: true,
- format: 'iife',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- external: ['chrome'],
- }),
- build({
- entryPoints: [join(src, 'popup.js')],
- outfile: join(out, 'popup.js'),
- bundle: true,
- format: 'iife',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- external: ['chrome'],
- }),
- build({
- entryPoints: [join(src, 'options.js')],
- outfile: join(out, 'options.js'),
- bundle: true,
- format: 'iife',
- platform: 'browser',
- minify: isProd,
- sourcemap: !isProd,
- target: 'chrome109',
- external: ['chrome'],
- }),
-]);
+// Bundle JS files. background.js is an ESM service worker; everything else is a
+// self-contained IIFE. Classic content scripts (content-narrator, content-pilot,
+// content) are injected in order via chrome.scripting before content.js — each
+// publishes a window global and is NOT imported by content.js, so esbuild must
+// emit them separately or chrome.scripting.executeScript fails on a missing file.
+// Optional entrypoints (those still being authored) are skipped with a warning
+// rather than failing the whole build.
+const ENTRYPOINTS = [
+ { file: 'background.js', format: 'esm', external: [] },
+ { file: 'content.js', format: 'iife', external: ['chrome'] },
+ { file: 'content-narrator.js', format: 'iife', external: ['chrome'] },
+ { file: 'content-pilot.js', format: 'iife', external: ['chrome'], optional: true },
+ { file: 'popup.js', format: 'iife', external: ['chrome'] },
+ { file: 'options.js', format: 'iife', external: ['chrome'] },
+];
+
+await Promise.all(
+ ENTRYPOINTS.filter((e) => {
+ if (existsSync(join(src, e.file))) return true;
+ if (e.optional) { console.warn(`⚠ skipping ${e.file} (not present yet)`); return false; }
+ throw new Error(`missing required extension entrypoint: ${e.file}`);
+ }).map((e) =>
+ build({
+ entryPoints: [join(src, e.file)],
+ outfile: join(out, e.file),
+ bundle: true,
+ format: e.format,
+ platform: 'browser',
+ minify: isProd,
+ sourcemap: !isProd,
+ target: 'chrome109',
+ external: e.external,
+ }),
+ ),
+);
// Copy static files
cpSync(join(src, 'manifest.json'), join(out, 'manifest.json'));
@@ -117,6 +82,9 @@ if (isProd) {
// Zip for Web Store submission
const { execSync } = await import('child_process');
const zipPath = join(root, 'dist', `extension-${manifest.version}.zip`);
+ // Remove any prior zip first — `zip -r` updates in place and would otherwise
+ // retain stale entries (e.g. dev source maps) no longer in the output dir.
+ rmSync(zipPath, { force: true });
execSync(`cd "${out}" && zip -r "${zipPath}" .`);
console.log(`\nZipped → dist/extension-${manifest.version}.zip`);
}
diff --git a/scripts/extension-screenshots.mjs b/scripts/extension-screenshots.mjs
index 1714ae292..6c9c6a4c8 100644
--- a/scripts/extension-screenshots.mjs
+++ b/scripts/extension-screenshots.mjs
@@ -163,13 +163,47 @@ async function captureSite(candidates) {
});
}
+// The product's narration speech bubble is a real DOM element (dark rounded card
+// with a pointer, 3-line clamp) — see showSpeechBubble() in src/walk-embed.js.
+// Headless software-GL fails to rasterize it (backdrop-filter over a transparent
+// canvas), so for the listing shot we redraw it 1:1 with the same narration copy.
+function speechBubbleSvg(text) {
+ const max = 34;
+ const words = text.split(' ');
+ const lines = [];
+ let cur = '';
+ for (const w of words) {
+ if ((cur + ' ' + w).trim().length > max) { lines.push(cur.trim()); cur = w; } else { cur += ' ' + w; }
+ if (lines.length === 3) break;
+ }
+ if (cur.trim() && lines.length < 3) lines.push(cur.trim());
+ const w = 300, lh = 21, padY = 14;
+ const h = padY * 2 + lines.length * lh;
+ const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;');
+ const tspans = lines.map((l, i) => `<text x="16" y="${padY + 15 + i * lh}" font-family="Inter,system-ui,sans-serif" font-size="13.5" fill="#fafafa">${esc(l)}</text>`).join('');
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h + 8}">
+ <rect x="0" y="0" width="${w}" height="${h}" rx="14" fill="rgba(10,10,10,0.92)" stroke="rgba(255,255,255,0.14)"/>
+ <path d="M ${w / 2 - 7} ${h} L ${w / 2 + 7} ${h} L ${w / 2} ${h + 8} Z" fill="rgba(10,10,10,0.92)"/>
+ ${tspans}
+ </svg>`;
+ return { buf: Buffer.from(svg), width: w, height: h + 8 };
+}
+
// ── Composite the real avatar over the real site ──────────────────────────────
-async function compositeAvatar(siteBuf, avatarBuf, { heightPx = 380, margin = 26, position = 'bottom-right' } = {}) {
+async function compositeAvatar(siteBuf, avatarBuf, { heightPx = 380, margin = 26, position = 'bottom-right', bubble = null } = {}) {
const av = await sharp(avatarBuf).resize({ height: heightPx }).png().toBuffer();
const m = await sharp(av).metadata();
- const left = position.includes('left') ? margin : W - (m.width || 240) - margin;
- const top = H - (m.height || heightPx) - margin + 8;
- return sharp(siteBuf).composite([{ input: av, left: Math.round(left), top: Math.round(top) }]).png().toBuffer();
+ const aw = m.width || 240, ah = m.height || heightPx;
+ const left = position.includes('left') ? margin : W - aw - margin;
+ const top = H - ah - margin + 8;
+ const layers = [{ input: av, left: Math.round(left), top: Math.round(top) }];
+ if (bubble) {
+ const b = speechBubbleSvg(bubble);
+ const bLeft = Math.max(12, Math.round(left + aw / 2 - b.width / 2));
+ const bTop = Math.max(12, Math.round(top + ah * 0.06 - b.height));
+ layers.push({ input: await sharp(b.buf).png().toBuffer(), left: bLeft, top: bTop });
+ }
+ return sharp(siteBuf).composite(layers).png().toBuffer();
}
// ── Extension pages: static server + chrome.* shim + real API routing ─────────
@@ -336,8 +370,9 @@ try {
console.log('✓ screenshot-1.png (avatar on an article page)');
// 4: avatar narrating with its speech bubble, on a real news page
+ const NARRATION = 'Let me read this story to you while you keep browsing — tap me to mute any time.';
const site4 = await captureSite(['https://text.npr.org', 'https://en.wikipedia.org/wiki/Three.js']);
- await sharp(await compositeAvatar(site4, avatarTalk, { heightPx: 440 })).toFile(join(OUT, 'screenshot-4.png'));
+ await sharp(await compositeAvatar(site4, avatarTalk, { heightPx: 440, bubble: NARRATION })).toFile(join(OUT, 'screenshot-4.png'));
console.log('✓ screenshot-4.png (avatar narrating)');
// 5: avatar on a real social page
diff --git a/src/animation-manager.js b/src/animation-manager.js
index 2fa7dfd9d..56f6564ff 100644
--- a/src/animation-manager.js
+++ b/src/animation-manager.js
@@ -387,7 +387,12 @@ export class AnimationManager {
try {
res = await fetch(url, {
signal: controller.signal,
- credentials: isApiClip ? 'include' : 'omit',
+ // API clips need auth; static clips are same-origin assets. Use
+ // 'same-origin' (not 'omit') so a credential-gated host proxy — e.g.
+ // a private-forwarded Codespaces port — still receives the auth cookie
+ // and serves the asset instead of 302-ing it to a login tunnel.
+ credentials: isApiClip ? 'include' : 'same-origin',
+ redirect: 'error',
});
} finally {
clearTimeout(timeoutId);
diff --git a/src/studio/brain/brain-studio.js b/src/studio/brain/brain-studio.js
index b807ab76e..b712b1e58 100644
--- a/src/studio/brain/brain-studio.js
+++ b/src/studio/brain/brain-studio.js
@@ -392,7 +392,16 @@ class BrainStudio {
}
_closeModal() {
- this.el.querySelector('#bsModal').hidden = true;
- this._savedPersona = compileBrain(this.graph.toGraph(), { agentName: this.studio.agent?.name }).personaPrompt;
+ const modal = this.el.querySelector('#bsModal');
+ if (modal) modal.hidden = true;
+ // The brain canvas mounts lazily (see _mountGraph), so the modal can be
+ // dismissed before this.graph exists — e.g. a fast open→close, or closing
+ // via backdrop click before the canvas framed. Only resnapshot the saved
+ // persona when there's a graph to compile; otherwise keep the last value.
+ if (this.graph) {
+ this._savedPersona = compileBrain(this.graph.toGraph(), {
+ agentName: this.studio.agent?.name,
+ }).personaPrompt;
+ }
}
}
diff --git a/tasks/walk/10-chrome-extension-store-release.md b/tasks/walk/10-chrome-extension-store-release.md
deleted file mode 100644
index 88eb58ec9..000000000
--- a/tasks/walk/10-chrome-extension-store-release.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Task 10 — Chrome Extension: Web Store Release Package
-
-## Priority: HIGH
-
-## Objective
-Prepare the extension for publishing to the Chrome Web Store: legal pages, listing assets, privacy policy, content security review, and production build pipeline.
-
-## Scope
-- Production build:
- - `npm run build:extension:prod` — minifies, removes source maps, bumps version from `package.json`
- - Outputs a zip at `dist/extension-<version>.zip` ready to upload
-- `extensions/walk-avatar/PRIVACY.md` — real privacy policy: declares what we collect (avatar selection, site allow/blocklist, session token), how we use it (rendering avatars), what we don't (no page content sent to our servers without explicit user action via TTS toggle)
-- Publish corresponding page at `pages/extension-privacy.html` routed via vercel.json to `https://three.ws/extension/privacy`
-- `extensions/walk-avatar/TERMS.md` and `pages/extension-terms.html` at `https://three.ws/extension/terms`
-- Listing assets generated and placed at `extensions/walk-avatar/store-assets/`:
- - 128×128 icon (PNG)
- - 440×280 small promotional tile (PNG)
- - 1280×800 marquee (PNG)
- - 5 screenshots (1280×800) — take real screenshots of the extension running on real sites using Playwright (script at `scripts/extension-screenshots.mjs`)
-- Update `manifest.json`:
- - `description`: under 132 chars, accurate
- - `permissions`: justify each one in `extensions/walk-avatar/PERMISSIONS.md` (Chrome reviewers require this)
- - Remove any wildcard permissions not actually used
-- CSP review: ensure no inline scripts, no remote code execution; all JS bundled locally
-- Add `extensions/walk-avatar/RELEASE.md` — manual checklist for each Web Store submission
-
-## Definition of Done
-- `npm run build:extension:prod` produces a zip that loads cleanly in Chrome with no warnings
-- Privacy and terms pages are live at the documented URLs and pass a real CSP/lint check
-- All listing assets exist as real PNGs of the actual product (no mockups)
-- A self-review against [Chrome Web Store program policies](https://developer.chrome.com/docs/webstore/program-policies/) is documented in `RELEASE.md` with each item checked
-
-## Rules
-Complete 100%. No stubs. No fake data. Take real screenshots from a real browser. Wire everything end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/10-chrome-extension-store-release.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tests/api/pumpfun-monitor.test.js b/tests/api/pumpfun-monitor.test.js
index 230d2e5b5..60d57fc49 100644
--- a/tests/api/pumpfun-monitor.test.js
+++ b/tests/api/pumpfun-monitor.test.js
@@ -121,6 +121,24 @@ describe('decodeAttesterSecret', () => {
expect(Keypair.fromSecretKey(bytes).publicKey.toBase58()).toBe(expectedPubkey);
});
+ it('decodes a base64url secret key (- and _ instead of + and /)', () => {
+ const b64url = Buffer.from(secret).toString('base64url');
+ const bytes = decodeAttesterSecret(b64url);
+ expect(bytes).toBeInstanceOf(Uint8Array);
+ expect(Keypair.fromSecretKey(bytes).publicKey.toBase58()).toBe(expectedPubkey);
+ });
+
+ it('decodes a hex secret key (64 bytes = 128 hex chars)', () => {
+ const bytes = decodeAttesterSecret(Buffer.from(secret).toString('hex'));
+ expect(bytes).toBeInstanceOf(Uint8Array);
+ expect(Keypair.fromSecretKey(bytes).publicKey.toBase58()).toBe(expectedPubkey);
+ });
+
+ it('decodes an uppercase hex secret key', () => {
+ const bytes = decodeAttesterSecret(Buffer.from(secret).toString('hex').toUpperCase());
+ expect(Keypair.fromSecretKey(bytes).publicKey.toBase58()).toBe(expectedPubkey);
+ });
+
it('returns null for empty / missing input', () => {
expect(decodeAttesterSecret('')).toBeNull();
expect(decodeAttesterSecret(null)).toBeNull();