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
docs+test: Trading Copilot chat upgrade — data cards, slash commands, markdown, persistence
fudjia45c6d814ff94
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 47c202cb0..aacd24d7d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Tutorial · Customize Your Shopify 3D Store Guide** (`/tutorials/shopify-store-guide-advanced`) — Hand-tune the store guide: exact section targeting, multi-page tours, real spoken voices, your own avatar, autostart, deep links, and the JavaScript API.- **@three-ws/retarget — the animation engine behind every avatar, now a standalone package** — The rig-agnostic animation system that powers all three.ws avatars is now on npm as @three-ws/retarget. It maps bone names from Mixamo, VRM/VRoid, Avaturn, Daz, MakeHuman, Unreal, and Blender rigs onto one canonical skeleton, retargets any clip onto any humanoid with rest-pose and hip-axis correction, and ships the crossfading runtime that keeps characters from ever freezing in a T-pose. Only dependency: your own copy of Three.js. Same engine, same tests (2,800 lines of them) — now usable in any Three.js project. `[sdk, feature]`- **2,800+ new motion-capture animations in the library** — The animation library just grew from around 100 curated clips to more than 2,800 — the full professional motion-capture set, including complete themed movement packs (breakdance, sword-and-shield combat, capoeira, zombie, rifle and pistol sets, and more), every one retargeted to the universal three.ws skeleton so it plays on any humanoid avatar. Walks, runs, dances, combat, idles, reactions, sports, and hundreds more are all searchable in the animations gallery, previewable on a live avatar, and one click away from the pose studio or any embed. The clips are served from the CDN, so the site stays fast no matter how big the library gets. (`/animations`) `[feature, improvement]`+- **A redesigned Portfolio tab — see your whole wallet at a glance** — The agent wallet's Portfolio tab got a full visual pass. Net worth now leads with a bold headline figure beside a gradient trend chart that fills in live. A new Allocation bar shows exactly how the wallet is split across SOL, stablecoins, $THREE and any memecoins — one glance tells you the composition, with a colour-coded legend. The Risk tiles gained heat-coloured meters (green when calm, amber-to-red as concentration or tape exposure climbs) plus hover detail, P&L figures now sit in clean chips, and the whole panel animates in with a subtle staggered entrance. Every agent's Portfolio view gets it. `[improvement]`- **Agent creation now tells you what to do when your avatar library is full** — If you hit your plan's avatar limit while creating an agent, the wizard used to fail with a bare error and leave you stuck. It now explains what happened and gives you three ways forward, right in the form: connect an avatar you already own (one click jumps you to your library), free up a slot by deleting an old avatar, or upgrade your plan. Oversized model files get a clearer message too. (`/create-agent`) `[fix, improvement]`- **Animation Gallery rebuilt — see every clip before you use it** — The animation gallery at three.ws/animations got a ground-up upgrade. All 2,100+ clips now show a real poster image of the avatar mid-motion instead of a blank tile, and hovering any card plays the full animation live in 3D. Clips are organized into 16 browsable categories (dance, combat, weapons, sports, and more) with search, sorting, and loop filters, and every clip has its own shareable link with playback controls — scrub the timeline, change the speed, then send it straight to the Animation Studio or copy an embed snippet for your own site. (`/animations`) `[feature, improvement]`- **Animation Studio — avatars no longer crumple when you preview a motion** — Loading your own avatar and playing a preset like Facepalm sometimes folded the whole character into a heap on the floor — even though the studio reported a clean "100% retargeted." The baked motion clips carry a per-bone scale and length channel from the character they were authored on, and those were being stamped onto your avatar, overwriting its own proportions. The Animation Studio now drives only what's actually motion — the joint rotations and the root's travel — and leaves every rig's bone lengths and scale untouched, so any avatar (tall, short, generated, Mixamo) plays every clip standing up in its own body. The "retargeted" percentage now counts only those real motion channels, so it reflects what you see. (`/pose`) `[fix]`@@ -24,6 +25,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **The sniper engine now pages us when it goes down — and restarts itself** — The on-chain sniper worker went quiet on July 3 and nothing noticed: the status page showed the engine offline and zero launches scored, but no alert fired. The platform's watchdog now checks the sniper's own heartbeat every 5 minutes and pages the ops channel within 10 minutes of a stall, with hourly re-pages until it recovers. The worker also gained a dead-man switch: if it loses its database for 15 minutes straight it restarts itself instead of running as a zombie that scores nothing. (`/status`) `[fix, infra]`- **Tour Builder — design a walking 3D store guide with zero code** — Building a guided 3D tour for your store used to mean hand-writing a JSON file. Now there's a live, Wix-style playground at /tour-builder: a demo storefront on one side, a point-and-click editor on the other. Pick who guides the tour, click the sections you want it to walk to, type what it should say, and hit Preview to watch the real tour run exactly as your visitors will see it. When it looks right, one click gives you the curriculum file plus the exact snippets to paste into Shopify. The Shopify tutorial is rebuilt around it — a ten-minute no-code path — with a new advanced guide for multi-page tours, exact section targeting, real spoken voices, custom avatars, deep links, and the JavaScript API. (`/tour-builder`) `[feature, docs]`- **Trading Copilot no longer freezes after reading your wallet** — When you asked the Copilot about your portfolio, it sometimes read your wallet, then read it again, and got stuck on "Analyzing…" with the typing dots spinning forever — you'd see the same "Portfolio: … 6 tokens" line twice and never get an answer. The Copilot now remembers what it just looked up within a single reply, so a repeated lookup is instant instead of a wasted round, and the moment it starts going in circles it stops and answers with what it already knows. As a backstop, the chat now detects a genuinely dead connection and offers a Retry instead of hanging — so it can never leave you staring at a frozen indicator again. `[fix, improvement]`+- **Trading Copilot, rebuilt — a real chat that reads your wallet and shows the numbers** — The Copilot in your agent's wallet went from a plain text box to a proper trading chat. Ask "how's my portfolio?" and it just checks — no more "would you like me to look?" — and answers with a live card showing your SOL, your tokens, and each open position's profit or loss. Ask if a coin is safe and you get a firewall verdict card (allow / warn / block) with the actual reasons; ask for a quote and you see expected output and price impact laid out. Replies are formatted (bold, lists, links) instead of a wall of text, you can copy or regenerate any answer, stop a reply mid-stream, and type "/" for quick commands like /portfolio, /safety and /limits. Your conversation and its cards are now remembered per wallet, so switching tabs or reloading doesn't wipe it. Every actual trade still comes back as a card you confirm, running through the same spend caps, kill switch, and rug/honeypot firewall as before — the chat can read and prepare, but it can never sign on its own. `[feature, improvement]`- **Wallet chips on avatar and agent cards no longer overflow their card** — On the Avatars and Agents dashboards, the wallet identity chip — address, ownership, live balance, rarity and the vanity shortcut — was crammed onto a single line and spilled past the edge of narrow cards, bleeding into the card beside it. It now fills the card footer as a tidy rounded block and wraps its badges onto a second line when space is tight, so every card stays clean at any width. The Community and Characters galleries get the same fix. (`/dashboard/avatars`) `[fix]`## 2026-07-04diff --git a/STRUCTURE.md b/STRUCTURE.mdindex 98b4c0292..7e1674087 100644--- a/STRUCTURE.md+++ b/STRUCTURE.md@@ -47,6 +47,7 @@ bottom.| Economy funding root (master wallet) | [api/_lib/economy-master.js](api/_lib/economy-master.js), cron [api/cron/treasury-topup.js](api/cron/treasury-topup.js), registry [api/_lib/solana-signers.js](api/_lib/solana-signers.js) | In-repo (inert until keyed) | One master wallet (`WwwuGbq…T3WwW`, `ECONOMY_MASTER_SECRET_BASE58`) auto-tops-up every other Solana engine below its floor. Funder-only — never trades/settles; reserve/per-engine/per-run guarded; allowlisted to registry wallets; fee-minimized. See [docs/economy-master.md](docs/economy-master.md) + the signer registry [api/_lib/solana-signers.js](api/_lib/solana-signers.js) || Economy master audit ledger + breach monitor | ledger [api/_lib/economy-ledger.js](api/_lib/economy-ledger.js) ([schema](api/_lib/migrations/20260702010000_economy_master_ledger.sql)), reconcile cron [api/cron/economy-reconcile.js](api/cron/economy-reconcile.js), export [scripts/economy-ledger-export.mjs](scripts/economy-ledger-export.mjs) | In-repo | Tamper-evident (SHA-256 hash-chained) accounting book of every SOL movement from the master, with running balance + USD-at-transfer-time. The reconcile cron checks it every 30 min for tamper, unrecorded on-chain outbound (breach/key-compromise), and on-chain integrity; findings land in `payment_reconciliation`. Accounting CSV/JSON export. See [docs/economy-master.md](docs/economy-master.md#audit-accounting--breach-monitoring) || Autonomous trading experiment | policy [scripts/trading-experiment-setup.mjs](scripts/trading-experiment-setup.mjs), laddered exit [workers/agent-sniper/exit-logic.js](workers/agent-sniper/exit-logic.js) (`decideLadderedExit`), no-Mayhem gate [workers/agent-sniper/mayhem-gate.js](workers/agent-sniper/mayhem-gate.js), journal [workers/agent-sniper/journal.js](workers/agent-sniper/journal.js) → [api/sniper/journal.js](api/sniper/journal.js) | In-repo | One agent, ~10 SOL, newer pump.fun launches ($10k–$100k mcap, no Mayhem). Take-initials-at-2× laddered exit keeps a moon bag (never a 100% exit up), hard stop-loss underneath. Every decision journaled with its reasoning. UI-funded, simulate-first. See [docs/trading-experiment.md](docs/trading-experiment.md) |+| Trading Copilot (conversational) | client [src/agent-copilot.js](src/agent-copilot.js), hub tab [src/agent-wallet-hub/tabs/copilot.js](src/agent-wallet-hub/tabs/copilot.js), server [api/agents/copilot.js](api/agents/copilot.js) `→ POST /api/agents/:id/copilot` (SSE) | In-repo | Owner-only chat over an agent's Solana wallet: text/voice in, markdown replies, live **data cards** (portfolio, firewall, quote, smart-money, intel) and **confirm-before-execute** trade/limits cards. Read-only tools run server-side; state-changing intents return as proposals the browser re-quotes and runs through the existing spend guards + firewall + custody audit. Slash commands, copy/regenerate, localStorage persistence. See [docs/trading-copilot.md](docs/trading-copilot.md) || Real-funds risk acknowledgment | gate [public/risk-ack.js](public/risk-ack.js) `→ /legal/risk`, app wrapper [src/shared/risk-ack.js](src/shared/risk-ack.js), record endpoint [api/legal/risk-ack.js](api/legal/risk-ack.js), disclosure [public/legal/risk.html](public/legal/risk.html) | In-repo | Versioned, once-per-browser acceptance dialog every money-committing surface awaits before executing (trade, snipe, withdraw, swap, launch, x402, onramp — devnet exempt). Acceptances persist in `audit_log` (`risk-ack-accept`). See [docs/risk-acknowledgment.md](docs/risk-acknowledgment.md) || Global markets + coin detail pages | [pages/coins.html](pages/coins.html) + [src/coins-index.js](src/coins-index.js) `→ /coins`, [pages/coin.html](pages/coin.html) + [src/coin-page.js](src/coin-page.js) `→ /coin/:id`, backend [api/coin/](api/coin) (detail, ohlc, markets, news, global over [api/_lib/coingecko.js](api/_lib/coingecko.js)) | In-repo | CoinGecko-style markets index (global stats bar, sortable top-coins table, search, sparklines) + a rich detail page per coin (interactive chart, stats grid, related news, links). Design adopted from cryptocurrency.cv; accepts CoinGecko slugs or Solana mints. Docs: [docs/coin-pages.md](docs/coin-pages.md) |diff --git a/data/changelog.json b/data/changelog.jsonindex 9d6070e4c..1ba6c613e 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-05",+ "title": "Trading Copilot, rebuilt — a real chat that reads your wallet and shows the numbers",+ "summary": "The Copilot in your agent's wallet went from a plain text box to a proper trading chat. Ask \"how's my portfolio?\" and it just checks — no more \"would you like me to look?\" — and answers with a live card showing your SOL, your tokens, and each open position's profit or loss. Ask if a coin is safe and you get a firewall verdict card (allow / warn / block) with the actual reasons; ask for a quote and you see expected output and price impact laid out. Replies are formatted (bold, lists, links) instead of a wall of text, you can copy or regenerate any answer, stop a reply mid-stream, and type \"/\" for quick commands like /portfolio, /safety and /limits. Your conversation and its cards are now remembered per wallet, so switching tabs or reloading doesn't wipe it. Every actual trade still comes back as a card you confirm, running through the same spend caps, kill switch, and rug/honeypot firewall as before — the chat can read and prepare, but it can never sign on its own.",+ "tags": [+ "feature",+ "improvement"+ ]+ },{"date": "2026-07-05","title": "Animation Studio — avatars no longer crumple when you preview a motion",@@ -38,6 +47,14 @@"infra"]},+ {+ "date": "2026-07-05",+ "title": "A redesigned Portfolio tab — see your whole wallet at a glance",+ "summary": "The agent wallet's Portfolio tab got a full visual pass. Net worth now leads with a bold headline figure beside a gradient trend chart that fills in live. A new Allocation bar shows exactly how the wallet is split across SOL, stablecoins, $THREE and any memecoins — one glance tells you the composition, with a colour-coded legend. The Risk tiles gained heat-coloured meters (green when calm, amber-to-red as concentration or tape exposure climbs) plus hover detail, P&L figures now sit in clean chips, and the whole panel animates in with a subtle staggered entrance. Every agent's Portfolio view gets it.",+ "tags": [+ "improvement"+ ]+ },{"date": "2026-07-05","title": "Portfolio risk panel stops crying wolf on fresh wallets",diff --git a/docs/trading-copilot.md b/docs/trading-copilot.mdnew file mode 100644index 000000000..0579514b5--- /dev/null+++ b/docs/trading-copilot.md@@ -0,0 +1,132 @@+# The Trading Copilot — talk to your wallet++The **Trading Copilot** is the conversational front door to an agent's self-custodied+Solana wallet. You talk to it — by text or by voice — and it answers with **real live+data** (your balance, holdings, open positions, coin safety, smart-money) and prepares+**guarded trades you confirm**. It never signs on its own.++It lives in the **Copilot** tab of the Agent Wallet hub (`/agents/<id>/wallet` →+Copilot) and is **owner-only**: only the wallet's owner can open it, because it reads+that wallet's positions and can place trades from it.++> Think of it as a ChatGPT-style chat that happens to hold a wallet: markdown replies,+> streamed tokens, tool-use disclosure, copy/regenerate — plus crypto-native data cards+> and confirm-before-execute trade cards.++---++## What it can do++| You say | It does |+| --- | --- |+| "How's my portfolio?" | Reads your live SOL balance, SPL holdings, and open sniper positions, and shows a **portfolio card** |+| "Is `<mint>` safe to buy?" | Runs the rug/honeypot **firewall** and shows a verdict card (allow / warn / block) with reasons |+| "Is smart money in `<mint>`?" | Counts reputable wallets and scores smart-money conviction |+| "Buy 0.25 SOL of `<mint>`" | Surfaces a **buy card** — fresh quote + firewall verdict — that you confirm |+| "Sell 50% of `<mint>`" | Surfaces a **sell card** grounded on your actual held balance |+| "Cap my trades at 0.5 SOL" / "Pause trading" | Surfaces a **risk-limits card** (per-trade cap, daily budget, max impact, kill switch) |++Every read is instant and free — the copilot calls the tool immediately instead of+asking permission. Every **trade or limit change** comes back as a card you explicitly+confirm.++## Slash commands++Type `/` in the composer to open the command palette:++| Command | Action |+| --- | --- |+| `/portfolio` | Show live balance, holdings & positions |+| `/limits` | Read your current risk guardrails |+| `/safety <mint>` | Run the firewall on a mint |+| `/buy 0.2 <mint>` | Start a buy proposal |+| `/sell 50% <mint>` | Start a sell proposal |+| `/clear` | Clear the conversation |+| `/help` | List what the copilot can do |++Arrow keys move through the menu, `Enter`/`Tab` selects, `Esc` closes.++## Chat conveniences++- **Markdown replies** — bold, lists, and links render inline (via [`src/md.js`](../src/md.js)).+- **Live data cards** — grounded numbers appear as cards under a "Looked at N sources"+ disclosure, so the narration stays short (and voice-friendly) while the figures are+ always visible and exact.+- **Copy / Regenerate** — hover any reply to copy it or re-run the last turn.+- **Stop** — the send button becomes a stop button while a reply streams.+- **Voice** — 🎙 dictates your message (browser `SpeechRecognition`); 🔊 speaks replies+ in the agent's configured voice (ElevenLabs, with a browser-speech fallback).+- **Persistence** — the conversation, its data cards, and the executed-action log are+ saved per wallet + network in `localStorage` and restored when you return. Live trade+ proposals are intentionally **not** persisted, so a reload never resurrects a+ confirmable card grounded on a stale quote.++---++## How safety is enforced++The model is **read-and-propose only**. It cannot sign, and it cannot bypass a guard:++1. Read-only tools (`get_portfolio`, `get_coin_intel`, `get_smart_money`,+ `assess_safety`, `get_quote`, `get_trade_limits`) run **server-side** and feed+ grounded numbers back into the conversation. The model can never invent a balance,+ price, or safety verdict.+2. Any state-changing intent (buy / sell / risk-limits) is returned to the browser as a+ **structured proposal**, never executed on the server.+3. The browser **re-quotes it live** and, only on your confirmation, calls the existing+ guarded endpoints:+ - `POST /api/agents/:id/solana/trade` — enforces the spend guards+ ([`api/_lib/agent-trade-guards.js`](../api/_lib/agent-trade-guards.js)), the+ rug/honeypot firewall ([`api/_lib/trade-firewall.js`](../api/_lib/trade-firewall.js)),+ and the custody audit (`agent_custody_events`).+ - `PUT /api/agents/:id/trade/limits` — patches guardrails by key.++A conversation can therefore never bypass a spend cap, the kill switch, or the firewall.+If the firewall verdict is **block**, the buy card cannot be confirmed at all.++## The endpoint++```+POST /api/agents/:id/copilot Owner-only. Body: { messages:[{role,content}], network }+ → text/event-stream+```++SSE events:++| Event | Payload | Meaning |+| --- | --- | --- |+| `status` | `{ phase }` | thinking / continuing / finalizing |+| `tool` | `{ name, summary, data }` | a read-only tool ran; `data` is the card payload |+| `proposal` | trade/limits proposal | a confirm-before-execute card |+| `chunk` | `{ text }` | streamed narration tokens |+| `done` | `{ reply, proposals, citations }` | final reply |+| `error` | `{ code, message }` | turn failed |++The provider chain is free-first and OpenAI-compatible (Groq → OpenRouter → NVIDIA, with+paid OpenAI as the backstop), so the copilot works without any paid key. A 15s heartbeat+keeps the stream alive across slow tool rounds; the client aborts a genuinely dead stream+and offers Retry rather than hanging.++## $THREE++`$THREE` (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`) is the only coin three.ws+promotes. The copilot trades **whatever mint the owner names at runtime** — coin-agnostic+plumbing — and never suggests, shills, or names another token on its own initiative.++---++## Code map++| Piece | Location |+| --- | --- |+| Client mount (chat UI, cards, slash, persistence, voice) | [`src/agent-copilot.js`](../src/agent-copilot.js) |+| Wallet-hub tab wrapper | [`src/agent-wallet-hub/tabs/copilot.js`](../src/agent-wallet-hub/tabs/copilot.js) |+| Server (tool loop, SSE, proposals) | [`api/agents/copilot.js`](../api/agents/copilot.js) |+| Markdown renderer | [`src/md.js`](../src/md.js) |+| UI contract tests | [`tests/agent-copilot-ui.test.js`](../tests/agent-copilot-ui.test.js) |++## Related++- [The trading surfaces: Radar, Mission Control, Feed, Watchlist, Intel](trading-surfaces.md)+- [Financial controls & custody guardrails](financial-controls.md)+- [The autonomous trading experiment](trading-experiment.md)diff --git a/docs/trading-surfaces.md b/docs/trading-surfaces.mdindex 9ce999b1b..99d93f6c8 100644--- a/docs/trading-surfaces.md+++ b/docs/trading-surfaces.md@@ -131,6 +131,7 @@ Agents wanting the same intel over MCP: see [docs/mcp.md](mcp.md) (`@three-ws/in## Related+- [The Trading Copilot — talk to your wallet](trading-copilot.md) — conversational trading over these same numbers- [Oracle — the conviction engine](oracle.md) · [/oracle/docs](https://three.ws/oracle/docs)- [The autonomous trading experiment](trading-experiment.md)- [Financial controls & custody guardrails](financial-controls.md)diff --git a/public/changelog.json b/public/changelog.jsonindex 5da7c5aee..71e569c22 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-05T12:40:04.902Z",+ "generated_at": "2026-07-05T12:50:36.095Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -48,6 +48,16 @@"improvement"]},+ {+ "date": "2026-07-05",+ "type": "update",+ "title": "A redesigned Portfolio tab — see your whole wallet at a glance",+ "summary": "The agent wallet's Portfolio tab got a full visual pass. Net worth now leads with a bold headline figure beside a gradient trend chart that fills in live. A new Allocation bar shows exactly how the wallet is split across SOL, stablecoins, $THREE and any memecoins — one glance tells you the composition, with a colour-coded legend. The Risk tiles gained heat-coloured meters (green when calm, amber-to-red as concentration or tape exposure climbs) plus hover detail, P&L figures now sit in clean chips, and the whole panel animates in with a subtle staggered entrance. Every agent's Portfolio view gets it.",+ "link": null,+ "tags": [+ "improvement"+ ]+ },{"date": "2026-07-05","type": "update",@@ -198,6 +208,17 @@"improvement"]},+ {+ "date": "2026-07-05",+ "type": "update",+ "title": "Trading Copilot, rebuilt — a real chat that reads your wallet and shows the numbers",+ "summary": "The Copilot in your agent's wallet went from a plain text box to a proper trading chat. Ask \"how's my portfolio?\" and it just checks — no more \"would you like me to look?\" — and answers with a live card showing your SOL, your tokens, and each open position's profit or loss. Ask if a coin is safe and you get a firewall verdict card (allow / warn / block) with the actual reasons; ask for a quote and you see expected output and price impact laid out. Replies are formatted (bold, lists, links) instead of a wall of text, you can copy or regenerate any answer, stop a reply mid-stream, and type \"/\" for quick commands like /portfolio, /safety and /limits. Your conversation and its cards are now remembered per wallet, so switching tabs or reloading doesn't wipe it. Every actual trade still comes back as a card you confirm, running through the same spend caps, kill switch, and rug/honeypot firewall as before — the chat can read and prepare, but it can never sign on its own.",+ "link": null,+ "tags": [+ "feature",+ "improvement"+ ]+ },{"date": "2026-07-05","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 6162e5da6..731236d90 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -38,6 +38,14 @@<category>feature</category><description>The animation library just grew from around 100 curated clips to more than 2,800 — the full professional motion-capture set, including complete themed movement packs (breakdance, sword-and-shield combat, capoeira, zombie, rifle and pistol sets, and more), every one retargeted to the universal three.ws skeleton so it plays on any humanoid avatar. Walks, runs, dances, combat, idles, reactions, sports, and hundreds more are all searchable in the animations gallery, previewable on a live avatar, and one click away from the pose studio or any embed. The clips are served from the CDN, so the site stays fast no matter how big the library gets.</description></item>+ <item>+ <title>A redesigned Portfolio tab — see your whole wallet at a glance</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-05:A redesigned Portfolio tab — see your whole wallet at a glance</guid>+ <pubDate>Sun, 05 Jul 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>The agent wallet's Portfolio tab got a full visual pass. Net worth now leads with a bold headline figure beside a gradient trend chart that fills in live. A new Allocation bar shows exactly how the wallet is split across SOL, stablecoins, $THREE and any memecoins — one glance tells you the composition, with a colour-coded legend. The Risk tiles gained heat-coloured meters (green when calm, amber-to-red as concentration or tape exposure climbs) plus hover detail, P&L figures now sit in clean chips, and the whole panel animates in with a subtle staggered entrance. Every agent's Portfolio view gets it.</description>+ </item><item><title>Agent creation now tells you what to do when your avatar library is full</title><link>https://three.ws/create-agent</link>@@ -150,6 +158,14 @@<category>fix</category><description>When you asked the Copilot about your portfolio, it sometimes read your wallet, then read it again, and got stuck on "Analyzing…" with the typing dots spinning forever — you'd see the same "Portfolio: … 6 tokens" line twice and never get an answer. The Copilot now remembers what it just looked up within a single reply, so a repeated lookup is instant instead of a wasted round, and the moment it starts going in circles it stops and answers with what it already knows. As a backstop, the chat now detects a genuinely dead connection and offers a Retry instead of hanging — so it can never leave you staring at a frozen indicator again.</description></item>+ <item>+ <title>Trading Copilot, rebuilt — a real chat that reads your wallet and shows the numbers</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-05:Trading Copilot, rebuilt — a real chat that reads your wallet and shows the numbers</guid>+ <pubDate>Sun, 05 Jul 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>The Copilot in your agent's wallet went from a plain text box to a proper trading chat. Ask "how's my portfolio?" and it just checks — no more "would you like me to look?" — and answers with a live card showing your SOL, your tokens, and each open position's profit or loss. Ask if a coin is safe and you get a firewall verdict card (allow / warn / block) with the actual reasons; ask for a quote and you see expected output and price impact laid out. Replies are formatted (bold, lists, links) instead of a wall of text, you can copy or regenerate any answer, stop a reply mid-stream, and type "/" for quick commands like /portfolio, /safety and /limits. Your conversation and its cards are now remembered per wallet, so switching tabs or reloading doesn't wipe it. Every actual trade still comes back as a card you confirm, running through the same spend caps, kill switch, and rug/honeypot firewall as before — the chat can read and prepare, but it can never sign on its own.</description>+ </item><item><title>Wallet chips on avatar and agent cards no longer overflow their card</title><link>https://three.ws/dashboard/avatars</link>diff --git a/public/features.json b/public/features.jsonindex f8e14ea65..65c520608 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-05T12:40:04.887Z",+ "generated_at": "2026-07-05T12:50:36.083Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/agent-copilot-ui.test.js b/tests/agent-copilot-ui.test.jsnew file mode 100644index 000000000..d234146df--- /dev/null+++ b/tests/agent-copilot-ui.test.js@@ -0,0 +1,144 @@+// @vitest-environment jsdom+//+// Trading Copilot UI contract — the chat surface that lets a wallet owner talk+// to their agent, see live data as cards, and confirm guarded trades. These+// tests lock the client-side shell that mountTradingCopilot() paints WITHOUT a+// network round-trip: the composer, slash-command palette, per-message actions,+// grounded tool cards, and localStorage persistence. The SSE turn, guarded+// execution, and firewall live in api/agents/copilot.js and are covered+// server-side; here we prove the frontend renders and reacts correctly.++import { describe, it, expect, beforeEach, vi } from 'vitest';+import { mountTradingCopilot } from '../src/agent-copilot.js';++function mount(opts = {}) {+ const panel = document.createElement('div');+ document.body.appendChild(panel);+ const handle = mountTradingCopilot({+ panel,+ agentId: opts.agentId || 'agent-test',+ agentName: opts.agentName || 'Swarm 5',+ isOwner: opts.isOwner ?? true,+ getNetwork: () => opts.network || 'mainnet',+ toast: () => {},+ ...opts,+ });+ return { panel, handle };+}++beforeEach(() => {+ document.body.innerHTML = '';+ try { localStorage.clear(); } catch { /* noop */ }+});++describe('mountTradingCopilot — owner shell', () => {+ it('renders the composer with a slash hint and send button for the owner', () => {+ const { panel } = mount();+ expect(panel.querySelector('[data-host="input"]')).toBeTruthy();+ expect(panel.querySelector('[data-act="send"]')).toBeTruthy();+ expect(panel.querySelector('[data-host="slash"]')).toBeTruthy();+ expect(panel.querySelector('[data-host="input"]').placeholder).toMatch(/type \/ for commands/i);+ });++ it('locks the copilot for a non-owner with an explanatory note', () => {+ const { panel } = mount({ isOwner: false });+ expect(panel.querySelector('[data-host="input"]')).toBeNull();+ expect(panel.textContent).toMatch(/private to/i);+ });++ it('shows the intro + suggestion chips before any message', () => {+ const { panel } = mount();+ const chips = panel.querySelectorAll('[data-suggest]');+ expect(chips.length).toBeGreaterThan(0);+ expect(panel.textContent).toMatch(/Talk to Swarm 5 to trade/);+ });+});++describe('slash-command palette', () => {+ it('opens a filtered menu when the input starts with "/"', () => {+ const { panel } = mount();+ const input = panel.querySelector('[data-host="input"]');+ input.value = '/p';+ input.dispatchEvent(new Event('input', { bubbles: true }));+ const menu = panel.querySelector('[data-host="slash"]');+ expect(menu.hidden).toBe(false);+ const items = [...menu.querySelectorAll('[data-slash]')].map((el) => el.dataset.slash);+ expect(items).toContain('/portfolio');+ expect(items.every((c) => c.startsWith('/p'))).toBe(true);+ });++ it('stays closed for ordinary prose', () => {+ const { panel } = mount();+ const input = panel.querySelector('[data-host="input"]');+ input.value = 'how is my portfolio';+ input.dispatchEvent(new Event('input', { bubbles: true }));+ expect(panel.querySelector('[data-host="slash"]').hidden).toBe(true);+ });++ it('/clear wipes a persisted conversation', () => {+ const key = 'awh.copilot.agent-clear.mainnet';+ localStorage.setItem(key, JSON.stringify({ v: 2, messages: [{ role: 'user', content: 'hi' }], actionLog: [] }));+ const { panel } = mount({ agentId: 'agent-clear' });+ // restored history paints a user bubble+ expect(panel.textContent).toContain('hi');+ const input = panel.querySelector('[data-host="input"]');+ input.value = '/clear';+ input.dispatchEvent(new Event('input', { bubbles: true }));+ input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));+ expect(localStorage.getItem(key)).toBeNull();+ expect(panel.querySelector('.awh-cop-msg')).toBeNull();+ });+});++describe('persistence + grounded tool cards on restore', () => {+ it('restores prior messages and renders a portfolio card from saved tool data', () => {+ localStorage.setItem('awh.copilot.agent-r.mainnet', JSON.stringify({+ v: 2,+ messages: [+ { role: 'user', content: "How's my portfolio?" },+ { role: 'agent', content: 'You hold **0.0041 SOL** across 6 tokens.', tools: [+ { name: 'get_portfolio', summary: 'Portfolio: 0.0041 SOL, 6 token(s), 0 open position(s)', data: {+ kind: 'portfolio', sol_balance: 0.0041, holdings: [{ mint: 'So11111111111111111111111111111111111111112', ui_amount: 1200, decimals: 6 }], open_positions: [],+ } },+ ] },+ ],+ actionLog: [],+ }));+ const { panel } = mount({ agentId: 'agent-r' });+ // markdown rendered (bold), not raw asterisks+ expect(panel.querySelector('.awh-cop-md strong')).toBeTruthy();+ expect(panel.textContent).not.toContain('**0.0041 SOL**');+ // grounded portfolio card+ const card = panel.querySelector('.awh-cop-card');+ expect(card).toBeTruthy();+ expect(card.textContent).toMatch(/Portfolio/i);+ expect(card.textContent).toMatch(/0\.0041/);+ // activity disclosure summarises the read+ expect(panel.querySelector('.awh-cop-activity')).toBeTruthy();+ // copy action is present on a settled reply with text+ expect(panel.querySelector('[data-msgact="copy"]')).toBeTruthy();+ });++ it('renders a safety verdict card with a blocking pill', () => {+ localStorage.setItem('awh.copilot.agent-s.mainnet', JSON.stringify({+ v: 2,+ messages: [+ { role: 'user', content: 'is X safe' },+ { role: 'agent', content: 'That one is blocked by the firewall.', tools: [+ { name: 'assess_safety', summary: 'Firewall: BLOCK (12/100)', data: { kind: 'safety', mint: 'MintMintMintMintMintMintMintMintMintMintMi', verdict: 'block', score: 12, reasons: ['Mint authority not revoked'], simulated: true } },+ ] },+ ],+ actionLog: [],+ }));+ const { panel } = mount({ agentId: 'agent-s' });+ const pill = panel.querySelector('.awh-cop-verdict.is-block');+ expect(pill).toBeTruthy();+ expect(panel.textContent).toMatch(/Mint authority not revoked/);+ });++ it('ignores persisted history from a different storage version', () => {+ localStorage.setItem('awh.copilot.agent-v.mainnet', JSON.stringify({ v: 1, messages: [{ role: 'user', content: 'stale' }] }));+ const { panel } = mount({ agentId: 'agent-v' });+ expect(panel.textContent).not.toContain('stale');+ });+});