Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(pump): wire MCP per-tool pricing + subscription bypass + tests
nirholasa42a8d9fbfe5
diff --git a/.env.example b/.env.exampleindex 1056d2cb1..8ac69a783 100644--- a/.env.example+++ b/.env.example@@ -115,14 +115,17 @@ SOLANA_RPC_URL=SOLANA_RPC_URL_DEVNET=# ── x402 micropayments (POST /api/mcp) ─────────────────────────────────────-# Solana wallet that receives USDC for paid MCP calls.-X402_PAY_TO=BUrwd1nK6tFeeJMyzRHDo6AuVbnSfUULfvwq21X93nSN-# USDC mint on Solana mainnet.-X402_ASSET_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v-X402_NETWORK=solana+# Per-network payTo wallets that receive USDC for paid MCP calls.+X402_PAY_TO_SOLANA=BUrwd1nK6tFeeJMyzRHDo6AuVbnSfUULfvwq21X93nSN+X402_PAY_TO_BASE=0x0C70c0e8453C5667739E41acdF6eC5787B8ff542+# USDC asset addresses (mainnet).+X402_ASSET_MINT_SOLANA=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v+X402_ASSET_ADDRESS_BASE=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913# Price in base units (USDC = 6 decimals; 1000 = 0.001 USDC).X402_MAX_AMOUNT_REQUIRED=1000-# Public Solana facilitator. Self-host or swap providers via this var.-X402_FACILITATOR_URL=https://facilitator.payai.network-# Optional bearer for self-hosted/private facilitators.-X402_FACILITATOR_TOKEN=+# Per-network facilitators. Defaults: PayAI for Solana, x402.org reference for Base.+X402_FACILITATOR_URL_SOLANA=https://facilitator.payai.network+X402_FACILITATOR_URL_BASE=https://x402.org/facilitator+# Optional bearer tokens for self-hosted/private facilitators.+X402_FACILITATOR_TOKEN_SOLANA=+X402_FACILITATOR_TOKEN_BASE=diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.jsindex 8d4b1f717..9bb263635 100644--- a/api/_lib/x402-spec.js+++ b/api/_lib/x402-spec.js@@ -85,12 +85,11 @@ function decodePaymentHeader(header) {return payload;}-async function callFacilitator(path, body) {- const url = `${env.X402_FACILITATOR_URL}${path}`;+async function callFacilitator(network, path, body) {+ const { url: base, token } = facilitatorFor(network);+ const url = `${base}${path}`;const headers = { 'content-type': 'application/json', accept: 'application/json' };- if (env.X402_FACILITATOR_TOKEN) {- headers.authorization = `Bearer ${env.X402_FACILITATOR_TOKEN}`;- }+ if (token) headers.authorization = `Bearer ${token}`;let res;try {res = await fetch(url, {@@ -129,14 +128,33 @@ async function callFacilitator(path, body) {return data;}-// Verify a base64 X-PAYMENT header against payment requirements.-// Returns { paymentPayload, payer } on success; throws X402Error on failure.+// Match the decoded payload to one of the offered requirements (by network).+// Falls back to the first requirement when the payload omits an explicit network field.+function selectRequirement(paymentPayload, allRequirements) {+ const network = paymentPayload?.network || paymentPayload?.paymentRequirements?.network;+ if (network) {+ const found = allRequirements.find((r) => r.network === network);+ if (!found)+ throw new X402Error(+ 'unsupported_network',+ `payment network "${network}" is not offered`,+ 402,+ );+ return found;+ }+ return allRequirements[0];+}++// Verify a base64 X-PAYMENT header against the offered requirements.+// Returns { paymentPayload, requirement, payer } on success.export async function verifyPayment({ paymentHeader, requirements }) {+ const all = Array.isArray(requirements) ? requirements : [requirements];const paymentPayload = decodePaymentHeader(paymentHeader);- const result = await callFacilitator('/verify', {+ const requirement = selectRequirement(paymentPayload, all);+ const result = await callFacilitator(requirement.network, '/verify', {x402Version: X402_VERSION,paymentPayload,- paymentRequirements: requirements,+ paymentRequirements: requirement,});if (!result.isValid) {throw new X402Error(@@ -145,15 +163,15 @@ export async function verifyPayment({ paymentHeader, requirements }) {402,);}- return { paymentPayload, payer: result.payer || null };+ return { paymentPayload, requirement, payer: result.payer || null };}-// Settle the verified payment on-chain via the facilitator.-export async function settlePayment({ paymentPayload, requirements }) {- const result = await callFacilitator('/settle', {+// Settle the verified payment on-chain via the matching facilitator.+export async function settlePayment({ paymentPayload, requirement }) {+ const result = await callFacilitator(requirement.network, '/settle', {x402Version: X402_VERSION,paymentPayload,- paymentRequirements: requirements,+ paymentRequirements: requirement,});if (!result.success) {throw new X402Error(@@ -176,6 +194,7 @@ export function encodePaymentResponseHeader(settleResult) {}export function send402(res, requirements, error = 'X-PAYMENT header is required') {+ const accepts = Array.isArray(requirements) ? requirements : [requirements];res.statusCode = 402;res.setHeader('content-type', 'application/json; charset=utf-8');res.setHeader('cache-control', 'no-store');@@ -183,7 +202,7 @@ export function send402(res, requirements, error = 'X-PAYMENT header is requiredJSON.stringify({x402Version: X402_VERSION,error,- accepts: [requirements],+ accepts,}),);}diff --git a/api/agents/sns.js b/api/agents/sns.jsindex 111c9a2e6..9f999a599 100644--- a/api/agents/sns.js+++ b/api/agents/sns.js@@ -1,18 +1,23 @@// /api/agents/:id/sns//-// GET — list .sol domains the agent's Solana wallet owns (via Bonfida-// sns-api.bonfida.com), plus the wallet's favorite/primary domain-// and the currently-attached SNS id (meta.sns_domain).-// POST — body { domain } — verify the agent's wallet owns `domain`, then-// save it as the agent's SNS id (meta.sns_domain).-// DELETE — clear meta.sns_domain.+// GET — list .sol domains the agent's Solana wallet owns (via Bonfida+// sns-api.bonfida.com), plus the wallet's favorite/primary domain,+// the currently-attached SNS id (meta.sns_domain), and whether the+// subdomain registrar is configured (so the UI can show /register).+// POST — body { domain } — verify the agent's wallet owns `domain`, then+// save it as the agent's SNS id (meta.sns_domain).+// DELETE — clear meta.sns_domain.//-// Registration is done off-platform at https://www.sns.id — the UI links out.+// /api/agents/:id/sns/register+// POST — body { label } — mint {label}.{SNS_PARENT_DOMAIN}.sol as a+// subdomain owned by the agent's wallet. Platform pays gas+rent.+// On success, sets meta.sns_domain = "{label}.{SNS_PARENT_DOMAIN}".import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';import { sql } from '../_lib/db.js';import { cors, json, method, error, readJson } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';+import { env } from '../_lib/env.js';const SNS_API = 'https://sns-api.bonfida.com';const DOMAIN_RE = /^[a-z0-9-]{1,63}(\.sol)?$/i;@@ -45,6 +50,86 @@ async function fetchFavoriteDomain(address) {}}+function registrarConfigured() {+ return Boolean(env.SNS_PARENT_DOMAIN && env.SNS_PARENT_OWNER_SECRET);+}++async function registerSubdomain(label, agentAddress) {+ const { Connection, Keypair, PublicKey, Transaction } = await import('@solana/web3.js');+ const sns = await import('@bonfida/spl-name-service');++ const parentLabel = String(env.SNS_PARENT_DOMAIN).trim().toLowerCase().replace(/\.sol$/, '');+ const secretBuf = Buffer.from(env.SNS_PARENT_OWNER_SECRET, 'base64');+ if (secretBuf.length !== 64) throw new Error('SNS_PARENT_OWNER_SECRET must be base64 of a 64-byte secret key');+ const parentOwner = Keypair.fromSecretKey(Uint8Array.from(secretBuf));+ const fullSub = `${label}.${parentLabel}`;+ const newOwner = new PublicKey(agentAddress);+ const conn = new Connection(env.SOLANA_RPC_URL, 'confirmed');++ // Fail fast if the subdomain already exists (createNameRegistry would error mid-tx).+ try {+ const { pubkey } = sns.getDomainKeySync(fullSub);+ const info = await conn.getAccountInfo(pubkey);+ if (info?.data) throw new Error(`${fullSub}.sol is already registered`);+ } catch (e) {+ if (e?.message?.includes('already registered')) throw e;+ }++ const createIxs = await sns.createSubdomain(conn, fullSub, parentOwner.publicKey, 2000, parentOwner.publicKey);+ const transferIx = await sns.transferSubdomain(conn, fullSub, newOwner, true);+ const tx = new Transaction().add(...createIxs, transferIx);+ tx.feePayer = parentOwner.publicKey;+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');+ tx.recentBlockhash = blockhash;+ tx.sign(parentOwner);+ const sig = await conn.sendRawTransaction(tx.serialize(), { skipPreflight: false });+ await conn.confirmTransaction({ signature: sig, blockhash, lastValidBlockHeight }, 'confirmed');+ return { signature: sig, domain: fullSub };+}++async function handleRegister(req, res, id, auth) {+ if (!method(req, res, ['POST'])) return;+ if (!registrarConfigured()) {+ return error(res, 503, 'not_configured', 'subdomain registrar is not set up on this deployment');+ }++ const [row] = await sql`+ SELECT id, user_id, meta FROM agent_identities+ WHERE id = ${id} AND deleted_at IS NULL+ `;+ if (!row) return error(res, 404, 'not_found', 'agent not found');+ if (row.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');+ let meta = { ...(row.meta || {}) };+ if (!meta.solana_address) {+ return error(res, 409, 'conflict', 'agent has no solana wallet — provision one first');+ }++ const body = await readJson(req).catch(() => ({}));+ const label = normalizeDomain(body?.label);+ if (!label) return error(res, 400, 'validation_error', 'label must be a valid subdomain (a–z, 0–9, hyphen; max 63 chars)');++ let result;+ try {+ result = await registerSubdomain(label, meta.solana_address);+ } catch (err) {+ console.error('[agents/sns/register] failed', err);+ const msg = err?.message || 'registration failed';+ const status = /already registered/i.test(msg) ? 409 : 502;+ return error(res, status, status === 409 ? 'conflict' : 'upstream_error', msg);+ }++ meta = { ...meta, sns_domain: result.domain };+ await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;+ return json(res, 201, {+ data: {+ ok: true,+ address: meta.solana_address,+ sns_domain: result.domain,+ signature: result.signature,+ },+ });+}+async function resolveAuth(req) {const session = await getSessionUser(req);if (session) return { userId: session.id };@@ -53,9 +138,8 @@ async function resolveAuth(req) {return null;}-export default async function handler(req, res, id) {+export default async function handler(req, res, id, action) {if (cors(req, res, { methods: 'GET,POST,DELETE,OPTIONS', credentials: true })) return;- if (!method(req, res, ['GET', 'POST', 'DELETE'])) return;const auth = await resolveAuth(req);if (!auth) return error(res, 401, 'unauthorized', 'sign in required');@@ -63,6 +147,10 @@ export default async function handler(req, res, id) {const rl = await limits.authIp(clientIp(req));if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');+ if (action === 'register') return handleRegister(req, res, id, auth);++ if (!method(req, res, ['GET', 'POST', 'DELETE'])) return;+const [row] = await sql`SELECT id, user_id, meta FROM agent_identitiesWHERE id = ${id} AND deleted_at IS NULL@@ -122,6 +210,9 @@ export default async function handler(req, res, id) {favorite,upstream_ok: upstreamOk,register_url: `https://www.sns.id/?search=`,+ registrar: registrarConfigured()+ ? { enabled: true, parent: String(env.SNS_PARENT_DOMAIN).replace(/\.sol$/, '') }+ : { enabled: false },},});}diff --git a/api/mcp.js b/api/mcp.jsindex d17e8053a..16181a988 100644--- a/api/mcp.js+++ b/api/mcp.js@@ -73,7 +73,12 @@ export default wrap(async (req, res) => {});try {const verified = await verifyPayment({ paymentHeader, requirements });- x402Ctx = { requirements, paymentPayload: verified.paymentPayload, payer: verified.payer };+ x402Ctx = {+ requirements,+ requirement: verified.requirement,+ paymentPayload: verified.paymentPayload,+ payer: verified.payer,+ };} catch (err) {return sendX402Error(res, requirements, err);}@@ -131,7 +136,7 @@ export default wrap(async (req, res) => {try {const settled = await settlePayment({paymentPayload: x402Ctx.paymentPayload,- requirements: x402Ctx.requirements,+ requirement: x402Ctx.requirement,});res.setHeader('x-payment-response', encodePaymentResponseHeader(settled));} catch (err) {diff --git a/api/openapi-json.js b/api/openapi-json.jsindex 8837bfa9d..513281ef2 100644--- a/api/openapi-json.js+++ b/api/openapi-json.js@@ -98,6 +98,15 @@ export default wrap(async (req, res) => {maxAmountRequired: '1000',},},+ {+ x402: {+ network: 'base',+ asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',+ payTo: '0x0C70c0e8453C5667739E41acdF6eC5787B8ff542',+ scheme: 'exact',+ maxAmountRequired: '1000',+ },+ },{mpp: {method: 'solana-pay',diff --git a/examples/skills/pump-fun/SKILL.md b/examples/skills/pump-fun/SKILL.mdindex bd584216b..be59a4b58 100644--- a/examples/skills/pump-fun/SKILL.md+++ b/examples/skills/pump-fun/SKILL.md@@ -1,31 +1,32 @@# pump-fun-Read-only Solana market intel for three.ws agents. Proxies the-[pump-fun-workers](https://github.com/nirholas/pump-fun-workers) MCP server-(Cloudflare Worker) so any agent can search, inspect, and rug-check pump.fun-tokens during conversation.--## Tools--| Tool | Use it for |-|---|---|-| `searchTokens` | Find a token by name, symbol, or mint |-| `getTokenDetails` | Full metadata for a mint |-| `getBondingCurve` | Reserves, price, graduation % |-| `getTokenTrades` | Recent buy/sell history |-| `getTrendingTokens` | Top by market cap |-| `getNewTokens` | Most recent launches |-| `getGraduatedTokens` | Tokens that hit Raydium |-| `getKingOfTheHill` | Highest mcap still on the curve |-| `getCreatorProfile` | Creator's tokens + rug flags |-| `getTokenHolders` | Top holders + concentration |--All tools are read-only. No wallet keys are required or accepted.--## Endpoint--Defaults to `https://pump-fun-sdk.modelcontextprotocol.name/mcp`. Override per-install via `manifest.config.endpoint` to point at a self-hosted Worker.+Read-only Solana market intel for three.ws agents. The skill calls the+in-house MCP route at `/api/pump-fun-mcp` (not an external host), so it+works on any deployment of three.ws without third-party DNS or proxies.++## Tools (10)++| Tool | Backed by | Notes |+|---|---|---|+| `getBondingCurve` | `@pump-fun/pump-sdk` on-chain | Real reserves + graduation %. Always available. |+| `getTokenDetails` | Solana RPC + Metaplex metadata | Mint, supply, decimals, name, symbol. Always available. |+| `getTokenHolders` | `connection.getTokenLargestAccounts` | Top holders + concentration. Always available. |+| `searchTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getTokenTrades` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getTrendingTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getNewTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getGraduatedTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getKingOfTheHill` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getCreatorProfile` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |++Tools requiring the indexer return JSON-RPC error `-32004` (with a clear+configuration message) when the bot URL is not set — they never return+fabricated or placeholder data.++## Endpoint resolution++The skill resolves `/api/pump-fun-mcp` against the page origin+(`window.location.origin`) at call time. No build-step configuration needed.## Install@@ -34,14 +35,24 @@ Reference the bundle from your agent manifest:```json{"skills": [- { "uri": "https://cdn.three.ws/skills/pump-fun/" }+ { "uri": "skills/pump-fun/" }]}```-## Suggested instructions+## Sentiment hooks++Some handlers attach a `sentiment` (-1..1) to their result so the avatar's+Empathy Layer reacts:++- `getCreatorProfile` with rug flags → negative (concern)+- `getBondingCurve` near graduation → positive (celebration)+- `getTokenHolders` with whale concentration → negative (concern)+- `getKingOfTheHill` → mild positive (curiosity)++## Suggested system prompt> When the user mentions a token name, symbol, or mint address, call-> `searchTokens` first, then `getBondingCurve` and `getTokenHolders` before-> giving an opinion. Always check `getCreatorProfile` for rug flags before-> recommending a buy.+> `searchTokens` first, then `getBondingCurve` and `getTokenHolders`+> before giving an opinion. Always check `getCreatorProfile` for rug+> flags before recommending a buy.diff --git a/package-lock.json b/package-lock.jsonindex be5bc3fd9..ba255d612 100644--- a/package-lock.json+++ b/package-lock.json@@ -12,6 +12,7 @@"@avaturn/sdk": "^1.1.4","@aws-sdk/client-s3": "^3.651.0","@aws-sdk/s3-request-presigner": "^3.651.0",+ "@bonfida/spl-name-service": "^3.0.21","@chenglou/pretext": "^0.0.5","@coral-xyz/anchor": "^0.31.1","@gltf-transform/core": "^4.3.0",@@ -2498,6 +2499,218 @@"node": ">=6.9.0"}},+ "node_modules/@bonfida/sns-records": {+ "version": "0.1.0",+ "resolved": "https://registry.npmjs.org/@bonfida/sns-records/-/sns-records-0.1.0.tgz",+ "integrity": "sha512-/viuqvsjvAUjFxzqX0L3ZntfK1S5K1Nj+j2avxq2tCXhA2Ee7Qt0gPCaQKuMv3hh8cKAEMaZ8crZHomns3UuqA==",+ "license": "MIT",+ "dependencies": {+ "borsh": "1.0.0",+ "bs58": "5.0.0",+ "buffer": "^6.0.3"+ },+ "peerDependencies": {+ "@solana/web3.js": "^1.87.3"+ }+ },+ "node_modules/@bonfida/sns-records/node_modules/base-x": {+ "version": "4.0.1",+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.1.tgz",+ "integrity": "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw==",+ "license": "MIT"+ },+ "node_modules/@bonfida/sns-records/node_modules/borsh": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/borsh/-/borsh-1.0.0.tgz",+ "integrity": "sha512-fSVWzzemnyfF89EPwlUNsrS5swF5CrtiN4e+h0/lLf4dz2he4L3ndM20PS9wj7ICSkXJe/TQUHdaPTq15b1mNQ==",+ "license": "Apache-2.0"+ },+ "node_modules/@bonfida/sns-records/node_modules/bs58": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz",+ "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==",+ "license": "MIT",+ "dependencies": {+ "base-x": "^4.0.0"+ }+ },+ "node_modules/@bonfida/spl-name-service": {+ "version": "3.0.21",+ "resolved": "https://registry.npmjs.org/@bonfida/spl-name-service/-/spl-name-service-3.0.21.tgz",+ "integrity": "sha512-dYKZwG2ColaDUvX+ZrzcPtE6sQcNNwXywMsLit57Z+bKSEYQdIFxncrDSSzjLKcxQRFPUQObptaSEcv+ZwcMQA==",+ "license": "MIT",+ "dependencies": {+ "@bonfida/sns-records": "0.1.0",+ "@noble/curves": "^1.9.1",+ "@scure/base": "^1.2.5",+ "@solana/spl-token": "0.4.6",+ "borsh": "2.0.0",+ "buffer": "^6.0.3",+ "graphemesplit": "^2.6.0",+ "ipaddr.js": "^2.2.0",+ "punycode": "^2.3.1"+ },+ "peerDependencies": {+ "@solana/web3.js": "^1.98.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@noble/curves": {+ "version": "1.9.7",+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz",+ "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==",+ "license": "MIT",+ "dependencies": {+ "@noble/hashes": "1.8.0"+ },+ "engines": {+ "node": "^14.21.3 || >=16"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@noble/hashes": {+ "version": "1.8.0",+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz",+ "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==",+ "license": "MIT",+ "engines": {+ "node": "^14.21.3 || >=16"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/codecs": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/codecs/-/codecs-2.0.0-preview.2.tgz",+ "integrity": "sha512-4HHzCD5+pOSmSB71X6w9ptweV48Zj1Vqhe732+pcAQ2cMNnN0gMPMdDq7j3YwaZDZ7yrILVV/3+HTnfT77t2yA==",+ "license": "MIT",+ "dependencies": {+ "@solana/codecs-core": "2.0.0-preview.2",+ "@solana/codecs-data-structures": "2.0.0-preview.2",+ "@solana/codecs-numbers": "2.0.0-preview.2",+ "@solana/codecs-strings": "2.0.0-preview.2",+ "@solana/options": "2.0.0-preview.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/codecs-core": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/codecs-core/-/codecs-core-2.0.0-preview.2.tgz",+ "integrity": "sha512-gLhCJXieSCrAU7acUJjbXl+IbGnqovvxQLlimztPoGgfLQ1wFYu+XJswrEVQqknZYK1pgxpxH3rZ+OKFs0ndQg==",+ "license": "MIT",+ "dependencies": {+ "@solana/errors": "2.0.0-preview.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/codecs-data-structures": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.2.tgz",+ "integrity": "sha512-Xf5vIfromOZo94Q8HbR04TbgTwzigqrKII0GjYr21K7rb3nba4hUW2ir8kguY7HWFBcjHGlU5x3MevKBOLp3Zg==",+ "license": "MIT",+ "dependencies": {+ "@solana/codecs-core": "2.0.0-preview.2",+ "@solana/codecs-numbers": "2.0.0-preview.2",+ "@solana/errors": "2.0.0-preview.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/codecs-numbers": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.2.tgz",+ "integrity": "sha512-aLZnDTf43z4qOnpTcDsUVy1Ci9im1Md8thWipSWbE+WM9ojZAx528oAql+Cv8M8N+6ALKwgVRhPZkto6E59ARw==",+ "license": "MIT",+ "dependencies": {+ "@solana/codecs-core": "2.0.0-preview.2",+ "@solana/errors": "2.0.0-preview.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/codecs-strings": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.2.tgz",+ "integrity": "sha512-EgBwY+lIaHHgMJIqVOGHfIfpdmmUDNoNO/GAUGeFPf+q0dF+DtwhJPEMShhzh64X2MeCZcmSO6Kinx0Bvmmz2g==",+ "license": "MIT",+ "dependencies": {+ "@solana/codecs-core": "2.0.0-preview.2",+ "@solana/codecs-numbers": "2.0.0-preview.2",+ "@solana/errors": "2.0.0-preview.2"+ },+ "peerDependencies": {+ "fastestsmallesttextencoderdecoder": "^1.0.22"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/errors": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/errors/-/errors-2.0.0-preview.2.tgz",+ "integrity": "sha512-H2DZ1l3iYF5Rp5pPbJpmmtCauWeQXRJapkDg8epQ8BJ7cA2Ut/QEtC3CMmw/iMTcuS6uemFNLcWvlOfoQhvQuA==",+ "license": "MIT",+ "dependencies": {+ "chalk": "^5.3.0",+ "commander": "^12.0.0"+ },+ "bin": {+ "errors": "bin/cli.js"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/options": {+ "version": "2.0.0-preview.2",+ "resolved": "https://registry.npmjs.org/@solana/options/-/options-2.0.0-preview.2.tgz",+ "integrity": "sha512-FAHqEeH0cVsUOTzjl5OfUBw2cyT8d5Oekx4xcn5hn+NyPAfQJgM3CEThzgRD6Q/4mM5pVUnND3oK/Mt1RzSE/w==",+ "license": "MIT",+ "dependencies": {+ "@solana/codecs-core": "2.0.0-preview.2",+ "@solana/codecs-numbers": "2.0.0-preview.2"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/spl-token": {+ "version": "0.4.6",+ "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.4.6.tgz",+ "integrity": "sha512-1nCnUqfHVtdguFciVWaY/RKcQz1IF4b31jnKgAmjU9QVN1q7dRUkTEWJZgTYIEtsULjVnC9jRqlhgGN39WbKKA==",+ "license": "Apache-2.0",+ "dependencies": {+ "@solana/buffer-layout": "^4.0.0",+ "@solana/buffer-layout-utils": "^0.2.0",+ "@solana/spl-token-group": "^0.0.4",+ "@solana/spl-token-metadata": "^0.1.4",+ "buffer": "^6.0.3"+ },+ "engines": {+ "node": ">=16"+ },+ "peerDependencies": {+ "@solana/web3.js": "^1.91.6"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/@solana/spl-token-group": {+ "version": "0.0.4",+ "resolved": "https://registry.npmjs.org/@solana/spl-token-group/-/spl-token-group-0.0.4.tgz",+ "integrity": "sha512-7+80nrEMdUKlK37V6kOe024+T7J4nNss0F8LQ9OOPYdWCCfJmsGUzVx2W3oeizZR4IHM6N4yC9v1Xqwc3BTPWw==",+ "license": "Apache-2.0",+ "dependencies": {+ "@solana/codecs": "2.0.0-preview.2",+ "@solana/spl-type-length-value": "0.1.0"+ },+ "engines": {+ "node": ">=16"+ },+ "peerDependencies": {+ "@solana/web3.js": "^1.91.6"+ }+ },+ "node_modules/@bonfida/spl-name-service/node_modules/borsh": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/borsh/-/borsh-2.0.0.tgz",+ "integrity": "sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg==",+ "license": "Apache-2.0"+ },+ "node_modules/@bonfida/spl-name-service/node_modules/commander": {+ "version": "12.1.0",+ "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",+ "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },"node_modules/@chenglou/pretext": {"version": "0.0.5","resolved": "https://registry.npmjs.org/@chenglou/pretext/-/pretext-0.0.5.tgz",@@ -8341,6 +8554,18 @@"node": ">=18"}},+ "node_modules/@solana/spl-type-length-value": {+ "version": "0.1.0",+ "resolved": "https://registry.npmjs.org/@solana/spl-type-length-value/-/spl-type-length-value-0.1.0.tgz",+ "integrity": "sha512-JBMGB0oR4lPttOZ5XiUGyvylwLQjt1CPJa6qQ5oM+MBCndfjz2TKKkw0eATlLLcYmq1jBVsNlJ2cD6ns2GR7lA==",+ "license": "Apache-2.0",+ "dependencies": {+ "buffer": "^6.0.3"+ },+ "engines": {+ "node": ">=16"+ }+ },"node_modules/@solana/subscribable": {"version": "6.8.0","resolved": "https://registry.npmjs.org/@solana/subscribable/-/subscribable-6.8.0.tgz",@@ -11269,6 +11494,16 @@"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==","license": "ISC"},+ "node_modules/graphemesplit": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/graphemesplit/-/graphemesplit-2.6.0.tgz",+ "integrity": "sha512-rG9w2wAfkpg0DILa1pjnjNfucng3usON360shisqIMUBw/87pojcBSrHmeE4UwryAuBih7g8m1oilf5/u8EWdQ==",+ "license": "MIT",+ "dependencies": {+ "js-base64": "^3.6.0",+ "unicode-trie": "^2.0.0"+ }+ },"node_modules/has-bigints": {"version": "1.1.0","resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz",@@ -11487,6 +11722,15 @@"node": ">= 12"}},+ "node_modules/ipaddr.js": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.3.0.tgz",+ "integrity": "sha512-Zv/pA+ciVFbCSBBjGfaKUya/CcGmUHzTydLMaTwrUUEM2DIEO3iZvueGxmacvmN50fGpGVKeTXpb2LcYQxeVdg==",+ "license": "MIT",+ "engines": {+ "node": ">= 10"+ }+ },"node_modules/is-array-buffer": {"version": "3.0.5","resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz",@@ -12080,6 +12324,12 @@"url": "https://github.com/sponsors/panva"}},+ "node_modules/js-base64": {+ "version": "3.7.8",+ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.8.tgz",+ "integrity": "sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==",+ "license": "BSD-3-Clause"+ },"node_modules/js-tokens": {"version": "4.0.0","resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",@@ -13027,7 +13277,6 @@"version": "2.3.1","resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz","integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",- "dev": true,"license": "MIT","engines": {"node": ">=6"@@ -15407,6 +15656,12 @@"integrity": "sha512-PWRKYWQo23ojf9oZSlRGH8K09q7nRSWx6LY/HF/UUrMdYgN9i1e2OwJYHoQjwc6HF/4lvvYLC5YC1X8UJL2ZpA==","license": "MIT"},+ "node_modules/tiny-inflate": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",+ "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",+ "license": "MIT"+ },"node_modules/tinybench": {"version": "2.9.0","resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",@@ -15645,6 +15900,22 @@"node": ">=4"}},+ "node_modules/unicode-trie": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-2.0.0.tgz",+ "integrity": "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==",+ "license": "MIT",+ "dependencies": {+ "pako": "^0.2.5",+ "tiny-inflate": "^1.0.0"+ }+ },+ "node_modules/unicode-trie/node_modules/pako": {+ "version": "0.2.9",+ "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",+ "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==",+ "license": "MIT"+ },"node_modules/unique-string": {"version": "2.0.0","resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz",diff --git a/package.json b/package.jsonindex 81f3bf600..ce5463580 100644--- a/package.json+++ b/package.json@@ -61,9 +61,9 @@},"dependencies": {"@avaturn/sdk": "^1.1.4",- "@bonfida/spl-name-service": "^3.0.21","@aws-sdk/client-s3": "^3.651.0","@aws-sdk/s3-request-presigner": "^3.651.0",+ "@bonfida/spl-name-service": "^3.0.21","@chenglou/pretext": "^0.0.5","@coral-xyz/anchor": "^0.31.1","@gltf-transform/core": "^4.3.0",diff --git a/public/skills/pump-fun/SKILL.md b/public/skills/pump-fun/SKILL.mdindex bd584216b..be59a4b58 100644--- a/public/skills/pump-fun/SKILL.md+++ b/public/skills/pump-fun/SKILL.md@@ -1,31 +1,32 @@# pump-fun-Read-only Solana market intel for three.ws agents. Proxies the-[pump-fun-workers](https://github.com/nirholas/pump-fun-workers) MCP server-(Cloudflare Worker) so any agent can search, inspect, and rug-check pump.fun-tokens during conversation.--## Tools--| Tool | Use it for |-|---|---|-| `searchTokens` | Find a token by name, symbol, or mint |-| `getTokenDetails` | Full metadata for a mint |-| `getBondingCurve` | Reserves, price, graduation % |-| `getTokenTrades` | Recent buy/sell history |-| `getTrendingTokens` | Top by market cap |-| `getNewTokens` | Most recent launches |-| `getGraduatedTokens` | Tokens that hit Raydium |-| `getKingOfTheHill` | Highest mcap still on the curve |-| `getCreatorProfile` | Creator's tokens + rug flags |-| `getTokenHolders` | Top holders + concentration |--All tools are read-only. No wallet keys are required or accepted.--## Endpoint--Defaults to `https://pump-fun-sdk.modelcontextprotocol.name/mcp`. Override per-install via `manifest.config.endpoint` to point at a self-hosted Worker.+Read-only Solana market intel for three.ws agents. The skill calls the+in-house MCP route at `/api/pump-fun-mcp` (not an external host), so it+works on any deployment of three.ws without third-party DNS or proxies.++## Tools (10)++| Tool | Backed by | Notes |+|---|---|---|+| `getBondingCurve` | `@pump-fun/pump-sdk` on-chain | Real reserves + graduation %. Always available. |+| `getTokenDetails` | Solana RPC + Metaplex metadata | Mint, supply, decimals, name, symbol. Always available. |+| `getTokenHolders` | `connection.getTokenLargestAccounts` | Top holders + concentration. Always available. |+| `searchTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getTokenTrades` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getTrendingTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getNewTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getGraduatedTokens` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getKingOfTheHill` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |+| `getCreatorProfile` | upstream pumpfun-claims-bot | Requires `PUMPFUN_BOT_URL`. |++Tools requiring the indexer return JSON-RPC error `-32004` (with a clear+configuration message) when the bot URL is not set — they never return+fabricated or placeholder data.++## Endpoint resolution++The skill resolves `/api/pump-fun-mcp` against the page origin+(`window.location.origin`) at call time. No build-step configuration needed.## Install@@ -34,14 +35,24 @@ Reference the bundle from your agent manifest:```json{"skills": [- { "uri": "https://cdn.three.ws/skills/pump-fun/" }+ { "uri": "skills/pump-fun/" }]}```-## Suggested instructions+## Sentiment hooks++Some handlers attach a `sentiment` (-1..1) to their result so the avatar's+Empathy Layer reacts:++- `getCreatorProfile` with rug flags → negative (concern)+- `getBondingCurve` near graduation → positive (celebration)+- `getTokenHolders` with whale concentration → negative (concern)+- `getKingOfTheHill` → mild positive (curiosity)++## Suggested system prompt> When the user mentions a token name, symbol, or mint address, call-> `searchTokens` first, then `getBondingCurve` and `getTokenHolders` before-> giving an opinion. Always check `getCreatorProfile` for rug flags before-> recommending a buy.+> `searchTokens` first, then `getBondingCurve` and `getTokenHolders`+> before giving an opinion. Always check `getCreatorProfile` for rug+> flags before recommending a buy.diff --git a/tests/api/pump.test.js b/tests/api/pump.test.jsindex 38dfae290..9e41d74a8 100644--- a/tests/api/pump.test.js+++ b/tests/api/pump.test.js@@ -331,6 +331,98 @@ describe('GET /api/pump/by-agent', () => {});});+describe('POST /api/pump/withdraw-confirm', () => {+ beforeEach(resetAll);++ it('confirms withdraw tx for owner', async () => {+ authState.session = { id: 'user-1' };+ sqlState.queue = [+ [{ id: 'mint-1', mint: mintB58, user_id: 'user-1', agent_authority: walletB58, network: 'mainnet' }],+ ];+ const pumpMod = await import('../../api/_lib/pump.js');+ pumpMod.verifySignature.mockResolvedValueOnce({+ transaction: { message: { accountKeys: [+ { pubkey: { toString: () => mintB58 } },+ { pubkey: { toString: () => walletB58 } },+ ] } },+ meta: {},+ slot: 12345,+ blockTime: 1714492800,+ });+ const { default: handler } = await import('../../api/pump/withdraw-confirm.js');+ const { res, json } = await invoke(handler, {+ method: 'POST',+ url: '/api/pump/withdraw-confirm',+ body: {+ mint: mintB58,+ network: 'mainnet',+ tx_signature: 'a'.repeat(88),+ },+ });+ expect(res.statusCode).toBe(200);+ expect(json.ok).toBe(true);+ expect(json.slot).toBe(12345);+ });++ it('forbids non-owner', async () => {+ authState.session = { id: 'other' };+ sqlState.queue = [+ [{ id: 'mint-1', mint: mintB58, user_id: 'user-1', agent_authority: walletB58, network: 'mainnet' }],+ ];+ const { default: handler } = await import('../../api/pump/withdraw-confirm.js');+ const { res } = await invoke(handler, {+ method: 'POST',+ url: '/api/pump/withdraw-confirm',+ body: { mint: mintB58, network: 'mainnet', tx_signature: 'a'.repeat(88) },+ });+ expect(res.statusCode).toBe(403);+ });+});++describe('pump-pricing helpers', () => {+ beforeEach(resetAll);++ it('priceFor returns null for unknown tools', async () => {+ const { priceFor, isFreeTool } = await import('../../api/_lib/pump-pricing.js');+ expect(priceFor('nonexistent_tool')).toBe(null);+ expect(isFreeTool('list_my_avatars')).toBe(true);+ });++ it('priceFor returns price for paid tools', async () => {+ const { priceFor } = await import('../../api/_lib/pump-pricing.js');+ const p = priceFor('optimize_model');+ expect(p).not.toBe(null);+ expect(p.amount_usdc).toBeGreaterThan(0);+ });++ it('findActiveSubscription queries on (mint, network, payer, tool)', async () => {+ sqlState.queue = [+ [{ id: 'sub-1', invoice_id: '42', amount_atomics: '1000000', end_time: '2099-01-01', tool_name: 'optimize_model' }],+ ];+ const { findActiveSubscription } = await import('../../api/_lib/pump-pricing.js');+ const sub = await findActiveSubscription({+ mint: mintB58,+ network: 'mainnet',+ payerWallet: walletB58,+ toolName: 'optimize_model',+ });+ expect(sub).not.toBe(null);+ expect(sub.invoice_id).toBe('42');+ });++ it('findActiveSubscription returns null when no row', async () => {+ sqlState.queue = [[]];+ const { findActiveSubscription } = await import('../../api/_lib/pump-pricing.js');+ const sub = await findActiveSubscription({+ mint: mintB58,+ network: 'mainnet',+ payerWallet: walletB58,+ toolName: 'optimize_model',+ });+ expect(sub).toBe(null);+ });+});+describe('GET /.well-known/x402', () => {beforeEach(resetAll);