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(brownout): align the proofs endpoint and preflight with their page contracts

nirholas00fb740f81d7
diff --git a/api/brownout.js b/api/brownout.js
index c4f2af86f..9a0067813 100644
--- a/api/brownout.js
+++ b/api/brownout.js
@@ -12,8 +12,8 @@
// plainly as a failure, because a proof that did not run is not a pass.
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
-import { cors, json, method, wrap, error } from './_lib/http.js';
-import { limits, clientIp, rateLimited } from './_lib/rate-limit.js';
+import { cors, json, method, wrap, error, rateLimited } from './_lib/http.js';
+import { limits, clientIp } from './_lib/rate-limit.js';
const ROOT = process.cwd();
let _cached = null;
diff --git a/api/x402/preflight.js b/api/x402/preflight.js
index acdbde59b..945bbdb14 100644
--- a/api/x402/preflight.js
+++ b/api/x402/preflight.js
@@ -173,14 +173,22 @@ export default wrap(async function handler(req, res) {
if (cors(req, res, { origins: '*', methods: 'GET,OPTIONS' })) return;
if (!method(req, res, ['GET'])) return;
- const url = new URL(req.url, `https://${req.headers.host || 'three.ws'}`);
+ // TLS terminates at the load balancer, so the origin sees plain http and must
+ // take the client-visible scheme from the forwarded header. Getting this wrong
+ // is not cosmetic: `subject` is inside the signature, and a verifier that
+ // pinned the origin it asked about would reject every attestation as a
+ // subject_mismatch. Default https, which is what the production LB sends.
+ const proto = String(req.headers['x-forwarded-proto'] || '').split(',')[0].trim()
+ || (req.socket?.encrypted ? 'https' : 'http');
+ const host = req.headers.host || 'three.ws';
+ const url = new URL(req.url, `${proto}://${host}`);
const ttl = Math.min(
PREFLIGHT_MAX_TTL_SECONDS,
Math.max(1, Number(url.searchParams.get('ttl')) || PREFLIGHT_TTL_SECONDS),
);
const network = url.searchParams.get('network');
const endpointPath = url.searchParams.get('endpoint');
- const origin = `https://${req.headers.host || 'three.ws'}`;
+ const origin = `${proto}://${host}`;
const key = cacheKey(ttl, endpointPath);
const now = Date.now();
diff --git a/packages/motion/src/compose.js b/packages/motion/src/compose.js
index ad8be9d37..d03df4c5e 100644
--- a/packages/motion/src/compose.js
+++ b/packages/motion/src/compose.js
@@ -22,6 +22,13 @@
import { EFFORTS } from './vocabulary.js';
+// Hands forward and low, counterweighting a dropped centre of mass: what a body
+// does with its arms the moment it drops into a crouch.
+const BRACED = Object.freeze({
+ left: { at: 'front', up: -0.16, out: 0.06, forward: -0.02, palm: 'down', hand: 'relaxed', elbow: 'down' },
+ right: { at: 'front', up: -0.16, out: 0.06, forward: -0.02, palm: 'down', hand: 'relaxed', elbow: 'down' },
+});
+
// Both hands resting on the thighs: the shape a body makes sitting down or
// bracing on its legs, reused by every posture that needs it.
const HANDS_ON_THIGHS = Object.freeze({
@@ -97,7 +104,7 @@ const ACTIONS = {
{
label: 'point',
posture: direction === 'down' ? 'lean_in' : 'easy',
- arms: { [side]: { at, up: direction === 'down' ? -0.3 : 0, forward: direction === 'forward' ? 0.12 : 0.04, palm: 'down', point: direction === 'up' ? 'up' : direction === 'down' ? 'down' : 'forward', hand: 'point', elbow: 'down' } },
+ arms: { [side]: { at, up: direction === 'down' ? -0.24 : 0, forward: direction === 'forward' ? 0.12 : 0.02, palm: 'down', point: direction === 'up' ? 'up' : direction === 'down' ? 'down' : 'forward', hand: 'point', elbow: 'down' } },
gaze: direction === 'down' ? 'down' : direction === 'up' ? 'up' : 'forward',
in: 0.3,
hold: 0.6,
@@ -134,11 +141,11 @@ const ACTIONS = {
sit: ({ effort }) => [
{ label: 'stand', posture: 'easy', in: 0.25, effort },
{ label: 'lower', posture: 'crouch', gaze: 'down', in: 0.55, effort },
- { label: 'seated', posture: 'sit', torso: { lean: 18 }, gaze: 'forward', arms: { left: HANDS_ON_THIGHS.left, right: HANDS_ON_THIGHS.right }, in: 0.5, hold: 0.9, effort },
+ { label: 'seated', posture: 'sit', torso: { lean: 24 }, gaze: 'forward', arms: { left: HANDS_ON_THIGHS.left, right: HANDS_ON_THIGHS.right }, in: 0.5, hold: 0.9, effort },
],
stand_up: ({ effort }) => [
- { label: 'seated', posture: 'sit', torso: { lean: 18 }, arms: { left: HANDS_ON_THIGHS.left, right: HANDS_ON_THIGHS.right }, in: 0.25, effort },
+ { label: 'seated', posture: 'sit', torso: { lean: 24 }, arms: { left: HANDS_ON_THIGHS.left, right: HANDS_ON_THIGHS.right }, in: 0.25, effort },
{ label: 'lean out', posture: 'sit', torso: { lean: 26 }, gaze: 'down', in: 0.4, effort },
{ label: 'rise', posture: 'crouch', in: 0.45, effort },
{ label: 'stand', posture: 'easy', gaze: 'forward', in: 0.5, hold: 0.3, effort },
@@ -146,7 +153,7 @@ const ACTIONS = {
crouch: ({ effort }) => [
{ label: 'stand', posture: 'easy', in: 0.25, effort },
- { label: 'down', posture: 'crouch', torso: { lean: 30 }, gaze: 'down', arms: { left: HANDS_ON_THIGHS.left, right: HANDS_ON_THIGHS.right }, in: 0.55, hold: 0.7, effort },
+ { label: 'down', posture: 'crouch', gaze: 'down', arms: { left: BRACED.left, right: BRACED.right }, in: 0.55, hold: 0.7, effort },
{ label: 'up', posture: 'easy', gaze: 'forward', in: 0.6, hold: 0.2, effort },
],
@@ -228,7 +235,7 @@ const ACTIONS = {
{
label: 'reach',
posture: direction === 'down' ? 'crouch' : 'lean_in',
- arms: { [side]: { at: direction === 'up' ? 'overhead' : 'front', up: direction === 'down' ? -0.3 : 0, forward: 0.1, palm: direction === 'down' ? 'down' : 'up', hand: 'open', elbow: 'down' } },
+ arms: { [side]: { at: direction === 'up' ? 'overhead' : 'front', up: direction === 'down' ? -0.24 : 0, forward: direction === 'down' ? 0.02 : 0.1, palm: direction === 'down' ? 'down' : 'up', hand: 'open', elbow: 'down' } },
gaze: direction === 'down' ? 'down' : direction === 'up' ? 'up' : 'forward',
in: 0.5,
hold: 0.4,
diff --git a/packages/motion/src/rig/anchors.js b/packages/motion/src/rig/anchors.js
index 57bbfdb51..f863b9d60 100644
--- a/packages/motion/src/rig/anchors.js
+++ b/packages/motion/src/rig/anchors.js
@@ -97,13 +97,13 @@ export const ANCHORS = Object.freeze({
Right: vAdd(shoulderR, vAdd(above(-hang * 0.86), vAdd(lateral(0.02), ahead(-hang * 0.42)))),
},
/**
- * On the thigh, a third of the way from hip to knee: where a hand actually
+ * On the thigh, a little under a third of the way from hip to knee: where a hand actually
* rests when someone sits down or leans on their legs. The knee itself is
* past a wrist's reach on a human skeleton, which is why hands go here.
*/
thigh: {
- Left: vLerp(restPos('LeftUpLeg'), restPos('LeftLeg'), 0.35),
- Right: vLerp(restPos('RightUpLeg'), restPos('RightLeg'), 0.35),
+ Left: vLerp(restPos('LeftUpLeg'), restPos('LeftLeg'), 0.28),
+ Right: vLerp(restPos('RightUpLeg'), restPos('RightLeg'), 0.28),
},
/** The knee joint itself: a place to look at, or to reach for in a crouch. */
knee: {