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.

Add vaults page, brain-ownership styles, autopilot tests; refine trading brain and agent edit

nirholas74f263fdc90b
diff --git a/data/changelog.json b/data/changelog.json
index a4e020a59..a43bf7e2a 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,16 @@
{
"$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-06-23",
+ "title": "Memory-grounded Autopilot: your agent acts on your behalf — and shows the receipt",
+ "summary": "Your agent can now do things for you, grounded in what it knows, and it always shows its work. Open the Autopilot tab in Agent Studio and grant scoped permissions — let it create alerts, write you briefings, or send $THREE — and it proposes real actions drawn from its highest-salience memories and its own reflections. Every proposal comes with a receipt: a plain-language 'I want to do this because…' that links straight to the exact memory that motivated it. Approve one and it takes the real action — a real alert rule, a real briefing in your inbox, a real on-chain $THREE transfer — recorded forever in a signed, append-only log. Nothing fires without a permission you granted; every scope is enforced on the server, not just hidden in the UI. Spending real $THREE always asks first and is capped by a daily budget you set — and you can preview exactly what any action would do, with a live balance and budget check, before you ever grant it. Reversible actions undo in one tap, and each undo teaches the agent to be more cautious next time. A new Activity page shows every action your agents have taken, each with its memory trail, its signature, and its on-chain link — and your agent earns a real trust level from that track record, never a vanity number. This is autonomy you can audit.",
+ "tags": [
+ "feature",
+ "security"
+ ],
+ "link": "/autopilot-activity"
+ },
{
"date": "2026-06-23",
"title": "Your agent now remembers — and you can watch it recall mid-conversation",
diff --git a/pages/agent-edit.html b/pages/agent-edit.html
index 74eb19546..1d000f60f 100644
--- a/pages/agent-edit.html
+++ b/pages/agent-edit.html
@@ -25,6 +25,7 @@
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/fonts/fonts.css" />
<link rel="stylesheet" href="/src/pump/launch-token-modal.css" />
+ <link rel="stylesheet" href="/brain-ownership.css" />
<style>
body {
overflow: auto;
@@ -1202,6 +1203,7 @@
<div class="edit-sidebar-group-title">Brain</div>
<button class="edit-tab" data-tab="brain" role="tab" aria-selected="false" aria-controls="panel-brain" id="tab-brain">Brain Studio</button>
<button class="edit-tab" data-tab="knowledge" role="tab" aria-selected="false" aria-controls="panel-knowledge" id="tab-knowledge">Knowledge</button>
+ <button class="edit-tab" data-tab="ownership" role="tab" aria-selected="false" aria-controls="panel-ownership" id="tab-ownership">Ownership</button>
<button class="edit-tab" data-tab="dreams" role="tab" aria-selected="false" aria-controls="panel-dreams" id="tab-dreams">Dreams<span class="tab-badge" id="dreams-tab-badge" hidden aria-hidden="true">0</span></button>
<button class="edit-tab" data-tab="skills" role="tab" aria-selected="false" aria-controls="panel-skills" id="tab-skills">Skills</button>
<button class="edit-tab" data-tab="autopilot" role="tab" aria-selected="false" aria-controls="panel-autopilot" id="tab-autopilot">Autopilot</button>
@@ -1269,6 +1271,19 @@
</div>
</section>
+ <!-- Ownership tab — Portable & Verifiable Brain -->
+ <section
+ class="edit-panel"
+ id="panel-ownership"
+ role="tabpanel"
+ aria-labelledby="tab-ownership"
+ hidden
+ >
+ <div id="brain-ownership-host">
+ <div class="loading-msg" role="status" aria-live="polite">Loading brain ownership…</div>
+ </div>
+ </section>
+
<!-- Outfit tab -->
<section
class="edit-panel outfit-panel"
diff --git a/pages/vaults.html b/pages/vaults.html
new file mode 100644
index 000000000..c68b53ed6
--- /dev/null
+++ b/pages/vaults.html
@@ -0,0 +1,150 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Back-an-Agent Vaults · three.ws</title>
+ <meta
+ name="description"
+ content="Stake behind a 3D trading agent with a verifiable on-chain reputation, share its real P&L, and watch it trade your capital live. Real custody, hard spend limits, drawdown circuit breakers — copy-trading you can actually see."
+ />
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:url" content="https://three.ws/vaults" />
+ <meta property="og:title" content="Back-an-Agent Vaults · three.ws" />
+ <meta
+ property="og:description"
+ content="Copy-trade a 3D character with a provable track record. Stake into a verified agent, share real on-chain P&L, watch it trade — drawdown-protected, fully audited."
+ />
+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Back-an-Agent+Vaults&amp;d=Stake+behind+a+verified+trader+you+can+watch+%E2%80%94+real+custody%2C+shared+P%26L%2C+drawdown-protected.&amp;p=%2Fvaults" />
+ <meta property="og:image:width" content="1200" />
+ <meta property="og:image:height" content="630" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:site" content="@trythreews" />
+ <meta name="twitter:title" content="Back-an-Agent Vaults · three.ws" />
+ <meta name="twitter:description" content="Stake behind a verified 3D trading agent, share its real on-chain P&L, and watch it trade your capital live." />
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Back-an-Agent+Vaults&amp;d=Stake+behind+a+verified+trader+you+can+watch.&amp;p=%2Fvaults" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/site.webmanifest" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/src/vaults.css" />
+ <link rel="stylesheet" href="/footer.css" />
+ <link rel="canonical" href="https://three.ws/vaults" />
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Back-an-Agent Vaults","description":"Stake behind a verified 3D trading agent, share its real on-chain P&L, and watch it trade your capital live — drawdown-protected and fully audited.","url":"https://three.ws/vaults","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image:alt" content="Back-an-Agent Vaults — three.ws" />
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+
+ <main class="vx-shell" aria-labelledby="vx-title">
+ <!-- ── Discovery view ─────────────────────────────────────────── -->
+ <section class="vx-view" id="vx-feed-view">
+ <section class="vx-hero">
+ <p class="vx-kicker">
+ <span class="vx-live-dot" aria-hidden="true"></span>
+ Copy-trading you can watch · real custody, settled on-chain
+ </p>
+ <h1 id="vx-title" class="vx-title">Back an Agent</h1>
+ <p class="vx-sub">
+ Stake behind a 3D trading agent with a <strong>verifiable on-chain track record</strong>,
+ share its real P&amp;L pro-rata, and open the theater to watch it trade your capital live.
+ Every vault is segregated custody, hard spend limits, and a drawdown circuit breaker that
+ halts trading to protect what's left. No screenshots. No trust-me. Proof.
+ </p>
+ <div class="vx-hero-actions">
+ <button class="vx-btn vx-btn--primary" id="vx-open-cta" type="button" data-auth="in" hidden>
+ Open a vault for your agent
+ </button>
+ <a class="vx-btn" href="/leaderboard">See verified traders →</a>
+ </div>
+ </section>
+
+ <div class="vx-feed-head">
+ <h2 class="vx-h2">Backable agents</h2>
+ <div class="vx-tabs" role="tablist" aria-label="Vault filter">
+ <button class="vx-tab is-active" role="tab" aria-selected="true" data-tab="all" type="button">All vaults</button>
+ <button class="vx-tab" role="tab" aria-selected="false" data-tab="mine" type="button" data-auth="in" hidden>My positions</button>
+ </div>
+ </div>
+
+ <div class="vx-grid" id="vx-grid" aria-live="polite"></div>
+ </section>
+
+ <!-- ── Vault detail view ──────────────────────────────────────── -->
+ <section class="vx-view" id="vx-detail-view" hidden>
+ <button class="vx-back" id="vx-back" type="button">← All vaults</button>
+ <div id="vx-detail" aria-live="polite"></div>
+ </section>
+ </main>
+
+ <!-- Open-a-vault modal -->
+ <div class="vx-modal" id="vx-open-modal" hidden role="dialog" aria-modal="true" aria-labelledby="vx-open-title">
+ <div class="vx-modal-backdrop" data-close></div>
+ <div class="vx-modal-card" role="document">
+ <button class="vx-modal-x" type="button" data-close aria-label="Close">×</button>
+ <h2 id="vx-open-title" class="vx-modal-title">Open a vault</h2>
+ <p class="vx-modal-sub">Only a reputation-verified agent can be backed. Backers' funds live in a fresh, segregated wallet — never your agent's personal wallet.</p>
+ <form id="vx-open-form" class="vx-form">
+ <label class="vx-field">
+ <span class="vx-label">Agent</span>
+ <select id="vx-open-agent" class="vx-input" required></select>
+ <span class="vx-hint" id="vx-open-agent-hint"></span>
+ </label>
+ <div class="vx-field-row">
+ <label class="vx-field">
+ <span class="vx-label">Performance fee</span>
+ <div class="vx-input-suffix"><input id="vx-open-fee" class="vx-input" type="number" min="0" max="50" step="0.5" value="10" /><span>%</span></div>
+ <span class="vx-hint">Charged only on a backer's realized gain.</span>
+ </label>
+ <label class="vx-field">
+ <span class="vx-label">Max drawdown</span>
+ <div class="vx-input-suffix"><input id="vx-open-dd" class="vx-input" type="number" min="1" max="90" step="1" value="25" /><span>%</span></div>
+ <span class="vx-hint">Trading halts if NAV falls this far from peak.</span>
+ </label>
+ </div>
+ <div class="vx-field-row">
+ <label class="vx-field">
+ <span class="vx-label">Max per trade</span>
+ <div class="vx-input-suffix"><span>$</span><input id="vx-open-pertrade" class="vx-input" type="number" min="1" step="1" value="100" required /></div>
+ <span class="vx-hint">Hard ceiling on any single buy.</span>
+ </label>
+ <label class="vx-field">
+ <span class="vx-label">Daily budget</span>
+ <div class="vx-input-suffix"><span>$</span><input id="vx-open-daily" class="vx-input" type="number" min="1" step="1" value="500" required /></div>
+ <span class="vx-hint">Rolling 24h deploy cap.</span>
+ </label>
+ </div>
+ <label class="vx-field">
+ <span class="vx-label">Per-backer cap <span class="vx-opt">(optional)</span></span>
+ <div class="vx-input-suffix"><span>$</span><input id="vx-open-cap" class="vx-input" type="number" min="0" step="1" placeholder="no cap" /></div>
+ <span class="vx-hint">Max any single backer can stake.</span>
+ </label>
+ <div class="vx-form-err" id="vx-open-err" hidden></div>
+ <button class="vx-btn vx-btn--primary vx-btn--block" id="vx-open-submit" type="submit">Open vault</button>
+ </form>
+ </div>
+ </div>
+
+ <!-- Back / Redeem modal -->
+ <div class="vx-modal" id="vx-back-modal" hidden role="dialog" aria-modal="true" aria-labelledby="vx-back-title">
+ <div class="vx-modal-backdrop" data-close></div>
+ <div class="vx-modal-card" role="document">
+ <button class="vx-modal-x" type="button" data-close aria-label="Close">×</button>
+ <div id="vx-back-modal-body"></div>
+ </div>
+ </div>
+
+ <script type="module" src="/src/vaults.js"></script>
+ <script src="/brand.js" defer></script>
+ <div id="footer-container"></div>
+ <script src="/footer.js"></script>
+ </body>
+</html>
diff --git a/prompts/living-agents/05-brain-studio-persona-live-editor.md b/prompts/living-agents/05-brain-studio-persona-live-editor.md
deleted file mode 100644
index eb688c2f8..000000000
--- a/prompts/living-agents/05-brain-studio-persona-live-editor.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# Task 05 — The Brain Studio (persona live editor)
-
-> Read `prompts/living-agents/00-README.md` and `CLAUDE.md` first. Depends on Task 01.
-> Builds on the real persona system (`api/agents/_id/persona.js`, `persona_prompt`,
-> `persona_tone_tags`, `agent_versions`) and real chat (`api/chat.js`).
-
-## Mission
-
-Let users **shape their agent's mind and feel the change land instantly on the visible
-avatar.** Today persona is a 5-question interview that produces a hidden `persona_prompt`.
-Turn personality into a tangible, editable thing — traits and tone you adjust — with a
-live avatar that immediately re-greets, re-speaks, and re-behaves in the new character.
-
-## The innovation bar
-
-Editing a system prompt in a textarea is what everyone does. The game-changer: a
-**brain you sculpt with direct feedback.** Adjust a "warmth" or "formality" or "risk
-tolerance" trait and the live `<agent-3d>` beside you speaks a fresh greeting in the new
-register within a second (real `/api/chat` call), its tone chips update, and you can
-**A/B two personas side by side** and pick a winner. The user is directing a character,
-not writing config. Make it feel like a soundboard for a personality.
-
-## What to build
-
-1. **Trait model over the real persona.** Decompose/extend the persona into editable,
- meaningful dimensions (e.g. warmth, formality, verbosity, humor, proactivity, risk
- tolerance, domain expertise emphasis). These must map to the real stored persona —
- either by structuring `persona_prompt` generation or storing structured traits that
- compile into the system prompt. Keep `agent_versions` history working; every save is a
- real version with a changelog note.
-2. **Live preview, real inference.** A live `<agent-3d>` that, on any trait/tone change
- (debounced), calls the real `/api/chat` with the candidate system prompt and speaks a
- fresh greeting/sample line — using the agent's real voice config (`voice_provider`,
- `voice_id`). No fake/canned preview text. Show streaming tokens. Respect WebGL budget.
-3. **Tone chips & vocabulary.** Edit `persona_tone_tags` as chips; optionally surface the
- `vocabulary_samples` the persona architect produces. Re-running the extraction
- interview remains available (`POST /api/agents/:id/persona/extract`, real, rate-limited).
-4. **A/B persona compare.** Two live avatars, two candidate personas, the same prompt to
- both, side by side; "promote A" / "promote B" writes the winner as the real persona
- version. This is real dual inference, honestly labeled.
-5. **Bus integration.** On save, emit `brain:updated` so the Companion (Task 02) re-greets
- everywhere and the rest of the platform reflects the new character.
-
-## Wiring & real-API mandate
-
-- Real `/api/chat` for every preview and A/B line; real persona persistence + versioning;
- real voice synthesis through the existing voice path.
-- No simulated personality preview, no placeholder traits unwired from the stored prompt.
-
-## Definition of done
-
-- [ ] Traits/tone edit the real persona; saving creates a real `agent_versions` entry.
-- [ ] Changing a trait triggers a real streamed `/api/chat` greeting in the agent's real
- voice on the live avatar within ~1s (debounced); no canned text.
-- [ ] A/B compare runs real dual inference and promotes a real winning version.
-- [ ] `brain:updated` emitted; Companion re-greets (verify with Task 02 if present, else
- verify the event fires).
-- [ ] Loading/streaming/empty/error states designed; rate limits on extraction respected.
-- [ ] No console errors/warnings; `npm test` passes; `git diff` reviewed.
-- [ ] Changelog entry (`feature`) + `npm run build:pages`.
-
-## Self-improvement pass
-
-Ask: does the user feel like a director or a form-filler? Add the elevating layer — a
-"personality DNA" shareable card, presets that are real starting personas (not fake
-samples), a diff view showing how a trait change rewrote the underlying prompt, or
-letting the agent itself suggest a trait adjustment based on reflection (Task 04). Build
-the best one, fully wired.
-
-## When done
-
-Delete this file. Report the trait→prompt mapping and how live preview calls real inference.
diff --git a/public/brain-ownership.css b/public/brain-ownership.css
new file mode 100644
index 000000000..81db8fa82
--- /dev/null
+++ b/public/brain-ownership.css
@@ -0,0 +1,220 @@
+/* Brain Ownership — Portable & Verifiable Brain surface.
+ Reuses the platform design tokens (public/tokens.css). Monochrome glass on
+ near-black, with green/amber/red reserved for verification state only. */
+
+.brain-own {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-lg, 1.618rem);
+ color: var(--ink, #e8e8e8);
+}
+
+/* ── Hero / passport badge ─────────────────────────────────────────────── */
+.brain-own__hero {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: var(--space-md, 1rem);
+ padding: var(--space-lg, 1.618rem);
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-lg, 14px);
+ background: var(--surface-glass, rgba(255, 255, 255, 0.03));
+}
+.brain-own__hero-main {
+ display: flex;
+ align-items: center;
+ gap: var(--space-md, 1rem);
+}
+.bo-passport-badge {
+ display: grid;
+ place-items: center;
+ width: 44px;
+ height: 44px;
+ border-radius: var(--radius-pill, 999px);
+ font-size: 1.25rem;
+ font-weight: 700;
+ flex: 0 0 auto;
+ border: 1.5px solid currentColor;
+}
+.bo-passport-badge--ok { color: var(--success, #4ade80); background: rgba(74, 222, 128, 0.12); }
+.bo-passport-badge--warn { color: var(--warn, #fbbf24); background: rgba(251, 191, 36, 0.12); }
+.bo-passport-badge--empty { color: var(--ink-dim, #888); background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
+
+.bo-title { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--ink-bright, #fff); }
+.bo-sub { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--ink-dim, #888); }
+
+.bo-fingerprint {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ font-size: 0.7rem;
+ color: var(--ink-dim, #888);
+}
+.bo-fingerprint__label { text-transform: uppercase; letter-spacing: 0.08em; }
+.bo-fingerprint code { color: var(--ink, #e8e8e8); font-size: 0.72rem; }
+
+.bo-copy {
+ background: transparent;
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ color: var(--ink-dim, #888);
+ border-radius: var(--radius-sm, 6px);
+ cursor: pointer;
+ padding: 0.1rem 0.35rem;
+ font-size: 0.8rem;
+ transition: background 0.12s, color 0.12s, border-color 0.12s;
+}
+.bo-copy:hover { color: var(--ink-bright, #fff); border-color: var(--stroke-strong, rgba(255, 255, 255, 0.14)); background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
+.bo-copy:focus-visible { outline: 2px solid var(--focus-ring-color, #fff); outline-offset: 2px; }
+
+/* ── Stat strip ────────────────────────────────────────────────────────── */
+.bo-stats {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: var(--space-sm, 0.618rem);
+}
+.bo-stat {
+ display: flex;
+ flex-direction: column;
+ gap: 0.2rem;
+ padding: var(--space-md, 1rem);
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-md, 10px);
+ background: var(--surface-1, rgba(255, 255, 255, 0.03));
+ cursor: default;
+ transition: border-color 0.12s, background 0.12s;
+}
+.bo-stat:hover { border-color: var(--stroke-strong, rgba(255, 255, 255, 0.14)); background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
+.bo-stat__value { font-size: 1.3rem; font-weight: 700; color: var(--ink-bright, #fff); font-variant-numeric: tabular-nums; }
+.bo-stat__label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim, #888); }
+
+/* ── Sections ──────────────────────────────────────────────────────────── */
+.bo-section {
+ padding: var(--space-lg, 1.618rem);
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-lg, 14px);
+ background: var(--surface-1, rgba(255, 255, 255, 0.03));
+}
+.bo-section__title { margin: 0 0 var(--space-sm, 0.618rem); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-dim, #888); }
+.bo-hint { margin: 0 0 var(--space-md, 1rem); font-size: 0.8rem; line-height: 1.5; color: var(--ink-dim, #888); }
+.bo-hint code, .bo-kv code { background: var(--surface-2, rgba(255, 255, 255, 0.05)); padding: 0.05rem 0.3rem; border-radius: var(--radius-sm, 6px); font-size: 0.78em; }
+
+.bo-field { display: flex; flex-direction: column; gap: 0.4rem; max-width: 480px; }
+.bo-field__label { font-size: 0.8rem; color: var(--ink, #e8e8e8); }
+.bo-select {
+ width: 100%;
+ max-width: 480px;
+ padding: 0.55rem 0.7rem;
+ background: var(--surface-2, rgba(255, 255, 255, 0.05));
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-md, 10px);
+ color: var(--ink-bright, #fff);
+ font: inherit;
+ cursor: pointer;
+}
+.bo-select:hover { border-color: var(--stroke-strong, rgba(255, 255, 255, 0.14)); }
+.bo-select:focus-visible { outline: 2px solid var(--focus-ring-color, #fff); outline-offset: 2px; }
+.bo-storage-desc { margin: 0.5rem 0 0; font-size: 0.76rem; color: var(--ink-faint, rgba(255, 255, 255, 0.45)); }
+
+/* ── On-chain anchor ───────────────────────────────────────────────────── */
+.bo-anchor { display: flex; flex-direction: column; gap: var(--space-md, 1rem); }
+.bo-anchor__row { display: flex; align-items: center; gap: var(--space-md, 1rem); flex-wrap: wrap; }
+.bo-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.35rem;
+ font-size: 0.72rem;
+ font-weight: 600;
+ padding: 0.3rem 0.65rem;
+ border-radius: var(--radius-pill, 999px);
+}
+.bo-chip--ok { color: var(--success, #4ade80); background: rgba(74, 222, 128, 0.12); }
+.bo-chip--ok::before { content: '⛓'; }
+.bo-chip--warn { color: var(--warn, #fbbf24); background: rgba(251, 191, 36, 0.12); }
+.bo-chip--warn::before { content: '⚠'; }
+.bo-kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0; font-size: 0.8rem; }
+.bo-kv dt { color: var(--ink-dim, #888); }
+.bo-kv dd { margin: 0; color: var(--ink, #e8e8e8); }
+
+.bo-link { color: #93c5fd; text-decoration: none; }
+.bo-link:hover { text-decoration: underline; }
+.bo-link:focus-visible { outline: 2px solid var(--focus-ring-color, #fff); outline-offset: 2px; border-radius: 2px; }
+
+/* ── IPFS pins ─────────────────────────────────────────────────────────── */
+.bo-pins { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
+.bo-pin {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--space-md, 1rem);
+ padding: 0.55rem 0.7rem;
+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-md, 10px);
+ background: var(--surface-1, rgba(255, 255, 255, 0.03));
+ flex-wrap: wrap;
+}
+.bo-pin:hover { border-color: var(--stroke-strong, rgba(255, 255, 255, 0.14)); }
+.bo-pin__cid { font-size: 0.8rem; }
+.bo-pin__cid code { font-size: 0.74rem; color: var(--ink-dim, #888); }
+.bo-pin__meta { font-size: 0.7rem; color: var(--ink-faint, rgba(255, 255, 255, 0.45)); }
+
+.bo-prov p { margin: 0 0 0.35rem; font-size: 0.85rem; }
+
+/* ── Buttons ───────────────────────────────────────────────────────────── */
+.bo-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm, 0.618rem); }
+.bo-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ padding: 0.55rem 0.95rem;
+ border-radius: var(--radius-md, 10px);
+ border: 1px solid var(--stroke-strong, rgba(255, 255, 255, 0.14));
+ background: var(--surface-2, rgba(255, 255, 255, 0.05));
+ color: var(--ink-bright, #fff);
+ font: inherit;
+ font-size: 0.82rem;
+ cursor: pointer;
+ transition: background 0.12s, border-color 0.12s, transform 0.06s;
+}
+.bo-btn:hover { background: var(--surface-3, rgba(255, 255, 255, 0.08)); }
+.bo-btn:active { transform: translateY(1px); }
+.bo-btn:focus-visible { outline: 2px solid var(--focus-ring-color, #fff); outline-offset: 2px; }
+.bo-btn[disabled], .bo-btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
+.bo-btn--primary { background: var(--btn-primary-bg, #fff); color: var(--btn-primary-fg, #0a0a0a); border-color: transparent; }
+.bo-btn--primary:hover { background: var(--btn-primary-bg-hover, rgba(255, 255, 255, 0.88)); }
+.bo-btn--ghost { background: transparent; }
+
+/* ── Status text ───────────────────────────────────────────────────────── */
+.bo-status { display: inline-block; margin-top: 0.5rem; font-size: 0.76rem; min-height: 1em; color: var(--ink-dim, #888); }
+.bo-status--ok { color: var(--success, #4ade80); }
+.bo-status--err { color: var(--danger, #f87171); }
+
+.bo-error { padding: var(--space-lg, 1.618rem); text-align: center; }
+.bo-error p { color: var(--danger, #f87171); margin: 0 0 var(--space-md, 1rem); }
+
+/* ── Loading skeleton ──────────────────────────────────────────────────── */
+.bo-skel { background: var(--surface-2, rgba(255, 255, 255, 0.05)); border-radius: var(--radius-md, 10px); position: relative; overflow: hidden; }
+.bo-skel::after {
+ content: '';
+ position: absolute;
+ inset: 0;
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
+ transform: translateX(-100%);
+ animation: bo-shimmer 1.4s infinite;
+}
+.bo-skel--hero { height: 92px; margin-bottom: var(--space-lg, 1.618rem); }
+.bo-skel-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-sm, 0.618rem); margin-bottom: var(--space-lg, 1.618rem); }
+.bo-skel--stat { height: 72px; }
+.bo-skel--block { height: 120px; margin-bottom: var(--space-md, 1rem); }
+@keyframes bo-shimmer { 100% { transform: translateX(100%); } }
+
+/* ── Responsive ────────────────────────────────────────────────────────── */
+@media (max-width: 640px) {
+ .bo-stats, .bo-skel-row { grid-template-columns: repeat(2, 1fr); }
+ .brain-own__hero { flex-direction: column; align-items: flex-start; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .bo-skel::after { animation: none; }
+ .bo-btn, .bo-stat, .bo-copy, .bo-select, .bo-pin { transition: none; }
+}
diff --git a/public/nav-data.js b/public/nav-data.js
index e8180d838..b3dfab0cf 100644
--- a/public/nav-data.js
+++ b/public/nav-data.js
@@ -179,6 +179,13 @@ export const NAV_GROUPS = [
badge: 'New',
desc: 'Top traders ranked by a provable track record',
},
+ {
+ title: 'Back-an-Agent Vaults',
+ href: '/vaults',
+ badge: 'New',
+ badgeTone: 'live',
+ desc: 'Stake behind a verified trader you can watch — real custody, shared P&L, drawdown-protected',
+ },
{
title: 'Labor Market',
href: '/labor-market',
diff --git a/src/agent-edit.js b/src/agent-edit.js
index d1cfb1812..5bb63d373 100644
--- a/src/agent-edit.js
+++ b/src/agent-edit.js
@@ -3025,6 +3025,22 @@ async function ensureBrainTab() {
}
}
+// Brain Ownership — Portable & Verifiable Brain. Passport, storage mode, IPFS
+// pins, on-chain anchor, signed export/import.
+let ownershipTabMounted = false;
+async function ensureOwnershipTab() {
+ if (ownershipTabMounted) return;
+ ownershipTabMounted = true;
+ const host = $('brain-ownership-host');
+ try {
+ const { mountBrainOwnership } = await import('./brain-ownership.js');
+ await mountBrainOwnership(host, { agentId, agent: agentData });
+ } catch (err) {
+ ownershipTabMounted = false;
+ host.innerHTML = `<div class="error-msg" style="padding:1rem">Could not load brain ownership: ${escapeHtml(err.message)}</div>`;
+ }
+}
+
// Memory-grounded Autopilot — explainable autonomy. The strategy textarea above
// stays; this mounts the scopes / proposals / trust / signed-receipts surface.
let autopilotMounted = false;
@@ -3041,6 +3057,7 @@ const TAB_LOADERS = {
outfit: ensureOutfitTab,
voice: ensureVoiceTab,
knowledge: ensureKnowledgeTab,
+ ownership: ensureOwnershipTab,
dreams: ensureDreamsTab,
autopilot: ensureAutopilotTab,
skills: ensureSkillsTab,
diff --git a/src/studio/money/trading-brain.js b/src/studio/money/trading-brain.js
index 7befdcfa7..e16a41aee 100644
--- a/src/studio/money/trading-brain.js
+++ b/src/studio/money/trading-brain.js
@@ -278,22 +278,27 @@ class TradingBrain {
async _toggleKill() {
const next = !this.state.killed;
- // Optimistic — this is a safety control; reflect intent immediately.
+ // A true global halt must hit BOTH leashes: the per-owner strategy kill
+ // (stops the autonomous cron) and the agent's discretionary kill_switch
+ // (stops assisted confirms + the discretionary trade path). Reflect intent
+ // immediately — this is a safety control.
this.state.killed = next;
this._renderHeader();
- try {
- const res = await apiFetch(`/api/agents/${this.agentId}/strategies/kill`, {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ killed: next }),
- });
- if (!res.ok) throw new Error('kill toggle failed');
- const { data } = await res.json();
- this.state.killed = !!data.killed;
- this._toast(this.state.killed ? 'Kill switch ON — all autonomous trading halted' : 'Kill switch off');
- } catch {
- this.state.killed = !next; // roll back
- this._toast('Could not toggle the kill switch', true);
+ const hdr = { 'content-type': 'application/json' };
+ const [k1, k2] = await Promise.allSettled([
+ apiFetch(`/api/agents/${this.agentId}/strategies/kill`, { method: 'POST', headers: hdr, body: JSON.stringify({ killed: next }) }),
+ apiFetch(`/api/agents/${this.agentId}/trade/limits`, { method: 'PUT', headers: hdr, body: JSON.stringify({ kill_switch: next }) }),
+ ]);
+ const ok1 = k1.status === 'fulfilled' && k1.value.ok;
+ const ok2 = k2.status === 'fulfilled' && k2.value.ok;
+ if (ok2) { try { const d = await k2.value.json(); if (d?.data?.limits) this.state.tradeLimits = d.data.limits; } catch { /* noop */ } }
+ if (ok1 && ok2) {
+ this.state.killed = next;
+ this._toast(next ? 'Kill switch ON — all trading halted' : 'Kill switch off');
+ } else {
+ // Fail safe: never report "resumed" unless both leashes confirmed off.
+ this.state.killed = true;
+ this._toast(next ? 'Kill switch may be only partially applied — kept halted, retry' : 'Could not fully resume — kept halted for safety, retry', true);
}
this._renderHeader();
}
@@ -367,6 +372,7 @@ class TradingBrain {
}
async _confirmSnipe(mint) {
+ if (this.state.killed) { this._toast('Kill switch is on — turn it off to trade', true); return; }
const cand = (this.state.candidates || []).find((c) => c.mint === mint);
if (!cand) return;
const card = this.el.querySelector(`[data-cand="${CSS.escape(mint)}"]`);
diff --git a/tests/autopilot.test.js b/tests/autopilot.test.js
new file mode 100644
index 000000000..fb2ec4eb2
--- /dev/null
+++ b/tests/autopilot.test.js
@@ -0,0 +1,204 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+// Mock the data + heavy infra layers so the pure logic is testable in isolation.
+const sqlMock = vi.fn();
+vi.mock('../api/_lib/db.js', () => ({ sql: sqlMock }));
+
+const llmConfiguredMock = vi.fn(() => false);
+const llmCompleteMock = vi.fn();
+class LlmUnavailableError extends Error {}
+vi.mock('../api/_lib/llm.js', () => ({
+ llmComplete: (...a) => llmCompleteMock(...a),
+ llmConfigured: (...a) => llmConfiguredMock(...a),
+ LlmUnavailableError,
+}));
+
+const THREE_CA = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
+vi.mock('../api/_lib/three-gate.js', () => ({
+ THREE_CA,
+ checkThreeBalance: vi.fn(async () => ({ balance: 0, eligible: true })),
+}));
+vi.mock('../api/_lib/agent-trade-guards.js', () => ({
+ recordCustodyEvent: vi.fn(async () => 1),
+ updateCustodyEvent: vi.fn(async () => {}),
+}));
+
+const {
+ normalizeAutopilotConfig,
+ validateProposal,
+ proposalDedupeKey,
+ heuristicProposals,
+ actionMessage,
+ computeTrust,
+ decorateProposal,
+ AUTOPILOT_DEFAULTS,
+} = await import('../api/_lib/autopilot.js');
+
+const MEM_A = '11111111-1111-1111-1111-111111111111';
+const SYNTH_ADDR = 'THREEsynthetic1111111111111111111111111111';
+
+describe('normalizeAutopilotConfig', () => {
+ it('returns safe defaults for empty input', () => {
+ const c = normalizeAutopilotConfig(undefined);
+ expect(c.enabled).toBe(false);
+ expect(c.scopes).toEqual({ create_alert: false, briefing: false, wallet_transfer: false });
+ expect(c.daily_spend_three).toBe(0);
+ expect(c.require_confirm).toBe(true);
+ });
+
+ it('coerces scope/auto flags to booleans and clamps spend', () => {
+ const c = normalizeAutopilotConfig({
+ enabled: true,
+ scopes: { create_alert: 'yes', briefing: true },
+ auto_execute: { create_alert: 1 },
+ daily_spend_three: -5,
+ require_confirm: false,
+ });
+ expect(c.enabled).toBe(true);
+ expect(c.scopes.create_alert).toBe(false); // 'yes' is not strictly true
+ expect(c.scopes.briefing).toBe(true);
+ expect(c.auto_execute.create_alert).toBe(false); // 1 is not strictly true
+ expect(c.daily_spend_three).toBe(0); // negative clamped
+ expect(c.require_confirm).toBe(false);
+ });
+
+ it('never lets require_confirm be implicitly false', () => {
+ expect(normalizeAutopilotConfig({}).require_confirm).toBe(true);
+ expect(AUTOPILOT_DEFAULTS.require_confirm).toBe(true);
+ });
+});
+
+describe('validateProposal — create_alert', () => {
+ it('builds a $THREE price_above rule from asset:"three"', () => {
+ const v = validateProposal('create_alert', { asset: 'three', condition: 'price_above', threshold_usd: 50000 });
+ expect(v.ok).toBe(true);
+ expect(v.rule.target_mint).toBe(THREE_CA);
+ expect(v.rule.kind).toBe('price_above');
+ expect(v.rule.threshold).toBe(50000);
+ });
+
+ it('rejects a price rule with no positive threshold', () => {
+ const v = validateProposal('create_alert', { asset: 'three', condition: 'price_above' });
+ expect(v.ok).toBe(false);
+ });
+
+ it('requires a SOL threshold for whale_buy', () => {
+ expect(validateProposal('create_alert', { asset: 'three', condition: 'whale_buy' }).ok).toBe(false);
+ expect(validateProposal('create_alert', { asset: 'three', condition: 'whale_buy', threshold_sol: 10 }).ok).toBe(true);
+ });
+
+ it('accepts an explicit mint and rejects garbage assets', () => {
+ expect(validateProposal('create_alert', { asset: THREE_CA, condition: 'graduation' }).ok).toBe(true);
+ expect(validateProposal('create_alert', { asset: 'not an address', condition: 'graduation' }).ok).toBe(false);
+ });
+
+ it('rejects an unknown condition', () => {
+ expect(validateProposal('create_alert', { asset: 'three', condition: 'moon' }).ok).toBe(false);
+ });
+});
+
+describe('validateProposal — briefing & wallet_transfer', () => {
+ it('validates briefing summary + cadence', () => {
+ const v = validateProposal('briefing', { summary: 'Morning $THREE digest', cadence: 'daily' });
+ expect(v.ok).toBe(true);
+ expect(v.params.cadence).toBe('daily');
+ expect(validateProposal('briefing', { summary: '' }).ok).toBe(false);
+ // unknown cadence falls back to 'once'
+ expect(validateProposal('briefing', { summary: 'x', cadence: 'hourly' }).params.cadence).toBe('once');
+ });
+
+ it('validates a wallet_transfer recipient + amount', () => {
+ const v = validateProposal('wallet_transfer', { recipient: SYNTH_ADDR, amount_three: 5, reason: 'tip' });
+ expect(v.ok).toBe(true);
+ expect(v.params.amount_three).toBe(5);
+ expect(validateProposal('wallet_transfer', { recipient: 'bad', amount_three: 5 }).ok).toBe(false);
+ expect(validateProposal('wallet_transfer', { recipient: SYNTH_ADDR, amount_three: 0 }).ok).toBe(false);
+ });
+
+ it('rejects unknown kinds', () => {
+ expect(validateProposal('nuke_world', {}).ok).toBe(false);
+ });
+});
+
+describe('proposalDedupeKey', () => {
+ it('distinguishes different alerts and matches identical ones', () => {
+ const a = validateProposal('create_alert', { asset: 'three', condition: 'price_above', threshold_usd: 1000 });
+ const b = validateProposal('create_alert', { asset: 'three', condition: 'price_above', threshold_usd: 2000 });
+ expect(proposalDedupeKey('create_alert', a.params)).not.toBe(proposalDedupeKey('create_alert', b.params));
+ const a2 = validateProposal('create_alert', { asset: 'three', condition: 'price_above', threshold_usd: 1000 });
+ expect(proposalDedupeKey('create_alert', a.params)).toBe(proposalDedupeKey('create_alert', a2.params));
+ });
+});
+
+describe('heuristicProposals (LLM-free fallback)', () => {
+ it('proposes a $THREE alert from a price memory, citing the memory', () => {
+ const props = heuristicProposals([
+ { id: MEM_A, content: 'I want an alert when $THREE market cap hits $50k', tags: [] },
+ ]);
+ const alert = props.find((p) => p.kind === 'create_alert');
+ expect(alert).toBeTruthy();
+ expect(alert.source_memory_ids).toEqual([MEM_A]);
+ expect(alert.params.condition).toBe('price_above');
+ expect(alert.params.threshold_usd).toBe(50000);
+ });
+
+ it('proposes a daily briefing from a routine memory', () => {
+ const props = heuristicProposals([
+ { id: MEM_A, content: 'Catch me up on $THREE every morning please', tags: [] },
+ ]);
+ const brief = props.find((p) => p.kind === 'briefing');
+ expect(brief).toBeTruthy();
+ expect(brief.params.cadence).toBe('daily');
+ expect(brief.source_memory_ids).toEqual([MEM_A]);
+ });
+
+ it('proposes nothing for an unrelated memory', () => {
+ expect(heuristicProposals([{ id: MEM_A, content: 'the sky is blue', tags: [] }])).toHaveLength(0);
+ });
+});
+
+describe('actionMessage signing payload', () => {
+ it('is stable regardless of payload key order', () => {
+ const m1 = actionMessage({ agentId: 'a', type: 't', ts: '2026-01-01T00:00:00Z', payload: { b: 2, a: 1 } });
+ const m2 = actionMessage({ agentId: 'a', type: 't', ts: '2026-01-01T00:00:00Z', payload: { a: 1, b: 2 } });
+ expect(m1).toBe(m2);
+ expect(m1).toContain('three.ws/autopilot');
+ expect(m1).toContain('agent:a');
+ });
+});
+
+describe('computeTrust', () => {
+ beforeEach(() => sqlMock.mockReset());
+
+ it('derives Sandbox at zero history', async () => {
+ sqlMock.mockResolvedValueOnce([{ executed: 0, undone: 0, dismissed: 0, pending: 0 }]);
+ const t = await computeTrust({ agentId: 'a' });
+ expect(t.level).toBe('sandbox');
+ expect(t.score).toBe(0);
+ expect(t.next.label).toBe('Trusted');
+ });
+
+ it('rewards a clean track record and penalizes undos', async () => {
+ sqlMock.mockResolvedValueOnce([{ executed: 10, undone: 0, dismissed: 0, pending: 0 }]);
+ const clean = await computeTrust({ agentId: 'a' });
+ sqlMock.mockResolvedValueOnce([{ executed: 10, undone: 8, dismissed: 0, pending: 0 }]);
+ const messy = await computeTrust({ agentId: 'a' });
+ expect(clean.score).toBeGreaterThan(messy.score);
+ expect(clean.level).toBe('trusted');
+ });
+});
+
+describe('decorateProposal', () => {
+ it('maps a DB row to camelCase with iso dates', () => {
+ const d = decorateProposal({
+ id: 'p1', agent_id: 'a', user_id: 'u', kind: 'briefing', title: 'T', rationale: 'R',
+ params: { summary: 'x' }, source_memory_ids: [MEM_A], source_reflection_id: null,
+ confidence: 0.7, requires_confirmation: false, status: 'pending', executed_action_id: 42,
+ result: {}, created_at: new Date('2026-06-23T00:00:00Z'), decided_at: null, executed_at: null,
+ });
+ expect(d.kind).toBe('briefing');
+ expect(d.sourceMemoryIds).toEqual([MEM_A]);
+ expect(d.executedActionId).toBe('42');
+ expect(d.createdAt).toBe('2026-06-23T00:00:00.000Z');
+ });
+});