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 x402 ring setup and treasury top-up functionality with dry run option and new environment variables
nrpoc25819b361cc
diff --git a/.env.example b/.env.exampleindex 354b577f8..5862ac9d9 100644--- a/.env.example+++ b/.env.example@@ -458,6 +458,13 @@ X402_RING_DAILY_CAP_ATOMIC=50000000# Default $0.10. Lower it so the (120s) rebalancer tops the payer up sooner as# the per-minute tick cycles the float in small increments.X402_RING_MIN_SWEEP_ATOMIC=100000+# Hard per-payment network-fee ceiling (lamports). payX402 refuses to broadcast+# a ring payment whose fee configuration could exceed it. Default 10000 —+# double the 1-signature self-pay floor, so both modes fit with headroom.+X402_RING_MAX_FEE_PER_TX_LAMPORTS=10000+# Daily SOL fee budget for the whole ring (lamports). The nightly fee audit+# pages ops when the day's real, chain-read burn crosses it. Default 0.05 SOL.+X402_RING_DAILY_FEE_BUDGET_LAMPORTS=50000000# Only OUR endpoints get paid — disables the external x402 section of the loop.X402_EXTERNAL_ENABLED=false# No charity split leaves the ring (basis points; 0 = nothing leaves).diff --git a/api/_lib/economy-master.js b/api/_lib/economy-master.jsindex 1eaf6e30d..49f8b81e6 100644--- a/api/_lib/economy-master.js+++ b/api/_lib/economy-master.js@@ -180,7 +180,7 @@ export async function resolveRegistryPubkeys() {* @param {'mainnet'|'devnet'} [args.network]* @returns {Promise<object>}*/-export async function sweepTopUps({ connection, targets, network = 'mainnet' }) {+export async function sweepTopUps({ connection, targets, network = 'mainnet', dryRun = false }) {const master = await loadEconomyMaster();if (!master) {return { configured: false, funded: [], failed: [], skipped: [], rejected: [], spentSol: 0 };@@ -192,6 +192,23 @@ export async function sweepTopUps({ connection, targets, network = 'mainnet' })const { sol: masterSol } = await getSolBalance(connection, master.publicKey);const { plan, skipped, spendableSol } = planTopUps(masterSol, safe);+ if (dryRun) {+ return {+ configured: true,+ dryRun: true,+ master: master.publicKey.toBase58(),+ masterSol: round(masterSol),+ reserveSol: RESERVE_SOL,+ spendableSol,+ plan,+ funded: [],+ failed: [],+ skipped,+ rejected,+ spentSol: 0,+ };+ }+const funded = [];const failed = [];for (const step of plan) {diff --git a/api/cron/treasury-topup.js b/api/cron/treasury-topup.jsindex 65e071cef..b42b06296 100644--- a/api/cron/treasury-topup.js+++ b/api/cron/treasury-topup.js@@ -100,7 +100,26 @@ export default wrapCron(async (req, res) => {});}- const result = await sweepTopUps({ connection, targets, network: 'mainnet' });+ // ?dry=1 → plan only: same balance reads, allowlist filter, and cap math, but+ // no SOL moves, no ledger write, no alerts. Lets an operator inspect exactly+ // what the next sweep would do (e.g. after adding a signer to the registry).+ const dryRun = /[?&]dry=(1|true)\b/.test(req.url || '');+ const result = await sweepTopUps({ connection, targets, network: 'mainnet', dryRun });+ if (dryRun) {+ return json(res, 200, {+ ok: true,+ dry_run: true,+ rpc: rpcUrl,+ configured: result.configured,+ targets,+ plan: result.plan || [],+ skipped: result.skipped || [],+ rejected: result.rejected || [],+ master_sol: result.masterSol ?? null,+ spendable_sol: result.spendableSol ?? null,+ read_errors: errors,+ });+ }// Record the sweep to the tamper-evident accounting ledger. Every transfer,// block, and failure becomes a hash-chained row; the heartbeat row proves thediff --git a/api/cron/x402-ring-leak-scan.js b/api/cron/x402-ring-leak-scan.jsindex ec10cae0d..abbe3d444 100644--- a/api/cron/x402-ring-leak-scan.js+++ b/api/cron/x402-ring-leak-scan.js@@ -480,6 +480,7 @@ export async function scanWallet(conn, PublicKey, wallet, { allowed, usdcMint, r/** |observed - audited| / max(...). null when either side is unknown/zero. */export function feeDivergence(observed, audited) {+ if (observed == null || audited == null) return null;const a = Number(observed);const b = Number(audited);if (!Number.isFinite(a) || !Number.isFinite(b)) return null;diff --git a/data/changelog.json b/data/changelog.jsonindex dbdbe0c35..8355e4e90 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": "Agents in the ring — platform agents now buy and sell services from each other",+ "summary": "The closed-loop x402 economy is no longer a scheduler paying itself: real platform agents with their own custodial wallets now do the buying. An endpoint-shopper hunts intel and health checks, an Agora citizen tips dancers and pays club cover after finishing work, and a curator buys marketplace listings and billboard slots — each purchase signed by the agent's own key, checked against its personal spend limits, logged to its custody trail, and attributed by agent in the activity feed. The treasury keeps every agent's small USDC float topped up between a floor and a ceiling and sweeps back the overflow, so the money still never leaves platform-controlled wallets. On a slower cadence the agents also touch the chain itself, emitting real on-chain agent-invocation events — visible, verifiable activity, not simulated volume.",+ "tags": [+ "feature"+ ],+ "link": "/docs/x402-ring-economy"+ },{"date": "2026-07-03","title": "x402 ring: paid endpoints now settle every minute, cap-coherent",diff --git a/scripts/x402-ring-setup.mjs b/scripts/x402-ring-setup.mjsindex 4c060feb1..209495df2 100644--- a/scripts/x402-ring-setup.mjs+++ b/scripts/x402-ring-setup.mjs@@ -20,10 +20,14 @@// node scripts/x402-ring-setup.mjs --out=./secrets.json// node scripts/x402-ring-setup.mjs --register # also record pubkeys in DB// node scripts/x402-ring-setup.mjs --print-secrets # echo secrets to stdout too+// node scripts/x402-ring-setup.mjs --force-regenerate # bypass the overwrite guard (DANGER)+//+// A role that already has a key (in the secrets file or env) is NEVER+// regenerated without --force-regenerate — an existing wallet may hold funds.import { Keypair } from '@solana/web3.js';import bs58 from 'bs58';-import { writeFileSync } from 'node:fs';+import { existsSync, readFileSync, writeFileSync } from 'node:fs';const args = process.argv.slice(2);const flag = (name) => args.includes(`--${name}`);@@ -51,7 +55,24 @@ if (roles.length === 0) {const outFile = opt('out', '.x402-ring-secrets.json');const printSecrets = flag('print-secrets');-const generated = {};+// Overwrite guard: a role that already has a key — in the secrets file or in+// env — may hold funds. Regenerating it would orphan that wallet. Refuse unless+// the operator explicitly passes --force-regenerate for that run.+const existing = existsSync(outFile) ? JSON.parse(readFileSync(outFile, 'utf8')) : {};+const forceRegenerate = flag('force-regenerate');+const blocked = roles.filter(+ (role) => !forceRegenerate && (existing[role]?.secret || process.env[ROLE_ENV[role].secret]),+);+if (blocked.length > 0) {+ console.error(+ `Refusing to regenerate role(s) that already have a key: ${blocked.join(', ')}.\n` ++ `An existing role wallet may hold funds — regenerating orphans it.\n` ++ `Use --roles=<missing roles only>, or --force-regenerate if you are CERTAIN the old wallets are empty and retired.`,+ );+ process.exit(1);+}++const generated = { ...existing };const envLines = [];for (const role of roles) {const kp = Keypair.generate();@@ -64,7 +85,8 @@ for (const role of roles) {}// Persist secrets to a gitignored file so they are not lost and never echoed-// into shell history / CI logs by default.+// into shell history / CI logs by default. Roles not generated this run are+// carried over from the existing file untouched.writeFileSync(outFile, JSON.stringify(generated, null, 2) + '\n', { mode: 0o600 });console.log('\n=== three.ws x402 ring — wallets generated ===\n');