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.

feat: watch all controlled wallets for leaks and gate implicit sniper auto-funding

nirholas94801fbe943c
diff --git a/data/changelog.json b/data/changelog.json
index 47b08023c..ca9db0067 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-07-03",
+ "title": "Every platform wallet is now watched for leaks — and arming a sniper no longer moves money",
+ "summary": "Two safety upgrades to how the platform handles money. First, a new on-chain leak scanner watches every wallet the platform controls — the funding masters, all treasuries, the x402 ring wallets — not just a subset, and pages ops within minutes if a single lamport or token ever leaves one of them to an address outside the controlled set. Second, we closed an implicit-funding footgun: previously, simply arming an autonomous trading strategy could cause a master wallet to start pushing real SOL to that agent on a schedule. Now that only happens if the strategy explicitly opts in, and it is off by default, so arming a strategy never moves money on its own.",
+ "tags": [
+ "security",
+ "infra"
+ ]
+ },
{
"date": "2026-07-03",
"title": "Autonomous trading experiment — take initials, hold a moon bag, never dump the whole bag",
diff --git a/docs/financial-controls.md b/docs/financial-controls.md
index a3fb1184c..12b8e4a70 100644
--- a/docs/financial-controls.md
+++ b/docs/financial-controls.md
@@ -204,9 +204,15 @@ Ranked by accounting/regulatory risk. Each is a tracked remediation item.
Merkle-anchor it (reuse `custody-proof.js`).*
8. **No consolidated P&L / all-flows export.** *Fix: an admin-auth endpoint that
unions every ledger into one dated cash-flow CSV, with the cost side.*
-9. **Custodial-signer drains don't page ops and aren't anomaly-scored.** *Fix: extend
- `wallet-anomaly` (or a balance-delta monitor) to treasury/master/coin signers and
- route to `sendOpsAlert`.*
+9. ✅ **Custodial-signer drains now page ops (on-chain leak scan).** The general
+ scanner `api/cron/wallets-leak-scan.js` (every 15 min) watches EVERY resolvable
+ mainnet `SOLANA_SIGNERS` wallet — economy/launcher masters, all treasuries, x402
+ sponsor/payer — and reuses the ring scanner's audited `classifyWalletDebits`: any
+ SOL/token debit to an address outside `ringAllowedAddresses()` (or an SPL Approve)
+ raises a CRITICAL `sendOpsAlert` + a `payment_reconciliation` verdict
+ (`source='wallets_onchain'`). *Remaining: a balance-delta (velocity) monitor on top
+ of the leak scan, and per-agent custodial wallets (currently only preventively
+ anomaly-scored, owner-alerted).*
### P2
10. **Buyback/distribute run tables and `x402_autonomous_log` lack idempotency keys.**
@@ -223,6 +229,16 @@ Ranked by accounting/regulatory risk. Each is a tracked remediation item.
writes.
### Done
+- ✅ **All controlled wallets are on-chain leak-scanned** (`wallets-leak-scan.js`,
+ every 15 min) — not just the ring. Any SOL/token debit leaving a
+ `SOLANA_SIGNERS` wallet to an address outside the controlled set pages ops and
+ files a `wallets_onchain` verdict. Closes the "custodial-signer drains are
+ silent" gap (P1-#9).
+- ✅ **Implicit sniper auto-funding is gated behind explicit consent.** Arming a
+ mainnet `agent_sniper_strategies` row no longer causes the launcher master to
+ push SOL to the agent wallet: the auto-funder only tops up agents whose strategy
+ set `auto_fund_enabled = true` (default false, fail-safe on a missing value).
+ Removes an implicit fund-moving trigger.
- ✅ **Reconciliation discrepancies now page ops** (`revenue-reconciliation.js`) —
was detected-but-silent (G1/R1).
- ✅ **The closed-loop ring's own books are now chain-reconciled**
diff --git a/src/theater-stage.js b/src/theater-stage.js
index 71164c8f8..5cbca90c1 100644
--- a/src/theater-stage.js
+++ b/src/theater-stage.js
@@ -40,6 +40,8 @@ import {
CircleGeometry,
RingGeometry,
CylinderGeometry,
+ BoxGeometry,
+ PlaneGeometry,
MeshStandardMaterial,
MeshBasicMaterial,
Mesh,
@@ -66,9 +68,20 @@ const REACTIONS = {
pay: ['av-cheering', 'wave'],
loss: ['defeated', 'reaction'],
taunt: ['taunt', 'reaction'],
+ guard: ['reaction', 'defeated'], // a safety refusal — the trader waves the bad trade off
};
const ALL_REACTION_CLIPS = [...new Set(Object.values(REACTIONS).flat())];
+// The colour a trader's monitor flashes for each event — green on a fill, violet
+// on a verify/pay, amber when a safety rule refuses a buy. The resting glow is a
+// dim blue so a room of idle desks still reads as "screens on, market open".
+const SCREEN_IDLE = 0x2a3550;
+const SCREEN_FLASH = {
+ buy: 0x22c55e, win: 0x22c55e, launch: 0x22c55e,
+ verify: 0x8b5cf6, pay: 0x8b5cf6,
+ loss: 0xf59e0b, guard: 0xf59e0b,
+};
+
// Clips every performer registers. `idle` loops as the resting state; the rest
// are one-shots loaded lazily on first reaction so startup only fetches idle.
const CLIP_DEFS = [
@@ -124,7 +137,22 @@ function arcSlot(index, total) {
return { x, z, scale };
}
-export function createStage({ canvas, overlay, onSelect, reducedMotion = false }) {
+/**
+ * Dealing-room layout: even rows of workstations facing the camera, like desks in
+ * a trading pit. Partial last row is centred. Returns { x, z, scale, row }.
+ */
+function deskSlot(index, total) {
+ const perRow = total <= 6 ? 3 : total <= 12 ? 4 : 5;
+ const row = Math.floor(index / perRow);
+ const inRow = index % perRow;
+ const rowItems = Math.min(perRow, total - row * perRow);
+ const x = (inRow - (rowItems - 1) / 2) * 2.9;
+ const z = -1 - row * 3.0; // rows recede from the camera
+ const scale = Math.max(0.9, 1 - row * 0.03);
+ return { x, z, scale, row };
+}
+
+export function createStage({ canvas, overlay, onSelect, reducedMotion = false, environmentUrl = null }) {
const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true, powerPreference: 'high-performance' });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = SRGBColorSpace;
@@ -132,12 +160,14 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false }
renderer.toneMappingExposure = 1.12;
const scene = new Scene();
- scene.fog = new Fog(0x05050a, 14, 38);
+ scene.fog = new Fog(0x05050a, 16, 46);
- const CAM_BASE_Z = 9.4;
+ // A dealing-room vantage: raised and pulled back so several rows of desks read
+ // as a room, not a line-up. Looks slightly down into the pit.
+ const CAM_BASE_Z = 11.6;
const camera = new PerspectiveCamera(42, 1, 0.1, 200);
- camera.position.set(0, 2.35, CAM_BASE_Z);
- camera.lookAt(0, 1.25, -2);
+ camera.position.set(0, 3.1, CAM_BASE_Z);
+ camera.lookAt(0, 1.05, -4);
// Lighting — a cool key from above the audience plus a warm rim so avatars
// read against the near-black backdrop. Violet accent matches the finance tokens.
@@ -170,7 +200,36 @@ export function createStage({ canvas, overlay, onSelect, reducedMotion = false }
ring.position.y = 0.01;
scene.add(ring);
- // Group that holds all performers so we can gently auto-orbit the whole cast.
+ // Procedural dealing-room shell — a big back-wall board and side glow so the
+ // desks sit in a room, not a void. A supplied `environmentUrl` GLB drops in
+ // behind the desks as a richer backdrop; the desks themselves are always ours
+ // so every workstation lands at a known, data-driven spot.
+ const board = new Mesh(
+ new PlaneGeometry(22, 6),
+ new MeshStandardMaterial({ color: 0x07070e, emissive: new Color(0x160f2e), emissiveIntensity: 0.7, roughness: 0.9, metalness: 0.1 }),
+ );
+ board.position.set(0, 3.4, -16);
+ scene.add(board);
+ const boardEdge = new Mesh(
+ new PlaneGeometry(22, 0.08),
+ new MeshBasicMaterial({ color: 0x8b5cf6, transparent: true, opacity: 0.5 }),
+ );
+ boardEdge.position.set(0, 0.9, -15.98);
+ scene.add(boardEdge);
+
+ if (environmentUrl) {
+ gltfLoader(renderer)
+ .loadAsync(environmentUrl)
+ .then((gltf) => { if (!disposed) { gltf.scene.position.set(0, 0, 0); scene.add(gltf.scene); } })
+ .catch((err) => log.warn('[theater] environment load failed', environmentUrl, err?.message));
+ }
+
+ // Shared desk material — one instance across every workstation (never disposed
+ // per-performer, only at teardown).
+ const deskMat = new MeshStandardMaterial({ color: 0x14141f, roughness: 0.72, metalness: 0.3 });
+
+ // Group that holds all performers + their desks so a gentle sway moves the room
+ // as one (a full spin would look wrong for a room; this is a subtle drift).
const cast = new Group();
scene.add(cast);
diff --git a/tests/wallets-leak-scan.test.js b/tests/wallets-leak-scan.test.js
new file mode 100644
index 000000000..50d6401a3
--- /dev/null
+++ b/tests/wallets-leak-scan.test.js
@@ -0,0 +1,39 @@
+import { describe, it, expect } from 'vitest';
+import { isScannableSpec, dedupeWallets } from '../api/cron/wallets-leak-scan.js';
+
+// The general leak scanner watches every mainnet controlled wallet. These pin
+// the wallet-selection rules: mainnet-only, and one scan per pubkey even when
+// two registry specs (fallback envs) resolve to the same wallet.
+
+describe('isScannableSpec', () => {
+ it('scans mainnet + unspecified-network signers', () => {
+ expect(isScannableSpec({ name: 'a', network: 'mainnet' })).toBe(true);
+ expect(isScannableSpec({ name: 'b' })).toBe(true); // network defaults to mainnet elsewhere
+ });
+ it('skips devnet signers (no real funds)', () => {
+ expect(isScannableSpec({ name: 'c', network: 'devnet' })).toBe(false);
+ });
+ it('is safe on nullish', () => {
+ expect(isScannableSpec(null)).toBe(false);
+ expect(isScannableSpec(undefined)).toBe(false);
+ });
+});
+
+describe('dedupeWallets', () => {
+ it('collapses two specs pointing at the same wallet', () => {
+ const out = dedupeWallets([
+ { pubkey: 'W1', name: 'ring-payer' },
+ { pubkey: 'W1', name: 'agent-fallback' }, // same wallet via fallback env
+ { pubkey: 'W2', name: 'sponsor' },
+ ]);
+ expect(out).toEqual([
+ { pubkey: 'W1', name: 'ring-payer' }, // first name wins
+ { pubkey: 'W2', name: 'sponsor' },
+ ]);
+ });
+ it('drops entries without a pubkey and handles empty input', () => {
+ expect(dedupeWallets([{ name: 'x' }, null, { pubkey: '', name: 'y' }])).toEqual([]);
+ expect(dedupeWallets([])).toEqual([]);
+ expect(dedupeWallets(undefined)).toEqual([]);
+ });
+});
diff --git a/vercel.json b/vercel.json
index b9ea37a9e..4c7f312da 100644
--- a/vercel.json
+++ b/vercel.json
@@ -4940,6 +4940,10 @@
{
"path": "/api/cron/x402-ring-leak-scan",
"schedule": "*/10 * * * *"
+ },
+ {
+ "path": "/api/cron/wallets-leak-scan",
+ "schedule": "*/15 * * * *"
}
]
}