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
fix(ibm): keep the galaxy cache latch retryable and stop an empty back-test from wiping the twin
nirholascfe93ff3c0ce
diff --git a/api/ibm/galaxy.js b/api/ibm/galaxy.jsindex 67156771d..342666c25 100644--- a/api/ibm/galaxy.js+++ b/api/ibm/galaxy.js@@ -70,6 +70,17 @@ function ensureCacheTable() {computed_at timestamptz NOT NULL DEFAULT now())`.then(() => true);+ // Drop the latch if the DDL rejects. Caching the promise unconditionally means+ // one transient DB blip (a dropped connection, a cold Neon branch) is memoized+ // as a permanently rejected promise, and every later request on that warm+ // instance re-awaits the same rejection: the galaxy stays down until the+ // instance recycles, long after the database recovered. Clearing it lets the+ // next caller retry the create, while concurrent callers still share one+ // round-trip on the happy path.+ _cacheReady = _cacheReady.catch((err) => {+ _cacheReady = null;+ throw err;+ });return _cacheReady;}@@ -404,7 +415,11 @@ async function handleSearch(req, res) {let body;try {- body = await readJson(req, 8_000);+ // A body of `null` / a bare string is valid JSON that readJson returns as-is+ // on the raw-stream path, and reading .query off it throws a TypeError that+ // surfaces as a 500. Malformed input answers 400 like every other bad body.+ const parsed = await readJson(req, 8_000);+ body = parsed && typeof parsed === 'object' ? parsed : {};} catch (e) {return error(res, e.status || 400, 'bad_request', e.message);}diff --git a/api/ibm/twin.js b/api/ibm/twin.jsindex 98e297bca..22cf2ba20 100644--- a/api/ibm/twin.js+++ b/api/ibm/twin.js@@ -354,8 +354,13 @@ async function handleGet(req, res) {inputWindow: projFc.inputWindow,};- if (btFc && realized) {- const predicted = pointsFrom(btFc);+ // An empty predicted series (a forecast that answers with no points) would+ // make fidelityOf index realized[-1] and throw, and that throw lands in the+ // outer catch below, which replaces the good `ibm` block with an error and+ // skips the persona entirely. A back-test with nothing to score simply has+ // no fidelity to report.+ const predicted = btFc && realized ? pointsFrom(btFc) : null;+ if (predicted?.length) {const cutoffPrice = btSlice[btSlice.length - 1].c;const f = fidelityOf(realized, predicted, cutoffPrice);out.fidelity = {@@ -395,7 +400,14 @@ async function handleGet(req, res) {// ── POST: a what-if simulation ────────────────────────────────────────────────async function handlePost(req, res) {- const body = await readJson(req);+ // `null`, a bare string, or a number is valid JSON, and readJson hands it back+ // as-is on the raw-stream path (Vercel-style invocation, the MCP server, a+ // direct handler call). Reading params off it throws a TypeError that surfaces+ // as a sanitized 500, when malformed input belongs in the documented 4xx+ // contract. Collapsing a non-object to {} routes it through the normal+ // bad_request path instead.+ const parsed = await readJson(req);+ const body = parsed && typeof parsed === 'object' ? parsed : {};const { candles, token, freq, timeframe, aggregate } = await loadSeries(body);const scenario = clampScenario(body.scenario);const label = scenarioLabel(scenario);diff --git a/api/ibm/vision.js b/api/ibm/vision.jsindex 674522fb3..14aee7930 100644--- a/api/ibm/vision.js+++ b/api/ibm/vision.js@@ -174,7 +174,12 @@ async function handleVision(req, res) {let body;try {- body = await readJson(req, 9_000_000); // a base64 data URL of a snapshot can be large+ // a base64 data URL of a snapshot can be large+ const parsed = await readJson(req, 9_000_000);+ // `null` / a bare string is valid JSON that readJson returns as-is on the+ // raw-stream path, and reading .image off it throws a TypeError that surfaces+ // as a 500. Malformed input takes the documented 400 bad_image path instead.+ body = parsed && typeof parsed === 'object' ? parsed : {};} catch (e) {return error(res, e.status || 400, 'bad_request', e.message);}