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: aixbt market intelligence bridge — endpoints, agent skills, MCP tools, NPC

nirholas31e627ec5eea
diff --git a/.env.example b/.env.example
index b8ff30e20..a71d3eee5 100644
--- a/.env.example
+++ b/.env.example
@@ -241,6 +241,18 @@ PUMPFUN_BOT_URL=
# Optional bearer token if the upstream MCP requires auth.
PUMPFUN_BOT_TOKEN=
+# ── aixbt intelligence bridge (api/_lib/aixbt.js, api/aixbt/*) ───────────────
+# Connects three.ws agents to aixbt's live narrative + momentum intelligence.
+# When set, /api/aixbt/{intel,projects,grounding,chat} go live, the aixbt agent
+# skills (aixbt-intel, aixbt-scan) work, and the paid MCP tools (aixbt_intel,
+# aixbt_projects) return real data. Without it those endpoints return a designed
+# "not configured" 503 — never fake data.
+# Get a key with a full aixbt.tech subscription or by paying for a time-boxed
+# x402 key pass: POST https://api.aixbt.tech/x402/v2/api-keys/{1d|1w|4w} (USDC on Base).
+AIXBT_API_KEY=
+# Optional override for the aixbt REST base (defaults to the v2 API).
+AIXBT_API_BASE=https://api.aixbt.tech/v2
+
# ── ERC-8004 agent registry crawler (api/cron/erc8004-crawl) ─────────────────
# Blocks to scan on first run (no cursor). Default 2000 keeps cron under 300s.
# For a one-time backfill, set to 50000 and trigger the endpoint manually —
diff --git a/api/_lib/aixbt.js b/api/_lib/aixbt.js
new file mode 100644
index 000000000..b0465549c
--- /dev/null
+++ b/api/_lib/aixbt.js
@@ -0,0 +1,241 @@
+// aixbt intelligence client — REST v2 (https://api.aixbt.tech/v2).
+//
+// This is the three.ws ⇄ aixbt bridge: it lets three.ws agents tap aixbt's
+// narrative / momentum intelligence the same way external builders use the
+// aixbt REST API and MCP. The secret (AIXBT_API_KEY) lives only here on the
+// server; the MCP tools and agent skills reach aixbt by calling the
+// /api/aixbt/* endpoints that wrap this module, so the key never ships to a
+// client or an MCP subprocess.
+//
+// Auth: `x-api-key: <AIXBT_API_KEY>`. Keys come from a full aixbt.tech
+// subscription or a time-boxed x402 key pass (see env.js / .env.example).
+//
+// Endpoints used (per https://docs.aixbt.tech/builders):
+// GET /projects — momentum-ranked projects (filters: names, chain, limit, page)
+// GET /projects/{id} — single project detail
+// GET /intel — recent narrative intel items
+// GET /grounding — hourly structured market context (crypto + tradfi)
+// POST /agents/indigo — agent chat (Pro/Holder plans)
+// GET /api-keys/info — current key metadata (tier, scopes, rate limit)
+//
+// Responses are wrapped by aixbt as { status, data, pagination }. We unwrap to
+// the bare `data` and normalize the fields three.ws renders into stable shapes
+// so a downstream change to aixbt's payload doesn't ripple through the UI.
+
+import { env } from './env.js';
+import { cacheGet, cacheSet } from './cache.js';
+
+const SOURCE = 'aixbt';
+const TIMEOUT_MS = 10_000;
+
+// Cache TTLs (seconds). aixbt grounding updates hourly and intel/projects move
+// on the order of minutes; these keep us well under the key's rate limit while
+// staying fresh enough for a live feed.
+const TTL = {
+ projects: 90,
+ project: 120,
+ intel: 120,
+ grounding: 600,
+};
+
+/** @returns {boolean} whether an aixbt API key is configured. */
+export function aixbtEnabled() {
+ return env.AIXBT_ENABLED;
+}
+
+class AixbtError extends Error {
+ constructor(message, status) {
+ super(message);
+ this.name = 'AixbtError';
+ this.status = status || 502;
+ this.code = status === 401 || status === 403
+ ? 'aixbt_unauthorized'
+ : status === 429
+ ? 'aixbt_rate_limited'
+ : 'aixbt_upstream_error';
+ }
+}
+
+/** Thrown when no key is configured — callers map this to a 503 + setup hint. */
+export class AixbtNotConfiguredError extends Error {
+ constructor() {
+ super('aixbt is not configured on this deployment (set AIXBT_API_KEY)');
+ this.name = 'AixbtNotConfiguredError';
+ this.status = 503;
+ this.code = 'aixbt_not_configured';
+ }
+}
+
+function buildUrl(path, query) {
+ const url = new URL(`${env.AIXBT_API_BASE}${path}`);
+ for (const [k, v] of Object.entries(query || {})) {
+ if (v === undefined || v === null || v === '') continue;
+ url.searchParams.set(k, String(v));
+ }
+ return url.toString();
+}
+
+async function request(path, { query, method = 'GET', body } = {}) {
+ if (!aixbtEnabled()) throw new AixbtNotConfiguredError();
+
+ const url = buildUrl(path, query);
+ let res;
+ try {
+ res = await fetch(url, {
+ method,
+ headers: {
+ 'x-api-key': env.AIXBT_API_KEY,
+ accept: 'application/json',
+ ...(body ? { 'content-type': 'application/json' } : {}),
+ },
+ body: body ? JSON.stringify(body) : undefined,
+ signal: AbortSignal.timeout(TIMEOUT_MS),
+ });
+ } catch (err) {
+ throw new AixbtError(`aixbt unreachable: ${err?.message || 'fetch failed'}`, 504);
+ }
+
+ const payload = await res.json().catch(() => null);
+ if (!res.ok) {
+ const detail = payload?.error || payload?.message || `HTTP ${res.status}`;
+ throw new AixbtError(`aixbt ${path} failed: ${detail}`, res.status);
+ }
+ // aixbt wraps successful reads as { status, data, pagination }.
+ return {
+ data: payload?.data ?? payload ?? null,
+ pagination: payload?.pagination ?? null,
+ };
+}
+
+// Read-through cache around a GET. Cache keys are content-addressed by path +
+// query so distinct filters never collide. Errors are never cached.
+async function cachedGet(cacheKey, ttl, path, query) {
+ const cached = await cacheGet(cacheKey).catch(() => null);
+ if (cached) return cached;
+ const fresh = await request(path, { query });
+ await cacheSet(cacheKey, fresh, ttl).catch(() => {});
+ return fresh;
+}
+
+function num(v) {
+ const n = typeof v === 'string' ? Number(v) : v;
+ return Number.isFinite(n) ? n : null;
+}
+
+// ── Normalizers ───────────────────────────────────────────────────────────
+// Map aixbt's verbose objects into the lean shapes three.ws renders + speaks.
+
+function normalizeProject(p) {
+ if (!p || typeof p !== 'object') return null;
+ const primaryToken = Array.isArray(p.tokens) ? p.tokens[0] : null;
+ return {
+ id: p._id || p.id || p.name || null,
+ name: p.name || null,
+ ticker: p.ticker || p.symbol || null,
+ x_handle: p.xHandle || null,
+ address: primaryToken?.address || p.address || null,
+ chain: primaryToken?.chain || p.chain || null,
+ scores: {
+ spiking: num(p.spikingScore),
+ climbing: num(p.climbingScore),
+ active: num(p.activeScore),
+ },
+ trajectory:
+ p.momentumContext?.spikingTrajectory ||
+ p.momentumContext?.climbingTrajectory ||
+ null,
+ market: {
+ price_usd: num(p.price),
+ market_cap: num(p.marketCap),
+ volume_24h: num(p.volume24h),
+ change_24h: num(p.priceChange24h ?? p.change24h),
+ },
+ intel: Array.isArray(p.intel) ? p.intel.slice(0, 10).map(normalizeIntel).filter(Boolean) : [],
+ categories: p.coingeckoData?.categories || [],
+ source: SOURCE,
+ };
+}
+
+function normalizeIntel(i) {
+ if (!i || typeof i !== 'object') return null;
+ return {
+ category: i.category || null,
+ description: i.description || i.summary || null,
+ detected_at: i.detectedAt || i.createdAt || null,
+ reinforced_at: i.reinforcedAt || null,
+ observations: num(i.observationCount),
+ official_source: Boolean(i.hasOfficialSource),
+ project: i.project?.name || i.projectName || null,
+ ticker: i.project?.ticker || i.ticker || null,
+ source: SOURCE,
+ };
+}
+
+// ── Public API ──────────────────────────────────────────────────────────────
+
+/**
+ * Momentum-ranked projects. Optional filters mirror aixbt's query params.
+ * @param {{ limit?: number, page?: number, names?: string, chain?: string }} [opts]
+ */
+export async function getProjects({ limit = 20, page = 1, names, chain } = {}) {
+ const lim = Math.min(Math.max(1, Number(limit) || 20), 50);
+ const key = `aixbt:projects:${page}:${lim}:${names || '*'}:${chain || '*'}`;
+ const { data, pagination } = await cachedGet(key, TTL.projects, '/projects', {
+ limit: lim,
+ page,
+ names,
+ chain,
+ });
+ const list = Array.isArray(data) ? data : data?.projects || [];
+ return { projects: list.map(normalizeProject).filter(Boolean), pagination };
+}
+
+/** Single project detail by aixbt id, ticker, or name. */
+export async function getProject(id) {
+ const key = `aixbt:project:${id}`;
+ const { data } = await cachedGet(key, TTL.project, `/projects/${encodeURIComponent(id)}`);
+ return normalizeProject(data);
+}
+
+/**
+ * Recent narrative intel items.
+ * @param {{ limit?: number, category?: string, chain?: string }} [opts]
+ */
+export async function getIntel({ limit = 20, category, chain } = {}) {
+ const lim = Math.min(Math.max(1, Number(limit) || 20), 50);
+ const key = `aixbt:intel:${lim}:${category || '*'}:${chain || '*'}`;
+ const { data, pagination } = await cachedGet(key, TTL.intel, '/intel', {
+ limit: lim,
+ category,
+ chain,
+ });
+ const list = Array.isArray(data) ? data : data?.intel || [];
+ return { intel: list.map(normalizeIntel).filter(Boolean), pagination };
+}
+
+/** Hourly structured market context (crypto + tradfi). Returned as-is. */
+export async function getGrounding() {
+ const key = 'aixbt:grounding';
+ const { data } = await cachedGet(key, TTL.grounding, '/grounding');
+ return { grounding: data, source: SOURCE };
+}
+
+/**
+ * Agent chat against aixbt's `indigo` agent (Pro/Holder plans only).
+ * Not cached — each turn is a distinct conversation.
+ * @param {Array<{ role: string, content: string }>} messages
+ */
+export async function chatIndigo(messages) {
+ const { data } = await request('/agents/indigo', { method: 'POST', body: { messages } });
+ const reply =
+ typeof data === 'string'
+ ? data
+ : data?.content || data?.message || data?.reply || data?.text || null;
+ return { reply, raw: data, source: SOURCE };
+}
+
+/** Current API key metadata — tier, scopes, rate limit. */
+export async function getKeyInfo() {
+ const { data } = await request('/api-keys/info');
+ return data;
+}
diff --git a/api/_lib/env.js b/api/_lib/env.js
index 245c1b851..ea9f98c4a 100644
--- a/api/_lib/env.js
+++ b/api/_lib/env.js
@@ -800,6 +800,22 @@ export const env = {
get CZ_AGENT_ID() { return opt('CZ_AGENT_ID', 'cz-preview'); },
get CZ_AGENT_NAME() { return opt('CZ_AGENT_NAME', 'CZ Agent'); },
+ // ── aixbt intelligence bridge (api/_lib/aixbt.js) ─────────────────────
+ // REST v2 API key for aixbt.tech. Powers /api/aixbt/* and the aixbt agent
+ // skills + MCP tools. Without it the endpoints return a designed
+ // "not configured" 503 (never fake data). Obtain a key with a full
+ // aixbt.tech subscription or by paying for a time-boxed x402 key pass at
+ // POST https://api.aixbt.tech/x402/v2/api-keys/{1d|1w|4w} (USDC on Base).
+ get AIXBT_API_KEY() {
+ return opt('AIXBT_API_KEY', '');
+ },
+ get AIXBT_API_BASE() {
+ return trimSlash(opt('AIXBT_API_BASE', 'https://api.aixbt.tech/v2'));
+ },
+ get AIXBT_ENABLED() {
+ return Boolean(this.AIXBT_API_KEY);
+ },
+
getRpcUrl(chainId) {
return (
opt(`RPC_URL_${chainId}`) ||
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.js
index 291b3b55c..bd0609f78 100644
--- a/api/_lib/rate-limit.js
+++ b/api/_lib/rate-limit.js
@@ -166,6 +166,11 @@ export const limits = {
pumpMetaIp: (ip) => getLimiter('pump:meta:ip', { limit: 60, window: '10 m' }).limit(ip),
oauthRegisterIp: (ip) =>
getLimiter('oauth:register:ip', { limit: 10, window: '1 h' }).limit(ip),
+ // aixbt intelligence bridge (api/aixbt/*). Each call may fall through to the
+ // upstream aixbt REST API, which is rate-limited per key — cap per IP so one
+ // caller can't drain the shared key's budget. Reads are cached, so this is
+ // generous enough for an interactive feed.
+ aixbtIp: (ip) => getLimiter('aixbt:ip', { limit: 90, window: '1 m' }).limit(ip),
mcpUser: (userId) => getLimiter('mcp:user', { limit: 1200, window: '1 m' }).limit(userId),
mcpIp: (ip) => getLimiter('mcp:ip', { limit: 600, window: '1 m' }).limit(ip),
// Paid MCP tools — each call runs real compute (glTF validation / inspection
diff --git a/api/aixbt/_shared.js b/api/aixbt/_shared.js
new file mode 100644
index 000000000..c4ba32d1a
--- /dev/null
+++ b/api/aixbt/_shared.js
@@ -0,0 +1,22 @@
+// Shared error responder for the /api/aixbt/* endpoints.
+//
+// Maps the typed errors thrown by api/_lib/aixbt.js onto stable JSON envelopes
+// the frontend can branch on. The "not configured" case carries a setup hint so
+// the UI can render an actionable empty state instead of a dead error.
+
+import { error, serverError } from '../_lib/http.js';
+
+export function respondAixbtError(res, err) {
+ if (err?.code === 'aixbt_not_configured') {
+ return error(res, 503, err.code, err.message, {
+ setup: 'Set AIXBT_API_KEY (full aixbt.tech subscription or an x402 key pass from https://api.aixbt.tech/x402/v2/api-keys).',
+ });
+ }
+ const status = Number(err?.status) || 502;
+ // 4xx/“upstream is the fault” (502/503/504/429) carry their descriptive code
+ // + message; only genuine internal faults get the sanitized 5xx treatment.
+ if (err?.code && (status < 500 || status === 502 || status === 503 || status === 504 || status === 429)) {
+ return error(res, status, err.code, err.message || 'aixbt request failed');
+ }
+ return serverError(res, 500, 'aixbt_error', err);
+}
diff --git a/api/aixbt/chat.js b/api/aixbt/chat.js
new file mode 100644
index 000000000..c6908093d
--- /dev/null
+++ b/api/aixbt/chat.js
@@ -0,0 +1,52 @@
+// POST /api/aixbt/chat — converse with aixbt's `indigo` research agent.
+//
+// Part of the three.ws ⇄ aixbt bridge. Lets a three.ws agent ask aixbt a
+// free-form market question and relay the answer (Pro/Holder aixbt plans).
+//
+// Body: { messages: [{ role, content }], ... } OR { message: "..." }
+// Response: { reply, source } | { error, error_description }
+
+import { wrap, cors, method, json, error, readJson } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { chatIndigo } from '../_lib/aixbt.js';
+import { respondAixbtError } from './_shared.js';
+
+const MAX_MESSAGES = 20;
+const MAX_LEN = 4000;
+
+function normalizeMessages(body) {
+ if (Array.isArray(body?.messages)) {
+ return body.messages
+ .filter((m) => m && typeof m.content === 'string' && m.content.trim())
+ .slice(-MAX_MESSAGES)
+ .map((m) => ({
+ role: m.role === 'assistant' || m.role === 'system' ? m.role : 'user',
+ content: m.content.slice(0, MAX_LEN),
+ }));
+ }
+ if (typeof body?.message === 'string' && body.message.trim()) {
+ return [{ role: 'user', content: body.message.slice(0, MAX_LEN) }];
+ }
+ return [];
+}
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const rl = await limits.aixbtIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const body = await readJson(req).catch(() => null);
+ const messages = normalizeMessages(body);
+ if (!messages.length) {
+ return error(res, 400, 'validation_error', 'provide a non-empty `message` or `messages` array');
+ }
+
+ try {
+ const result = await chatIndigo(messages);
+ return json(res, 200, result);
+ } catch (err) {
+ return respondAixbtError(res, err);
+ }
+});
diff --git a/api/aixbt/grounding.js b/api/aixbt/grounding.js
new file mode 100644
index 000000000..d04d0c235
--- /dev/null
+++ b/api/aixbt/grounding.js
@@ -0,0 +1,28 @@
+// GET /api/aixbt/grounding — hourly structured market context (crypto + tradfi).
+//
+// Part of the three.ws ⇄ aixbt bridge. Public, read-only. Updates hourly
+// upstream, so it is cached aggressively.
+//
+// Response: { grounding, source } | { error, error_description }
+
+import { wrap, cors, method, json, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { getGrounding } from '../_lib/aixbt.js';
+import { respondAixbtError } from './_shared.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.aixbtIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ try {
+ const result = await getGrounding();
+ return json(res, 200, result, {
+ 'cache-control': 'public, s-maxage=600, stale-while-revalidate=1800',
+ });
+ } catch (err) {
+ return respondAixbtError(res, err);
+ }
+});
diff --git a/api/aixbt/intel.js b/api/aixbt/intel.js
new file mode 100644
index 000000000..62acecb5e
--- /dev/null
+++ b/api/aixbt/intel.js
@@ -0,0 +1,35 @@
+// GET /api/aixbt/intel — recent aixbt narrative intelligence items.
+//
+// Part of the three.ws ⇄ aixbt bridge. Public, read-only, cache-friendly. The
+// aixbt API key stays server-side (api/_lib/aixbt.js); this endpoint is what
+// the aixbt agent skills and the aixbt_intel MCP tool call.
+//
+// Query: ?limit=20&category=<cat>&chain=<chain>
+// Response: { intel: [...], pagination } | { error, error_description, setup? }
+
+import { wrap, cors, method, json, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { getIntel } from '../_lib/aixbt.js';
+import { respondAixbtError } from './_shared.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.aixbtIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const url = new URL(req.url, 'http://x');
+ const limit = Number(url.searchParams.get('limit')) || 20;
+ const category = url.searchParams.get('category') || undefined;
+ const chain = url.searchParams.get('chain') || undefined;
+
+ try {
+ const result = await getIntel({ limit, category, chain });
+ return json(res, 200, result, {
+ 'cache-control': 'public, s-maxage=120, stale-while-revalidate=300',
+ });
+ } catch (err) {
+ return respondAixbtError(res, err);
+ }
+});
diff --git a/api/aixbt/projects.js b/api/aixbt/projects.js
new file mode 100644
index 000000000..f0fe9c95d
--- /dev/null
+++ b/api/aixbt/projects.js
@@ -0,0 +1,34 @@
+// GET /api/aixbt/projects — momentum-ranked projects from aixbt.
+//
+// Part of the three.ws ⇄ aixbt bridge. Public, read-only, cache-friendly.
+//
+// Query: ?limit=20&page=1&names=<comma list>&chain=<chain>
+// Response: { projects: [...], pagination } | { error, error_description }
+
+import { wrap, cors, method, json, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { getProjects } from '../_lib/aixbt.js';
+import { respondAixbtError } from './_shared.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.aixbtIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const url = new URL(req.url, 'http://x');
+ const limit = Number(url.searchParams.get('limit')) || 20;
+ const page = Number(url.searchParams.get('page')) || 1;
+ const names = url.searchParams.get('names') || undefined;
+ const chain = url.searchParams.get('chain') || undefined;
+
+ try {
+ const result = await getProjects({ limit, page, names, chain });
+ return json(res, 200, result, {
+ 'cache-control': 'public, s-maxage=90, stale-while-revalidate=240',
+ });
+ } catch (err) {
+ return respondAixbtError(res, err);
+ }
+});
diff --git a/mcp-server/src/index.js b/mcp-server/src/index.js
index 45a6c75d4..fc11ae8bc 100755
--- a/mcp-server/src/index.js
+++ b/mcp-server/src/index.js
@@ -38,6 +38,8 @@ import { buildAgentDelegateActionTool } from './tools/agent-delegate-action.js';
import { buildAgenCListTasksTool } from './tools/agenc-list-tasks.js';
import { buildAgenCGetTaskTool } from './tools/agenc-get-task.js';
import { buildAgenCGetAgentTool } from './tools/agenc-get-agent.js';
+import { buildAixbtIntelTool } from './tools/aixbt-intel.js';
+import { buildAixbtProjectsTool } from './tools/aixbt-projects.js';
const SERVER_INSTRUCTIONS =
'Paid x402 MCP tools from three.ws. Each tool quotes its USDC price in its description. ' +
@@ -51,7 +53,9 @@ const SERVER_INSTRUCTIONS =
'ERC-8004 agent reputation (agent_reputation), Solana vanity address mining ' +
'(vanity_grinder, upto-priced), and AgenC coordination protocol reads — ' +
'task discovery, task status + lifecycle, and agent registry lookup ' +
- '(agenc_list_tasks, agenc_get_task, agenc_get_agent).';
+ '(agenc_list_tasks, agenc_get_task, agenc_get_agent), and aixbt market ' +
+ 'intelligence — narrative intel feed and momentum-ranked project scans ' +
+ '(aixbt_intel, aixbt_projects).';
// Every tool builder. Each returns a descriptor
// { name, title, description, inputSchema (Zod shape), handler }. None of these
@@ -70,6 +74,8 @@ const TOOL_BUILDERS = [
buildAgenCListTasksTool,
buildAgenCGetTaskTool,
buildAgenCGetAgentTool,
+ buildAixbtIntelTool,
+ buildAixbtProjectsTool,
];
/**
diff --git a/mcp-server/src/tools/aixbt-intel.js b/mcp-server/src/tools/aixbt-intel.js
new file mode 100644
index 000000000..1c315cd0e
--- /dev/null
+++ b/mcp-server/src/tools/aixbt-intel.js
@@ -0,0 +1,92 @@
+// `aixbt_intel` — paid MCP tool that surfaces aixbt's narrative intelligence
+// feed (recent intel items: what's being said, where, and how reinforced) so a
+// three.ws agent can react to live market narratives.
+//
+// Pricing: $0.01 USDC, settled `exact` on Solana.
+//
+// Implementation: calls GET /api/aixbt/intel on the three.ws API surface, which
+// holds the aixbt API key server-side. This is the bridge the aixbt/three.ws
+// thread described — agents tap aixbt intelligence over the same x402 rails.
+
+import { z } from 'zod';
+
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
+
+const TOOL_NAME = 'aixbt_intel';
+const TOOL_DESCRIPTION =
+ 'aixbt narrative intelligence feed: recent intel items detected across crypto — category, description, observation count, official-source flag, and the project/ticker it concerns. Optionally filter by category or chain. Powered by the live aixbt REST API. Paid: $0.01 USDC.';
+
+function env(k, def) {
+ const v = process.env[k];
+ return v && String(v).trim() ? String(v).trim() : def;
+}
+
+const inputZodShape = {
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(50)
+ .describe('Max intel items to return (default 20).')
+ .optional(),
+ category: z.string().max(64).describe('Filter to a single aixbt intel category.').optional(),
+ chain: z.string().max(32).describe('Filter to a chain (e.g. solana, base, ethereum).').optional(),
+};
+
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
+export async function buildAixbtIntelTool() {
+ const handler = await paid(
+ {
+ toolName: TOOL_NAME,
+ description: TOOL_DESCRIPTION,
+ scheme: 'exact',
+ priceUsd: '$0.01',
+ inputSchema: inputJsonSchema,
+ example: { limit: 10, chain: 'solana' },
+ outputExample: {
+ intel: [
+ {
+ category: 'partnership',
+ description: 'Protocol X integrates with aixbt intelligence feeds',
+ observations: 12,
+ official_source: true,
+ project: 'three.ws',
+ ticker: 'THREE',
+ source: 'aixbt',
+ },
+ ],
+ },
+ },
+ async ({ limit, category, chain }) => {
+ const base = env('MCP_AIXBT_BASE', 'https://three.ws');
+ const url = new URL(`${base.replace(/\/$/, '')}/api/aixbt/intel`);
+ if (limit) url.searchParams.set('limit', String(limit));
+ if (category) url.searchParams.set('category', category);
+ if (chain) url.searchParams.set('chain', chain);
+
+ let res;
+ try {
+ res = await fetch(url, { headers: { accept: 'application/json' } });
+ } catch (err) {
+ return toolError('upstream_unreachable', err?.message || 'fetch failed');
+ }
+ const data = await res.json().catch(() => null);
+ if (!res.ok || !data || data.error) {
+ return toolError(
+ data?.error || 'aixbt_intel_failed',
+ data?.error_description || `endpoint returned ${res.status}`,
+ );
+ }
+ return data;
+ },
+ );
+ return {
+ name: TOOL_NAME,
+ title: 'aixbt intel ($0.01)',
+ description: TOOL_DESCRIPTION,
+ inputSchema: inputZodShape,
+ handler,
+ };
+}
diff --git a/mcp-server/src/tools/aixbt-projects.js b/mcp-server/src/tools/aixbt-projects.js
new file mode 100644
index 000000000..de1c8ed0a
--- /dev/null
+++ b/mcp-server/src/tools/aixbt-projects.js
@@ -0,0 +1,95 @@
+// `aixbt_projects` — paid MCP tool that returns aixbt's momentum-ranked
+// projects (spiking / climbing / active scores, market metrics, and the most
+// recent intel per project) so a three.ws agent can scan what's trending and
+// reason about where attention is flowing.
+//
+// Pricing: $0.01 USDC, settled `exact` on Solana.
+//
+// Implementation: calls GET /api/aixbt/projects on the three.ws API surface,
+// which holds the aixbt API key server-side.
+
+import { z } from 'zod';
+
+import { paid, toolError } from '../payments.js';
+import { jsonSchemaFromZod } from './_shared.js';
+
+const TOOL_NAME = 'aixbt_projects';
+const TOOL_DESCRIPTION =
+ 'aixbt momentum scan: projects ranked by aixbt spiking/climbing/active scores, with ticker, chain, market metrics (price, mcap, 24h volume + change) and recent intel. Filter by names (comma-separated) or chain. Powered by the live aixbt REST API. Paid: $0.01 USDC.';
+
+function env(k, def) {
+ const v = process.env[k];
+ return v && String(v).trim() ? String(v).trim() : def;
+}
+
+const inputZodShape = {
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(50)
+ .describe('Max projects to return (default 20).')
+ .optional(),
+ names: z
+ .string()
+ .max(256)
+ .describe('Comma-separated project names/tickers to filter to.')
+ .optional(),
+ chain: z.string().max(32).describe('Filter to a chain (e.g. solana, base, ethereum).').optional(),
+};
+
+const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
+
+export async function buildAixbtProjectsTool() {
+ const handler = await paid(
+ {
+ toolName: TOOL_NAME,
+ description: TOOL_DESCRIPTION,
+ scheme: 'exact',
+ priceUsd: '$0.01',
+ inputSchema: inputJsonSchema,
+ example: { limit: 10, chain: 'solana' },
+ outputExample: {
+ projects: [
+ {
+ name: 'three.ws',
+ ticker: 'THREE',
+ chain: 'solana',
+ scores: { spiking: 0.91, climbing: 0.74, active: 0.88 },
+ market: { price_usd: 0.00464, market_cap: null, volume_24h: null, change_24h: 45.9 },
+ source: 'aixbt',
+ },
+ ],
+ },
+ },
+ async ({ limit, names, chain }) => {
+ const base = env('MCP_AIXBT_BASE', 'https://three.ws');
+ const url = new URL(`${base.replace(/\/$/, '')}/api/aixbt/projects`);
+ if (limit) url.searchParams.set('limit', String(limit));
+ if (names) url.searchParams.set('names', names);
+ if (chain) url.searchParams.set('chain', chain);
+
+ let res;
+ try {
+ res = await fetch(url, { headers: { accept: 'application/json' } });
+ } catch (err) {
+ return toolError('upstream_unreachable', err?.message || 'fetch failed');
+ }
+ const data = await res.json().catch(() => null);
+ if (!res.ok || !data || data.error) {
+ return toolError(
+ data?.error || 'aixbt_projects_failed',
+ data?.error_description || `endpoint returned ${res.status}`,
+ );
+ }
+ return data;
+ },
+ );
+ return {
+ name: TOOL_NAME,
+ title: 'aixbt projects ($0.01)',
+ description: TOOL_DESCRIPTION,
+ inputSchema: inputZodShape,
+ handler,
+ };
+}
diff --git a/src/agent-skills-aixbt.js b/src/agent-skills-aixbt.js
new file mode 100644
index 000000000..89c4c3ef3
--- /dev/null
+++ b/src/agent-skills-aixbt.js
@@ -0,0 +1,151 @@
+/**
+ * aixbt intelligence skills
+ * -------------------------
+ * Lets a three.ws avatar tap aixbt's live market intelligence — narrative intel
+ * and momentum-ranked projects — then speak a concise read in-world. This is the
+ * three.ws ⇄ aixbt bridge surfaced as agent behaviour: the avatar reacts to real
+ * feeds the same way builders consume the aixbt API.
+ *
+ * Backed by /api/aixbt/* (the aixbt API key stays server-side). When aixbt is
+ * not configured the endpoint returns a 503 the handler turns into an honest,
+ * actionable message — never fabricated signals.
+ */
+
+import { log } from './shared/log.js';
+
+const BASE = '/api/aixbt';
+
+async function getJson(path) {
+ const res = await fetch(`${BASE}${path}`, { headers: { accept: 'application/json' } });
+ const body = await res.json().catch(() => null);
+ if (!res.ok || !body || body.error) {
+ const code = body?.error || `http_${res.status}`;
+ const msg = body?.error_description || `aixbt request failed (${res.status})`;
+ const err = new Error(msg);
+ err.code = code;
+ err.setup = body?.setup;
+ throw err;
+ }
+ return body;
+}
+
+function notConfiguredMessage(err) {
+ if (err?.code !== 'aixbt_not_configured') return null;
+ return {
+ success: false,
+ output:
+ "aixbt isn't connected yet on this deployment. Once an aixbt API key is set, I can pull live narrative intel and momentum scans for you.",
+ sentiment: -0.1,
+ data: { code: err.code, setup: err.setup },
+ };
+}
+
+export function registerAixbtSkills(agentSkills) {
+ // ── aixbt-intel ───────────────────────────────────────────────────────
+ agentSkills.register({
+ name: 'aixbt-intel',
+ description: 'Pull the latest aixbt narrative intelligence and read the top items',
+ instruction:
+ 'Fetch recent aixbt intel, optionally filtered by chain or category, and summarise the strongest signals out loud.',
+ animationHint: 'think',
+ voicePattern: 'Pulling the latest from aixbt...',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ limit: { type: 'number', description: 'How many intel items to scan (default 5).' },
+ chain: { type: 'string', description: 'Filter to a chain (solana, base, ethereum, …).' },
+ category: { type: 'string', description: 'Filter to a single intel category.' },
+ },
+ },
+ handler: async (args = {}) => {
+ const limit = Math.min(Math.max(1, Number(args.limit) || 5), 25);
+ try {
+ const params = new URLSearchParams({ limit: String(limit) });
+ if (args.chain) params.set('chain', args.chain);
+ if (args.category) params.set('category', args.category);
+ const { intel = [] } = await getJson(`/intel?${params}`);
+
+ if (!intel.length) {
+ return {
+ success: true,
+ output: 'aixbt has no fresh intel matching that filter right now. Try a broader chain or category.',
+ sentiment: 0,
+ data: { intel: [] },
+ };
+ }
+
+ const top = intel.slice(0, 3);
+ const lines = top.map((i) => {
+ const who = i.ticker ? `$${i.ticker}` : i.project || i.category || 'market';
+ return `${who}: ${i.description}`;
+ });
+ const output = `aixbt is tracking ${intel.length} signal${intel.length === 1 ? '' : 's'}. Top reads — ${lines.join(' · ')}`;
+ return { success: true, output, sentiment: 0.4, data: { intel } };
+ } catch (err) {
+ const nc = notConfiguredMessage(err);
+ if (nc) return nc;
+ log.error('aixbt-intel failed:', err);
+ return { success: false, output: `Couldn't reach aixbt intel: ${err.message}`, sentiment: -0.3 };
+ }
+ },
+ });
+
+ // ── aixbt-scan ────────────────────────────────────────────────────────
+ agentSkills.register({
+ name: 'aixbt-scan',
+ description: 'Scan aixbt momentum-ranked projects and read the movers',
+ instruction:
+ 'Fetch aixbt momentum projects, optionally filtered by chain or names, and call out the highest-momentum movers with their 24h change.',
+ animationHint: 'present',
+ voicePattern: 'Scanning aixbt momentum...',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ limit: { type: 'number', description: 'How many projects to scan (default 5).' },
+ names: { type: 'string', description: 'Comma-separated names/tickers to filter to.' },
+ chain: { type: 'string', description: 'Filter to a chain (solana, base, ethereum, …).' },
+ },
+ },
+ handler: async (args = {}) => {
+ const limit = Math.min(Math.max(1, Number(args.limit) || 5), 25);
+ try {
+ const params = new URLSearchParams({ limit: String(limit) });
+ if (args.names) params.set('names', args.names);
+ if (args.chain) params.set('chain', args.chain);
+ const { projects = [] } = await getJson(`/projects?${params}`);
+
+ if (!projects.length) {
+ return {
+ success: true,
+ output: 'aixbt has no projects matching that filter right now.',
+ sentiment: 0,
+ data: { projects: [] },
+ };
+ }
+
+ const top = projects.slice(0, 3);
+ const lines = top.map((p) => {
+ const tag = p.ticker ? `$${p.ticker}` : p.name || 'unknown';
+ const chg = p.market?.change_24h;
+ const chgStr = chg == null ? '' : ` (${chg >= 0 ? '+' : ''}${chg.toFixed(1)}% 24h)`;
+ return `${tag}${chgStr}`;
+ });
+ const avgChange = top
+ .map((p) => p.market?.change_24h)
+ .filter((c) => c != null);
+ const sentiment = avgChange.length
+ ? Math.max(-1, Math.min(1, avgChange.reduce((a, b) => a + b, 0) / avgChange.length / 50))
+ : 0.2;
+ const output = `aixbt momentum — ${lines.join(', ')}.`;
+ return { success: true, output, sentiment, data: { projects } };
+ } catch (err) {
+ const nc = notConfiguredMessage(err);
+ if (nc) return nc;
+ log.error('aixbt-scan failed:', err);
+ return { success: false, output: `Couldn't reach aixbt momentum: ${err.message}`, sentiment: -0.3 };
+ }
+ },
+ });
+}
diff --git a/src/agent-skills.js b/src/agent-skills.js
index 48db54b77..eda0743de 100644
--- a/src/agent-skills.js
+++ b/src/agent-skills.js
@@ -23,6 +23,7 @@ import { registerNftSkills } from './agent-skills-nfts.js';
import { registerSceneSkills } from './agent-skills-scene.js';
import { registerSentimentSkills } from './agent-skills-sentiment.js';
import { registerAgentPaymentSkills } from './agent-skills-agent-payments.js';
+import { registerAixbtSkills } from './agent-skills-aixbt.js';
/**
* @typedef {Object} SkillContext
@@ -75,6 +76,7 @@ export class AgentSkills {
registerSceneSkills(this);
registerSentimentSkills(this);
registerAgentPaymentSkills(this);
+ registerAixbtSkills(this);
}
// ── Registry ──────────────────────────────────────────────────────────────
diff --git a/src/dashboard-next/pages/api.js b/src/dashboard-next/pages/api.js
index b6a8e43b8..17ec484d4 100644
--- a/src/dashboard-next/pages/api.js
+++ b/src/dashboard-next/pages/api.js
@@ -1,6 +1,7 @@
// dashboard-next — API & Embed page.
//
-// Four sections:
+// Five sections:
+// 0. Agent Toolkit — Connect to Claude (one-click MCP), Skill/CLI/MCP resources
// 1. API keys — list, create (with one-shot secret reveal), revoke
// 2. MCP setup — Claude Desktop / Cursor / Generic JSON configs
// 3. Embed snippets — Script tag / iframe / web-component with live preview
@@ -43,8 +44,9 @@ const KEY_PLACEHOLDER = 'YOUR_API_KEY';
main.innerHTML = `
<h1 class="dn-h1">API & embed</h1>
- <p class="dn-h1-sub">Issue keys, configure MCP clients, embed agents anywhere.</p>
+ <p class="dn-h1-sub">Connect your agent, issue keys, configure MCP clients, embed agents anywhere.</p>
<div class="dn-stack" data-slot="content">
+ <div class="dn-panel dn-toolkit-panel" data-section="toolkit"><div class="dn-skeleton" style="height:220px"></div></div>
<div class="dn-panel" data-section="keys"><div class="dn-skeleton" style="height:180px"></div></div>
<div class="dn-panel" data-section="mcp"><div class="dn-skeleton" style="height:180px"></div></div>
<div class="dn-panel" data-section="embed"><div class="dn-skeleton" style="height:240px"></div></div>
@@ -75,10 +77,11 @@ const KEY_PLACEHOLDER = 'YOUR_API_KEY';
const content = main.querySelector('[data-slot="content"]');
const sections = {
- keys: content.querySelector('[data-section="keys"]'),
- mcp: content.querySelector('[data-section="mcp"]'),
- embed: content.querySelector('[data-section="embed"]'),
- policy: content.querySelector('[data-section="policy"]'),
+ toolkit: content.querySelector('[data-section="toolkit"]'),
+ keys: content.querySelector('[data-section="keys"]'),
+ mcp: content.querySelector('[data-section="mcp"]'),
+ embed: content.querySelector('[data-section="embed"]'),
+ policy: content.querySelector('[data-section="policy"]'),
};
// Fetch the four data sources concurrently. Each one is optional —
@@ -99,6 +102,7 @@ const KEY_PLACEHOLDER = 'YOUR_API_KEY';
state.selectedKeyForMcp = pickDisplayKey(state.keys);
state.embed.selection = pickDefaultEmbedTarget(state.avatars, state.widgets, state.agents);
+ renderToolkit(sections.toolkit, state);
renderKeys(sections.keys, state);
renderMcp(sections.mcp, state);
renderEmbed(sections.embed, state);
@@ -195,6 +199,166 @@ function origin() {
return location.origin.replace(/\/$/, '');
}
+// ── Section 0: Agent Toolkit ──────────────────────────────────────────────
+//
+// The "connect your agent" front door — mirrors the way other agent platforms
+// surface a one-click client hookup plus the three install surfaces (Skill,
+// CLI, MCP). Every command here is real and copy-paste runnable:
+// Skill → `/plugin marketplace add nirholas/three.ws` (Claude Code plugins)
+// CLI → `npm i -g @three-ws/avatar-cli` (the three-ws-avatar bin)
+// MCP → https://<host>/api/mcp (hosted streamable HTTP)
+// "Connect to Claude" opens a modal with the exact `claude mcp add` one-liner
+// and the Claude Desktop config, pre-filled with the active key prefix.
+
+function toolkitResources() {
+ return [
+ {
+ id: 'skill',
+ tag: 'Skill',
+ title: 'Claude plugins',
+ desc: 'Install the three.ws skill pack — wallet, payments, pump.fun, and agent scaffolding.',
+ cmd: '/plugin marketplace add nirholas/three.ws',
+ doc: { href: '/docs/quick-start', label: 'Skill docs' },
+ },
+ {
+ id: 'cli',
+ tag: 'CLI',
+ title: 'Command line',
+ desc: 'Drive avatars and agents from your terminal or CI with the three-ws-avatar binary.',
+ cmd: 'npm i -g @three-ws/avatar-cli',
+ doc: { href: '/docs/quick-start', label: 'CLI docs' },
+ },
+ {
+ id: 'mcp',
+ tag: 'MCP',
+ title: 'MCP server',
+ desc: 'Point Claude, Cursor, or any MCP host at your agents over streamable HTTP.',
+ cmd: `${origin()}/api/mcp`,
+ doc: { href: '/docs/mcp', label: 'MCP setup' },
+ },
+ ];
+}
+
+function renderToolkit(host, state) {
+ const resources = toolkitResources();
+ host.innerHTML = `
+ <div class="dn-toolkit-hero">
+ <div class="dn-toolkit-copy">
+ <div class="dn-toolkit-eyebrow">Agent Toolkit</div>
+ <h2 class="dn-toolkit-h">Connect your agent to three.ws.</h2>
+ <p class="dn-toolkit-sub">Drive 3D avatars, query live market intel, and pay per call — straight from Claude, Cursor, your CLI, or any MCP client.</p>
+ <div class="dn-toolkit-cta">
+ <button class="dn-btn primary dn-connect-claude" data-act="connect-claude">
+ <svg viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path fill="currentColor" d="M4.7 16.6 9 5.4h2.1l4.3 11.2h-2.05l-1-2.74H7.7l-1 2.74H4.7Zm3.55-4.4h3.4L10 7.2l-1.75 5Zm9.05 4.4V5.4h1.95v11.2H17.3Z"/></svg>
+ Connect to Claude
+ </button>
+ <a class="dn-btn" href="/docs/mcp">Builder docs <span aria-hidden="true">→</span></a>
+ </div>
+ </div>
+ </div>
+
+ <div class="dn-toolkit-grid">
+ ${resources.map((r) => `
+ <div class="dn-toolkit-card">
+ <div class="dn-toolkit-card-head">
+ <span class="dn-toolkit-card-tag">${esc(r.tag)}</span>
+ <span class="dn-toolkit-card-title">${esc(r.title)}</span>
+ </div>
+ <p class="dn-toolkit-card-desc">${esc(r.desc)}</p>
+ <div class="dn-toolkit-cmd">
+ <code data-snippet="toolkit-${esc(r.id)}">${esc(r.cmd)}</code>
+ <button type="button" class="dn-code-copy dn-toolkit-copy" data-copy="toolkit-${esc(r.id)}" aria-label="Copy ${esc(r.title)} command">Copy</button>
+ </div>
+ <a class="dn-toolkit-card-doc" href="${esc(r.doc.href)}">${esc(r.doc.label)} <span aria-hidden="true">↗</span></a>
+ </div>
+ `).join('')}
+ </div>
+
+ <div class="dn-toolkit-foot">
+ <a class="dn-link" href="/docs">Builder docs</a>
+ <a class="dn-link" href="/docs/api-reference">API docs</a>
+ <a class="dn-link" href="/docs/mcp">MCP setup</a>
+ <button type="button" class="dn-link" data-act="jump-keys">API keys</button>
+ </div>
+ `;
+
+ host.querySelector('[data-act="connect-claude"]').addEventListener('click', () => openConnectClaudeModal(state));
+ host.querySelector('[data-act="jump-keys"]').addEventListener('click', () => {
+ document.querySelector('[data-section="keys"]')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
+ });
+ host.querySelectorAll('[data-copy]').forEach((b) => {
+ b.addEventListener('click', () => {
+ const code = host.querySelector(`[data-snippet="${b.dataset.copy}"]`)?.textContent || '';
+ copyToClipboard(code, b);
+ });
+ });
+}
+
+function openConnectClaudeModal(state) {
+ const live = state.keys.filter((k) => !k.revoked_at);
+ const selected = (state.selectedKeyForMcp && live.find((k) => k.id === state.selectedKeyForMcp.id)) || live[0] || null;
+ const token = selected ? `${selected.prefix}…` : KEY_PLACEHOLDER;
+ const mcpUrl = `${origin()}/api/mcp`;
+
+ const cliCmd = `claude mcp add --transport http three-ws ${mcpUrl} --header "Authorization: Bearer ${token}"`;
+ const desktopCfg = JSON.stringify({
+ mcpServers: {
+ 'three-ws': {
+ url: mcpUrl,
+ headers: { authorization: `Bearer ${token}` },
+ },
+ },
+ }, null, 2);
+
+ const { el } = openModal(`
+ <div class="dn-modal-head">
+ <h2>Connect to Claude</h2>
+ <button type="button" class="dn-btn ghost" data-modal-close aria-label="Close">×</button>
+ </div>
+ ${selected
+ ? `<p class="dn-modal-body" style="margin-bottom:14px">Using key <strong>${esc(selected.name)}</strong> (<code>${esc(selected.prefix)}…</code>). Swap the prefix for your full secret — the one shown once at creation.</p>`
+ : `<div class="dn-warn-banner"><strong>No API key yet.</strong>These snippets use the <code>${esc(KEY_PLACEHOLDER)}</code> placeholder. Create a key first, then paste it in.</div>`}
+
+ <div class="dn-modal-block">
+ <div class="dn-modal-block-label">Claude Code — one command</div>
+ <div class="dn-code-block">
+ <pre><code data-snippet="cc-cli">${esc(cliCmd)}</code></pre>
+ <button type="button" class="dn-code-copy" data-copy="cc-cli">Copy</button>
+ </div>
+ </div>
+
+ <div class="dn-modal-block">
+ <div class="dn-modal-block-label">Claude Desktop — config</div>
+ <p class="dn-modal-hint">Add to <code>claude_desktop_config.json</code>, then restart Claude Desktop.</p>
+ <div class="dn-code-block">
+ <pre><code data-snippet="cc-desktop">${esc(desktopCfg)}</code></pre>
+ <button type="button" class="dn-code-copy" data-copy="cc-desktop">Copy</button>
+ </div>
+ </div>
+
+ <div class="dn-modal-foot">
+ ${!selected ? `<button type="button" class="dn-btn primary" data-act="make-key">Create an API key</button>` : ''}
+ <a class="dn-btn ghost" href="/docs/mcp">Full MCP setup ↗</a>
+ <button type="button" class="dn-btn ${selected ? 'primary' : ''}" data-modal-close data-autofocus>Done</button>
+ </div>
+ `);
+
+ el.querySelectorAll('[data-copy]').forEach((b) => {
+ b.addEventListener('click', () => {
+ const code = el.querySelector(`[data-snippet="${b.dataset.copy}"]`)?.textContent || '';
+ copyToClipboard(code, b);
+ });
+ });
+ const makeKeyBtn = el.querySelector('[data-act="make-key"]');
+ if (makeKeyBtn) {
+ makeKeyBtn.addEventListener('click', () => {
+ el.closest('.dn-modal-backdrop')?.remove();
+ document.querySelector('[data-section="keys"]')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
+ document.querySelector('[data-act="new-key"]')?.click();
+ });
+ }
+}
+
// ── Section 1: API keys ───────────────────────────────────────────────────
function renderKeys(host, state) {
@@ -1059,6 +1223,38 @@ function injectStyles() {
.dn-code-copy:hover { color: var(--nxt-ink); }
.dn-code-copy.copied { color: var(--nxt-success); }
+ /* Agent Toolkit */
+ .dn-toolkit-panel { background: radial-gradient(120% 140% at 0% 0%, var(--nxt-accent-soft, rgba(255,255,255,0.06)) 0%, transparent 55%), var(--nxt-panel, rgba(255,255,255,0.02)); }
+ .dn-toolkit-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
+ .dn-toolkit-copy { max-width: 560px; }
+ .dn-toolkit-eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--nxt-ink-fade); margin-bottom: 8px; }
+ .dn-toolkit-h { margin: 0 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--nxt-ink); }
+ .dn-toolkit-sub { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--nxt-ink-dim); }
+ .dn-toolkit-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
+ .dn-connect-claude { display: inline-flex; align-items: center; gap: 7px; }
+ .dn-connect-claude svg { flex-shrink: 0; }
+
+ .dn-toolkit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
+ @media (max-width: 820px) { .dn-toolkit-grid { grid-template-columns: 1fr; } }
+ .dn-toolkit-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--nxt-stroke); border-radius: var(--nxt-radius-sm); background: rgba(255,255,255,0.015); transition: border-color 0.14s ease, transform 0.14s ease; }
+ .dn-toolkit-card:hover { border-color: var(--nxt-accent, rgba(255,255,255,0.25)); transform: translateY(-1px); }
+ .dn-toolkit-card-head { display: flex; align-items: center; gap: 8px; }
+ .dn-toolkit-card-tag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--nxt-ink); background: var(--nxt-accent-soft, rgba(255,255,255,0.08)); padding: 2px 7px; border-radius: var(--nxt-radius-pill); }
+ .dn-toolkit-card-title { font-size: 13.5px; font-weight: 500; color: var(--nxt-ink); }
+ .dn-toolkit-card-desc { margin: 0; font-size: 12px; line-height: 1.5; color: var(--nxt-ink-fade); flex: 1; }
+ .dn-toolkit-cmd { position: relative; display: flex; align-items: center; }
+ .dn-toolkit-cmd code { display: block; width: 100%; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; color: #d8dbe5; background: #0a0a10; border: 1px solid var(--nxt-stroke); border-left: 2px solid var(--nxt-accent); border-radius: var(--nxt-radius-sm); padding: 9px 52px 9px 11px; overflow-x: auto; white-space: nowrap; }
+ .dn-toolkit-copy { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); opacity: 0.5; }
+ .dn-toolkit-cmd:hover .dn-toolkit-copy { opacity: 1; }
+ .dn-toolkit-card-doc { font-size: 11.5px; color: var(--nxt-ink-dim); text-decoration: none; transition: color 0.12s ease; }
+ .dn-toolkit-card-doc:hover { color: var(--nxt-ink); }
+ .dn-toolkit-foot { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--nxt-stroke); }
+
+ .dn-modal-block { margin-bottom: 16px; }
+ .dn-modal-block-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--nxt-ink-fade); margin-bottom: 7px; }
+ .dn-modal-hint { margin: 0 0 7px; font-size: 12px; color: var(--nxt-ink-dim); }
+ .dn-modal-hint code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; padding: 1px 5px; background: rgba(255,255,255,0.06); border-radius: 4px; }
+
/* MCP */
.dn-mcp-key-picker { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dn-mcp-key-picker select { background: rgba(255,255,255,0.04); border: 1px solid var(--nxt-stroke); color: var(--nxt-ink); padding: 6px 9px; border-radius: var(--nxt-radius-sm); font-size: 12.5px; }
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index 080fac252..a97166b67 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -46,6 +46,7 @@ import { AgentCommerce } from './agent-commerce.js';
import { WorldLife } from './npc/world-life.js';
import { isChatPanelOpen } from './npc/npc-chat.js';
import { isServicePanelOpen } from './npc/npc-services.js';
+import { isAixbtPanelOpen } from './npc/npc-aixbt.js';
import { VoiceChat, voiceSupported } from './voice-chat.js';
import { requestHolderPass, signInWithX, ensureSolanaWallet, relinkSolanaWallet, getSession, getWorldGate, setWorldGate } from '../community/town-auth.js';
import { ensurePlayAccess } from './play-gate.js';
@@ -1418,7 +1419,7 @@ export class CoinCommunities {
e.preventDefault();
// A conversation or counter is already open — let it own the moment
// instead of reopening on top of itself.
- if (isChatPanelOpen() || isServicePanelOpen()) return;
+ if (isChatPanelOpen() || isServicePanelOpen() || isAixbtPanelOpen()) return;
// Talk to the nearest townsperson (vendor/quest/flavor); if none is
// in range, fall through to the home town's Agent Exchange.
if (!this.worldLife?.interact()) this.agentCommerce?.interact();
diff --git a/src/game/npc/npc-aixbt.js b/src/game/npc/npc-aixbt.js
new file mode 100644
index 000000000..92b5d9bb1
--- /dev/null
+++ b/src/game/npc/npc-aixbt.js
@@ -0,0 +1,272 @@
+// AIXBT — the town's intelligence terminal.
+//
+// Unlike the vendor counters (npc-services.js), aixbt doesn't sell a one-shot
+// paid call: he's the wired-in oracle. Walk up, press E, and he immediately
+// pulls the live aixbt feed — narrative intel + momentum-ranked movers — and
+// reads it back in a terminal panel. A query bar re-runs the feed for a token
+// or chain. Data is the three.ws ⇄ aixbt bridge (/api/aixbt/*); the upstream
+// aixbt key stays server-side.
+//
+// Free at the counter because three.ws already pays aixbt upstream; the paid
+// layer lives on the MCP tools (aixbt_intel / aixbt_projects) for other agents.
+//
+// Self-contained: reuses the .npc-svc-* panel chrome for native look + the
+// shared overlay lifecycle, plus a small .aixbt-* stylesheet injected once.
+
+// ── tiny DOM helper (mirrors npc-services.js conventions) ─────────────────────
+function el(tag, attrs, kids) {
+ const node = document.createElement(tag);
+ if (attrs) {
+ for (const [k, v] of Object.entries(attrs)) {
+ if (v == null || v === false) continue;
+ if (k === 'class') node.className = v;
+ else if (k === 'text') node.textContent = v;
+ else if (k === 'html') node.innerHTML = v;
+ else if (k.startsWith('on') && typeof v === 'function') node.addEventListener(k.slice(2).toLowerCase(), v);
+ else node.setAttribute(k, v === true ? '' : v);
+ }
+ }
+ for (const kid of [].concat(kids || [])) {
+ if (kid == null || kid === false) continue;
+ node.appendChild(typeof kid === 'string' ? document.createTextNode(kid) : kid);
+ }
+ return node;
+}
+
+function fmtPct(n) {
+ if (n == null || Number.isNaN(Number(n))) return '—';
+ const v = Number(n);
+ return (v >= 0 ? '+' : '') + v.toFixed(2) + '%';
+}
+function fmtUsd(n) {
+ if (n == null || Number.isNaN(Number(n))) return '—';
+ const v = Number(n);
+ if (v >= 1) return '$' + v.toLocaleString(undefined, { maximumFractionDigits: 2 });
+ return '$' + v.toLocaleString(undefined, { maximumSignificantDigits: 4 });
+}
+function scoreBar(label, score) {
+ const pct = Math.max(0, Math.min(100, Math.round((Number(score) || 0) * 100)));
+ return el('div', { class: 'aixbt-score' }, [
+ el('span', { class: 'aixbt-score-k', text: label }),
+ el('span', { class: 'aixbt-score-track' }, [
+ el('span', { class: 'aixbt-score-fill', style: `width:${pct}%` }),
+ ]),
+ el('span', { class: 'aixbt-score-v', text: score == null ? '—' : pct + '%' }),
+ ]);
+}
+
+const CHAINS = [
+ { value: '', label: 'All chains' },
+ { value: 'solana', label: 'Solana' },
+ { value: 'base', label: 'Base' },
+ { value: 'ethereum', label: 'Ethereum' },
+];
+
+function injectStyles() {
+ if (document.getElementById('aixbt-term-styles')) return;
+ const s = document.createElement('style');
+ s.id = 'aixbt-term-styles';
+ s.textContent = `
+ .npc-svc-card.is-aixbt { max-width: 640px; }
+ .npc-svc-card.is-aixbt .npc-svc-title { display: flex; align-items: center; gap: 8px; }
+ .aixbt-live { display:inline-flex; align-items:center; gap:5px; font-size:10px; font-weight:800; letter-spacing:0.08em; color:#27e0c4; }
+ .aixbt-live::before { content:''; width:7px; height:7px; border-radius:50%; background:#27e0c4; box-shadow:0 0 8px #27e0c4; animation:aixbt-pulse 1.6s ease-in-out infinite; }
+ @keyframes aixbt-pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
+ .aixbt-bar { display:flex; gap:8px; margin:4px 0 14px; }
+ .aixbt-bar .npc-svc-input { margin:0; }
+ .aixbt-bar .aixbt-token { flex:1 1 auto; }
+ .aixbt-bar .aixbt-chain { flex:0 0 130px; }
+ .aixbt-refresh { flex:0 0 auto; border:1px solid var(--cc-edge, rgba(255,255,255,0.14)); background:rgba(39,224,196,0.12); color:#9ff4e6; font-weight:700; border-radius:var(--cc-radius,4px); padding:0 14px; cursor:pointer; transition:background .15s ease; }
+ .aixbt-refresh:hover { background:rgba(39,224,196,0.22); }
+ .aixbt-refresh:disabled { opacity:0.5; cursor:default; }
+ .aixbt-section-h { font-size:11px; font-weight:800; letter-spacing:0.07em; text-transform:uppercase; color:var(--cc-muted,#9a9aa2); margin:16px 0 8px; }
+ .aixbt-row { padding:10px 0; border-top:1px solid var(--cc-edge, rgba(255,255,255,0.08)); }
+ .aixbt-row:first-of-type { border-top:0; }
+ .aixbt-row-top { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
+ .aixbt-tkr { font-weight:800; letter-spacing:0.02em; }
+ .aixbt-cat { font-size:10px; font-weight:700; letter-spacing:0.05em; text-transform:uppercase; color:#8fb8ff; background:rgba(120,170,255,0.12); border-radius:3px; padding:1px 6px; }
+ .aixbt-chg.up { color:#43d6a0; } .aixbt-chg.down { color:#ff7a8a; } .aixbt-chg.flat { color:var(--cc-muted,#9a9aa2); }
+ .aixbt-chg { font-weight:800; font-variant-numeric:tabular-nums; }
+ .aixbt-desc { margin:5px 0 0; color:var(--cc-text,#e9e9ec); font-size:13px; line-height:1.45; }
+ .aixbt-meta { margin-top:5px; font-size:11px; color:var(--cc-muted,#9a9aa2); display:flex; gap:12px; flex-wrap:wrap; }
+ .aixbt-official { color:#43d6a0; }
+ .aixbt-scores { margin-top:7px; display:grid; gap:5px; }
+ .aixbt-score { display:grid; grid-template-columns:64px 1fr 38px; align-items:center; gap:8px; }
+ .aixbt-score-k { font-size:10px; text-transform:uppercase; letter-spacing:0.05em; color:var(--cc-muted,#9a9aa2); }
+ .aixbt-score-track { height:5px; border-radius:3px; background:rgba(255,255,255,0.08); overflow:hidden; }
+ .aixbt-score-fill { display:block; height:100%; background:linear-gradient(90deg,#27e0c4,#7aa8ff); border-radius:3px; transition:width .4s ease; }
+ .aixbt-score-v { font-size:11px; text-align:right; color:var(--cc-text,#e9e9ec); font-variant-numeric:tabular-nums; }
+ .aixbt-skel { height:54px; border-radius:6px; background:linear-gradient(90deg,rgba(255,255,255,0.05),rgba(255,255,255,0.11),rgba(255,255,255,0.05)); background-size:200% 100%; animation:aixbt-shimmer 1.2s linear infinite; margin-bottom:8px; }
+ @keyframes aixbt-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
+ .aixbt-empty, .aixbt-error { color:var(--cc-muted,#9a9aa2); font-size:13px; padding:14px 0; }
+ .aixbt-error { color:#ffb4be; }
+ .aixbt-setup { margin-top:8px; font-size:12px; color:var(--cc-muted,#9a9aa2); }`;
+ document.head.appendChild(s);
+}
+
+// ── panel lifecycle (single instance, ESC, overlay click) ─────────────────────
+let openPanel = null;
+
+export function isAixbtPanelOpen() { return !!openPanel; }
+
+function closePanel() {
+ if (!openPanel) return;
+ const { overlay, onKey, opener } = openPanel;
+ document.removeEventListener('keydown', onKey, true);
+ overlay.classList.remove('is-in');
+ const node = overlay;
+ setTimeout(() => node.remove(), 180);
+ openPanel = null;
+ if (opener && typeof opener.focus === 'function') opener.focus();
+}
+
+async function fetchJson(path) {
+ const res = await fetch(path, { headers: { accept: 'application/json' } });
+ const body = await res.json().catch(() => null);
+ if (!res.ok || !body || body.error) {
+ const err = new Error(body?.error_description || `request failed (${res.status})`);
+ err.code = body?.error || `http_${res.status}`;
+ err.setup = body?.setup;
+ throw err;
+ }
+ return body;
+}
+
+function renderIntel(items) {
+ if (!items.length) return el('div', { class: 'aixbt-empty', text: 'No fresh narratives for that filter.' });
+ return el('div', {}, items.map((i) => el('div', { class: 'aixbt-row' }, [
+ el('div', { class: 'aixbt-row-top' }, [
+ i.ticker ? el('span', { class: 'aixbt-tkr', text: `$${i.ticker}` }) : (i.project ? el('span', { class: 'aixbt-tkr', text: i.project }) : null),
+ i.category ? el('span', { class: 'aixbt-cat', text: i.category }) : null,
+ ]),
+ i.description ? el('p', { class: 'aixbt-desc', text: i.description }) : null,
+ el('div', { class: 'aixbt-meta' }, [
+ i.observations != null ? el('span', { text: `${i.observations} observation${i.observations === 1 ? '' : 's'}` }) : null,
+ i.official_source ? el('span', { class: 'aixbt-official', text: '✓ official source' }) : null,
+ ]),
+ ])));
+}
+
+function renderProjects(items) {
+ if (!items.length) return el('div', { class: 'aixbt-empty', text: 'No projects matched that filter.' });
+ return el('div', {}, items.map((p) => {
+ const chg = p.market?.change_24h;
+ const tone = chg == null ? 'flat' : chg > 0 ? 'up' : chg < 0 ? 'down' : 'flat';
+ return el('div', { class: 'aixbt-row' }, [
+ el('div', { class: 'aixbt-row-top' }, [
+ el('span', { class: 'aixbt-tkr', text: p.ticker ? `$${p.ticker}` : (p.name || 'unknown') }),
+ p.chain ? el('span', { class: 'aixbt-cat', text: p.chain }) : null,
+ el('span', { class: `aixbt-chg ${tone}`, text: fmtPct(chg) }),
+ p.market?.price_usd != null ? el('span', { class: 'aixbt-meta', text: fmtUsd(p.market.price_usd) }) : null,
+ ]),
+ el('div', { class: 'aixbt-scores' }, [
+ scoreBar('Spiking', p.scores?.spiking),
+ scoreBar('Climbing', p.scores?.climbing),
+ scoreBar('Active', p.scores?.active),
+ ]),
+ ]);
+ }));
+}
+
+// Open aixbt's intelligence terminal. Auto-loads the live feed; the query bar
+// re-runs it. Manages its own lifecycle (no return value).
+export function openAixbtTerminal(npc, { ui } = {}) {
+ injectStyles();
+ closePanel();
+
+ const titleId = 'aixbt-term-title';
+ const card = el('div', { class: 'npc-svc-card is-aixbt', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': titleId });
+ const overlay = el('div', { class: 'npc-svc-overlay' }, [card]);
+ overlay.addEventListener('mousedown', (e) => { if (e.target === overlay) closePanel(); });
+
+ const close = el('button', { class: 'npc-svc-close', type: 'button', 'aria-label': 'Close', text: '✕', onclick: closePanel });
+ card.appendChild(el('header', { class: 'npc-svc-head' }, [
+ el('div', {}, [
+ npc?.def?.name ? el('div', { class: 'npc-svc-who', text: npc.def.name }) : null,
+ el('h2', { id: titleId, class: 'npc-svc-title' }, ['Intelligence Terminal', el('span', { class: 'aixbt-live', text: 'LIVE' })]),
+ ]),
+ close,
+ ]));
+ card.appendChild(el('p', { class: 'npc-svc-intro', text: 'Live aixbt feed — narrative intel and momentum movers. Filter by token or chain.' }));
+
+ // Query bar.
+ const tokenInput = el('input', { class: 'npc-svc-input aixbt-token', type: 'text', placeholder: 'Token or ticker (optional)' });
+ const chainSelect = el('select', { class: 'npc-svc-input aixbt-chain' }, CHAINS.map((c) =>
+ el('option', { value: c.value }, [c.label])));
+ const refreshBtn = el('button', { class: 'aixbt-refresh', type: 'button', text: 'Refresh' });
+ // Keep typing out of the world's movement handlers (window-level keydown).
+ for (const node of [tokenInput, chainSelect]) {
+ node.addEventListener('keydown', (e) => { e.stopPropagation(); if (e.key === 'Enter') { e.preventDefault(); run(); } });
+ node.addEventListener('keyup', (e) => e.stopPropagation());
+ }
+ card.appendChild(el('div', { class: 'aixbt-bar' }, [tokenInput, chainSelect, refreshBtn]));
+
+ const body = el('div', { class: 'npc-svc-result', style: 'display:block' });
+ card.appendChild(body);
+
+ function skeleton() {
+ body.textContent = '';
+ body.appendChild(el('div', { class: 'aixbt-section-h', text: 'Narratives' }));
+ for (let i = 0; i < 3; i++) body.appendChild(el('div', { class: 'aixbt-skel' }));
+ }
+
+ let busy = false;
+ async function run() {
+ if (busy) return;
+ busy = true;
+ refreshBtn.disabled = true;
+ refreshBtn.textContent = 'Loading…';
+ skeleton();
+ const token = tokenInput.value.trim();
+ const chain = chainSelect.value;
+ const intelQs = new URLSearchParams({ limit: '6' });
+ if (chain) intelQs.set('chain', chain);
+ const projQs = new URLSearchParams({ limit: '6' });
+ if (chain) projQs.set('chain', chain);
+ if (token) projQs.set('names', token);
+
+ try {
+ const [intelRes, projRes] = await Promise.all([
+ fetchJson(`/api/aixbt/intel?${intelQs}`),
+ fetchJson(`/api/aixbt/projects?${projQs}`),
+ ]);
+ body.textContent = '';
+ body.appendChild(el('div', { class: 'aixbt-section-h', text: token ? `Momentum · ${token.toUpperCase()}` : 'Momentum' }));
+ body.appendChild(renderProjects(projRes.projects || []));
+ body.appendChild(el('div', { class: 'aixbt-section-h', text: 'Narratives' }));
+ body.appendChild(renderIntel(intelRes.intel || []));
+ npc?.say?.(
+ (projRes.projects || []).length || (intelRes.intel || []).length
+ ? 'Here\'s what the feed is showing right now.'
+ : 'Quiet on that filter — try a broader chain.',
+ );
+ } catch (err) {
+ body.textContent = '';
+ if (err?.code === 'aixbt_not_configured') {
+ body.appendChild(el('div', { class: 'aixbt-error', text: 'aixbt isn\'t connected on this deployment yet.' }));
+ if (err.setup) body.appendChild(el('div', { class: 'aixbt-setup', text: err.setup }));
+ npc?.say?.('My feed isn\'t wired up here yet.');
+ } else {
+ body.appendChild(el('div', { class: 'aixbt-error', text: `Couldn't reach the aixbt feed: ${err.message}` }));
+ body.appendChild(el('button', { class: 'aixbt-refresh', type: 'button', text: 'Retry', style: 'margin-top:10px', onclick: run }));
+ ui?.toast?.('aixbt feed unavailable', 'warn');
+ }
+ } finally {
+ busy = false;
+ refreshBtn.disabled = false;
+ refreshBtn.textContent = 'Refresh';
+ }
+ }
+ refreshBtn.addEventListener('click', run);
+
+ // Mount + ESC + autoload.
+ const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
+ const onKey = (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePanel(); } };
+ document.addEventListener('keydown', onKey, true);
+ document.body.appendChild(overlay);
+ openPanel = { overlay, onKey, opener };
+ requestAnimationFrame(() => {
+ overlay.classList.add('is-in');
+ run();
+ });
+}
diff --git a/src/game/npc/npc-catalog.js b/src/game/npc/npc-catalog.js
index 50bc89bca..47e792f10 100644
--- a/src/game/npc/npc-catalog.js
+++ b/src/game/npc/npc-catalog.js
@@ -15,9 +15,11 @@
import { isHomeTown } from '../home-town.js';
import { openChat } from './npc-chat.js';
+import { openAixbtTerminal } from './npc-aixbt.js';
const AVATAR_A = '/avatars/default.glb';
const AVATAR_B = '/avatars/cz.glb';
+const AVATAR_AIXBT = '/avatars/michelle.glb';
// Bind an NPC to a conversation. On interact the NPC greets in-world, plays a
// beat, and opens a real chat: it answers in character, live from the same models
@@ -38,6 +40,26 @@ export function npcCatalogFor(world) {
const home = isHomeTown(world?.mint);
if (home) {
+ // AIXBT — the intelligence terminal. Walk up, press E, and he pulls the
+ // live aixbt feed (narrative intel + momentum movers) into a terminal
+ // panel. Not a one-shot counter: he's the wired-in oracle, backed by the
+ // three.ws ⇄ aixbt bridge (/api/aixbt/*). Stands center-plaza facing spawn.
+ list.push({
+ id: 'npc-aixbt',
+ name: 'AIXBT · Intel',
+ role: 'vendor',
+ avatar: AVATAR_AIXBT,
+ pos: { x: 0, z: 8 },
+ yaw: Math.PI,
+ range: 5,
+ prompt: 'Pull market intel',
+ onInteract: ({ npc, ui }) => {
+ npc.say('Reading the feed — narratives and momentum, live.');
+ npc.emote('av-call-me');
+ openAixbtTerminal(npc, { ui });
+ },
+ });
+
// Marisol — the trading desk. Sells live market signals (crypto-intel).
list.push({
id: 'svc-crypto-intel',