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.

fix(v1-market): map aixbt failures through the shared classifier

nirholas44f9826d2aae
diff --git a/api/v1/market/intel.js b/api/v1/market/intel.js
index 639c371ca..471470e45 100644
--- a/api/v1/market/intel.js
+++ b/api/v1/market/intel.js
@@ -6,7 +6,7 @@
// (or many) can't drain the shared key.
import { defineEndpoint, fail } from '../../_lib/gateway.js';
-import { getIntel, aixbtEnabled } from '../../_lib/aixbt.js';
+import { getIntel, aixbtEnabled, mapAixbtFailure } from '../../_lib/aixbt.js';
import { limits } from '../../_lib/rate-limit.js';
export default defineEndpoint({
@@ -25,11 +25,23 @@ export default defineEndpoint({
const g = await limits.aixbtGlobal();
if (!g.success) fail(429, 'rate_limited', 'market intelligence is busy — retry shortly');
- const { intel, pagination } = await getIntel({
- limit: query.limit,
- category: query.category,
- chain: query.chain,
- });
- return { intel, pagination, source: 'aixbt' };
+ let result;
+ try {
+ result = await getIntel({
+ limit: query.limit,
+ category: query.category,
+ chain: query.chain,
+ });
+ } catch (err) {
+ // Shared classifier (api/_lib/aixbt.js), the same one /api/aixbt/*
+ // answers through: an upstream credential rejection becomes a 503
+ // deployment fault instead of a 401 that reads as "your key is bad" on
+ // a door that takes no client credential. An unclassified fault is
+ // rethrown so wrap() sanitizes it.
+ const mapped = mapAixbtFailure(err);
+ if (!mapped) throw err;
+ fail(mapped.status, mapped.code, mapped.message);
+ }
+ return { intel: result.intel, pagination: result.pagination, source: 'aixbt' };
},
});
diff --git a/api/v1/market/projects.js b/api/v1/market/projects.js
index f93d2e7f1..529645f8f 100644
--- a/api/v1/market/projects.js
+++ b/api/v1/market/projects.js
@@ -5,7 +5,7 @@
// gateway's per-principal budget so the shared upstream key stays protected.
import { defineEndpoint, fail } from '../../_lib/gateway.js';
-import { getProjects, aixbtEnabled } from '../../_lib/aixbt.js';
+import { getProjects, aixbtEnabled, mapAixbtFailure } from '../../_lib/aixbt.js';
import { limits } from '../../_lib/rate-limit.js';
export default defineEndpoint({
@@ -21,12 +21,21 @@ export default defineEndpoint({
const g = await limits.aixbtGlobal();
if (!g.success) fail(429, 'rate_limited', 'market intelligence is busy — retry shortly');
- const { projects, pagination } = await getProjects({
- limit: query.limit,
- page: query.page,
- names: query.names,
- chain: query.chain,
- });
- return { projects, pagination, source: 'aixbt' };
+ let result;
+ try {
+ result = await getProjects({
+ limit: query.limit,
+ page: query.page,
+ names: query.names,
+ chain: query.chain,
+ });
+ } catch (err) {
+ // See api/v1/market/intel.js — one shared classifier so this door and
+ // /api/aixbt/* can never disagree about whose fault a failure is.
+ const mapped = mapAixbtFailure(err);
+ if (!mapped) throw err;
+ fail(mapped.status, mapped.code, mapped.message);
+ }
+ return { projects: result.projects, pagination: result.pagination, source: 'aixbt' };
},
});