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: add Jupiter provider for crypto market data with keyless endpoints and tests
nich07bcb9707d0b
diff --git a/api/v1/_providers.js b/api/v1/_providers.jsindex 0daa6c151..c63b00d88 100644--- a/api/v1/_providers.js+++ b/api/v1/_providers.js@@ -148,6 +148,135 @@ export const PROVIDERS = [},],},+ {+ id: 'jupiter',+ name: 'Jupiter',+ category: 'crypto-market-data',+ // Jupiter's keyless "lite" tier (no API key). The paid/keyed tier lives on+ // api.jup.ag behind an x-api-key header; the descriptor base is static, so+ // we intentionally stay on the lite base and expose no BYOK header — every+ // endpoint here is Jupiter's free keyless surface.+ base: 'https://lite-api.jup.ag',+ requiresKey: false,+ envVar: null,+ byokHeader: null,+ applyKey: () => {},+ endpoints: [+ {+ id: 'price',+ method: 'GET',+ // Verified live 2026-07-06: /price/v3 responds; /price/v2 → "Route not found".+ path: '/price/v3',+ query: (q) => ({ ids: required(q.ids, 'ids') }),+ // v3 returns { [mint]: { usdPrice, decimals, priceChange24h, liquidity,+ // blockId, createdAt, launchpad? } }. Keep the stable, agent-useful+ // fields under normalized names; unknown mints are simply absent.+ transform: (data) => {+ if (!data || typeof data !== 'object' || Array.isArray(data)) return {};+ const out = {};+ for (const [mint, v] of Object.entries(data)) {+ if (!v || typeof v !== 'object') continue;+ out[mint] = {+ price_usd: v.usdPrice,+ decimals: v.decimals,+ price_change_24h: v.priceChange24h,+ liquidity: v.liquidity,+ block_id: v.blockId,+ };+ }+ return out;+ },+ free: { perMin: 20, perDay: 2000 },+ priceAtomics: '1000',+ scope: 'agents:read',+ summary: 'Live USD price for one or more Solana tokens by mint (Jupiter keyless tier).',+ params: {+ ids: 'comma-separated Solana mint addresses, e.g. "FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump,So11111111111111111111111111111111111111112" (required)',+ },+ },+ {+ id: 'quote',+ method: 'GET',+ // Verified live 2026-07-06: /swap/v1/quote responds; /v6/quote → "Route not found".+ path: '/swap/v1/quote',+ query: (q) => ({+ inputMint: required(q.inputMint, 'inputMint'),+ outputMint: required(q.outputMint, 'outputMint'),+ amount: required(q.amount, 'amount'),+ slippageBps: q.slippageBps || '50',+ }),+ // The true executable price. Keep the amounts + impact + a slimmed route+ // (label, mints, percent per hop); drop the heavy AMM/quote-report noise.+ transform: (data) => {+ if (!data || typeof data !== 'object') return data;+ return {+ inputMint: data.inputMint,+ outputMint: data.outputMint,+ inAmount: data.inAmount,+ outAmount: data.outAmount,+ otherAmountThreshold: data.otherAmountThreshold,+ swapMode: data.swapMode,+ slippageBps: data.slippageBps,+ priceImpactPct: data.priceImpactPct,+ routePlan: Array.isArray(data.routePlan)+ ? data.routePlan.map((hop) => ({+ label: hop?.swapInfo?.label,+ inputMint: hop?.swapInfo?.inputMint,+ outputMint: hop?.swapInfo?.outputMint,+ percent: hop?.percent,+ }))+ : [],+ };+ },+ free: { perMin: 20, perDay: 2000 },+ priceAtomics: '1000',+ scope: 'agents:read',+ summary: 'Executable swap quote (true routed price) between two Solana mints (Jupiter keyless tier).',+ params: {+ inputMint: 'input token mint address, e.g. "So11111111111111111111111111111111111111112" (required)',+ outputMint: 'output token mint address, e.g. USDC "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" (required)',+ amount: 'input amount in atomic units (integer string), e.g. "1000000000" for 1 SOL (required)',+ slippageBps: 'allowed slippage in basis points (default "50" = 0.5%)',+ },+ },+ {+ id: 'token-search',+ method: 'GET',+ // Verified live 2026-07-06: /tokens/v2/search responds; /tokens/v1/* → "Route not found".+ path: '/tokens/v2/search',+ query: (q) => ({ query: required(q.query, 'query') }),+ // v2 search returns a rich array; slim each hit to the identity fields+ // agents use and derive 24h volume from the stats24h buy/sell split.+ // Cap 20 so one call never ships a multi-hundred-KB payload.+ transform: (data) => {+ if (!Array.isArray(data)) return [];+ return data.slice(0, 20).map((t) => {+ const s = t?.stats24h;+ const daily_volume =+ s && (s.buyVolume != null || s.sellVolume != null)+ ? (Number(s.buyVolume) || 0) + (Number(s.sellVolume) || 0)+ : undefined;+ return {+ address: t?.id,+ name: t?.name,+ symbol: t?.symbol,+ decimals: t?.decimals,+ logoURI: t?.icon,+ tags: Array.isArray(t?.tags) ? t.tags : undefined,+ daily_volume,+ };+ });+ },+ free: { perMin: 20, perDay: 2000 },+ priceAtomics: '1000',+ scope: 'agents:read',+ summary: 'Search Solana tokens by name/symbol/mint → address, metadata, tags, 24h volume (Jupiter keyless tier).',+ params: {+ query: 'search text — token name, symbol, or mint address, e.g. "three.ws" or a mint (required)',+ },+ },+ ],+ },{id: 'openai',name: 'OpenAI-compatible LLM',diff --git a/tests/api/v1-provider-jupiter.test.js b/tests/api/v1-provider-jupiter.test.jsnew file mode 100644index 000000000..88d654ae0--- /dev/null+++ b/tests/api/v1-provider-jupiter.test.js@@ -0,0 +1,243 @@+// Tests for the Jupiter aggregator provider (api/v1/_providers.js).+//+// Jupiter's keyless "lite" tier gives agents three free, high-value Solana+// calls through the unified three.ws API: live token prices, executable swap+// quotes (the true routed price, not a mid-market estimate), and token search.+//+// No live network here — the descriptor's transforms are pure functions, so we+// exercise them against fixtures captured from the REAL lite-api.jup.ag on+// 2026-07-06 (versions verified: /price/v3, /swap/v1/quote, /tokens/v2/search)+// plus malformed payloads, and assert descriptor integrity via ENDPOINT_INDEX+// and required-param enforcement via the query() builders.++import { describe, it, expect } from 'vitest';+import { PROVIDERS, ENDPOINT_INDEX } from '../../api/v1/_providers.js';++const jupiter = PROVIDERS.find((p) => p.id === 'jupiter');+const ep = (id) => ENDPOINT_INDEX.get(`jupiter/${id}`).endpoint;++// ── Fixtures: trimmed but real-shaped captures from lite-api.jup.ag ───────────+const PRICE_FIXTURE = {+ FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump: {+ createdAt: '2026-04-29T05:41:49Z',+ liquidity: 217828.6725114084,+ usdPrice: 0.0016321026673506269,+ blockId: 431244672,+ decimals: 6,+ priceChange24h: 4.548816264001991,+ launchpad: 'pump.fun',+ },+ So11111111111111111111111111111111111111112: {+ createdAt: '2024-06-05T08:55:25.527Z',+ liquidity: 688122254.2024628,+ usdPrice: 82.49319522938384,+ blockId: 431244687,+ decimals: 9,+ priceChange24h: 1.1801959999610383,+ },+};++const QUOTE_FIXTURE = {+ inputMint: 'So11111111111111111111111111111111111111112',+ inAmount: '1000000000',+ outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ outAmount: '82520581',+ otherAmountThreshold: '82107979',+ swapMode: 'ExactIn',+ slippageBps: 50,+ platformFee: null,+ priceImpactPct: '0',+ routePlan: [+ {+ swapInfo: {+ ammKey: '8R5qdXKMn2KcfHBy9rEpi43KScHewqvRAcpFyqoL3wap',+ label: 'Quantum',+ inputMint: 'So11111111111111111111111111111111111111112',+ outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ inAmount: '1000000000',+ outAmount: '82520581',+ },+ percent: 100,+ bps: null,+ },+ ],+ contextSlot: 431244698,+ timeTaken: 0.001351873,+ swapUsdValue: '82.45175776511278468757404683',+ mostReliableAmmsQuoteReport: { info: { foo: '1', bar: '2' } },+};++const SEARCH_FIXTURE = [+ {+ id: 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump',+ name: 'three.ws',+ symbol: 'three',+ icon: 'https://ipfs.io/ipfs/bafybeihe22b5sxr3ihnxt7pregfieyteqvubqhik3j3y4bbx243xlqjw3q',+ decimals: 6,+ tags: ['token-2022', 'verified', 'moonshot-verified'],+ usdPrice: 0.0016146354029005611,+ mcap: 1614124.408731268,+ holderCount: 14754,+ stats24h: { buyVolume: 346052.3096565032, sellVolume: 338862.090834 },+ },+];++describe('jupiter provider — descriptor integrity', () => {+ it('is registered as a keyless crypto-market-data provider on the lite base', () => {+ expect(jupiter).toBeTruthy();+ expect(jupiter.category).toBe('crypto-market-data');+ expect(jupiter.base).toBe('https://lite-api.jup.ag');+ expect(jupiter.requiresKey).toBe(false);+ expect(jupiter.byokHeader).toBeNull();+ expect(jupiter.envVar).toBeNull();+ });++ it('exposes exactly price, quote, token-search — all indexed, GET, scoped, priced, free-tiered', () => {+ expect(jupiter.endpoints.map((e) => e.id)).toEqual(['price', 'quote', 'token-search']);+ for (const id of ['price', 'quote', 'token-search']) {+ const e = ENDPOINT_INDEX.get(`jupiter/${id}`);+ expect(e, `jupiter/${id} indexed`).toBeTruthy();+ expect(e.endpoint.method).toBe('GET');+ expect(e.endpoint.scope).toBe('agents:read');+ expect(e.endpoint.priceAtomics).toBe('1000');+ expect(e.endpoint.free).toEqual({ perMin: 20, perDay: 2000 });+ expect(typeof e.endpoint.summary).toBe('string');+ expect(e.endpoint.summary.length).toBeGreaterThan(0);+ expect(e.endpoint.params).toBeTruthy();+ }+ });+});++describe('jupiter/price — transform', () => {+ const t = ep('price').transform;++ it('flattens each mint to normalized price fields', () => {+ const out = t(PRICE_FIXTURE);+ expect(out).toEqual({+ FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump: {+ price_usd: 0.0016321026673506269,+ decimals: 6,+ price_change_24h: 4.548816264001991,+ liquidity: 217828.6725114084,+ block_id: 431244672,+ },+ So11111111111111111111111111111111111111112: {+ price_usd: 82.49319522938384,+ decimals: 9,+ price_change_24h: 1.1801959999610383,+ liquidity: 688122254.2024628,+ block_id: 431244687,+ },+ });+ });++ it('returns {} for an unknown mint (upstream returns {})', () => {+ expect(t({})).toEqual({});+ });++ it('tolerates malformed payloads', () => {+ expect(t(null)).toEqual({});+ expect(t('Route not found')).toEqual({});+ expect(t([])).toEqual({});+ expect(t({ MINT: null })).toEqual({});+ });++ it('requires ids', () => {+ expect(() => ep('price').query({})).toThrow(/ids/);+ expect(ep('price').query({ ids: 'MINT' })).toEqual({ ids: 'MINT' });+ });+});++describe('jupiter/quote — transform', () => {+ const t = ep('quote').transform;++ it('keeps amounts + impact and slims the route plan to label/mints/percent', () => {+ const out = t(QUOTE_FIXTURE);+ expect(out).toEqual({+ inputMint: 'So11111111111111111111111111111111111111112',+ outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ inAmount: '1000000000',+ outAmount: '82520581',+ otherAmountThreshold: '82107979',+ swapMode: 'ExactIn',+ slippageBps: 50,+ priceImpactPct: '0',+ routePlan: [+ {+ label: 'Quantum',+ inputMint: 'So11111111111111111111111111111111111111112',+ outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ percent: 100,+ },+ ],+ });+ // Heavy fields are dropped.+ expect(out).not.toHaveProperty('mostReliableAmmsQuoteReport');+ expect(out).not.toHaveProperty('contextSlot');+ expect(out).not.toHaveProperty('swapUsdValue');+ });++ it('yields an empty routePlan when the field is missing', () => {+ expect(t({ inAmount: '1', outAmount: '2' }).routePlan).toEqual([]);+ });++ it('tolerates malformed payloads', () => {+ expect(t(null)).toBeNull();+ expect(t('Route not found')).toBe('Route not found');+ });++ it('requires inputMint, outputMint, amount and defaults slippageBps to 50', () => {+ const q = ep('quote').query;+ expect(() => q({ outputMint: 'B', amount: '1' })).toThrow(/inputMint/);+ expect(() => q({ inputMint: 'A', amount: '1' })).toThrow(/outputMint/);+ expect(() => q({ inputMint: 'A', outputMint: 'B' })).toThrow(/amount/);+ expect(q({ inputMint: 'A', outputMint: 'B', amount: '1' })).toEqual({+ inputMint: 'A',+ outputMint: 'B',+ amount: '1',+ slippageBps: '50',+ });+ expect(q({ inputMint: 'A', outputMint: 'B', amount: '1', slippageBps: '100' }).slippageBps).toBe('100');+ });+});++describe('jupiter/token-search — transform', () => {+ const t = ep('token-search').transform;++ it('slims each hit and derives daily_volume from the 24h buy/sell split', () => {+ const out = t(SEARCH_FIXTURE);+ expect(out).toEqual([+ {+ address: 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump',+ name: 'three.ws',+ symbol: 'three',+ decimals: 6,+ logoURI: 'https://ipfs.io/ipfs/bafybeihe22b5sxr3ihnxt7pregfieyteqvubqhik3j3y4bbx243xlqjw3q',+ tags: ['token-2022', 'verified', 'moonshot-verified'],+ daily_volume: 346052.3096565032 + 338862.090834,+ },+ ]);+ });++ it('leaves daily_volume/tags undefined when the source omits them', () => {+ const out = t([{ id: 'M', name: 'n', symbol: 's', decimals: 0 }]);+ expect(out[0].daily_volume).toBeUndefined();+ expect(out[0].tags).toBeUndefined();+ });++ it('caps at 20 hits', () => {+ const many = Array.from({ length: 50 }, (_, i) => ({ id: `M${i}`, symbol: `S${i}` }));+ expect(t(many)).toHaveLength(20);+ });++ it('tolerates malformed payloads (empty search returns [])', () => {+ expect(t([])).toEqual([]);+ expect(t(null)).toEqual([]);+ expect(t('Route not found')).toEqual([]);+ });++ it('requires query', () => {+ expect(() => ep('token-search').query({})).toThrow(/query/);+ expect(ep('token-search').query({ query: 'three.ws' })).toEqual({ query: 'three.ws' });+ });+});