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.

refactor: webhook hardening, MCP tool cleanup, and nav overhaul

nirholas0111642206d8
diff --git a/api/_lib/env.js b/api/_lib/env.js
index 36a4deba0..dc7747d3a 100644
--- a/api/_lib/env.js
+++ b/api/_lib/env.js
@@ -174,7 +174,21 @@ export const env = {
// internal notify webhook. Falls back to HOLDER_PASS_SECRET (already shared
// with the multiplayer process) so a single secret configures both gates.
get MULTIPLAYER_SHARED_SECRET() {
- return opt('MULTIPLAYER_SHARED_SECRET') || opt('HOLDER_PASS_SECRET') || 'dev-insecure-multiplayer-secret';
+ const s = opt('MULTIPLAYER_SHARED_SECRET') || opt('HOLDER_PASS_SECRET');
+ if (s) return s;
+ // Fail closed in production exactly like holder-pass.js / token/quote.js:
+ // this secret is the HMAC key for world-service auth tokens, presence
+ // tickets, and the internal notify webhook signature. Returning a publicly
+ // known constant would let anyone forge a `{svc:'world'}` service token
+ // (bypassing world-store permissions), forge presence tickets for any
+ // userId, and forge the notify webhook signature. Refuse rather than do that.
+ if (opt('NODE_ENV') === 'production' || opt('VERCEL_ENV') === 'production') {
+ throw new Error(
+ '[multiplayer] MULTIPLAYER_SHARED_SECRET (or HOLDER_PASS_SECRET) is required in production — ' +
+ 'refusing to sign world-service tokens and presence tickets with the dev secret.',
+ );
+ }
+ return 'dev-insecure-multiplayer-secret';
},
// Base URL of the multiplayer server's internal API, used to push live DMs /
// friend events to connected clients. Optional: when unset, delivery falls
diff --git a/api/_mcp3d/tools/studio.js b/api/_mcp3d/tools/studio.js
index 719bb6704..67413c5bf 100644
--- a/api/_mcp3d/tools/studio.js
+++ b/api/_mcp3d/tools/studio.js
@@ -7,6 +7,7 @@
// renders any public GLB the same way.
import { limits } from '../../_lib/rate-limit.js';
+import { assertSafePublicUrl } from '../../_lib/ssrf-guard.js';
import { createRegenProvider } from '../../_providers/replicate.js';
import { textToImage } from '../text-to-image.js';
import {
@@ -46,14 +47,14 @@ function regenProvider() {
}
}
-function isPublicHttpsUrl(s) {
+// Validate via the shared DNS-resolving SSRF guard: https-only, the hostname is
+// resolved and every A/AAAA record is checked against the full private/loopback/
+// link-local/ULA/IPv4-mapped/metadata blocklist (covering 172.16/12, [::1],
+// fc00::/7, fe80::/10, ::ffff: and decimal/hex IP encodings the old ad-hoc
+// prefix checks missed). Async because it performs DNS resolution.
+async function isPublicHttpsUrl(s) {
try {
- const u = new URL(String(s));
- if (u.protocol !== 'https:') return false;
- const h = u.hostname;
- if (h === 'localhost' || h === '127.0.0.1' || h === '0.0.0.0') return false;
- if (h.startsWith('169.254.') || h.startsWith('10.') || h.startsWith('192.168.')) return false;
- if (h.endsWith('.internal') || h.endsWith('.local')) return false;
+ await assertSafePublicUrl(String(s), { allowHttp: false });
return true;
} catch {
return false;
@@ -162,7 +163,7 @@ export const toolDefs = [
},
async handler(args, auth) {
await enforce(limits.mcp3dGenerate, auth);
- if (!isPublicHttpsUrl(args.image_url)) {
+ if (!(await isPublicHttpsUrl(args.image_url))) {
return {
content: [{ type: 'text', text: 'Error: image_url must be a public https URL.' }],
isError: true,
@@ -276,7 +277,7 @@ export const toolDefs = [
additionalProperties: false,
},
async handler(args) {
- if (!isPublicHttpsUrl(args.glb_url)) {
+ if (!(await isPublicHttpsUrl(args.glb_url))) {
return {
content: [{ type: 'text', text: 'Error: glb_url must be a public https URL.' }],
isError: true,
diff --git a/api/admin/news/[action].js b/api/admin/news/[action].js
index f8749eafc..e926a4f68 100644
--- a/api/admin/news/[action].js
+++ b/api/admin/news/[action].js
@@ -14,6 +14,8 @@ import { readFile, writeFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { json, error, method, cors, readJson, wrap } from '../../_lib/http.js';
+import { requireAdmin } from '../../_lib/admin.js';
+import { requireCsrf } from '../../_lib/csrf.js';
import { loadCuratedItems } from '../../_lib/rss-feed.js';
import { writeAllPages } from '../../../scripts/build-news.mjs';
import { syndicateAll, cmcCopyBlock } from '../../_lib/syndicate.js';
@@ -57,6 +59,33 @@ async function regeneratePages() {
return writeAllPages(items);
}
+// body_html is rich text written verbatim into the generated permalink pages
+// (scripts/build-news.mjs injects item.bodyHtml unescaped). Even though writes
+// now require an authenticated admin + CSRF, strip the active-content vectors so
+// a compromised admin session, a stored value, or a syndication round-trip can't
+// plant script execution / clickjacking into a public, cacheable page.
+function sanitizeBodyHtml(html) {
+ let out = String(html || '');
+ // Remove entire dangerous elements (open tag → close tag, case-insensitive).
+ out = out.replace(/<\s*(script|style|iframe|object|embed|form|link|meta|base)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi, '');
+ // Remove self-closing / unclosed variants of those same elements.
+ out = out.replace(/<\s*(script|style|iframe|object|embed|form|link|meta|base)\b[^>]*\/?>/gi, '');
+ // Strip inline event handlers (onclick=, onerror=, …) in both quoted and bare forms.
+ out = out.replace(/\son[a-z0-9_-]+\s*=\s*"[^"]*"/gi, '');
+ out = out.replace(/\son[a-z0-9_-]+\s*=\s*'[^']*'/gi, '');
+ out = out.replace(/\son[a-z0-9_-]+\s*=\s*[^\s">]+/gi, '');
+ // Neutralize javascript:/vbscript:/data: targets in href/src/srcset/xlink:href.
+ out = out.replace(
+ /((?:href|src|srcset|xlink:href|formaction)\s*=\s*)("|')\s*(?:javascript|vbscript|data)\s*:[^"']*\2/gi,
+ '$1$2#$2',
+ );
+ out = out.replace(
+ /((?:href|src|srcset|xlink:href|formaction)\s*=\s*)(?:javascript|vbscript|data)\s*:[^\s">]*/gi,
+ '$1#',
+ );
+ return out;
+}
+
function sanitizeImageFilename(name) {
const base = String(name || '').toLowerCase().replace(/[^a-z0-9._-]/g, '-').replace(/-+/g, '-').replace(/^-+|-+$/g, '');
if (!base) return '';
@@ -146,6 +175,7 @@ function sanitizeItem(input) {
err.code = 'invalid_item';
throw err;
}
+ out.body_html = sanitizeBodyHtml(out.body_html);
if (Array.isArray(out.tags)) {
out.tags = out.tags.filter((t) => typeof t === 'string' && t.trim()).map((t) => t.trim().toLowerCase());
}
@@ -158,12 +188,26 @@ function sanitizeItem(input) {
return out;
}
+// Mutating actions write files into the public web root, regenerate pages, and
+// fire external syndication — they require an admin session + a CSRF token.
+const MUTATING_ACTIONS = new Set(['save', 'delete', 'upload-image', 'resyndicate']);
+
export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: false })) return;
- if (refuseIfNotLocal(req, res)) return;
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: true })) return;
const action = String(req.query?.action || '').toLowerCase();
+ // Identity is the primary gate (independent of host / NODE_ENV), exactly like
+ // every other /api/admin/* route. refuseIfNotLocal stays below as
+ // defense-in-depth for the filesystem-write surface.
+ const admin = await requireAdmin(req, res);
+ if (!admin) return;
+ if (MUTATING_ACTIONS.has(action)) {
+ if (!(await requireCsrf(req, res, admin.id))) return;
+ }
+
+ if (refuseIfNotLocal(req, res)) return;
+
if (action === 'list') {
if (!method(req, res, ['GET'])) return;
const data = await readItemsFile();
diff --git a/api/pump/deliver-telegram.js b/api/pump/deliver-telegram.js
index 5ea85f486..c4d1d49c4 100644
--- a/api/pump/deliver-telegram.js
+++ b/api/pump/deliver-telegram.js
@@ -1,25 +1,79 @@
+// POST /api/pump/deliver-telegram
+//
+// Pushes a single pump.fun signal to a Telegram chat via the platform bot.
+// This drives the verified platform bot identity, so it is gated behind an
+// authenticated session OR a valid bearer token and rate-limited per-IP —
+// without that, anyone on the internet could turn the bot into a spam/phishing
+// relay (a direct server-to-server POST is not subject to browser CORS).
+
import { cors, error, json, method, readJson, wrap } from '../_lib/http.js';
+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { z } from 'zod';
+import { parse } from '../_lib/validate.js';
+
+const deliverSchema = z.object({
+ chatId: z.union([z.string().min(1).max(64), z.number().int()]),
+ signal: z.object({
+ kind: z.enum(['mint', 'whale', 'claim', 'graduation']),
+ mint: z.string().max(64).optional().default(''),
+ summary: z.string().max(2000).optional().default(''),
+ ts: z.number().optional(),
+ }),
+});
+
+// Escape text for Telegram's legacy `Markdown` parse_mode so attacker-supplied
+// summary/mint text can't inject markup or break out of the formatting (and so
+// it can't smuggle clickable links under the bot's identity). Legacy Markdown
+// treats _ * ` [ as control characters.
+function escapeMarkdown(text) {
+ return String(text).replace(/[_*`[]/g, '\\$&');
+}
function formatSignal(signal) {
const time = signal.ts ? new Date(signal.ts).toUTCString() : '';
- return `*${signal.kind?.toUpperCase() || 'SIGNAL'}* — \`${signal.mint || ''}\`\n${signal.summary || ''}\n${time}`;
+ const kind = escapeMarkdown((signal.kind || 'signal').toUpperCase());
+ const mint = escapeMarkdown(signal.mint || '');
+ const summary = escapeMarkdown(signal.summary || '');
+ return `*${kind}* — \`${mint}\`\n${summary}\n${escapeMarkdown(time)}`;
}
export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'POST,OPTIONS' })) return;
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
if (!method(req, res, ['POST'])) return;
+ // Authenticate: a signed-in session or a valid bearer token. This bot speaks
+ // under the platform's verified identity — never let an anonymous caller
+ // drive it.
+ let authed = false;
+ try {
+ const session = await getSessionUser(req);
+ if (session) authed = true;
+ } catch { /* fall through to bearer */ }
+ if (!authed) {
+ const token = extractBearer(req);
+ if (token) {
+ const bearer = await authenticateBearer(token).catch(() => null);
+ if (bearer) authed = true;
+ }
+ }
+ if (!authed) return error(res, 401, 'unauthorized', 'sign in or provide a valid bearer token');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many delivery requests');
+
const token = process.env.TELEGRAM_BOT_TOKEN;
if (!token) return error(res, 500, 'misconfigured', 'TELEGRAM_BOT_TOKEN is not set');
const body = await readJson(req).catch(() => null);
- if (!body?.chatId) return error(res, 400, 'validation_error', 'chatId required');
+ if (!body) return error(res, 400, 'validation_error', 'JSON body required');
+ const { chatId, signal } = parse(deliverSchema, body);
- const text = formatSignal(body.signal || {});
+ const text = formatSignal(signal);
const r = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ chat_id: body.chatId, parse_mode: 'Markdown', text }),
+ body: JSON.stringify({ chat_id: chatId, parse_mode: 'Markdown', text }),
});
const data = await r.json().catch(() => ({}));
diff --git a/api/webhooks/replicate.js b/api/webhooks/replicate.js
index 8397b5445..774cca861 100644
--- a/api/webhooks/replicate.js
+++ b/api/webhooks/replicate.js
@@ -14,8 +14,11 @@
// with `whsec_` — we strip it. The signing input is exactly `${id}.${timestamp}.${body}`
// joined with periods. Compare with timingSafeEqual.
//
-// If the key isn't set the endpoint accepts the payload but does NOT mark the
-// job as authenticated — useful in local dev. In production, set the env var.
+// If REPLICATE_WEBHOOK_SIGNING_KEY is unset the endpoint FAILS CLOSED in
+// production (401) — an unsigned webhook would otherwise let anyone who can
+// guess an ext_job_id spoof job completion and drive a server-side fetch of an
+// attacker-controlled URL (SSRF). The unsigned dev path is allowed only when
+// NODE_ENV !== 'production' AND ALLOW_UNSIGNED_WEBHOOKS=1 is explicitly set.
import { createHmac, timingSafeEqual } from 'node:crypto';
import { sql } from '../_lib/db.js';
@@ -55,6 +58,27 @@ function verifyStandardWebhook({ signingKey, id, timestamp, body, headerSig }) {
return false;
}
+// Replicate serves prediction outputs from its own delivery hosts. Pin the
+// fetched GLB URL to https on one of those hosts so a forged/compromised payload
+// can't point the server-side fetch at an internal/metadata endpoint (SSRF).
+const REPLICATE_RESULT_HOSTS = [
+ 'replicate.delivery',
+ 'replicate.com',
+ 'pbxt.replicate.delivery',
+];
+
+function isAllowedResultUrl(raw) {
+ let u;
+ try {
+ u = new URL(raw);
+ } catch {
+ return false;
+ }
+ if (u.protocol !== 'https:') return false;
+ const host = u.hostname.toLowerCase();
+ return REPLICATE_RESULT_HOSTS.some((h) => host === h || host.endsWith(`.${h}`));
+}
+
function extractGlbUrl(output) {
if (!output) return null;
if (typeof output === 'string') return output;
@@ -124,6 +148,14 @@ export default wrap(async (req, res) => {
if (!verified) {
return error(res, 401, 'invalid_signature', 'webhook signature mismatch');
}
+ } else {
+ // Fail closed: an unsigned webhook is forgeable (spoofed job completion +
+ // server-side SSRF fetch). Only accept it in dev when explicitly opted in.
+ const allowUnsigned =
+ process.env.NODE_ENV !== 'production' && process.env.ALLOW_UNSIGNED_WEBHOOKS === '1';
+ if (!allowUnsigned) {
+ return error(res, 401, 'unsigned_webhook', 'webhook signing key not configured');
+ }
}
let prediction;
@@ -170,6 +202,7 @@ export default wrap(async (req, res) => {
if (
nextStatus === 'done' &&
nextGlbUrl &&
+ isAllowedResultUrl(nextGlbUrl) &&
job.mode === 'reconstruct' &&
!job.result_avatar_id
) {
diff --git a/api/webhooks/solana-pay.js b/api/webhooks/solana-pay.js
index bc0cd5d27..9acb8411e 100644
--- a/api/webhooks/solana-pay.js
+++ b/api/webhooks/solana-pay.js
@@ -12,6 +12,7 @@
* a unique secret, so the surface is narrow; we still gate to avoid spammy
* DoS-via-confirm probes.
*/
+import { timingSafeEqual } from 'node:crypto';
import { sql } from '../_lib/db.js';
import { error, json, method, readJson, wrap } from '../_lib/http.js';
import { confirmSkillPurchase } from '../_lib/purchase-confirm.js';
@@ -20,7 +21,11 @@ function authOk(req) {
const secret = process.env.WEBHOOK_SECRET;
if (!secret) return false;
const header = req.headers?.authorization || '';
- return header === `Bearer ${secret}`;
+ // Constant-time compare so the static webhook secret can't be recovered via a
+ // timing side-channel (mirrors api/webhooks/replicate.js).
+ const expected = Buffer.from(`Bearer ${secret}`);
+ const provided = Buffer.from(header);
+ return expected.length === provided.length && timingSafeEqual(expected, provided);
}
export default wrap(async (req, res) => {
diff --git a/mcp-server/src/tools/agent-reputation.js b/mcp-server/src/tools/agent-reputation.js
index df5506f57..02cc85201 100644
--- a/mcp-server/src/tools/agent-reputation.js
+++ b/mcp-server/src/tools/agent-reputation.js
@@ -21,7 +21,8 @@
import { JsonRpcProvider, Contract, isAddress, ZeroAddress } from 'ethers';
import { z } from 'zod';
-import { paid } from '../payments.js';
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
const TOOL_NAME = 'agent_reputation';
const TOOL_DESCRIPTION =
@@ -177,28 +178,20 @@ async function readRecentEvents(provider, agentId) {
};
}
-const inputJsonSchema = {
- type: 'object',
- properties: {
- address: {
- type: 'string',
- description:
- 'ERC-8004 agentId (uint), EVM wallet address (0x...), or CAIP-10 "eip155:<chainId>:<wallet>".',
- },
- chain: {
- type: 'string',
- description: 'Chain to query (default: base). Accepts name or numeric chainId. Overridden by CAIP-10 input.',
- },
- },
- required: ['address'],
- additionalProperties: false,
-};
-
+// Single source of truth: Zod shape with descriptions; JSON Schema derived.
const inputZodShape = {
- address: z.string().min(1),
- chain: z.string().optional(),
+ address: z
+ .string()
+ .min(1)
+ .describe('ERC-8004 agentId (uint), EVM wallet address (0x...), or CAIP-10 "eip155:<chainId>:<wallet>".'),
+ chain: z
+ .string()
+ .describe('Chain to query (default: base). Accepts name or numeric chainId. Overridden by CAIP-10 input.')
+ .optional(),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
export async function buildAgentReputationTool() {
const handler = await paid(
{
@@ -228,15 +221,18 @@ export async function buildAgentReputationTool() {
if (!agentId) {
agentId = await resolveAgentId(provider, walletResolved);
if (!agentId) {
- return {
- chain: parsed.chain.name,
- chainId: parsed.chain.id,
- input: address,
- resolvedWallet: walletResolved,
- error: 'no_agent_registered_for_wallet',
- identityRegistry: IDENTITY_REGISTRY_MAINNET,
- reputationRegistry: REPUTATION_REGISTRY_MAINNET,
- };
+ return toolError(
+ 'no_agent_registered_for_wallet',
+ `no ERC-8004 agent is registered for ${walletResolved} on ${parsed.chain.name}`,
+ {
+ chain: parsed.chain.name,
+ chainId: parsed.chain.id,
+ input: address,
+ resolvedWallet: walletResolved,
+ identityRegistry: IDENTITY_REGISTRY_MAINNET,
+ reputationRegistry: REPUTATION_REGISTRY_MAINNET,
+ },
+ );
}
}
diff --git a/mcp-server/src/tools/pose-seed.js b/mcp-server/src/tools/pose-seed.js
index 14469458d..c0c897d2e 100644
--- a/mcp-server/src/tools/pose-seed.js
+++ b/mcp-server/src/tools/pose-seed.js
@@ -18,6 +18,7 @@ import { createHash } from 'node:crypto';
import { z } from 'zod';
import { paid } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
import { PRESETS, PRESET_GROUPS } from '../../../src/pose-presets.js';
const TOOL_NAME = 'get_pose_seed';
@@ -97,23 +98,20 @@ function deriveSeed(prompt, presetId) {
return createHash('sha256').update(`${prompt}|${presetId}`).digest('hex').slice(0, 16);
}
-const inputJsonSchema = {
- type: 'object',
- properties: {
- prompt: {
- type: 'string',
- description:
- 'Natural-language description of the pose, e.g. "warrior stance", "wave hello", "sitting cross-legged".',
- },
- },
- required: ['prompt'],
- additionalProperties: false,
-};
-
+// Single source of truth: declare the args once as a Zod shape (with the
+// human-facing descriptions + bounds), and derive the JSON Schema the MCP
+// client / bazaar sees from it. The previous hand-written JSON Schema had no
+// length bounds; the Zod (min 1, max 500) is stricter and now wins.
const inputZodShape = {
- prompt: z.string().min(1).max(500),
+ prompt: z
+ .string()
+ .min(1)
+ .max(500)
+ .describe('Natural-language description of the pose, e.g. "warrior stance", "wave hello", "sitting cross-legged".'),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
export async function buildPoseSeedTool() {
const handler = await paid(
{
diff --git a/mcp-server/src/tools/pump-snapshot.js b/mcp-server/src/tools/pump-snapshot.js
index 828110460..8280b8553 100644
--- a/mcp-server/src/tools/pump-snapshot.js
+++ b/mcp-server/src/tools/pump-snapshot.js
@@ -17,7 +17,8 @@
import { Connection, PublicKey } from '@solana/web3.js';
import { z } from 'zod';
-import { paid } from '../payments.js';
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
const TOOL_NAME = 'pump_snapshot';
const TOOL_DESCRIPTION =
@@ -170,24 +171,21 @@ async function getHeliusHolderCount(mint) {
}
}
-const inputJsonSchema = {
- type: 'object',
- properties: {
- token: {
- type: 'string',
- description: 'Solana SPL or pump.fun mint pubkey (base58).',
- minLength: 32,
- maxLength: 64,
- },
- },
- required: ['token'],
- additionalProperties: false,
-};
-
+// Single source of truth: Zod shape carries the base58 validity refinement AND
+// the length bounds/description; the JSON Schema is derived from it. (The
+// refine() predicate is the strict check; the min/max length bounds mirror the
+// previous hand-written JSON Schema so the bazaar still advertises them.)
const inputZodShape = {
- token: z.string().refine((v) => isValidSolanaPubkey(v), 'must be a base58 Solana pubkey'),
+ token: z
+ .string()
+ .min(32)
+ .max(64)
+ .refine((v) => isValidSolanaPubkey(v), 'must be a base58 Solana pubkey')
+ .describe('Solana SPL or pump.fun mint pubkey (base58).'),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
export async function buildPumpSnapshotTool() {
const handler = await paid(
{
@@ -207,7 +205,7 @@ export async function buildPumpSnapshotTool() {
},
async ({ token }) => {
if (!isValidSolanaPubkey(token)) {
- return { error: 'invalid_mint', token };
+ return toolError('invalid_mint', 'token must be a base58 Solana pubkey', { token });
}
const [price, ds, meta, holders, helius] = await Promise.all([
getJupiterPrice(token),
diff --git a/mcp-server/src/tools/sentiment-pulse.js b/mcp-server/src/tools/sentiment-pulse.js
index b1b8eb774..12fd59f61 100644
--- a/mcp-server/src/tools/sentiment-pulse.js
+++ b/mcp-server/src/tools/sentiment-pulse.js
@@ -12,7 +12,8 @@
import { z } from 'zod';
-import { paid } from '../payments.js';
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
const TOOL_NAME = 'sentiment_pulse';
const TOOL_DESCRIPTION =
@@ -25,39 +26,29 @@ function env(k, def) {
const SOLANA_MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
-const inputJsonSchema = {
- type: 'object',
- properties: {
- token: {
- type: 'string',
- description: 'Solana SPL or pump.fun mint pubkey (base58).',
- minLength: 32,
- maxLength: 44,
- },
- limit: {
- type: 'integer',
- minimum: 1,
- maximum: 200,
- default: 100,
- description: 'Max pump.fun comments to score.',
- },
- extraTexts: {
- type: 'array',
- items: { type: 'string', maxLength: 2000 },
- maxItems: 200,
- description: 'Extra text snippets to include (e.g. X posts you have already collected).',
- },
- },
- required: ['token'],
- additionalProperties: false,
-};
-
+// Single source of truth: Zod shape carries the base58 refinement + bounds +
+// descriptions; JSON Schema derived. (The previous JSON Schema declared a
+// `default: 100` on limit, which Zod cannot express as a JSON-Schema default
+// while keeping the field optional — the handler already treats an absent
+// limit as "use the endpoint default", so dropping the advertised default is
+// the correct, drift-free outcome.)
const inputZodShape = {
- token: z.string().refine((v) => SOLANA_MINT_RE.test(v), 'token must be a base58 Solana mint pubkey'),
- limit: z.number().int().min(1).max(200).optional(),
- extraTexts: z.array(z.string().max(2000)).max(200).optional(),
+ token: z
+ .string()
+ .min(32)
+ .max(44)
+ .refine((v) => SOLANA_MINT_RE.test(v), 'token must be a base58 Solana mint pubkey')
+ .describe('Solana SPL or pump.fun mint pubkey (base58).'),
+ limit: z.number().int().min(1).max(200).describe('Max pump.fun comments to score.').optional(),
+ extraTexts: z
+ .array(z.string().max(2000))
+ .max(200)
+ .describe('Extra text snippets to include (e.g. X posts you have already collected).')
+ .optional(),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
export async function buildSentimentPulseTool() {
const handler = await paid(
{
@@ -84,7 +75,7 @@ export async function buildSentimentPulseTool() {
body: JSON.stringify({ token, limit, extraTexts }),
});
} catch (err) {
- return { ok: false, error: 'upstream_unreachable', message: err?.message || 'fetch failed' };
+ return toolError('upstream_unreachable', err?.message || 'fetch failed');
}
const data = await res.json().catch(() => null);
if (!res.ok || !data || data.ok === false) {
diff --git a/mcp-server/src/tools/text-to-avatar.js b/mcp-server/src/tools/text-to-avatar.js
index 6ebb972e1..92a310c4b 100644
--- a/mcp-server/src/tools/text-to-avatar.js
+++ b/mcp-server/src/tools/text-to-avatar.js
@@ -26,7 +26,8 @@
import { z } from 'zod';
-import { paid } from '../payments.js';
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
const TOOL_NAME = 'text_to_avatar';
const TOOL_DESCRIPTION =
@@ -151,33 +152,21 @@ async function rehostIfRequested(glbUrl, { prompt, images }) {
}
}
-const inputJsonSchema = {
- type: 'object',
- properties: {
- prompt: {
- type: 'string',
- description: 'Natural-language description of the avatar to generate.',
- maxLength: 1000,
- },
- images: {
- type: 'array',
- description: 'Optional reference image URLs. When provided, the model performs image-to-3D reconstruction.',
- items: { type: 'string', format: 'uri' },
- maxItems: 4,
- },
- seed: { type: 'integer', minimum: 0, maximum: 2147483647 },
- texture: { type: 'boolean', description: 'Request PBR textures when supported (default true).' },
- },
- additionalProperties: false,
-};
-
+// Single source of truth: Zod shape carries descriptions + bounds; JSON Schema
+// derived. (No required fields — the handler enforces "prompt OR images".)
const inputZodShape = {
- prompt: z.string().max(1000).optional(),
- images: z.array(z.string().url()).max(4).optional(),
+ prompt: z.string().max(1000).describe('Natural-language description of the avatar to generate.').optional(),
+ images: z
+ .array(z.string().url())
+ .max(4)
+ .describe('Optional reference image URLs. When provided, the model performs image-to-3D reconstruction.')
+ .optional(),
seed: z.number().int().min(0).max(2147483647).optional(),
- texture: z.boolean().optional(),
+ texture: z.boolean().describe('Request PBR textures when supported (default true).').optional(),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
export async function buildTextToAvatarTool() {
const handler = await paid(
{
@@ -200,15 +189,13 @@ export async function buildTextToAvatarTool() {
async ({ prompt, images, seed, texture }) => {
const version = env('REPLICATE_TEXT_TO_AVATAR_MODEL');
if (!version) {
- return {
- ok: false,
- error: 'not_configured',
- message:
- 'REPLICATE_TEXT_TO_AVATAR_MODEL is not set on the MCP server. Pin a commercial-OK image/text-to-3D version (e.g. tencent/hunyuan-3d-3.1 latest).',
- };
+ return toolError(
+ 'not_configured',
+ 'REPLICATE_TEXT_TO_AVATAR_MODEL is not set on the MCP server. Pin a commercial-OK image/text-to-3D version (e.g. tencent/hunyuan-3d-3.1 latest).',
+ );
}
if (!prompt && (!images || images.length === 0)) {
- return { ok: false, error: 'invalid_input', message: 'Provide either prompt or images[].' };
+ return toolError('invalid_input', 'Provide either prompt or images[].');
}
const input = {
prompt: prompt || undefined,
@@ -224,7 +211,7 @@ export async function buildTextToAvatarTool() {
try {
submitted = await submitPrediction({ version, input });
} catch (err) {
- return { ok: false, error: err.code || 'provider_error', message: err.message };
+ return toolError(err.code || 'provider_error', err.message);
}
const timeoutMs = Number(env('MCP_TEXT_TO_AVATAR_TIMEOUT_MS', '110000'));
@@ -233,48 +220,37 @@ export async function buildTextToAvatarTool() {
try {
finalState = await pollPrediction(submitted.id, { timeoutMs, intervalMs });
} catch (err) {
- return {
- ok: false,
- error: err.code || 'provider_error',
- message: err.message,
+ return toolError(err.code || 'provider_error', err.message, {
predictionId: submitted.id,
- };
+ });
}
const durationMs = Date.now() - started;
if (finalState._timedOut) {
- return {
- ok: false,
- error: 'timeout',
- message: `prediction did not finish within ${timeoutMs}ms`,
+ return toolError('timeout', `prediction did not finish within ${timeoutMs}ms`, {
predictionId: submitted.id,
status: finalState.status,
resumeUrl: `${REPLICATE_BASE}/predictions/${submitted.id}`,
durationMs,
- };
+ });
}
if (finalState.status === 'failed' || finalState.status === 'canceled') {
- return {
- ok: false,
- error: 'prediction_failed',
- message: finalState.error || `prediction ended with status ${finalState.status}`,
- predictionId: submitted.id,
- durationMs,
- };
+ return toolError(
+ 'prediction_failed',
+ finalState.error || `prediction ended with status ${finalState.status}`,
+ { predictionId: submitted.id, durationMs },
+ );
}
const glbUrl = extractGlbUrl(finalState.output);
if (!glbUrl) {
- return {
- ok: false,
- error: 'no_glb_in_output',
- message: 'prediction succeeded but no GLB url was found in output',
+ return toolError('no_glb_in_output', 'prediction succeeded but no GLB url was found in output', {
rawOutput: finalState.output,
predictionId: submitted.id,
durationMs,
- };
+ });
}
const rehost = await rehostIfRequested(glbUrl, { prompt, images });
diff --git a/mcp-server/src/tools/vanity-grinder.js b/mcp-server/src/tools/vanity-grinder.js
index 9d8807da8..e2dfdb3f4 100644
--- a/mcp-server/src/tools/vanity-grinder.js
+++ b/mcp-server/src/tools/vanity-grinder.js
@@ -19,6 +19,7 @@
import { z } from 'zod';
import { paid } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
import { grindMintKeypair, estimateAttempts, BASE58_ALPHABET } from '../../../api/_lib/pump-vanity.js';
import bs58 from 'bs58';
@@ -50,43 +51,35 @@ const TOOL_DESCRIPTION =
`import it into a wallet immediately, and never reuse a key that may have been logged. ` +
`Billed via x402 \`exact\` (flat ${PRICE_USD} USDC on Solana).`;
-const inputJsonSchema = {
- type: 'object',
- properties: {
- prefix: {
- type: 'string',
- description: `Base58 prefix the address must start with. Allowed chars: ${BASE58_ALPHABET}. 1-6 chars (longer prefixes are exponentially harder and are rejected).`,
- minLength: 1,
- maxLength: 6,
- },
- suffix: {
- type: 'string',
- description: 'Optional base58 suffix the address must end with. 1-6 chars.',
- minLength: 1,
- maxLength: 6,
- },
- ignoreCase: {
- type: 'boolean',
- description: 'Case-insensitive match (folds upper+lower base58 chars).',
- },
- maxIterations: {
- type: 'integer',
- description: `Hard cap on grinder iterations. Default ${DEFAULT_MAX_ITERATIONS}, clamped to ${MAX_ITERATIONS_CAP}.`,
- minimum: 1,
- maximum: MAX_ITERATIONS_CAP,
- },
- },
- required: ['prefix'],
- additionalProperties: false,
-};
-
+// Single source of truth: Zod shape carries descriptions + bounds; JSON Schema
+// derived. Previously the JSON Schema and Zod both capped prefix/suffix at 6
+// chars and maxIterations at MAX_ITERATIONS_CAP — kept identical here.
const inputZodShape = {
- prefix: z.string().min(1).max(6),
- suffix: z.string().min(1).max(6).optional(),
- ignoreCase: z.boolean().optional(),
- maxIterations: z.number().int().min(1).max(MAX_ITERATIONS_CAP).optional(),
+ prefix: z
+ .string()
+ .min(1)
+ .max(6)
+ .describe(
+ `Base58 prefix the address must start with. Allowed chars: ${BASE58_ALPHABET}. 1-6 chars (longer prefixes are exponentially harder and are rejected).`,
+ ),
+ suffix: z
+ .string()
+ .min(1)
+ .max(6)
+ .describe('Optional base58 suffix the address must end with. 1-6 chars.')
+ .optional(),
+ ignoreCase: z.boolean().describe('Case-insensitive match (folds upper+lower base58 chars).').optional(),
+ maxIterations: z
+ .number()
+ .int()
+ .min(1)
+ .max(MAX_ITERATIONS_CAP)
+ .describe(`Hard cap on grinder iterations. Default ${DEFAULT_MAX_ITERATIONS}, clamped to ${MAX_ITERATIONS_CAP}.`)
+ .optional(),
};
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
// Up-front difficulty guard. Returns null if the request is feasible within the
// iteration cap, or a helpful Error (status 400) if the requested prefix/suffix
// is so hard it would grind to the cap and time out. Exported for tests.
diff --git a/pages/tutorials.html b/pages/tutorials.html
index 6ec55785a..4ba09dfa4 100644
--- a/pages/tutorials.html
+++ b/pages/tutorials.html
@@ -32,6 +32,7 @@
<link rel="stylesheet" href="/footer.css" />
<link rel="stylesheet" href="/fonts/fonts.css" />
<link rel="stylesheet" href="/mobile.css" />
+ <script defer src="/nav.js"></script>
<script defer src="/footer-newsletter.js"></script>
<script defer src="/tutorials-manifest.js"></script>
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>
@@ -405,69 +406,7 @@
<div class="cursor" id="cursor" aria-hidden="true"></div>
<a href="#main-content" class="h-skip-link">Skip to main content</a>
- <header>
- <h1>
- <a href="/" aria-label="three.ws home"
- ><img class="wordmark-logo" src="/three.svg" alt="" aria-hidden="true" /><span
- class="wordmark-dot"
- aria-hidden="true"
- ></span
- >three.ws</a
- >
- </h1>
- <nav class="home-nav" aria-label="Primary">
- <ul class="nav-root" role="menubar">
- <li class="nav-item nav-has-menu" role="none">
- <button type="button" class="nav-trigger" aria-haspopup="true" aria-expanded="false" role="menuitem">
- Build<span class="nav-caret" aria-hidden="true">▾</span>
- </button>
- <ul class="nav-menu" role="menu" aria-label="Build">
- <li role="none"><a href="/create" role="menuitem"><span class="nav-mi-title">Create agent</span><span class="nav-mi-sub">Avatar + brain wizard</span></a></li>
- <li role="none"><a href="/app" role="menuitem"><span class="nav-mi-title">Viewer</span><span class="nav-mi-sub">Drag-and-drop GLB</span></a></li>
- <li role="none"><a href="/validation" role="menuitem"><span class="nav-mi-title">glTF Validator</span><span class="nav-mi-sub">Khronos spec check</span></a></li>
- </ul>
- </li>
- <li role="none"><a href="/discover" role="menuitem">Discover</a></li>
- <li class="nav-item nav-has-menu" role="none">
- <button type="button" class="nav-trigger" aria-haspopup="true" aria-expanded="false" role="menuitem">
- Solana<span class="nav-caret" aria-hidden="true">▾</span>
- </button>
- <ul class="nav-menu" role="menu" aria-label="Solana">
- <li role="none"><a href="/pumpfun" role="menuitem"><span class="nav-mi-title">Pump.fun stream</span><span class="nav-mi-sub">Mint agent tokens</span></a></li>
- <li role="none"><a href="/vanity-wallet" role="menuitem"><span class="nav-mi-title">Vanity wallet</span><span class="nav-mi-sub">Grind a Solana address</span></a></li>
- <li role="none"><a href="/eth-vanity" role="menuitem"><span class="nav-mi-title">ETH vanity (CREATE2)</span><span class="nav-mi-sub">Grind a smart-contract address</span></a></li>
- <li role="none"><a href="/strategy-lab" role="menuitem"><span class="nav-mi-title">Strategy Lab</span><span class="nav-mi-sub">DCA + subscriptions</span></a></li>
- <li role="none"><a href="/pump-live" role="menuitem"><span class="nav-mi-title">Live launches</span><span class="nav-mi-sub">Real-time mint feed</span></a></li>
- <li role="none"><a href="/pump-dashboard" role="menuitem"><span class="nav-mi-title">Pump Dashboard</span><span class="nav-mi-sub">Watches · scanner · quotes</span></a></li>
- <li role="none"><a href="/docs#solana" role="menuitem"><span class="nav-mi-title">Solana SDK</span><span class="nav-mi-sub">Attestations + agent-kit</span></a></li>
- </ul>
- </li>
- <li class="nav-item nav-has-menu" role="none">
- <button type="button" class="nav-trigger" aria-haspopup="true" aria-expanded="false" role="menuitem">
- Embed<span class="nav-caret" aria-hidden="true">▾</span>
- </button>
- <ul class="nav-menu" role="menu" aria-label="Embed">
- <li role="none"><a href="/studio" role="menuitem"><span class="nav-mi-title">Widget Studio</span><span class="nav-mi-sub">Pick avatar → copy snippet</span></a></li>
- <li role="none"><a href="/artifact" role="menuitem"><span class="nav-mi-title">Artifact viewer</span><span class="nav-mi-sub">Claude artifact bundle</span></a></li>
- <li role="none"><a href="/docs#embedding" role="menuitem"><span class="nav-mi-title">Embed docs</span><span class="nav-mi-sub">iframe + oEmbed</span></a></li>
- <li role="none"><a href="/docs#web-component" role="menuitem"><span class="nav-mi-title">&lt;agent-3d&gt;</span><span class="nav-mi-sub">Web component reference</span></a></li>
- </ul>
- </li>
- <li class="nav-item" role="none"><a href="/marketplace" role="menuitem">Marketplace</a></li>
- <li class="nav-item" role="none"><a href="/chat" role="menuitem">Chat</a></li>
- <li class="nav-item" role="none"><a href="/tutorials" role="menuitem" aria-current="page">Tutorials</a></li>
- <li class="nav-item" id="home-nav-my-agents-li" role="none" hidden>
- <a href="/my-agents" id="home-nav-my-agents" role="menuitem">My Agents</a>
- </li>
- <li class="nav-item" id="home-nav-user-li" role="none" hidden>
- <a href="/dashboard" id="home-nav-user" class="nav-user" role="menuitem"></a>
- </li>
- <li class="nav-item" role="none">
- <a href="/login" class="nav-cta" id="home-nav-cta" role="menuitem">Get started</a>
- </li>
- </ul>
- </nav>
- </header>
+ <header><div id="nav-container"></div></header>
<main id="main-content">
<div class="tut-hero">
@@ -604,52 +543,6 @@
});
})();
- // Auth-aware nav CTA
- (function () {
- try {
- const raw = localStorage.getItem('3dagent:auth-hint');
- if (!raw) return;
- const { authed, name } = JSON.parse(raw);
- if (!authed) return;
- const cta = document.getElementById('home-nav-cta');
- if (cta) { cta.textContent = 'Dashboard'; cta.href = '/dashboard'; }
- const myAgentsLi = document.getElementById('home-nav-my-agents-li');
- if (myAgentsLi) myAgentsLi.hidden = false;
- const userLi = document.getElementById('home-nav-user-li');
- const userEl = document.getElementById('home-nav-user');
- if (userEl && userLi && name) { userEl.textContent = name; userLi.hidden = false; }
- } catch (_) {}
- })();
-
- // Dropdown nav
- (function () {
- const triggers = document.querySelectorAll('.home-nav .nav-trigger');
- if (!triggers.length) return;
- function closeAll(except) {
- triggers.forEach((t) => { if (t !== except) t.setAttribute('aria-expanded', 'false'); });
- }
- triggers.forEach((trigger) => {
- trigger.addEventListener('click', (e) => {
- e.stopPropagation();
- const open = trigger.getAttribute('aria-expanded') === 'true';
- closeAll(open ? null : trigger);
- trigger.setAttribute('aria-expanded', open ? 'false' : 'true');
- if (!open) trigger.nextElementSibling?.querySelector('a')?.focus();
- });
- const menu = trigger.nextElementSibling;
- if (!menu) return;
- menu.addEventListener('keydown', (e) => {
- const items = Array.from(menu.querySelectorAll('a'));
- const idx = items.indexOf(document.activeElement);
- if (e.key === 'ArrowDown') { e.preventDefault(); items[(idx + 1) % items.length]?.focus(); }
- else if (e.key === 'ArrowUp') { e.preventDefault(); items[(idx - 1 + items.length) % items.length]?.focus(); }
- else if (e.key === 'Escape') { trigger.setAttribute('aria-expanded', 'false'); trigger.focus(); }
- });
- });
- document.addEventListener('click', (e) => { if (!e.target.closest('.home-nav')) closeAll(null); });
- document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeAll(null); });
- })();
-
// ── Tutorial index renderer ─────────────────────────────────
function escapeHtml(s) {
return String(s).replace(/[&<>"']/g, (c) => ({
diff --git a/public/nav.css b/public/nav.css
index b64fe7634..8b3f668e3 100644
--- a/public/nav.css
+++ b/public/nav.css
@@ -1,783 +1,217 @@
-/* ── Shared nav styles for .home-nav (used wherever nav.js is loaded) ── */
-
-/* ── Site header: refined glass bar with a soft gradient hairline ───── */
-
-.site-header {
- position: relative;
- background: rgba(6, 6, 6, 0.82);
- backdrop-filter: blur(22px) saturate(120%);
- -webkit-backdrop-filter: blur(22px) saturate(120%);
- border-bottom: 1px solid rgba(255, 255, 255, 0.06);
- box-shadow:
- 0 1px 0 rgba(255, 255, 255, 0.03) inset,
- 0 8px 28px -16px rgba(0, 0, 0, 0.7);
- /* style.css sets `header { overflow-x: auto; overflow-y: hidden }` so the
- bar can scroll horizontally on narrow widths. That clips our dropdown
- menus below the header bottom edge. With the hamburger menu handling
- small viewports, the horizontal scroll guard is no longer needed —
- let menus paint outside the header. */
- overflow: visible;
- /* Promote the header above sticky/relative siblings (e.g. marketplace
- sidebar) so the dropdown z-index actually wins. */
- z-index: 10;
-}
-
-/* Soft gradient hairline that lives on top of the header's border —
- adds a tiny bit of color without screaming. */
-.site-header::after {
- content: '';
- position: absolute;
- left: 0;
- right: 0;
- bottom: -1px;
- height: 1px;
- background: linear-gradient(
- 90deg,
- transparent 0%,
- rgba(255, 255, 255, 0.15) 30%,
- rgba(255, 255, 255, 0.12) 55%,
- rgba(255, 255, 255, 0.08) 78%,
- transparent 100%
- );
- pointer-events: none;
- opacity: 0.55;
-}
-
-/* ── Brand ──────────────────────────────────────────────────────────── */
-
-.site-header-brand {
- position: relative;
-}
-
-.site-header-brand > a {
- display: inline-flex;
- align-items: center;
- gap: 0.6rem;
- border-radius: 10px;
- transition: filter 0.2s ease;
-}
-
-.site-header-brand .wordmark-logo {
- width: 28px;
- height: 28px;
- display: inline-block;
- vertical-align: middle;
- filter: drop-shadow(0 2px 12px rgba(255, 255, 255, 0.15));
- transition: filter 0.25s ease;
-}
-
-.site-header-brand > a:hover .wordmark-logo {
- filter: drop-shadow(0 2px 16px rgba(255, 255, 255, 0.25));
-}
-
-.site-header-brand .wordmark-dot {
- width: 7px;
- height: 7px;
- border-radius: 50%;
- background: #ffffff;
- box-shadow:
- 0 0 0 1px rgba(255, 255, 255, 0.2),
- 0 0 14px rgba(255, 255, 255, 0.5);
- display: inline-block;
- animation: brand-dot-pulse 3.4s ease-in-out infinite;
-}
-
-@keyframes brand-dot-pulse {
- 0%, 100% {
- box-shadow:
- 0 0 0 1px rgba(255, 255, 255, 0.2),
- 0 0 12px rgba(255, 255, 255, 0.4);
- }
- 50% {
- box-shadow:
- 0 0 0 1px rgba(255, 255, 255, 0.35),
- 0 0 18px rgba(255, 255, 255, 0.7);
- }
-}
-
-/* ── Home nav root ──────────────────────────────────────────────────── */
-
-/* Header sets line-height: var(--header-h) (56px) which leaks into every
- descendant text node — empty whitespace inside the nav wrapper expands
- flex items to 56px tall, distorting absolute-positioned dropdown
- anchors. Reset it here so nav and its menus lay out at content height. */
-#nav-container,
-.home-nav {
- line-height: 1.2;
-}
-
-/* The header is a flex row of <h1> + <div id="nav-container">. Default flex
- items shrink to content width, so on mobile the nav-container collapses to
- just the burger and clings to the h1 — making the burger appear mid-header
- and shoving the mobile menu's `right: 0` anchor off-screen to the left.
- Force the wrapper to absorb the remaining width so the burger sits at the
- right edge and the menu opens flush right. */
-#nav-container {
- flex: 1 1 auto;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- min-width: 0;
-}
-
-.home-nav {
- margin-left: auto;
- display: flex;
- align-items: center;
- gap: var(--space-lg, 1.5rem);
- -webkit-app-region: no-drag;
-}
-
-.home-nav a {
- color: rgba(244, 244, 248, 0.7);
- text-decoration: none;
- font-size: 0.92rem;
- font-weight: 500;
- letter-spacing: 0.005em;
- font-family: 'Space Grotesk', 'Inter', sans-serif;
- transition: color 0.2s ease;
-}
-
-.home-nav a:hover {
- color: #fff;
-}
-
-/* ── CTA — refined warm gradient with a soft ambient glow ──────────── */
-
-.home-nav .nav-cta {
- position: relative;
- display: inline-flex;
- align-items: center;
- padding: 0.5rem 1.15rem;
- background: #fff;
- color: #000;
- border-radius: 999px;
- font-weight: 600;
- font-size: 0.88rem;
- line-height: 1.2;
- letter-spacing: 0.01em;
- box-shadow:
- 0 1px 0 rgba(255, 255, 255, 0.35) inset,
- 0 6px 22px -8px rgba(255, 255, 255, 0.15),
- 0 0 0 1px rgba(255, 255, 255, 0.2);
- transition:
- transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
- box-shadow 0.25s ease,
- filter 0.25s ease;
-}
-
-/* Subtle shine sweep on hover */
-.home-nav .nav-cta::after {
- content: '';
- position: absolute;
- inset: 0;
- border-radius: inherit;
- background: linear-gradient(
- 120deg,
- transparent 0%,
- rgba(255, 255, 255, 0.4) 45%,
- transparent 65%
- );
- transform: translateX(-120%);
- transition: transform 0.6s ease;
- pointer-events: none;
-}
-
-.home-nav .nav-cta:hover {
- transform: translateY(-1px);
- box-shadow:
- 0 1px 0 rgba(255, 255, 255, 0.5) inset,
- 0 12px 28px -8px rgba(255, 255, 255, 0.2),
- 0 0 0 1px rgba(255, 255, 255, 0.35);
- color: #000;
-}
-
-.home-nav .nav-cta:hover::after {
- transform: translateX(120%);
-}
-
-/* ── User chip (signed-in name) ────────────────────────────────────── */
-
-.home-nav .nav-user {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 5px 12px;
- border-radius: 999px;
- border: 1px solid rgba(255, 255, 255, 0.1);
- background:
- linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
- font-size: 0.85rem;
- line-height: 1.2;
- color: rgba(255, 255, 255, 0.7);
- max-width: 140px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
-}
-
-.home-nav .nav-user::before {
- content: '';
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: #fff;
- box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
- flex-shrink: 0;
-}
-
-.home-nav .nav-user:hover {
- color: #fff;
- border-color: rgba(255, 255, 255, 0.22);
- background:
- linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
-}
-
-.home-nav a:focus-visible {
- outline: 2px solid rgba(255, 255, 255, 0.5);
- outline-offset: 3px;
- border-radius: 6px;
-}
-
-/* Active page indicator */
-.home-nav a[aria-current='page']:not(.nav-cta):not(.nav-user) {
- color: #fff;
- background: rgba(255, 255, 255, 0.08);
-}
-
-.home-nav a[aria-current='page']:not(.nav-cta):not(.nav-user)::after {
- left: 12px;
- right: 12px;
- opacity: 0.9;
-}
-
-/* ── Badges & pills ─────────────────────────────────────────────────── */
-
-.home-nav .nav-badge {
- display: inline-block;
- padding: 1px 6px;
- margin-left: 6px;
- background: #fff;
- color: #000;
- border-radius: 999px;
- font-size: 9px;
- font-weight: 700;
- letter-spacing: 0.08em;
- vertical-align: 1px;
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
-}
-
-.home-nav .nav-link-with-badge {
- display: inline-flex;
- align-items: center;
-}
-
-/* Subdued pill used on the Labs trigger — signals experimental without
- competing with the vivid "NEW" badge. */
-.home-nav .nav-pill {
- display: inline-block;
- padding: 1px 6px;
- margin-left: 6px;
- background: rgba(255, 255, 255, 0.06);
- color: rgba(255, 255, 255, 0.7);
- border: 1px solid rgba(255, 255, 255, 0.14);
- border-radius: 999px;
- font-size: 9px;
- font-weight: 600;
- letter-spacing: 0.08em;
- vertical-align: 1px;
-}
-
-.home-nav .nav-menu-labs {
- min-width: 280px;
-}
-
-.home-nav .nav-menu-note {
- padding: 8px 12px 10px;
- margin-bottom: 4px;
- border-bottom: 1px solid rgba(255, 255, 255, 0.06);
- color: rgba(255, 255, 255, 0.5);
- font-size: 0.72rem;
- line-height: 1.4;
- letter-spacing: 0.01em;
- list-style: none;
-}
-
-/* ── Mobile nav backdrop overlay ────────────────────────────────────── */
-
-/* Injected into <body> by nav.js when the burger opens on mobile.
- Covers the page content behind the panel, gives proper visual hierarchy,
- and acts as a tap-to-close target. */
-.nav-backdrop {
- position: fixed;
- inset: 0;
- background: rgba(2, 2, 6, 0.72);
- backdrop-filter: blur(4px);
- -webkit-backdrop-filter: blur(4px);
- z-index: 997;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.22s ease;
-}
-
-.nav-backdrop.is-active {
- opacity: 1;
- pointer-events: auto;
-}
-
-/* Scroll lock applied to <body> when mobile nav is open */
-body.nav-open {
- overflow: hidden;
- touch-action: none;
-}
-
-/* ── Hamburger button (desktop: hidden) ─────────────────────────────── */
-
-.home-nav .nav-burger {
- display: none;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- gap: 5px;
- width: 44px;
- height: 44px;
- padding: 0;
- background: none;
- border: 1px solid rgba(255, 255, 255, 0.12);
- border-radius: 10px;
- cursor: pointer;
- -webkit-app-region: no-drag;
- transition: border-color 0.2s ease, background 0.2s ease;
-}
-
-.home-nav .nav-burger:hover {
- border-color: rgba(255, 255, 255, 0.25);
- background: rgba(255, 255, 255, 0.06);
-}
-
-.home-nav .nav-burger-bar {
+/* ─────────────────────────────────────────────────────────────────────────
+ three.ws shared site navigation
+ Single source of truth for the global header. Mirrors the homepage nav
+ (pages/home.html) so every page that injects #nav-container looks identical
+ to the homepage. Self-contained: design tokens fall back to the homepage
+ palette when a host page doesn't define them.
+ ───────────────────────────────────────────────────────────────────────── */
+
+.nav,
+.nav-drawer {
+ --nv-bg: var(--bg, #050505);
+ --nv-surface-1: var(--surface-1, #111111);
+ --nv-surface-2: var(--surface-2, #181818);
+ --nv-hairline: var(--hairline, #1c1c1c);
+ --nv-hairline-strong: var(--hairline-strong, #2a2a2a);
+ --nv-text: var(--text, #f6f6f6);
+ --nv-text-2: var(--text-2, #a8a8a8);
+ --nv-text-3: var(--text-3, #6a6a6a);
+ --nv-text-4: var(--text-4, #4a4a4a);
+ --nv-font-display: var(--font-display, "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif);
+ --nv-font-mono: var(--font-mono, "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace);
+ box-sizing: border-box;
+}
+.nav *, .nav-drawer * { box-sizing: border-box; }
+
+/* ── NAV ─────────────────────────────────────────────────────── */
+.nav {
+ position: sticky; top: 0; z-index: 100;
+ border-bottom: 1px solid var(--nv-hairline);
+ background: rgba(5,5,5,0.82);
+ backdrop-filter: blur(20px) saturate(140%);
+ -webkit-backdrop-filter: blur(20px) saturate(140%);
+}
+.nav a { color: inherit; text-decoration: none; }
+.nav button { font-family: inherit; cursor: pointer; }
+.nav-inner {
+ display: flex; align-items: center; gap: 32px;
+ padding: 16px 32px; max-width: 1440px; margin: 0 auto;
+}
+.nav .brand {
+ display: flex; align-items: center; gap: 10px;
+ font-family: var(--nv-font-display);
+ font-weight: 600; letter-spacing: -0.025em; font-size: 16.5px;
+ color: var(--nv-text); flex-shrink: 0;
+}
+.nav .brand-mark {
+ width: 24px; height: 24px;
+ border-radius: 5px;
display: block;
- width: 18px;
- height: 2px;
- background: rgba(255, 255, 255, 0.75);
- border-radius: 2px;
- transition: transform 0.22s ease, opacity 0.22s ease, width 0.22s ease;
-}
-
-.home-nav .nav-burger[aria-expanded='true'] .nav-burger-bar:nth-child(1) {
- transform: translateY(7px) rotate(45deg);
-}
-.home-nav .nav-burger[aria-expanded='true'] .nav-burger-bar:nth-child(2) {
- opacity: 0;
- width: 0;
-}
-.home-nav .nav-burger[aria-expanded='true'] .nav-burger-bar:nth-child(3) {
- transform: translateY(-7px) rotate(-45deg);
-}
-
-/* ── Nav root + items ──────────────────────────────────────────────── */
-
-.home-nav .nav-root,
-.home-nav .nav-menu {
- list-style: none !important;
- margin: 0;
- padding: 0;
-}
-
-.home-nav .nav-root {
- display: flex !important;
- align-items: center;
- gap: 0.35rem;
-}
-
-.home-nav .nav-item {
- position: relative;
- display: block;
-}
-
-.home-nav .nav-item[hidden] {
- display: none !important;
-}
-
-.home-nav .nav-menu li {
- display: block;
- margin: 0;
- padding: 0;
-}
-
-/* Top-level nav links — pill-shape on hover, animated underline glow.
- Excludes .nav-cta and .nav-user so their pill styling survives. */
-.home-nav .nav-item > a:not(.nav-cta):not(.nav-user),
-.home-nav .nav-trigger {
- position: relative;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- background: none;
- border: 0;
- padding: 0.45rem 0.75rem;
- border-radius: 10px;
- cursor: pointer;
- color: rgba(244, 244, 248, 0.65);
- font: inherit;
- font-size: 0.92rem;
- font-weight: 500;
- line-height: 1.2;
- letter-spacing: 0.005em;
- font-family: 'Space Grotesk', 'Inter', sans-serif;
- transition: color 0.18s ease, background 0.18s ease;
-}
-
-.home-nav .nav-item > a:not(.nav-cta):not(.nav-user):hover,
-.home-nav .nav-trigger:hover,
-.home-nav .nav-trigger[aria-expanded='true'] {
- color: #fff;
- background: rgba(255, 255, 255, 0.04);
-}
-
-/* Soft gradient underline on hover/open (top-level only) */
-.home-nav .nav-item > a:not(.nav-cta):not(.nav-user)::after,
-.home-nav .nav-trigger::after {
- content: '';
- position: absolute;
- left: 50%;
- right: 50%;
- bottom: 2px;
- height: 1.5px;
- background: rgba(255, 255, 255, 0.6);
- border-radius: 2px;
- opacity: 0;
- transition: left 0.25s ease, right 0.25s ease, opacity 0.2s ease;
- pointer-events: none;
-}
-
-.home-nav .nav-item > a:not(.nav-cta):not(.nav-user):hover::after,
-.home-nav .nav-trigger:hover::after,
-.home-nav .nav-trigger[aria-expanded='true']::after {
- left: 12px;
- right: 12px;
- opacity: 0.9;
-}
-
-.home-nav .nav-caret {
- font-size: 0.7em;
- opacity: 0.7;
- transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
-}
-
-.home-nav .nav-trigger[aria-expanded='true'] .nav-caret {
- transform: rotate(180deg);
-}
-
-/* ── Dropdown menus ────────────────────────────────────────────────── */
-
-.home-nav .nav-menu {
- position: absolute;
- top: calc(100% + 12px);
- left: -8px;
- min-width: 248px;
- margin: 0;
- padding: 8px;
- list-style: none;
- background: rgba(10, 10, 10, 0.96);
- backdrop-filter: blur(24px) saturate(120%);
- -webkit-backdrop-filter: blur(24px) saturate(120%);
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: 14px;
- box-shadow:
- 0 1px 0 rgba(255, 255, 255, 0.04) inset,
- 0 24px 48px -12px rgba(0, 0, 0, 0.7);
- opacity: 0;
- transform: translateY(-6px) scale(0.98);
- transform-origin: top left;
- pointer-events: none;
- transition:
- opacity 0.18s ease,
- transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
- z-index: 1000;
-}
-
-.home-nav .nav-trigger[aria-expanded='true'] + .nav-menu {
- opacity: 1;
- transform: translateY(0) scale(1);
- pointer-events: auto;
-}
-
-.home-nav .nav-menu a {
- display: flex;
- flex-direction: column;
- gap: 2px;
- padding: 10px 12px;
- border-radius: 9px;
- color: rgba(255, 255, 255, 0.88);
- text-decoration: none;
- line-height: 1.3;
- transition:
- background 0.15s ease,
- color 0.15s ease,
- transform 0.15s ease;
-}
-
-.home-nav .nav-menu a:hover,
-.home-nav .nav-menu a:focus-visible {
- background: rgba(255, 255, 255, 0.06);
- color: #fff;
- transform: translateX(2px);
-}
-
-.home-nav .nav-mi-title {
- font-size: 0.92rem;
- font-weight: 500;
- letter-spacing: 0.005em;
- display: inline-flex;
- align-items: center;
- gap: 6px;
-}
-
-.home-nav .nav-mi-sub {
- font-size: 0.78rem;
- color: rgba(255, 255, 255, 0.5);
- font-weight: 400;
-}
-
-.home-nav .nav-menu a:hover .nav-mi-sub,
-.home-nav .nav-menu a:focus-visible .nav-mi-sub {
- color: rgba(255, 255, 255, 0.72);
-}
-
-/* ── Tablet: tighten gap, flip dropdowns right-aligned ─────────────── */
-
-@media (min-width: 769px) and (max-width: 1024px) {
- .home-nav .nav-root {
- gap: 0.1rem;
- }
- .home-nav .nav-menu {
- left: auto;
- right: 0;
- transform-origin: top right;
- }
-}
-
-/* ── Mobile: hamburger + slide-down panel ──────────────────────────── */
-
-@media (max-width: 768px) {
- /* Labs has 14+ sub-items — not worth the accordion space on mobile.
- Users who want Labs features land there from other pages or search. */
- .home-nav #home-nav-labs-li {
- display: none !important;
- }
-
- .home-nav {
- position: relative;
- align-items: center;
- gap: 0;
- }
-
- .home-nav .nav-burger {
- display: flex;
- margin-left: auto;
- }
-
- /* Hidden by default; toggled via .is-open */
- .home-nav .nav-root {
- display: none !important;
- position: fixed;
- top: calc(var(--header-h, 3.5rem) + env(safe-area-inset-top, 0px) + 8px);
- left: 12px;
- right: 12px;
- width: auto;
- max-height: calc(100dvh - var(--header-h, 3.5rem) - env(safe-area-inset-top, 0px) - 24px);
- overflow-y: auto;
- overscroll-behavior: contain;
- flex-direction: column !important;
- align-items: stretch !important;
- gap: 2px !important;
- padding: 10px;
- background: rgba(10, 10, 10, 0.97);
- backdrop-filter: blur(24px) saturate(120%);
- -webkit-backdrop-filter: blur(24px) saturate(120%);
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: 14px;
- box-shadow:
- 0 1px 0 rgba(255, 255, 255, 0.04) inset,
- 0 24px 48px -12px rgba(0, 0, 0, 0.7);
- z-index: 1001;
- }
-
- .home-nav .nav-root.is-open {
- display: flex !important;
- animation: nav-mobile-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
- }
-
- @keyframes nav-mobile-in {
- from { opacity: 0; transform: translateY(-8px) scale(0.98); }
- to { opacity: 1; transform: translateY(0) scale(1); }
- }
-
- .home-nav .nav-item {
- width: 100%;
- }
-
- .home-nav .nav-item > a,
- .home-nav .nav-trigger {
- display: flex;
- align-items: center;
- width: 100%;
- min-height: 44px;
- padding: 11px 14px;
- border-radius: 9px;
- font-size: 0.95rem;
- color: rgba(255, 255, 255, 0.82);
- transition: background 0.15s ease, color 0.15s ease;
- box-sizing: border-box;
- }
-
- /* No gradient underline on mobile — accordions read better as solid rows */
- .home-nav .nav-item > a::after,
- .home-nav .nav-trigger::after {
- display: none;
- }
-
- .home-nav .nav-item > a:hover,
- .home-nav .nav-trigger:hover,
- .home-nav .nav-trigger[aria-expanded='true'] {
- background: rgba(255, 255, 255, 0.06);
- color: #fff;
- }
-
- .home-nav .nav-caret {
- margin-left: auto;
- }
-
- /* Dropdowns become inline accordions on mobile */
- .home-nav .nav-menu {
- position: static;
- opacity: 1 !important;
- transform: none !important;
- pointer-events: auto !important;
- display: none;
- min-width: 0;
- padding: 2px 0 6px 8px;
- margin: 0 0 4px 0;
- background: none;
- backdrop-filter: none;
- -webkit-backdrop-filter: none;
- border: none;
- border-left: 2px solid rgba(255, 255, 255, 0.12);
- box-shadow: none;
- border-radius: 0;
- }
-
- .home-nav .nav-trigger[aria-expanded='true'] + .nav-menu {
- display: block;
- }
-
- /* Divider after every dropdown group so the next top-level item
- is visually separate — prevents flat links reading as sub-items */
- .home-nav .nav-has-menu {
- border-bottom: 1px solid rgba(255, 255, 255, 0.06);
- margin-bottom: 2px;
- padding-bottom: 2px;
- }
-
- .home-nav .nav-menu a {
- min-height: 40px;
- padding: 8px 12px;
- border-radius: 7px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- }
-
- .home-nav .nav-menu a:hover {
- transform: none;
- background: rgba(255, 255, 255, 0.06);
- }
-
- /* Hide sub-descriptions on mobile — keep it scannable */
- .home-nav .nav-mi-sub {
- display: none;
- }
-
- .home-nav .nav-cta {
- display: block;
- text-align: center;
- margin-top: 8px;
- padding: 13px 16px;
- border-radius: 12px;
- font-size: 0.96rem;
- }
-
- .home-nav .nav-user {
- max-width: 100%;
- width: 100%;
- min-height: 44px;
- box-sizing: border-box;
- }
-
- /* Divider before CTA */
- .home-nav .nav-root > li:last-child {
- padding-top: 4px;
- margin-top: 4px;
- border-top: 1px solid rgba(255, 255, 255, 0.06);
- }
-}
-
-/* ── Walk Companion toggle ─────────────────────────────────────────────── */
-.home-nav .nav-walk-toggle {
- position: relative;
- display: inline-flex;
- align-items: center;
- gap: 6px;
- background: none;
- border: 0;
- padding: 0.45rem 0.7rem;
- border-radius: 999px;
- color: var(--nav-fg, rgba(255, 255, 255, 0.72));
- font-family: inherit;
- font-weight: 600;
- font-size: 0.86rem;
- line-height: 1.2;
- cursor: pointer;
- transition:
- color 0.18s ease,
- background 0.18s ease,
- box-shadow 0.18s ease;
-}
-
-.home-nav .nav-walk-toggle .nav-walk-ico {
- font-size: 1rem;
- transform: translateY(0);
- transition: transform 0.18s ease;
-}
-
-.home-nav .nav-walk-toggle:hover {
- color: #fff;
- background: rgba(255, 255, 255, 0.05);
-}
-
-.home-nav .nav-walk-toggle:hover .nav-walk-ico {
- transform: translateX(2px);
-}
-
-.home-nav .nav-walk-toggle:focus-visible {
- outline: 2px solid #7aa2ff;
- outline-offset: 2px;
-}
-
-/* Active / pressed state — companion is live */
-.home-nav .nav-walk-toggle.is-on,
-.home-nav .nav-walk-toggle[aria-pressed='true'] {
- color: #0a0c12;
- background: linear-gradient(120deg, #9fe6c8, #7aa2ff);
- box-shadow: 0 6px 16px -8px rgba(122, 162, 255, 0.8);
+ flex-shrink: 0;
}
-
-@media (max-width: 980px) {
- .home-nav .nav-walk-toggle {
- width: 100%;
- justify-content: center;
- min-height: 44px;
- }
+.nav-main { display: flex; align-items: center; gap: 2px; margin-left: 12px; flex: 1; }
+.nav-main > a {
+ display: inline-flex; align-items: center;
+ padding: 7px 12px; font-size: 14px; font-weight: 450;
+ color: var(--nv-text-2); transition: color 0.12s;
+}
+.nav-main > a:hover,
+.nav-main > a[aria-current="page"] { color: var(--nv-text); }
+.nav-mi[aria-current="page"] .nav-mi-t { color: var(--nv-text); }
+.nav-mi[aria-current="page"] { background: var(--nv-surface-1); }
+.nav-drawer a[aria-current="page"] { color: var(--nv-text); background: var(--nv-surface-1); }
+.nav-end { display: flex; align-items: center; gap: 4px; }
+.nav-end a {
+ display: inline-flex; align-items: center;
+ padding: 7px 12px; font-size: 14px; font-weight: 450; color: var(--nv-text-2);
+ transition: color 0.12s, border-color 0.15s, background 0.15s;
+}
+.nav-end a:hover { color: var(--nv-text); }
+.nav-end .console {
+ color: var(--nv-text); font-weight: 500;
+ border: 1px solid var(--nv-hairline-strong);
+ padding: 7px 16px; border-radius: 7px; margin-left: 6px;
+}
+.nav-end .console:hover { border-color: var(--nv-text); background: rgba(255,255,255,0.04); }
+.nav-end [hidden] { display: none; }
+
+/* Walk Companion toggle — lives in the nav, loads the avatar on demand */
+.nav-walk-toggle {
+ display: inline-flex; align-items: center; gap: 6px;
+ padding: 7px 12px; font-size: 14px; font-weight: 450;
+ color: var(--nv-text-2); background: none;
+ border: 1px solid transparent; border-radius: 7px;
+ font-family: inherit; cursor: pointer;
+ transition: color 0.12s, border-color 0.15s, background 0.15s;
+}
+.nav-walk-toggle:hover { color: var(--nv-text); border-color: var(--nv-hairline-strong); }
+.nav-walk-toggle.is-on {
+ color: var(--nv-text); border-color: var(--nv-hairline-strong);
+ background: rgba(255,255,255,0.04);
+}
+.nav-walk-ico { font-size: 14px; line-height: 1; }
+
+@media (max-width: 880px) {
+ .nav-main { display: none; }
+ .nav-inner { padding: 14px 20px; gap: 16px; }
+}
+
+/* ── NAV DROPDOWNS ───────────────────────────────────────────── */
+.nav-grp { position: relative; display: flex; }
+.nav-trigger {
+ display: inline-flex; align-items: center; gap: 5px;
+ padding: 7px 12px; font-size: 14px; font-weight: 450;
+ color: var(--nv-text-2); background: none; border: 0;
+ border-radius: 7px; font-family: inherit; cursor: pointer;
+ transition: color 0.12s, background 0.12s;
+}
+.nav-trigger:hover,
+.nav-grp.open .nav-trigger { color: var(--nv-text); }
+.nav-grp.open .nav-trigger { background: rgba(255,255,255,0.04); }
+.nav-caret { font-size: 9px; opacity: 0.55; transition: transform 0.2s ease; }
+.nav-grp.open .nav-caret { transform: rotate(180deg); }
+.nav-pop {
+ position: absolute; top: calc(100% + 9px); left: 0;
+ min-width: 272px; padding: 7px;
+ background: rgba(11,11,11,0.97);
+ backdrop-filter: blur(24px) saturate(140%);
+ -webkit-backdrop-filter: blur(24px) saturate(140%);
+ border: 1px solid var(--nv-hairline-strong);
+ border-radius: 13px;
+ box-shadow: 0 20px 54px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
+ display: grid; gap: 1px;
+ opacity: 0; transform: translateY(-6px) scale(0.985);
+ transform-origin: top left; pointer-events: none;
+ transition: opacity 0.16s ease, transform 0.16s ease;
+ z-index: 200;
+}
+/* invisible hover bridge so the menu doesn't close in the gap */
+.nav-pop::before {
+ content: ""; position: absolute; top: -10px; left: 0; right: 0; height: 12px;
+}
+.nav-grp.open .nav-pop {
+ opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
+}
+.nav-pop.wide { grid-template-columns: 1fr 1fr; min-width: 540px; }
+.nav-mi {
+ display: block; padding: 9px 12px; border-radius: 9px;
+ transition: background 0.12s;
+}
+.nav-mi:hover { background: var(--nv-surface-2); }
+.nav-mi-t {
+ display: flex; align-items: center; gap: 6px;
+ font-size: 13.5px; font-weight: 500; color: var(--nv-text);
+ letter-spacing: -0.01em;
+}
+.nav-mi-d {
+ display: block; font-size: 12px; color: var(--nv-text-3);
+ margin-top: 1px; line-height: 1.4;
+}
+.nav-pill-sm {
+ display: inline-block; padding: 1px 5px;
+ font-family: var(--nv-font-mono); font-size: 8.5px; font-weight: 600;
+ letter-spacing: 0.08em; line-height: 1.5; border-radius: 4px;
+ background: rgba(255,255,255,0.1); color: var(--nv-text);
+ text-transform: uppercase;
+}
+.nav-pop-note {
+ padding: 6px 12px 8px; font-size: 11px; color: var(--nv-text-4);
+ line-height: 1.45; grid-column: 1 / -1;
+ border-bottom: 1px solid var(--nv-hairline); margin-bottom: 2px;
+}
+
+/* ── MOBILE NAV ─────────────────────────────────────────────── */
+.nav-toggle {
+ display: none; align-items: center; justify-content: center;
+ width: 36px; height: 36px; padding: 0; margin-left: auto;
+ background: none; border: 1px solid var(--nv-hairline-strong);
+ border-radius: 7px; color: var(--nv-text); cursor: pointer;
+ transition: border-color 0.15s, background 0.15s;
+}
+.nav-toggle:hover { border-color: var(--nv-text); background: rgba(255,255,255,0.04); }
+.nav-toggle svg { width: 16px; height: 16px; }
+.nav-toggle .close { display: none; }
+.nav-toggle[aria-expanded="true"] .open { display: none; }
+.nav-toggle[aria-expanded="true"] .close { display: block; }
+.nav-drawer {
+ display: none; position: fixed; inset: 57px 0 0;
+ z-index: 99; background: rgba(5,5,5,0.96);
+ backdrop-filter: blur(24px) saturate(140%);
+ -webkit-backdrop-filter: blur(24px) saturate(140%);
+ padding: 20px 24px 40px; flex-direction: column; gap: 2px;
+ overflow-y: auto; -webkit-overflow-scrolling: touch;
+ overscroll-behavior: contain;
+ opacity: 0; transform: translateY(-8px);
+ transition: opacity 0.25s ease, transform 0.25s ease;
+}
+.nav-drawer a { color: var(--nv-text-2); text-decoration: none; }
+.nav-drawer.open { display: flex; opacity: 1; transform: translateY(0); }
+.nav-drawer .dr-h {
+ font-family: var(--nv-font-mono); font-size: 11px;
+ text-transform: uppercase; letter-spacing: 0.16em;
+ color: var(--nv-text-4); padding: 18px 16px 6px;
+}
+.nav-drawer .dr-h:first-child { padding-top: 4px; }
+.nav-drawer a {
+ padding: 11px 16px; font-size: 15.5px; font-weight: 450;
+ border-radius: 8px;
+ transition: background 0.12s, color 0.12s;
+}
+.nav-drawer a:hover { background: var(--nv-surface-1); color: var(--nv-text); }
+.nav-drawer [hidden] { display: none; }
+.nav-drawer .sep { height: 1px; background: var(--nv-hairline); margin: 12px 0; }
+.nav-drawer .btn {
+ display: inline-flex; align-items: center; justify-content: center; gap: 10px;
+ margin-top: 8px; padding: 13px 22px; border-radius: 8px;
+ font-size: 14.5px; font-weight: 500;
+ border: 1px solid var(--nv-hairline-strong);
+ background: transparent; color: var(--nv-text);
+ transition: border-color 0.15s, background 0.15s;
+}
+.nav-drawer .btn:hover { border-color: var(--nv-text); background: rgba(255,255,255,0.04); }
+.nav-drawer .btn.primary { background: var(--nv-text); color: var(--nv-bg); border-color: var(--nv-text); }
+.nav-drawer .btn.primary:hover { background: #fff; }
+@media (max-width: 880px) {
+ .nav-toggle { display: flex; }
+ .nav-end { display: none; }
}
diff --git a/public/nav.js b/public/nav.js
index 57ada1907..45f916b66 100644
--- a/public/nav.js
+++ b/public/nav.js
@@ -1,4 +1,13 @@
-document.addEventListener('DOMContentLoaded', () => {
+// three.ws shared site navigation loader.
+//
+// Injects the global header (public/nav.html) into any page that includes a
+// `<div id="nav-container"></div>` and `<script src="/nav.js">`, then wires the
+// homepage nav behavior: hover/click dropdowns, the mobile drawer, the Walk
+// Companion toggle, auth-aware CTAs, and active-page highlighting. The markup,
+// styles (public/nav.css) and behavior here mirror pages/home.html so every
+// page reads as the same site.
+
+function boot() {
const navContainer = document.getElementById('nav-container');
if (!navContainer) return;
if (!document.querySelector('link[href="/nav.css"]')) {
@@ -8,24 +17,179 @@ document.addEventListener('DOMContentLoaded', () => {
document.head.appendChild(link);
}
fetch('/nav.html')
- .then(response => response.text())
- .then(data => {
+ .then((response) => response.text())
+ .then((data) => {
navContainer.innerHTML = data;
initNav(navContainer);
- });
-});
+ })
+ .catch(() => {});
+}
+
+if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', boot);
+} else {
+ boot();
+}
function initNav(root) {
initDropdowns(root);
- initBurger(root);
+ initDrawer(root);
+ initWalkToggle(root);
initAuthHint(root);
initActivePage(root);
- initWalkToggle(root);
}
-// Walk Companion toggle. Loads the stable, unhashed /walk-companion.js module
-// (built from src/walk-companion.js — see vite.config.js) only when enabled, so
-// pages pay no Three.js cost when it's off. State lives in localStorage and the
+// ── Desktop dropdowns ──────────────────────────────────────────────────────
+// Hover to open on pointer devices; click/keyboard for touch + accessibility.
+function initDropdowns(root) {
+ const groups = Array.prototype.slice.call(root.querySelectorAll('.nav-main .nav-grp'));
+ if (!groups.length) return;
+ const hoverCapable = window.matchMedia('(hover: hover)').matches;
+
+ function setOpen(grp, on) {
+ grp.classList.toggle('open', on);
+ const t = grp.querySelector('.nav-trigger');
+ if (t) t.setAttribute('aria-expanded', on ? 'true' : 'false');
+ }
+ function closeAll(except) {
+ groups.forEach((g) => { if (g !== except) setOpen(g, false); });
+ }
+
+ groups.forEach((grp) => {
+ const trigger = grp.querySelector('.nav-trigger');
+ if (!trigger) return;
+ let closeTimer;
+
+ trigger.addEventListener('click', (e) => {
+ e.stopPropagation();
+ if (hoverCapable) {
+ // hover already opens it; a click just pins it open
+ closeAll(grp);
+ setOpen(grp, true);
+ return;
+ }
+ const willOpen = !grp.classList.contains('open');
+ closeAll(grp);
+ setOpen(grp, willOpen);
+ });
+
+ if (hoverCapable) {
+ grp.addEventListener('mouseenter', () => {
+ clearTimeout(closeTimer);
+ closeAll(grp);
+ setOpen(grp, true);
+ });
+ grp.addEventListener('mouseleave', () => {
+ closeTimer = setTimeout(() => setOpen(grp, false), 120);
+ });
+ }
+
+ // Keyboard navigation within the open menu.
+ const menu = trigger.nextElementSibling;
+ if (menu) {
+ menu.addEventListener('keydown', (e) => {
+ const items = Array.prototype.slice.call(menu.querySelectorAll('a'));
+ const idx = items.indexOf(document.activeElement);
+ if (e.key === 'ArrowDown') {
+ e.preventDefault();
+ (items[(idx + 1) % items.length] || items[0])?.focus({ preventScroll: true });
+ } else if (e.key === 'ArrowUp') {
+ e.preventDefault();
+ (items[(idx - 1 + items.length) % items.length] || items[0])?.focus({ preventScroll: true });
+ } else if (e.key === 'Escape') {
+ setOpen(grp, false);
+ trigger.focus({ preventScroll: true });
+ }
+ });
+ }
+
+ grp.querySelectorAll('.nav-mi').forEach((a) => {
+ a.addEventListener('click', () => setOpen(grp, false));
+ });
+ });
+
+ document.addEventListener('click', (e) => {
+ if (!e.target.closest('.nav-main .nav-grp')) closeAll(null);
+ });
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ const openGrp = root.querySelector('.nav-main .nav-grp.open');
+ if (openGrp) {
+ setOpen(openGrp, false);
+ const t = openGrp.querySelector('.nav-trigger');
+ if (t) t.focus({ preventScroll: true });
+ }
+ }
+ });
+}
+
+// ── Mobile drawer ──────────────────────────────────────────────────────────
+function initDrawer(root) {
+ const toggle = root.querySelector('#nav-toggle');
+ const drawer = root.querySelector('#nav-drawer');
+ if (!toggle || !drawer) return;
+
+ const isOpen = () => drawer.classList.contains('open');
+ function setOpen(open) {
+ toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
+ drawer.setAttribute('aria-hidden', open ? 'false' : 'true');
+ document.body.style.overflow = open ? 'hidden' : '';
+ drawer.classList.toggle('open', open);
+ }
+ toggle.addEventListener('click', () => setOpen(!isOpen()));
+ drawer.addEventListener('click', (e) => {
+ if (e.target.closest('a')) setOpen(false);
+ });
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape' && isOpen()) { setOpen(false); toggle.focus(); }
+ });
+ window.addEventListener('resize', () => {
+ if (window.innerWidth > 880 && isOpen()) setOpen(false);
+ });
+}
+
+// ── Active page highlighting ────────────────────────────────────────────────
+function initActivePage(root) {
+ const path = location.pathname.replace(/\/$/, '') || '/';
+ root.querySelectorAll('a[href]').forEach((a) => {
+ const raw = a.getAttribute('href');
+ if (!raw || !raw.startsWith('/')) return;
+ const href = raw.split('#')[0].replace(/\/$/, '') || '/';
+ if (href === path || (href !== '/' && path.startsWith(href + '/'))) {
+ a.setAttribute('aria-current', 'page');
+ }
+ });
+}
+
+// ── Auth-aware CTAs ──────────────────────────────────────────────────────────
+// When a signed-in hint exists, swap "Sign in" for the dashboard/My Agents
+// entry points. Mirrors the hint written by the account layer.
+function initAuthHint(root) {
+ try {
+ const raw = localStorage.getItem('3dagent:auth-hint');
+ if (!raw) return;
+ const { authed, name } = JSON.parse(raw);
+ if (!authed) return;
+
+ const signIn = root.querySelector('#home-nav-cta');
+ if (signIn) signIn.hidden = true;
+ const myAgents = root.querySelector('#home-nav-my-agents-li');
+ if (myAgents) myAgents.hidden = false;
+ const console = root.querySelector('#home-nav-user');
+ if (console && name) console.textContent = name;
+
+ // Mobile drawer equivalents.
+ const drawerSignIn = root.querySelector('#home-nav-drawer-cta');
+ if (drawerSignIn) drawerSignIn.hidden = true;
+ const drawerMyAgents = root.querySelector('#home-nav-drawer-my-agents');
+ if (drawerMyAgents) drawerMyAgents.hidden = false;
+ } catch (_) {}
+}
+
+// ── Walk Companion toggle ─────────────────────────────────────────────────────
+// Loads the stable, unhashed /walk-companion.js module (built from
+// src/walk-companion.js — see vite.config.js) only when enabled, so pages pay
+// no Three.js cost when it's off. State lives in localStorage and the
// ?walk=1 / ?walk=0 query param, both also honored by the module itself.
const WALK_ENABLED_KEY = 'walk:companion:enabled';
@@ -60,9 +224,7 @@ function initWalkToggle(root) {
// An explicit ?walk= override decides the initial state; otherwise restore.
if (override === '1' || override === '0') {
- try {
- localStorage.setItem(WALK_ENABLED_KEY, override);
- } catch (_) {}
+ try { localStorage.setItem(WALK_ENABLED_KEY, override); } catch (_) {}
}
sync();
@@ -76,9 +238,7 @@ function initWalkToggle(root) {
if (window.__walkCompanion) {
window.__walkCompanion.toggle();
} else {
- try {
- localStorage.setItem(WALK_ENABLED_KEY, '1');
- } catch (_) {}
+ try { localStorage.setItem(WALK_ENABLED_KEY, '1'); } catch (_) {}
ensureWalkCompanion();
}
sync();
@@ -86,112 +246,3 @@ function initWalkToggle(root) {
window.addEventListener('walk-companion:change', sync);
}
-
-function initActivePage(root) {
- const path = location.pathname.replace(/\/$/, '') || '/';
- root.querySelectorAll('.home-nav a[href]').forEach((a) => {
- const href = a.getAttribute('href').replace(/\/$/, '') || '/';
- if (!href.startsWith('/')) return;
- if (href === path || (href !== '/' && path.startsWith(href + '/'))) {
- a.setAttribute('aria-current', 'page');
- }
- });
-}
-
-function initDropdowns(root) {
- const triggers = root.querySelectorAll('.home-nav .nav-trigger');
- if (!triggers.length) return;
-
- function closeAll(except) {
- triggers.forEach((t) => {
- if (t !== except) t.setAttribute('aria-expanded', 'false');
- });
- }
-
- triggers.forEach((trigger) => {
- trigger.addEventListener('click', (e) => {
- e.stopPropagation();
- const open = trigger.getAttribute('aria-expanded') === 'true';
- closeAll(open ? null : trigger);
- trigger.setAttribute('aria-expanded', open ? 'false' : 'true');
- if (!open) {
- const first = trigger.nextElementSibling?.querySelector('a');
- first?.focus({ preventScroll: true });
- }
- });
-
- const menu = trigger.nextElementSibling;
- if (!menu) return;
- menu.addEventListener('keydown', (e) => {
- const items = Array.from(menu.querySelectorAll('a'));
- const idx = items.indexOf(document.activeElement);
- if (e.key === 'ArrowDown') {
- e.preventDefault();
- items[(idx + 1) % items.length]?.focus({ preventScroll: true });
- } else if (e.key === 'ArrowUp') {
- e.preventDefault();
- items[(idx - 1 + items.length) % items.length]?.focus({ preventScroll: true });
- } else if (e.key === 'Escape') {
- trigger.setAttribute('aria-expanded', 'false');
- trigger.focus({ preventScroll: true });
- }
- });
- });
-
- document.addEventListener('click', (e) => {
- if (!e.target.closest('.home-nav')) closeAll(null);
- });
- document.addEventListener('keydown', (e) => {
- if (e.key === 'Escape') closeAll(null);
- });
-}
-
-function initBurger(root) {
- const burger = root.querySelector('#home-nav-burger');
- const navRoot = root.querySelector('#home-nav-root');
- if (!burger || !navRoot) return;
-
- const backdrop = document.createElement('div');
- backdrop.className = 'nav-backdrop';
- // Must be in the same stacking context as nav-root: header's backdrop-filter
- // creates a stacking context (z-index 200 in root), so a backdrop appended
- // to body at z-index 997 paints above the nav panel at z-index 1001-within-header.
- (root.parentElement ?? document.body).appendChild(backdrop);
-
- function close() {
- burger.setAttribute('aria-expanded', 'false');
- navRoot.classList.remove('is-open');
- backdrop.classList.remove('is-active');
- document.body.classList.remove('nav-open');
- }
-
- burger.addEventListener('click', (e) => {
- e.stopPropagation();
- const open = burger.getAttribute('aria-expanded') === 'true';
- burger.setAttribute('aria-expanded', open ? 'false' : 'true');
- navRoot.classList.toggle('is-open', !open);
- backdrop.classList.toggle('is-active', !open);
- document.body.classList.toggle('nav-open', !open);
- });
-
- backdrop.addEventListener('click', close);
- document.addEventListener('keydown', (e) => {
- if (e.key === 'Escape') close();
- });
-}
-
-function initAuthHint(root) {
- try {
- const raw = localStorage.getItem('3dagent:auth-hint');
- if (!raw) return;
- const { authed, name } = JSON.parse(raw);
- if (!authed) return;
- const cta = root.querySelector('#home-nav-cta');
- if (cta) { cta.textContent = 'Dashboard'; cta.href = '/dashboard'; }
- const myAgentsLi = root.querySelector('#home-nav-my-agents-li');
- if (myAgentsLi) myAgentsLi.hidden = false;
- const userLi = root.querySelector('#home-nav-user-li');
- const userEl = root.querySelector('#home-nav-user');
- if (userEl && userLi && name) { userEl.textContent = name; userLi.hidden = false; }
- } catch (_) {}
-}
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index 64e28733d..23f1278ed 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -24,6 +24,7 @@ import { CommunityNet } from './community-net.js';
import { CommunityUI } from './coincommunities-ui.js';
import { createWorldEnvironment } from './world-env.js';
import { createChartScreen } from './chart-screen.js';
+import { mountOracleRibbon } from './oracle-ribbon.js';
import { MarketReactor } from './market-reactor.js';
import { VoxelWorld, createBuildHud, parseKey, MAX_BLOCKS } from './build-voxels.js';
import { normalizeGatewayURL } from '../ipfs.js';
@@ -354,6 +355,7 @@ export class CoinCommunities {
this._screenPulse.material.opacity = 0.35 + 0.35 * (0.5 + 0.5 * Math.sin(this._screenT * 2.4));
}
this._chartScreen?.update(dt);
+ this._oracleRibbon?.update(dt);
this._reactor?.update(dt);
}
@@ -637,6 +639,10 @@ export class CoinCommunities {
position: [0, 0, -30], width: 18,
onTrades: (trades, metrics) => this._reactor?.ingestTrades(trades, metrics),
});
+ // The /ibm/oracle 3D forecast line — the live $THREE price history + IBM
+ // Granite TimeSeries forecast, rendered as a glowing ribbon standing in the
+ // world (no backdrop, just the line) that players can walk around.
+ this._oracleRibbon = mountOracleRibbon(this.scene, { x: 17, y: 4.2, z: -20, scale: 0.7 });
this.localRig = new Group();
this.localRig.position.copy(this.localPos);
this.scene.add(this.localRig);
@@ -1002,6 +1008,7 @@ export class CoinCommunities {
this._screenArt = null; this._screenPulse = null;
}
if (this._chartScreen) { this._chartScreen.dispose(); this._chartScreen = null; }
+ if (this._oracleRibbon) { this._oracleRibbon.dispose(); this._oracleRibbon = null; }
if (this._reactor) { this._reactor.dispose(); this._reactor = null; }
if (this.voxels) { this.voxels.dispose(); this.voxels = null; }
this._cancelLongPress();
diff --git a/src/game/oracle-ribbon.js b/src/game/oracle-ribbon.js
index 9e2f2eb7f..d99a9e154 100644
--- a/src/game/oracle-ribbon.js
+++ b/src/game/oracle-ribbon.js
@@ -150,10 +150,7 @@ export function mountOracleRibbon(scene, opts = {}) {
(async () => {
try {
- const list = await fetch('/api/ibm/oracle?list=trending').then((r) => r.json());
- const pool = list?.pools?.[0]?.pool;
- if (!pool) return;
- const data = await fetch(`/api/ibm/oracle?pool=${encodeURIComponent(pool)}`).then((r) => r.json());
+ const data = await fetch(`/api/ibm/oracle?token=${THREE_MINT}`).then((r) => r.json());
if (data && data.history) buildSeries(series, data);
} catch {
/* offline / rate-limited — the world simply renders without the line */
diff --git a/src/walk.js b/src/walk.js
index eac4646ed..631c04517 100644
--- a/src/walk.js
+++ b/src/walk.js
@@ -46,7 +46,6 @@ import { clone as cloneSkinnedScene } from 'three/addons/utils/SkeletonUtils.js'
import nipplejs from 'nipplejs';
import { AnimationManager } from './animation-manager.js';
-import { mountOracleRibbon } from './game/oracle-ribbon.js';
import { WalkNet } from './walk-net.js';
import { getPresenceTicket, friendsClient } from './friends.js';
import { FriendsPanel } from './game/friends-panel.js';
@@ -1727,9 +1726,6 @@ function tick() {
// 4b. Animate the coin totem (billboard + bob + ring spin) when present.
if (coinTotem) coinTotem.update(dt);
- // 4c. Animate the Granite oracle forecast line (idle bob + slow spin).
- if (oracleRibbon) oracleRibbon.update(dt);
-
// 5. Update speech bubbles (3D -> 2D projection)
updateSpeechBubbles();
@@ -1763,10 +1759,6 @@ let net = null;
let netConnected = false;
let coinTotem = null; // CoinTotem instance when in a coin community world
-// Granite oracle forecast line — the /ibm/oracle 3D price+forecast ribbon,
-// standing in the world as a floating data sculpture you can walk around.
-const oracleRibbon = mountOracleRibbon(scene);
-
// Remote-avatar template cache. Each distinct GLB URL is fetched once and
// reused (via SkeletonUtils.clone) for every player wearing it, so a room full
// of the same avatar costs a single download. Keyed by URL → entry. Each entry