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(agent-economy): revive the dead balance guard on live SOL sends
nirholas1c0473490438
diff --git a/api/agent-economy/transact.js b/api/agent-economy/transact.jsindex 4bb8dbf86..f2e776670 100644--- a/api/agent-economy/transact.js+++ b/api/agent-economy/transact.js@@ -144,8 +144,13 @@ export default wrap(async (req, res) => {10_000,);- const balance = await getSolBalance(connection, fromKeypair.publicKey);- if (balance < lamports + FEE_BUFFER_LAMPORTS) {+ // getSolBalance returns { lamports, sol }. Comparing the whole object+ // against a number is always false, so this guard never fired: a dry+ // wallet sailed straight past it, consumed a slot of the daily spend+ // ceiling, and died at broadcast with "AccountNotFound" instead of+ // showing the funding path the UI already has waiting.+ const { lamports: balanceLamports } = await getSolBalance(connection, fromKeypair.publicKey);+ if (balanceLamports < lamports + FEE_BUFFER_LAMPORTS) {txResult = { error: 'insufficient_balance', message: 'Fund Agent A\'s wallet to enable live transactions.' };} else {// Global daily spend ceiling, consumed only here, with a send aboutdiff --git a/tests/agent-economy-transact.test.js b/tests/agent-economy-transact.test.jsindex 81d9f2282..ad29d81ee 100644--- a/tests/agent-economy-transact.test.js+++ b/tests/agent-economy-transact.test.js@@ -24,6 +24,9 @@ vi.mock('../api/_lib/llm.js', () => ({const sendSolMock = vi.fn();const getSolBalanceMock = vi.fn();const walletConfigMock = vi.fn();++// The shape avatar-wallet's getSolBalance actually resolves to.+const solBalance = (lamports) => ({ lamports, sol: lamports / 1_000_000_000 });vi.mock('../api/_lib/avatar-wallet.js', () => ({avatarWalletConfig: () => walletConfigMock(),loadAvatarKeypair: () => ({ publicKey: { toBase58: () => 'BUYERaddr1111111111111111111111111111111111' } }),@@ -85,7 +88,10 @@ beforeEach(() => {text: system ? 'Risk sits at 6. Liquidity is thinning and holder concentration is climbing.' : 'Oracle, price me a market read.',}));sendSolMock.mockReset().mockResolvedValue('SIGNATURE111');- getSolBalanceMock.mockReset().mockResolvedValue(5_000_000);+ // Mirror the real avatar-wallet return shape, { lamports, sol }. Resolving a+ // bare number here is what let the endpoint compare an object to a number and+ // still pass this suite while the balance guard was dead in production.+ getSolBalanceMock.mockReset().mockResolvedValue(solBalance(5_000_000));walletConfigMock.mockReset().mockReturnValue(FUNDED);ipLimitMock.mockReset().mockResolvedValue({ success: true });globalLimitMock.mockReset().mockResolvedValue({ success: true });@@ -165,7 +171,7 @@ describe('POST /api/agent-economy/transact', () => {});it('reports insufficient balance without consuming the daily spend budget', async () => {- getSolBalanceMock.mockResolvedValue(1_000);+ getSolBalanceMock.mockResolvedValue(solBalance(1_000));const res = mkRes();await transact(mkReq({ service: 'risk-score' }), res);