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
Net-worth avatar: respect owner reactivity on every surface; tips/P&L regalia
vwkb1f87536c35a8
diff --git a/prompts/agent-wallets/07-net-worth-reactive-avatar.md b/prompts/agent-wallets/07-net-worth-reactive-avatar.mddeleted file mode 100644index c437fc90c..000000000--- a/prompts/agent-wallets/07-net-worth-reactive-avatar.md+++ /dev/null@@ -1,103 +0,0 @@-# Task 07 — The Net-Worth-Reactive Avatar (the agent wears its wallet)--> **Read [00-README-orchestration.md](./00-README-orchestration.md) first** for the-> ownership model, design tokens, real APIs, hard rules, definition of done, and the-> "improve then delete this file" close-out. Builds on the shared wallet identity-> layer (**task 01**) for real balances/holdings and the live event/poll source.--## Why only three.ws can build this--Every other wallet shows a number on a card. We are the one platform where a real,-funded, self-custodial wallet is welded to a **rigged, talking, ownable 3D agent.**-So the wallet stops being a number and becomes the agent's **body**: an agent that is-doing well *looks* like it. Wealth, reputation, and live on-chain events become the-agent's appearance, animation, and aura — in the profile viewer, the galaxy, AR/IRL,-everywhere it is rendered. This is the moat feature; if a competitor could ship it,-you have not gone far enough.--## Mission--Drive the agent's **3D embodiment from its real on-chain state.** Holdings, lifetime-tips, fork count, realized P&L, and live events (a tip landing, its coin pumping, a-snipe filling) change how the avatar looks and moves — every reaction triggered by a-real chain read or a real confirmation, never a timer or a decorative-only loop.--## What exists (read it before building — do NOT reinvent)--- **Avatar render + animation:** [src/shared/agent-3d.js](../../src/shared/agent-3d.js)- (the shared 3D component factory) and- [src/agent-avatar.js](../../src/agent-avatar.js) (the performance layer — lip-sync,- gestures, emotion states). Hook your reactions into the existing emotion/animation- API; do not bolt on a parallel renderer.-- **Accessories / wearables:** [public/accessories/](../../public/accessories) and the- avatar appearance/equip pipeline. Cosmetic unlocks must be real equippable assets,- not painted-on overlays.-- **Real wallet state:** the task 01 normalizer + `GET /api/agents/:id/solana`,- `/solana/holdings`, lifetime tips / fork counts (real DB rows), and the live- pulse/event source task 01/02 established. Reuse it — one source of truth for "what- is this wallet worth right now."-- **Surfaces:** avatar page, agent detail, galaxy, IRL/AR/XR- ([src/irl.js](../../src/irl.js), [src/xr.js](../../src/xr.js),- [src/walk.js](../../src/walk.js)) — wherever the 3D body renders.--## What the reactive avatar must do (all driven by real data)--1. **Wealth → presence.** Map real portfolio value / reputation to tasteful,- non-gaudy embodiment: an aura intensity, a material/emissive tier, an idle-pose- confidence, an equipped cosmetic tier from real `public/accessories` assets. Tiers- unlock from **real** thresholds (lifetime tips, holdings, fork count) — show the- real number that unlocked each. Never invent a tier from a fake balance.-2. **Live event reactions.** When a real event fires — a tip confirms, the agent's- coin crosses a market-cap step, a snipe/trade fills — the avatar performs a short,- purposeful animation (celebrate, flex, glance-up) via the existing emotion API,- triggered by the **real confirmation** from task 01/02's event source. A drawdown- or a swept wallet reads as subdued, not punishing. No reaction without a real event.-3. **Reputation regalia.** Forks-of-this-agent, lifetime tip volume, and realized P&L- (real counts) earn legible, ownable cosmetic marks. The avatar's look becomes a- trust signal a visitor can read at a glance, and the marks link back to the real- numbers (and to the wallet HUD).-4. **Cross-surface coherence.** The same agent looks the same everywhere — its current- "net-worth look" is derived from one normalizer, so the galaxy star, the profile- hero, and the AR body agree. One agent, one body, one truth.-5. **Owner control.** The owner can dial reactivity (subtle ↔ expressive) and opt- specific signals in/out (e.g. hide balance-driven aura while keeping tips). Persist- the preference on the agent record. Visitors see the agent as the owner configured- it — never a forced flex.--## Innovation mandate--- Make it **screenshot-worthy and tasteful** — this is presence, not a slot machine.- Respect `prefers-reduced-motion`; the look must read even with motion off.-- Invent the mapping that makes wealth *feel* embodied without being garish. The best- version makes a well-funded, well-tipped agent simply look *alive and confident*.-- Wire the connection upward: a reaction should deep-link to the wallet HUD (task 02)- and to the moment that caused it (the tip, the fill) in the activity trail.--## Real-data & safety rules--- Every visual traces to a real chain read, a real confirmation, or a real DB count.- No mock balances, no decorative-only animation, no fake "pump" celebrations.-- Never render a secret. Public state only.-- Performance: this runs in dense galaxy scenes and on mobile AR. Reactions must be- cheap, batched/lazy, and stop offscreen / on `visibilitychange`. Hold 60fps; degrade- gracefully on low-end GPUs (a quieter look, never a stutter).--## States & edge cases (all designed, all honest)--Empty/zero-value wallet (a calm baseline look, never "poor-shamed"); provisioning in-progress; brand-new agent with no reputation; an agent mid-drawdown; 0 / 1 / 1000-agents in the galaxy at once; reduced-motion; low-end device; the real event source-briefly unavailable (hold last real state, don't invent one).--## Definition of done--Per the orchestration README's checklist. Plus: a real tip confirming makes the real-agent visibly react in at least the profile viewer and the galaxy; wealth/reputation-tiers are derived from real numbers and shown with their source; the owner reactivity-control persists and is respected for visitors; 60fps held with the reaction system-on; reduced-motion fully supported; no console errors/warnings.--When done: run the self-review + improvement pass, add a real changelog entry,-`npm run build:pages` to validate, commit (staging explicit paths only; push to-**both** `threeD` and `threews` if asked), then **delete this file**-(`prompts/agent-wallets/07-net-worth-reactive-avatar.md`).diff --git a/src/agent-detail.js b/src/agent-detail.jsindex bb8ead446..6820d06fc 100644--- a/src/agent-detail.js+++ b/src/agent-detail.js@@ -11,6 +11,7 @@import { onchainBadgeEl } from './shared/onchain-badge.js';import { walletChipEl } from './shared/agent-wallet-chip.js';import { mountMoneyPulse } from './shared/money-pulse.js';+import { mountMirrorPanel } from './shared/agent-mirror-panel.js';import { mountValidationBadge } from './shared/validation-badge.js';import { seeInWorldHref, agentAvatarGlb } from './shared/agent-3d.js';import { hydrateAvatarWallet } from './shared/wallet-aura.js';@@ -33,6 +34,7 @@ const coinStatusHandles = [];// The per-agent Money Pulse handle (live feed). Torn down on re-render so its// polling interval + observers don't leak.let _pulseHandle = null;+let _mirrorHandle = null;// The hero's wallet aura controller — torn down on re-render/unload so its live// poll + rAF never leak.@@ -45,7 +47,7 @@ function mountAgentDetailAura(agent) {adNetWorthAura = null;adNetWorthPanel?.destroy?.();adNetWorthPanel = null;- hydrateAvatarWallet(wrap, agent, { lod: 'full', live: true, network: 'mainnet' })+ hydrateAvatarWallet(wrap, agent, { lod: 'full', live: true, network: 'mainnet', fetchPrefs: false }).then((c) => {adNetWorthAura = c;// Mount the presence panel (tier + reputation regalia + owner reactivity@@ -782,6 +784,19 @@ function render(agent) {}}+ // Copy Trading (mirror) — manage who this agent mirrors (owner), or its honest+ // track record + a "Mirror this agent" CTA (visitor). The panel reveals its own+ // card (#ad-mirror-card) only when there's something to show, and renders every+ // state itself. The leash (kill switch + caps) is surfaced prominently.+ {+ const mirrorPanel = $('ad-mirror-panel');+ if (_mirrorHandle) { try { _mirrorHandle.destroy(); } catch { /* idempotent */ } _mirrorHandle = null; }+ const wMeta = agent.rawMetadata?.meta || {};+ if (mirrorPanel && wMeta.solana_address) {+ _mirrorHandle = mountMirrorPanel({ mount: mirrorPanel, agent, isOwner: !!agent.isOwner });+ }+ }+// A re-render (avatar refresh) clears the token body below; tear down any// coin-status widgets first so their refresh timers don't leak.destroyCoinStatus();diff --git a/src/avatar-page.js b/src/avatar-page.jsindex 313ad1420..c46a66697 100644--- a/src/avatar-page.js+++ b/src/avatar-page.js@@ -576,7 +576,7 @@ function mountNetWorthAura() {const agentId = avatar?.agent_id;if (!stage || !agentId || netWorthAura) return;- hydrateAvatarWallet(stage, avatar, { lod: 'full', live: true, network: 'mainnet' })+ hydrateAvatarWallet(stage, avatar, { lod: 'full', live: true, network: 'mainnet', fetchPrefs: false }).then((controller) => {if (!controller) return;netWorthAura = controller;diff --git a/src/shared/networth-presence.js b/src/shared/networth-presence.jsindex f7755bd29..2781253af 100644--- a/src/shared/networth-presence.js+++ b/src/shared/networth-presence.js@@ -113,18 +113,22 @@ export function createPresencePanel({ agentId, onPrefsSaved } = {}) {: 100;const provisioning = data.provisioning;+ const prefs = normalizePrefs(data.prefs);+const marks = (data.marks || []).map((m) => {const inner = `${esc(m.label)}${m.value != null && m.value !== '' ? ` <b>${esc(m.value)}</b>` : ''}`;return m.href? `<a class="nwp-mark" href="${esc(m.href)}" title="${esc(m.detail || m.label)}">${inner}</a>`: `<span class="nwp-mark" title="${esc(m.detail || m.label)}">${inner}</span>`;}).join('');+ // The owner can hide the regalia entirely (signals.reputation off). The row+ // stays in the DOM so toggling it back on is instant — just visually hidden.+ const repHidden = prefs.signals.reputation === false;const subline = provisioning? 'Wallet provisioning — presence wakes once it is funded.': `Portfolio <strong>${esc(fmtUsd(usd))}</strong>${hub ? ` · <a href="${esc(hub)}">wallet</a>` : ''}`;- const prefs = normalizePrefs(data.prefs);const controls = isOwner ? renderControls(prefs) : '';el.innerHTML = `@@ -136,7 +140,7 @@ export function createPresencePanel({ agentId, onPrefsSaved } = {}) {</div></div>${next && next.usd_to_next > 0 ? `<div class="nwp-next" title="${esc(fmtUsd(next.usd_to_next))} to ${esc(next.label)}"><i style="width:${nextPct}%"></i></div>` : ''}- ${marks ? `<div class="nwp-marks">${marks}</div>` : ''}+ ${marks ? `<div class="nwp-marks" data-marks${repHidden ? ' hidden' : ''}>${marks}</div>` : ''}${controls}<div class="nwp-foot">◎ Driven by this agent's real on-chain wallet</div>`;@@ -205,6 +209,9 @@ export function createPresencePanel({ agentId, onPrefsSaved } = {}) {c.disabled = off;c.closest('.nwp-sig')?.classList.toggle('is-disabled', off);}+ // Honour the reputation opt-out instantly: hide/show the regalia row in place.+ const marksRow = el.querySelector('[data-marks]');+ if (marksRow) marksRow.hidden = prefs.signals.reputation === false;}for (const b of el.querySelectorAll('[data-rx]')) {diff --git a/src/shared/wallet-aura.js b/src/shared/wallet-aura.jsindex a38899abf..ad175a8b7 100644--- a/src/shared/wallet-aura.js+++ b/src/shared/wallet-aura.js@@ -24,6 +24,7 @@import {fetchWalletState, computeWalletVisual, formatNetWorth,} from './wallet-networth.js';+import { fetchNetWorth } from './agent-networth.js';const STYLE_ID = 'tws-wallet-aura-styles';const REDUCED_MOTION =@@ -413,6 +414,15 @@ export async function hydrateAvatarWallet(container, agent, opts = {}) {// An owner reactivity pref known up front (e.g. passed by the page) gates the// look before the first paint so a muted agent never flashes a full aura first.if (opts.prefs) controller.setPrefs(opts.prefs);+ // Otherwise fetch the owner's saved reactivity prefs so EVERY surface — not just+ // the ones that mount the presence panel — honours how the owner configured the+ // agent. Surfaces that already mount the panel pass `fetchPrefs:false` to avoid a+ // duplicate read (the panel pushes prefs in via setPrefs itself).+ else if (opts.fetchPrefs !== false && agentId) {+ fetchNetWorth(agentId)+ .then((nw) => { if (nw?.prefs) controller.setPrefs(nw.prefs); })+ .catch(() => { /* read failed — aura stays at its real, un-muted look */ });+ }try {await controller.update(agent);if (opts.live !== false && agentId) {diff --git a/tests/networth-marks.test.js b/tests/networth-marks.test.jsnew file mode 100644index 000000000..b2c7e641a--- /dev/null+++ b/tests/networth-marks.test.js@@ -0,0 +1,59 @@+// Reputation regalia marks — the legible, ownable proof that the net-worth-reactive+// avatar's look is earned from REAL numbers (lifetime tips + realized P&L), not+// decoration. computeMarks is a pure function, so we can assert the exact contract+// the presence panel renders from.++import { describe, it, expect } from 'vitest';+import { computeMarks } from '../api/_lib/networth-model.js';++const HUB = '/agent/abc/wallet';+const byKey = (marks, key) => marks.find((m) => m.key === key);++describe('computeMarks — earned reputation regalia', () => {+ it('emits no tip/pnl marks for a fresh agent with no reputation', () => {+ const marks = computeMarks({ usd: 0 }, { hubUrl: HUB });+ expect(byKey(marks, 'tips')).toBeUndefined();+ expect(byKey(marks, 'pnl')).toBeUndefined();+ });++ it('surfaces lifetime tips with real USD volume, deep-linked to the hub', () => {+ const marks = computeMarks({ usd: 120, tipCount: 7, tipUsd: 42.5 }, { hubUrl: HUB });+ const tip = byKey(marks, 'tips');+ expect(tip).toBeTruthy();+ expect(tip.label).toContain('Tipped');+ expect(tip.detail).toContain('7 lifetime tips');+ expect(tip.href).toBe(HUB);+ });++ it('counts tips even when none were priceable (no USD)', () => {+ const tip = byKey(computeMarks({ tipCount: 3, tipUsd: 0 }, { hubUrl: HUB }), 'tips');+ expect(tip).toBeTruthy();+ expect(tip.value).toBe(3);+ expect(tip.label).toBe('Tipped 3×');+ });++ it('uses singular copy for a single tip', () => {+ const tip = byKey(computeMarks({ tipCount: 1, tipUsd: 0 }, { hubUrl: HUB }), 'tips');+ expect(tip.label).toBe('Tipped once');+ expect(tip.detail).toBe('1 lifetime tip');+ });++ it('shows realized P&L only when net-positive (never a scarlet letter)', () => {+ expect(byKey(computeMarks({ realizedPnlSol: -2.5, realizedWins: 0 }, { hubUrl: HUB }), 'pnl')).toBeUndefined();+ expect(byKey(computeMarks({ realizedPnlSol: 0, realizedWins: 0 }, { hubUrl: HUB }), 'pnl')).toBeUndefined();+ const pnl = byKey(computeMarks({ realizedPnlSol: 1.234, realizedWins: 4 }, { hubUrl: HUB }), 'pnl');+ expect(pnl).toBeTruthy();+ expect(pnl.label).toContain('SOL P&L');+ expect(pnl.detail).toContain('4 closed trades');+ });++ it('orders regalia after wealth/forks and keeps every mark hub-linked', () => {+ const marks = computeMarks(+ { usd: 5000, threeAmount: 1000, threeUsd: 50, forkCount: 3, tipCount: 9, tipUsd: 88, realizedPnlSol: 0.5, realizedWins: 2 },+ { hubUrl: HUB },+ );+ const keys = marks.map((m) => m.key);+ expect(keys).toEqual(['presence', 'three', 'forks', 'tips', 'pnl']);+ for (const m of marks) expect(m.href).toBe(HUB);+ });+});