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: enhance error handling in Oracle sources to distinguish between unknown coins and database outages; add regression tests for assembleIntel
nirholas62b77051d60d
diff --git a/api/_lib/oracle/sources.js b/api/_lib/oracle/sources.jsindex 7b37e9e26..4d2e90291 100644--- a/api/_lib/oracle/sources.js+++ b/api/_lib/oracle/sources.js@@ -46,7 +46,14 @@ async function tryRows(fn) {* @returns {Promise<object|null>} CoinIntel, or null if the coin is unknown*/export async function assembleIntel(mint, network = 'mainnet') {- const coin = await tryRow(() => sql`+ // The primary existence lookup does NOT use tryRow: a swallowed DB error here+ // is indistinguishable from "coin not observed", which makes every caller+ // return a misleading 404 during a database/connection outage — a transient+ // failure clients and the CDN then cache as an authoritative "doesn't exist".+ // Let a query failure throw (callers map it to 503); only an empty result set+ // is a true "unknown coin" → null. The secondary enrichment queries below stay+ // on tryRow, since partial intel is an acceptable degradation.+ const coinRows = await sql`select mint, symbol, name, image_uri, category, narrative, classify_confidence,created_at, first_seen_at,dev_buy_lamports, dev_sold, dev_sell_lamports,@@ -55,7 +62,8 @@ export async function assembleIntel(mint, network = 'mainnet') {bundle_score, organic_score, concentration_top10, bubblemap_connectivity,quality_score, risk_flagsfrom pump_coin_intel where mint = ${mint} and network = ${network} limit 1- `);+ `;+ const coin = coinRows[0] || null;if (!coin) return null;const [smart, narr, topBuyers] = await Promise.all([diff --git a/api/_mcp/tools/oracle.js b/api/_mcp/tools/oracle.jsindex 5b0ee3eb9..b3b80de44 100644--- a/api/_mcp/tools/oracle.js+++ b/api/_mcp/tools/oracle.js@@ -154,7 +154,15 @@ export const toolDefs = [const rl = await limits.mcpIp(auth.rateKey || 'anon');if (!rl.success) return mcpErr('Rate limit exceeded — try again in a moment.');- const scored = await scoreCoin(mint, { network, classify: true, persist: true }).catch(() => null);+ let scored;+ try {+ scored = await scoreCoin(mint, { network, classify: true, persist: true });+ } catch {+ // Intel store / DB degraded — distinct from "coin unknown". Tell the+ // agent it's transient so it retries rather than concluding the coin+ // doesn't exist.+ return mcpErr(`Oracle is temporarily unavailable for ${mint} — the intel store is degraded. Retry shortly.`);+ }if (!scored) {return mcpErr(`Coin ${mint} not found in Oracle — it may not have been observed on pump.fun yet.`);}diff --git a/api/oracle/coin.js b/api/oracle/coin.jsindex 9bfaebbdd..dd333d9fe 100644--- a/api/oracle/coin.js+++ b/api/oracle/coin.js@@ -34,12 +34,32 @@ export default wrap(async (req, res) => {// Cache miss (no verdict yet) → score it now, with a real narrative read.if (!coin || !coin.conviction) {- const scored = await scoreCoin(mint, { network, classify: true, persist: true }).catch(() => null);+ let scored;+ try {+ scored = await scoreCoin(mint, { network, classify: true, persist: true });+ } catch {+ // Scoring threw — the intel store / DB is degraded, NOT "coin unknown".+ // A 404 here would let clients and the CDN cache a transient outage as an+ // authoritative "this mint doesn't exist". Surface 503 so callers retry.+ return error(res, 503, 'scoring_unavailable', 'coin scoring is temporarily unavailable — retry shortly');+ }if (!scored) {- // The coin is unknown to the data brain (never observed).- return error(res, 404, 'not_found', 'this mint has not been observed yet');+ // Clean empty result — the coin is genuinely unknown to the data brain.+ // This is a stable, idempotent fact (coins are ingested by the always-on+ // observer, never inline here), so cache the negative answer briefly at the+ // CDN. The always-on polling surfaces (coin page, oracle UI) would otherwise+ // re-spin this function and re-run assembleIntel on every poll for a mint the+ // brain has never seen — one such mint produced hundreds of redundant+ // invocations. The window is short enough that a coin becoming known surfaces+ // within seconds.+ return json(res, 404, { error: 'not_found', error_description: 'this mint has not been observed yet', mint, network }, {+ 'cache-control': 'public, max-age=15, s-maxage=30, stale-while-revalidate=60',+ });}coin = await safeReadCoin(mint, network);+ // Scoring succeeded but the warm re-read came back empty (read-path blip) —+ // don't return a hollow 200; treat it as transient.+ if (!coin) return error(res, 503, 'scoring_unavailable', 'coin scoring is temporarily unavailable — retry shortly');}return json(res, 200, { network, mint, ...coin }, {diff --git a/api/oracle/signal.js b/api/oracle/signal.jsindex b7f53b255..fbf9d9220 100644--- a/api/oracle/signal.js+++ b/api/oracle/signal.js@@ -59,7 +59,14 @@ export default wrap(async (req, res) => {const mint = (p.get('mint') || '').trim();if (mint) {if (!MINT_RE.test(mint)) return error(res, 400, 'validation_error', 'invalid mint');- const scored = await scoreCoin(mint, { network, classify: true, persist: true }).catch(() => null);+ let scored;+ try {+ scored = await scoreCoin(mint, { network, classify: true, persist: true });+ } catch {+ // Downstream intel store / DB outage — not a true "not observed". 503 so+ // the transient failure isn't cached by clients as a permanent 404.+ return error(res, 503, 'scoring_unavailable', 'signal scoring is temporarily unavailable — retry shortly');+ }if (!scored) return error(res, 404, 'not_found', 'mint not observed yet');const v = scored.verdict;return json(res, 200, {diff --git a/docs/store-submissions/_generated/claude-submission.md b/docs/store-submissions/_generated/claude-submission.mdindex c7e69fa46..b624df6ae 100644--- a/docs/store-submissions/_generated/claude-submission.md+++ b/docs/store-submissions/_generated/claude-submission.md@@ -141,10 +141,11 @@ x402-gated — §0.4). The captured authenticated payload is `_generated/remote-- **Reads:** avatars (own + public search), glTF/GLB validation & inspection, animation presets,agent registry & reputation / attestations / passport, agent memory recall, pump.fun market data,Oracle signals, trader leaderboard & profiles, copy-subscription status, embed-code generation.-- **Writes:** save/render avatar assets, **delete avatar** (the one destructive op), register an- agent on-chain, call another agent, remember/forget memory, arm an Oracle watch, subscribe to- copy a trader. Writes that touch a chain or external API carry `openWorldHint: true`.-- **Destructive:** only `delete_avatar` (`destructiveHint: true`). All others set+- **Writes:** save/render avatar assets, delete avatar, register an agent on-chain, call another+ agent, remember/forget memory, arm an Oracle watch, subscribe to copy a trader. Writes that+ touch a chain or external API carry `openWorldHint: true`.+- **Destructive:** two tools carry `destructiveHint: true` on the wire — `delete_avatar`+ (deletes an avatar) and `forget` (deletes a stored memory). Every other tool sets`destructiveHint: false` explicitly.- **Payments:** paid tools return a structured x402 `PaymentRequired` (not an error) whenunauthenticated and unpaid; OAuth-connected account tools are operator-funded for the user.@@ -163,68 +164,84 @@ x402-gated — §0.4). The captured authenticated payload is `_generated/remote-## 4. Full tool list (with titles)-> Pulled from source. `free*` = no payment when called with an OAuth account (operator-funded) or-> when the tool is inherently free; `x402` = pay-per-call in USDC for unauthenticated callers.-> Read-only tools carry `readOnlyHint: true`; only `delete_avatar` is `destructiveHint: true`.--### `https://three.ws/api/mcp` — three.ws Avatars & Agents-| Tool name | Title | Kind |-|---|---|---|-| `getting_started` | Getting started with three.ws | free, read-only |-| `list_my_avatars` | List my avatars | OAuth, read |-| `get_avatar` | Get avatar | OAuth, read |-| `search_public_avatars` | Search public avatars | read |-| `render_avatar` | Render avatar | x402 |-| `render_avatar_image` | Render an avatar to an image | x402, generative |-| `delete_avatar` | Delete avatar | OAuth, **destructive** |-| `validate_model` | Validate glTF/GLB model | x402, read |-| `inspect_model` | Inspect glTF/GLB model | x402, read |-| `optimize_model` | Suggest optimizations for a glTF/GLB model | x402, read |-| `list_animations` | List animation presets | free, read |-| `apply_animation` | Apply an animation preset to a rigged model | write |-| `text_to_animation` | Generate an animation from a text prompt and retarget it onto a model | write, generative |-| `get_embed_code` | Get embed code | read |-| `call_agent` | Call agent | write, open-world |-| `register_agent` | Register an agent on-chain | write, open-world |-| `identity_check` | Screen an agent identity for impersonation | read, open-world |-| `remember` | Remember | OAuth, write |-| `recall` | Recall | OAuth, read |-| `forget` | Forget | OAuth, write |-| `solana_agent_reputation` | Get Solana agent reputation | read, open-world |-| `solana_agent_attestations` | List Solana agent attestations | read, open-world |-| `solana_agent_passport` | Get Solana agent passport | read, open-world |-| `pumpfun_recent_claims` | Recent pump.fun claims | read, open-world |-| `pumpfun_token_intel` | Pump.fun token intel | read, open-world |-| `pumpfun_creator_intel` | Pump.fun creator intel | read, open-world |-| `pumpfun_recent_graduations` | Recent pump.fun graduations | read, open-world |-| `oracle_top_plays` | Oracle top conviction plays | read |-| `oracle_coin` | Oracle verdict for one coin | read |-| `oracle_arm_watch` | Arm agent Oracle watch | write |-| `oracle_watch_status` | Oracle watch status + track record | read |-| `trader_leaderboard` | Top pump.fun traders | read |-| `trader_profile` | Full track record for one agent | read |-| `copy_subscribe` | Subscribe to copy a trader | write |-| `copy_status` | My copy subscriptions | read |+> Taken verbatim from `_generated/remote-tools-list.json` (the captured `tools/list` wire payload)+> and `_generated/tool-inventory.md` (prices). **R/O** = `readOnlyHint: true`; **Dx** =+> `destructiveHint: true`. **Price** = pay-per-call in USDC via x402 for unauthenticated callers;+> *free* tools never charge. OAuth-connected account tools are operator-funded for the user.++### `https://three.ws/api/mcp` — three.ws Avatars & Agents (35 tools)+| Tool name | Title | R/O | Dx | Price |+|---|---|:--:|:--:|---|+| `getting_started` | Getting Started (free) | ✅ | — | free |+| `list_my_avatars` | List my avatars | ✅ | — | free |+| `get_avatar` | Get avatar | ✅ | — | free |+| `search_public_avatars` | Search public avatars | ✅ | — | free |+| `render_avatar` | Render avatar | ✅ | — | $0.005 |+| `render_avatar_image` | Render an avatar to an image | — | — | free |+| `delete_avatar` | Delete avatar | — | ✅ | free |+| `get_embed_code` | Get embed code | ✅ | — | free |+| `validate_model` | Validate glTF/GLB model | ✅ | — | $0.01 |+| `inspect_model` | Inspect glTF/GLB model | ✅ | — | $0.01 |+| `optimize_model` | Suggest optimizations for a glTF/GLB model | ✅ | — | $0.05 |+| `list_animations` | List animation presets | ✅ | — | free |+| `apply_animation` | Apply an animation preset to a rigged model | — | — | $0.02 |+| `text_to_animation` | Generate an animation from a text prompt and retarget it onto a model | — | — | free |+| `solana_agent_reputation` | Get Solana agent reputation | ✅ | — | free |+| `solana_agent_attestations` | List Solana agent attestations | ✅ | — | free |+| `solana_agent_passport` | Get Solana agent passport | ✅ | — | free |+| `pumpfun_recent_claims` | Recent pump.fun claims | ✅ | — | free |+| `pumpfun_token_intel` | Pump.fun token intel | ✅ | — | free |+| `pumpfun_creator_intel` | Pump.fun creator intel | ✅ | — | free |+| `pumpfun_recent_graduations` | Recent pump.fun graduations | ✅ | — | free |+| `call_agent` | Call agent | — | — | free |+| `register_agent` | Register an agent on-chain | — | — | free |+| `identity_check` | Screen an agent identity for impersonation | ✅ | — | free |+| `remember` | Remember | — | — | free |+| `recall` | Recall | ✅ | — | free |+| `forget` | Forget | — | ✅ | free |+| `oracle_top_plays` | Oracle top conviction plays | ✅ | — | free |+| `oracle_coin` | Oracle verdict for one coin | ✅ | — | free |+| `oracle_arm_watch` | Arm agent Oracle watch | — | — | free |+| `oracle_watch_status` | Oracle watch status + track record | ✅ | — | free |+| `trader_leaderboard` | Top pump.fun traders | ✅ | — | free |+| `trader_profile` | Full track record for one agent | ✅ | — | free |+| `copy_subscribe` | Subscribe to copy a trader | — | — | free |+| `copy_status` | My copy subscriptions | ✅ | — | free |### `https://three.ws/api/mcp-3d` — three.ws 3D Studio (optional second listing)-| Tool name | Title | Kind |-|---|---|---|-| `getting_started` | Getting started with three.ws 3D Studio | free, read-only |-| `text_to_3d` | Generate a 3D model from a text prompt | x402, generative |-| `image_to_3d` | Reconstruct a 3D model from one or more images | x402, generative |-| `generation_status` | Check a 3D generation job | free, read |-| `preview_3d` | Preview any GLB as an interactive 3D artifact | free, read |-| `remove_background` | Remove the background from an image | generative |-| `remesh_model` | Remesh, simplify, repair, or convert a 3D model | x402 |-| `stylize_model` | Apply a one-click geometric stylization filter to a 3D model | x402, generative |-| `segment_model` | Split a 3D model into named, separable parts | x402 |-| `retexture_model` | Paint a new texture onto a 3D model from a text prompt | x402, generative |-| `retexture_region` | Repaint one masked region of a model's texture (magic brush) | x402, generative |-| `auto_rig_model` | Auto-rig a static 3D model (skeleton + skin weights) | x402 |-| `pose_model` | Resolve a text prompt to a pose-studio seed + joint rotations | read |-| `direct_prompt` | Optimize a rough idea into a 3D-generation prompt (IBM Granite) | x402 |-| `generate_material` | Generate a glTF PBR material from a description (IBM Granite) | x402, generative |-| `save_avatar` | Save a generated GLB as a durable, named avatar | OAuth, write |+> **Re-snapshot before this separate, later submission.** The captured wire payload+> (`remote-tools-list.json`) shows **21** tools; the live catalog has since grown+> (`capture_scene` plus the living-persona tools `create_agent_persona` / `get_agent_persona` /+> `persona_say`), so the current count is **24**. Regenerate `tool-inventory.md` /+> `remote-tools-list.json` at submission time and paste the fresh list here. Core tools below.+> Note the media-generation review risk in §0.2 applies to this server first.++| Tool name | Title | R/O | Dx | Price |+|---|---|:--:|:--:|---|+| `getting_started` | Getting Started (free) | ✅ | — | free |+| `text_to_3d` | Generate a 3D model from a text prompt | — | — | $0.15 |+| `image_to_3d` | Reconstruct a 3D model from one or more images | — | — | $0.15 |+| `generation_status` | Check a 3D generation job | ✅ | — | free |+| `preview_3d` | Preview any GLB as an interactive 3D artifact | ✅ | — | free |+| `remove_background` | Remove the background from an image | — | — | $0.01 |+| `remesh_model` | Remesh, simplify, repair, or convert a 3D model | — | — | $0.02 |+| `stylize_model` | Apply a one-click geometric stylization filter to a 3D model | — | — | $0.02 |+| `segment_model` | Split a 3D model into named, separable parts | — | — | $0.02 |+| `retexture_model` | Paint a new texture onto a 3D model from a text prompt | — | — | $0.05 |+| `retexture_region` | Repaint one masked region of a model's texture (magic brush) | — | — | $0.05 |+| `auto_rig_model` | Auto-rig a static 3D model (skeleton + skin weights) | — | — | $0.05 |+| `pose_model` | Resolve a text prompt to a pose-studio seed + joint rotations | ✅ | — | $0.01 |+| `direct_prompt` | Optimize a rough idea into a 3D-generation prompt (IBM Granite) | — | — | $0.01 |+| `generate_material` | Generate a glTF PBR material from a description (IBM Granite) | — | — | $0.01 |+| `save_avatar` | Save a generated GLB as a durable, named avatar | — | — | free |+| `inspect_model` | Inspect glTF/GLB model | ✅ | — | free |+| `optimize_model` | Suggest optimizations for a glTF/GLB model | ✅ | — | free |+| `list_animations` | List animation presets | ✅ | — | free |+| `apply_animation` | Apply an animation preset to a rigged model | — | — | $0.01 |+| `text_to_animation` | Generate an animation from a text prompt and retarget it onto a model | — | — | free |+| `create_agent_persona` | Mint a persistent, living agent persona from a rigged GLB | — | — | free |+| `get_agent_persona` | Reload a persisted persona by id (continuity across sessions) | ✅ | — | free |+| `persona_say` | Speak a reply through a persona — lip-sync + emotion + gesture | — | — | free |---diff --git a/tests/oracle/sources-assemble.test.js b/tests/oracle/sources-assemble.test.jsnew file mode 100644index 000000000..5e88e6a77--- /dev/null+++ b/tests/oracle/sources-assemble.test.js@@ -0,0 +1,31 @@+// Oracle source adapter — assembleIntel outage semantics.+//+// Regression guard: the primary coin lookup must distinguish a genuinely-unknown+// coin (empty result → null) from a database outage (query throws → propagate).+// Collapsing both into null made /api/oracle/coin return a misleading 404 during+// a DB/connection outage, which clients and the CDN then cached as an+// authoritative "this mint doesn't exist". A thrown error must reach the caller+// so it can answer 503 instead.++import { describe, it, expect, vi, beforeEach } from 'vitest';++const sqlMock = vi.fn();+vi.mock('../../api/_lib/db.js', () => ({+ sql: (...args) => sqlMock(...args),+}));++const { assembleIntel } = await import('../../api/_lib/oracle/sources.js');++describe('assembleIntel — outage vs unknown', () => {+ beforeEach(() => sqlMock.mockReset());++ it('returns null when the coin is genuinely unknown (empty primary result)', async () => {+ sqlMock.mockResolvedValue([]);+ await expect(assembleIntel('MintUnknownAAA', 'mainnet')).resolves.toBeNull();+ });++ it('throws when the primary lookup fails (DB outage) — never a silent null', async () => {+ sqlMock.mockRejectedValue(new Error('db query exceeded 15000ms deadline'));+ await expect(assembleIntel('MintXYZ', 'mainnet')).rejects.toThrow(/deadline/);+ });+});