Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: Introduce Brain Studio for visual agent mind building
nirholasb6da24bce9cb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 27ace68cb..41139dcda 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Align a whole room of agents in one gesture** — When you place several agents around a room, their spacing is already exact for everyone — but the whole cluster can sit a few metres off where it really is, because phone GPS only knows the spot to within several metres. Now you can fix that in one move: open any of your room agents and tap “Align this room,” then drag to slide the entire group onto its true spot and twist with two fingers to rotate it — every agent moves together, keeping its layout intact, instead of nudging them one at a time. A live readout shows the move in honest metres and degrees, and the room is labelled with how tightly it's anchored so you know when it's worth aligning. Only the room's owner can move it. And if you arrive at a room someone placed without a compass that looks turned the wrong way, a one-tap “Align to your view” straightens it out for you. (`/irl`) `[improvement]`- **AR & half-body avatar export fixed for compressed models** — View-in-AR (USDZ for iOS Quick Look) and the half-body VR-seat export now work for avatars that ship with meshopt or Draco geometry compression. Previously these exports silently failed on compressed GLBs because the loader had no decoder registered; the pipeline now loads the meshopt and Draco decoders before parsing, so every avatar — including the compressed ones produced by the server-side bake — converts cleanly. (`/gallery`) `[fix]`- **AR agents hold their place and size when you rotate your phone** — Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter. (`/irl`) `[improvement, fix]`+- **Brain Studio — build your agent’s mind as a visual circuit** — The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change. (`/agent-studio`) `[feature]`- **Clearer IRL onboarding and copy** — Opening IRL for the first time now spells out the core loop in plain words: turn on Camera AR, aim at the spot you want, then tap Pin here to anchor your agent in real space. The on-screen guidance updates as you go — it points you to the next step before you've pinned, and confirms when your agent is anchored. We rewrote the status messages around pinning to be calm and literal instead of technical or alarming: waiting on a GPS fix now tells you it's quicker outdoors, pinning without location explains your agent is saved on this device until you turn location on, and a missing compass reads as a gentle note rather than a warning. The caption keyboard now opens reliably when the panel slides up on iPhone. (`/irl`) `[improvement]`- **Creator royalty payouts protected against double-settlement** — Royalty payouts to skill authors now claim each pending amount atomically before sending funds on-chain, so two overlapping settlement runs can never pay the same balance twice. Creators are paid exactly once for what they've earned. `[fix]`- **Discovery now shows only real creator avatars** — The Explore / discovery feed previously padded itself with a set of built-in sample avatars and counted them in the totals. The feed and its counts now reflect only real avatars created by the community — no filler. (`/explore`) `[improvement]`diff --git a/api/_lib/migrations/20260619010000_agent_studio.sql b/api/_lib/migrations/20260619010000_agent_studio.sqlnew file mode 100644index 000000000..f55231956--- /dev/null+++ b/api/_lib/migrations/20260619010000_agent_studio.sql@@ -0,0 +1,49 @@+-- Migration: Agent Studio meta contract (P0 foundation).+--+-- Apply: node scripts/apply-migrations.mjs --apply --file 20260619010000_agent_studio.sql+-- Idempotent — additive only, NO column drops, NO type changes, NO data rewrites.+--+-- Agent Studio is the single surface where a user authors an agent's brain,+-- memory, body, money, and skills. Everything Studio (and the sub-studios P1-P5)+-- persist lives under a NAMESPACED jsonb sub-object on the existing+-- agent_identities.meta column — we add NO new columns, because meta is already+-- declared `jsonb not null default '{}'` (20260616235900_agent_identities_meta_skills.sql)+-- and PUT /api/agents/:id already deep-merges client meta over the stored row+-- while carrying the encrypted custodial-wallet keys through untouched.+--+-- ── meta.studio shape (the stable contract P1-P5 bind to) ───────────────────+-- meta.studio = {+-- studio_version : int -- schema version of the studio bag (currently 1)+-- brain : { model, provider, graph, ... } -- P1 (model/provider/graph)+-- memory : { ... } -- P2 (memory config/policy)+-- body : { outfit, animation, animationRefs } -- P3 (outfit/animation refs)+-- money : { ... } -- P4 (payouts/pricing knobs)+-- trading : { rules, ... } -- P5 (trade automation rules)+-- skills : { ... } -- skills surface config+-- }+-- The server (api/agents.js validateStudioMeta) rejects any OTHER top-level key+-- inside meta.studio and size-limits the bag, so this set is authoritative.+-- Secrets NEVER live here — custodial keys stay at meta.encrypted_* and are+-- stripped from every read (api/agents.js decorate()).+--+-- This migration:+-- 1. (re)states the meta contract as a column comment for future readers.+-- 2. Adds a GIN index on meta so future Studio queries (e.g. "agents whose+-- brain.provider = x", marketplace filtering by body/skills config) are+-- index-backed instead of full scans. jsonb_path_ops keeps the index small+-- and fast for the @> containment queries those lookups use.++begin;++create index if not exists idx_agent_identities_meta_gin+ on agent_identities using gin (meta jsonb_path_ops);++comment on column agent_identities.meta is+ 'jsonb. Custodial wallet (encrypted_solana_secret, solana_address, '+ 'encrypted_wallet_key — secrets stripped on read), unified on-chain identity '+ 'at meta.onchain, persona, payments, spend_limits, AND the Agent Studio bag '+ 'at meta.studio { studio_version, brain, memory, body, money, trading, skills }. '+ 'meta.studio top-level keys are whitelisted + size-limited by '+ 'api/agents.js validateStudioMeta. Secrets never leave the server.';++commit;diff --git a/api/agents.js b/api/agents.jsindex 92a122568..d42e51421 100644--- a/api/agents.js+++ b/api/agents.js@@ -45,6 +45,61 @@ const animationEntrySchema = z.object({const animationsSchema = z.array(animationEntrySchema).max(30);+// ── Agent Studio meta contract (P0 foundation) ───────────────────────────────+// PUT /api/agents/:id persists Agent Studio state under meta.studio. This is the+// stable contract the Studio sub-surfaces (P1-P5) bind to — keep it in sync with+// the column comment in 20260619010000_agent_studio.sql.+//+// meta.studio = {+// studio_version : number // schema version of this bag (currently 1)+// brain : object // P1 — { model, provider, graph, ... }+// memory : object // P2 — memory config / retention policy+// body : object // P3 — { outfit, animation, animationRefs, ... }+// money : object // P4 — payout / pricing knobs+// trading : object // P5 — { rules, ... } trade automation+// skills : object // skills surface config+// }+//+// Only these top-level keys are accepted inside meta.studio; any other is+// rejected (400) so a typo or rogue client can't pollute the shared bag. The+// serialized-size limit is enforced separately in handleUpdate. Secrets must+// never be written here — custodial keys live at meta.encrypted_* (stripped on read).+const STUDIO_ALLOWED_KEYS = new Set([+ 'studio_version',+ 'brain',+ 'memory',+ 'body',+ 'money',+ 'trading',+ 'skills',+]);++// Returns an error message when the client-supplied meta.studio bag is malformed,+// or null when it's absent (nothing to validate) / null (explicit clear) / valid.+// Validates the CLIENT INPUT only — never re-validates already-stored data, so a+// legacy row is never rejected by a later, stricter key set.+function validateStudioMeta(meta) {+ if (!meta || typeof meta !== 'object' || Array.isArray(meta)) return null;+ if (!('studio' in meta)) return null;+ const studio = meta.studio;+ if (studio === null) return null;+ if (typeof studio !== 'object' || Array.isArray(studio)) {+ return 'meta.studio must be an object';+ }+ for (const key of Object.keys(studio)) {+ if (!STUDIO_ALLOWED_KEYS.has(key)) {+ return `meta.studio: unknown key "${key}" (allowed: ${[...STUDIO_ALLOWED_KEYS].join(', ')})`;+ }+ }+ if (+ studio.studio_version !== undefined &&+ (typeof studio.studio_version !== 'number' || !Number.isFinite(studio.studio_version))+ ) {+ return 'meta.studio.studio_version must be a number';+ }+ return null;+}+export default wrap(async (req, res) => {if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: true })) return;if (!method(req, res, ['GET', 'POST'])) return;@@ -402,6 +457,11 @@ async function handleUpdate(req, res, id, auth) {const body = await readJson(req);+ // Reject a malformed Agent Studio bag up front (unknown top-level keys, bad+ // studio_version) so the shared meta.studio contract stays clean for P1-P5.+ const studioErr = validateStudioMeta(body.meta);+ if (studioErr) return error(res, 400, 'validation_error', studioErr);+// Server-side meta merge. GET strips encrypted_wallet_key /// encrypted_solana_secret before returning meta, so a client read-modify-write// must never be able to wipe (or set) them: merge the client's meta over the@@ -448,7 +508,8 @@ async function handleUpdate(req, res, id, auth) {skills = COALESCE(${body.skills || null}, skills),meta = COALESCE(${mergedMeta ? JSON.stringify(mergedMeta) : null}::jsonb, meta),persona_prompt = COALESCE(${personaPrompt}, persona_prompt),- home_url = COALESCE(${body.home_url || null}, home_url)+ home_url = COALESCE(${body.home_url || null}, home_url),+ updated_at = now()WHERE id = ${id}RETURNING *`;@@ -715,6 +776,10 @@ function decorate(row, isOwner = true) {// requests the backend will reject with 403.is_owner: !!isOwner,created_at: row.created_at,+ // updated_at lets the Agent Studio store reconcile concurrent edits: when a+ // PUT returns a newer timestamp than the client's optimistic copy, the store+ // takes the server record as truth instead of clobbering it.+ updated_at: row.updated_at,};// Voice fields are public (the runtime reads them to configure TTS).base.voice_provider = row.voice_provider || 'browser';diff --git a/data/changelog.json b/data/changelog.jsonindex df5a2ae62..4fa807f0e 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-06-19",+ "title": "Brain Studio — build your agent’s mind as a visual circuit",+ "summary": "The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change.",+ "tags": [+ "feature"+ ],+ "link": "/agent-studio"+ },{"date": "2026-06-19","title": "Agent Studio — one place to build your whole agent, with a live avatar",diff --git a/pages/agent-studio.html b/pages/agent-studio.htmlindex fb16436f3..ebb344f3d 100644--- a/pages/agent-studio.html+++ b/pages/agent-studio.html@@ -24,6 +24,7 @@<link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/mobile.css" /><link rel="stylesheet" href="/buttons.css" />+ <link rel="stylesheet" href="/brain-studio.css" /><style>html,@@ -386,5 +387,7 @@<script src="/footer.js"></script><script type="module" src="/src/studio/studio-shell.js"></script>+ <!-- P1: Brain Studio binds itself to the shell's Brain tab on studio-shell:ready. -->+ <script type="module" src="/src/studio/brain/brain-mount.js"></script></body></html>diff --git a/prompts/agent-studio/01-foundation.md b/prompts/agent-studio/01-foundation.mddeleted file mode 100644index 5007c8e5b..000000000--- a/prompts/agent-studio/01-foundation.md+++ /dev/null@@ -1,107 +0,0 @@-# P0 — Agent Studio Foundation (shell · store · global presence)--You are a senior engineer + product thinker building **three.ws**, a platform meant to-compete with the best in the world. Read `CLAUDE.md` and `STRUCTURE.md` before writing-anything. Your work here is the **foundation** that five other agents build on — they-depend on the contracts you publish, so get the seams right.--## The vision you are enabling--Agent Studio is the **one central place** where a user authors their entire 3D agent — its-brain, memory, money, body, and skills — and the avatar they edit is rendered **live on-every page of the platform**, reacting to real events. Editing in Studio updates that-presence **instantly, everywhere**, with no save/refresh. You are building the skeleton and-nervous system that makes both of those true. Everything must be **visual** and real.--## Your mission--Ship four things, fully wired, no stubs:--### 1. The Studio route + shell — `/studio`-- New page `pages/studio.html` + entry `src/studio/studio-shell.js`. Add one entry to- `data/pages.json` (auth-required, indexable false). Wire it into nav where agents live.-- Layout: a **persistent live 3D avatar stage** on one side (reuse the existing `Viewer` from- `src/viewer.js` and `src/agent-avatar.js` — do not fork rendering), and a **tabbed editing- surface** on the other with tabs: **Brain · Memory · Body · Money · Skills**. You build the- shell + empty tab containers with designed empty states; P1–P5 fill the tabs by mounting- into the containers you expose. Document the mount points clearly in code.-- Responsive: at 320px the avatar collapses to a sticky mini-stage; at 1440px it's a full- cinematic stage. Keyboard: number keys switch tabs, `Esc` closes panels, focus rings everywhere.-- Loads the caller's agent via `GET /api/agents/me` (auto-creates a default agent — see- `api/agents.js`). Handles: no agent yet (onboarding CTA), load error (retry), loading (skeleton).--### 2. The shared reactive store — `src/studio/agent-studio-store.js`-This is the integration seam every other agent uses. Build on the existing `src/agent-identity.js`-(`AgentIdentity` with `load/save/update`) — wrap it, don't replace it. Export a singleton `studio`:--```js-studio.agent // live AgentIdentity-studio.subscribe(fn) // fn(agent); returns unsubscribe-studio.patch(partial) // optimistic local merge + debounced PUT /api/agents/:id (real call)-studio.commit() // flush pending writes immediately; returns Promise-studio.on(event, fn) // 'brain:change'|'memory:change'|'body:change'|'wallet:change'|'skills:change'-studio.emit(event, data)// other studios call this after they mutate their domain-studio.preview(partial) // ephemeral preview — applies to live avatar WITHOUT persisting-studio.clearPreview()-studio.emitMarket(evt) // broadcast { type, mint, ... } market/trade events to presence listeners-studio.onMarket(fn)-```-Requirements: optimistic updates with rollback on failed PUT; debounce (~600ms) but flush on-tab change / page unload (`visibilitychange` + `beforeunload`); CSRF token handling consistent-with the existing pattern (see commit `1416805fc` and how `agent-wallet-chip.js` / wallet routes-do CSRF); conflict-safe (if PUT returns a newer `updated_at`, reconcile, don't clobber).--### 3. The global presence element — `src/studio/agent-presence.js`-A framework-agnostic **custom element** `<agent-presence>` that any page can drop in:--```html-<agent-presence data-agent-id="…" data-mode="stage|companion|mini"></agent-presence>-```-- Renders the user's live avatar using the shared `Viewer` + `agent-avatar.js` (emotion blend,- idle loop from `src/idle-animation.js`, lip-sync already exist — wire them, don't reinvent).-- Subscribes to `studio` so any edit anywhere reflects immediately.-- `mode="mini"` = a small floating companion (bottom-corner, draggable, remembers position);- `companion` = sidebar size; `stage` = full studio stage.-- Subscribes to `studio.onMarket(...)` and maps event types to avatar reactions via the existing- emotion system (e.g. `snipe:filled` → celebration, `position:down` → concern). Define a clean- `reactTo(event)` API; P4/P5 will emit the events. Ship sensible default mappings now.-- **Performance is critical** since this renders on every page: share a single WebGL context where- possible, pause rendering when offscreen/tab hidden (`IntersectionObserver` + `visibilitychange`),- cap DPR, lazy-load the heavy Three.js modules. The mini companion must never jank scrolling.--### 4. Schema + API contract-- Migration `api/_lib/migrations/*_agent_studio.sql`: extend `agent_identities.meta` (jsonb) with a- documented `studio` sub-object that namespaces what P1–P5 store: `brain` (model/provider/graph),- `body` (outfit/animation refs), `trading` (rules), plus a top-level `studio_version`. Don't break- existing columns; additive only. Add indexes only if you add queryable columns.-- Extend `PUT /api/agents/:id` in `api/agents.js` to accept and persist the `meta.studio` bag with- validation (reject unknown top-level keys, size-limit the jsonb). Keep owner-only enforcement.-- Document the exact accepted shape in a header comment so P1–P5 bind to a stable contract.--## Libraries you may adopt (research-backed)-- Keep the main app **vanilla JS** (it is today). The custom element approach avoids dragging React- into every page. If a sub-studio later wants React, it mounts as an island — your store/presence- must stay framework-agnostic so both work.-- Reuse what exists before adding deps: `src/viewer.js`, `src/agent-avatar.js`, `src/animation-manager.js`,- `src/idle-animation.js`, `src/agent-identity.js`, `public/tokens.css`.--## Definition of done-- `/studio` loads the real agent, shows the live avatar, tabs switch, empty states are designed.-- Editing a field (even a temporary debug control you then remove) flows through `studio.patch`,- hits the real `PUT`, and the avatar/presence updates with no refresh.-- `<agent-presence>` works standalone on a throwaway test page in all three modes with real data.-- No console errors/warnings; `npm test` passes; network tab shows real calls.-- Reviewed `git diff` line-by-line. Changelog entry added.--## Operating rules (override defaults)-No mocks/stubs/TODOs. $THREE is the only coin. Design tokens only. Stage explicit paths-(never `git add -A`); re-check `git status`/`git diff --staged` before commit — other agents are-editing `main` concurrently. Append-only on `data/pages.json` / `data/changelog.json`.--## When finished-Run the self-review (the five checks in CLAUDE.md). Then make a final integration check: write a-1-paragraph "Integration notes for P1–P5" as a comment block at the top of-`src/studio/agent-studio-store.js` so downstream agents bind correctly. Find the single biggest-quality gap in what you shipped and fix it. Then **delete this prompt file**-(`prompts/agent-studio/01-foundation.md`) and report exactly what you shipped + the final-store/presence API surface.diff --git a/public/brain-studio.css b/public/brain-studio.cssnew file mode 100644index 000000000..ddf932085--- /dev/null+++ b/public/brain-studio.css@@ -0,0 +1,207 @@+/* Brain Studio (P1) — the visual, programmable agent brain.+ * Mounts inside the Agent Studio shell's Brain tab. Uses platform design tokens+ * (public/tokens.css). Scoped under .brainstudio / .bgraph so it never touches+ * the shell's own (.studio-*) styles. */++.brainstudio {+ --node-persona: #8b8bff;+ --node-model: #4fd1c5;+ --node-memory: #f6ad55;+ --node-skill: #b794f4;+ --node-market: #68d391;+ --node-output: #fc8181;+ height: 100%;+ display: flex;+ flex-direction: column;+ min-height: 0;+}++/* The shell pads tab panels and animates them; the Brain wants the full canvas. */+.studio-tabpanel[data-studio-mount="brain"] { padding: 0; height: 100%; min-height: 480px; display: flex; }+.studio-tabpanel[data-studio-mount="brain"] > .brainstudio { flex: 1; }++/* Shared button (brain-local; double-underscore, won't collide with shell .studio-btn) */+.studio__btn {+ display: inline-flex; align-items: center; gap: var(--space-2xs);+ padding: var(--space-2xs) var(--space-md); border-radius: var(--radius-md);+ border: 1px solid var(--surface-3); background: var(--surface-1); color: var(--ink);+ font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; text-decoration: none;+ transition: background .15s, border-color .15s, transform .1s; font-family: inherit;+}+.studio__btn:hover { background: var(--surface-3); }+.studio__btn:active { transform: translateY(1px); }+.studio__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }+.studio__btn-primary { background: var(--accent); color: var(--bg-0); border-color: var(--accent); }+.studio__btn-primary:hover { filter: brightness(1.08); }+.studio__btn:disabled { opacity: .5; cursor: not-allowed; }++.brainstudio__editor { display: flex; flex-direction: column; height: 100%; min-height: 0; }++/* ── Onboarding ─────────────────────────────────────────────────────────── */+.brainstudio__onboard { height: 100%; display: grid; place-items: center; padding: var(--space-lg); }+.brainstudio__onboard-inner { max-width: 720px; text-align: center; }+.brainstudio__onboard h1 { font-size: var(--text-2xl); margin: 0 0 var(--space-xs); color: var(--ink-bright); }+.brainstudio__onboard p { color: var(--ink-dim); margin: 0 0 var(--space-lg); }+.brainstudio__templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-lg); }+.brainstudio__tpl {+ text-align: left; padding: var(--space-md); border-radius: var(--radius-lg); cursor: pointer;+ border: 1px solid var(--surface-3); background: var(--surface-1); color: var(--ink);+ display: flex; flex-direction: column; gap: var(--space-2xs); transition: transform .12s, border-color .15s, background .15s;+}+.brainstudio__tpl:hover { transform: translateY(-2px); background: var(--surface-2); }+.brainstudio__tpl::before { content: ''; width: 26px; height: 4px; border-radius: 2px; background: var(--accent); }+.brainstudio__tpl--persona::before { background: var(--node-persona); }+.brainstudio__tpl--model::before { background: var(--node-model); }+.brainstudio__tpl--memory::before { background: var(--node-memory); }+.brainstudio__tpl--market::before { background: var(--node-market); }+.brainstudio__tpl-name { font-weight: var(--weight-semibold); color: var(--ink-bright); }+.brainstudio__tpl-tag { font-size: var(--text-sm); color: var(--ink-dim); }++/* ── Toolbar ────────────────────────────────────────────────────────────── */+.brainstudio__toolbar { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm); flex-wrap: wrap; border-bottom: 1px solid var(--surface-2); }+.brainstudio__palette { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }+.brainstudio__tools { margin-left: auto; display: flex; gap: var(--space-2xs); }+.brainstudio__chip {+ padding: var(--space-3xs) var(--space-sm); border-radius: var(--radius-pill); cursor: pointer;+ border: 1px solid var(--surface-3); background: var(--surface-1); color: var(--ink-dim);+ font-size: var(--text-sm); font-weight: var(--weight-medium); transition: color .15s, border-color .15s, background .15s; font-family: inherit;+}+.brainstudio__chip:hover { color: var(--ink); background: var(--surface-2); }+.brainstudio__chip--persona:hover { border-color: var(--node-persona); }+.brainstudio__chip--model:hover { border-color: var(--node-model); }+.brainstudio__chip--memory:hover { border-color: var(--node-memory); }+.brainstudio__chip--skill:hover { border-color: var(--node-skill); }+.brainstudio__chip--market:hover { border-color: var(--node-market); }+.brainstudio__chip--output:hover { border-color: var(--node-output); }++/* ── Main split: canvas + side ──────────────────────────────────────────── */+.brainstudio__main { flex: 1; display: grid; grid-template-columns: 1fr minmax(280px, 360px); gap: var(--space-sm); min-height: 0; padding: var(--space-sm); }+.brainstudio__canvas {+ position: relative; overflow: hidden; border-radius: var(--radius-lg);+ border: 1px solid var(--surface-2); background-color: var(--bg-1);+ background-image: radial-gradient(var(--surface-3) 1px, transparent 1px);+ background-size: 22px 22px; touch-action: none; cursor: grab;+}+.brainstudio__canvas.is-panning { cursor: grabbing; }+.brainstudio__side { display: flex; flex-direction: column; gap: var(--space-sm); min-height: 0; }++/* ── Graph ──────────────────────────────────────────────────────────────── */+.bgraph { position: absolute; inset: 0; overflow: hidden; }+.bgraph__world { position: absolute; inset: 0; transform-origin: 0 0; }+.bgraph__edges { position: absolute; left: 0; top: 0; width: 8000px; height: 8000px; overflow: visible; pointer-events: none; }+.bgraph__nodes { position: absolute; inset: 0; }+.bgraph__hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: var(--text-sm); color: var(--ink-dim); background: var(--surface-1); padding: 2px 10px; border-radius: var(--radius-pill); pointer-events: none; }++.bedge { fill: none; stroke: var(--surface-3); stroke-width: 2; transition: stroke .2s; }+.bedge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }+.bedge.is-active { stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 0 4px var(--accent)); }+.bedge--ghost { stroke: var(--accent); stroke-dasharray: 5 4; opacity: .7; }+.bedge.is-flow { stroke-dasharray: 7 6; animation: bflow .6s linear infinite; }+@keyframes bflow { to { stroke-dashoffset: -26; } }++.bnode {+ position: absolute; left: 0; top: 0; box-sizing: border-box;+ border-radius: var(--radius-md); border: 1px solid var(--surface-3);+ background: var(--surface-glass); backdrop-filter: blur(8px);+ box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); user-select: none;+ transition: box-shadow .15s, border-color .15s;+}+.bnode.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 8px 28px rgba(0, 0, 0, 0.45); }+.bnode.is-active { border-color: var(--accent); }+.bnode.is-pulse { animation: bpulse .7s ease-out; }+@keyframes bpulse { 0% { box-shadow: 0 0 0 0 var(--accent); } 100% { box-shadow: 0 0 0 14px transparent; } }+.bnode.is-busy .bnode__head::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--node-memory); margin-left: auto; animation: bbusy .8s ease-in-out infinite; }+@keyframes bbusy { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }++.bnode__head { display: flex; align-items: center; gap: var(--space-2xs); height: 34px; padding: 0 var(--space-sm); border-bottom: 1px solid var(--surface-2); cursor: grab; border-radius: var(--radius-md) var(--radius-md) 0 0; }+.bnode__head::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }+.bnode--persona .bnode__head::before { background: var(--node-persona); }+.bnode--model .bnode__head::before { background: var(--node-model); }+.bnode--memory .bnode__head::before { background: var(--node-memory); }+.bnode--skill .bnode__head::before { background: var(--node-skill); }+.bnode--market .bnode__head::before { background: var(--node-market); }+.bnode--output .bnode__head::before { background: var(--node-output); }+.bnode__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--ink); }+.bnode__del { margin-left: auto; border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: var(--text-base); line-height: 1; padding: 2px 4px; border-radius: 4px; }+.bnode__del:hover { color: var(--node-output); background: var(--surface-2); }+.bnode__summary { padding: var(--space-2xs) var(--space-sm); font-size: var(--text-sm); color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.bnode__ports { display: flex; justify-content: space-between; padding-bottom: var(--space-2xs); }+.bnode__col { display: flex; flex-direction: column; gap: 6px; }+.bport { display: flex; align-items: center; gap: 5px; height: 20px; font-size: var(--text-2xs); color: var(--ink-faint); cursor: crosshair; padding: 0 var(--space-2xs); }+.bport--out { flex-direction: row-reverse; }+.bport__dot { width: 11px; height: 11px; border-radius: 50%; background: var(--bg-1); border: 2px solid var(--ink-dim); transition: transform .1s, border-color .15s; }+.bport:hover .bport__dot { transform: scale(1.25); }+.bport--signal .bport__dot { border-color: var(--node-persona); }+.bport--context .bport__dot { border-color: var(--node-memory); }+.bport--tool .bport__dot { border-color: var(--node-skill); }+.bnode__stat { padding: 2px var(--space-sm) var(--space-2xs); font-size: var(--text-2xs); color: var(--node-model); }++/* ── Inspector ──────────────────────────────────────────────────────────── */+.brainstudio__inspector { background: var(--surface-1); border: 1px solid var(--surface-2); border-radius: var(--radius-lg); padding: var(--space-md); overflow: auto; max-height: 48%; }+.brainstudio__inspector-empty h3, .brainstudio__insp-head h3 { margin: 0 0 var(--space-2xs); font-size: var(--text-md); color: var(--ink); }+.brainstudio__inspector-empty p { margin: 0; color: var(--ink-dim); font-size: var(--text-sm); }+.brainstudio__insp-head { display: flex; align-items: center; gap: var(--space-2xs); margin-bottom: var(--space-sm); }+.brainstudio__insp-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }+.brainstudio__insp-dot--persona { background: var(--node-persona); }+.brainstudio__insp-dot--model { background: var(--node-model); }+.brainstudio__insp-dot--memory { background: var(--node-memory); }+.brainstudio__insp-dot--skill { background: var(--node-skill); }+.brainstudio__insp-dot--market { background: var(--node-market); }+.brainstudio__insp-dot--output { background: var(--node-output); }+.brainstudio__fields { display: flex; flex-direction: column; gap: var(--space-sm); }+.brainstudio__field { display: flex; flex-direction: column; gap: var(--space-3xs); }+.brainstudio__field-label { font-size: var(--text-sm); color: var(--ink-dim); }+.brainstudio__input { width: 100%; box-sizing: border-box; padding: var(--space-2xs) var(--space-sm); background: var(--bg-1); color: var(--ink); border: 1px solid var(--surface-3); border-radius: var(--radius-md); font-size: var(--text-sm); font-family: inherit; }+.brainstudio__input:focus { outline: none; border-color: var(--accent); }+textarea.brainstudio__input { resize: vertical; }+.brainstudio__toggle { position: relative; display: inline-block; width: 38px; height: 22px; }+.brainstudio__toggle input { opacity: 0; width: 0; height: 0; }+.brainstudio__toggle span { position: absolute; inset: 0; background: var(--surface-3); border-radius: var(--radius-pill); transition: background .15s; cursor: pointer; }+.brainstudio__toggle span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--ink); border-radius: 50%; transition: transform .15s; }+.brainstudio__toggle input:checked + span { background: var(--accent); }+.brainstudio__toggle input:checked + span::before { transform: translateX(16px); background: var(--bg-0); }+.brainstudio__toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }++/* ── Test chat ──────────────────────────────────────────────────────────── */+.brainstudio__test { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface-1); border: 1px solid var(--surface-2); border-radius: var(--radius-lg); overflow: hidden; }+.brainstudio__test-head { padding: var(--space-2xs) var(--space-md); border-bottom: 1px solid var(--surface-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--ink); }+.brainstudio__test-model { color: var(--ink-faint); font-weight: var(--weight-regular); }+.brainstudio__transcript { flex: 1; overflow: auto; padding: var(--space-sm); display: flex; flex-direction: column; gap: var(--space-sm); }+.brainstudio__msg { max-width: 90%; padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-md); font-size: var(--text-sm); white-space: pre-wrap; word-break: break-word; }+.brainstudio__msg--user { align-self: flex-end; background: var(--accent); color: var(--bg-0); }+.brainstudio__msg--agent { align-self: flex-start; background: var(--surface-3); color: var(--ink); }+.brainstudio__msg.is-error { background: rgba(252, 129, 129, 0.15); color: var(--node-output); }+.brainstudio__msg-stat { margin-top: 4px; font-size: var(--text-2xs); color: var(--ink-faint); }+.brainstudio__msg--user .brainstudio__msg-stat { display: none; }+.brainstudio__compose { display: flex; gap: var(--space-2xs); padding: var(--space-2xs); border-top: 1px solid var(--surface-2); }+.brainstudio__compose textarea { flex: 1; resize: none; padding: var(--space-2xs) var(--space-sm); background: var(--bg-1); color: var(--ink); border: 1px solid var(--surface-3); border-radius: var(--radius-md); font-family: inherit; font-size: var(--text-sm); }+.brainstudio__compose textarea:focus { outline: none; border-color: var(--accent); }++/* ── Modal (templates + behavior diff) ──────────────────────────────────── */+.brainstudio__modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); padding: var(--space-md); }+.brainstudio__modal-card { width: min(720px, 100%); max-height: 86vh; overflow: auto; background: var(--bg-1); border: 1px solid var(--surface-3); border-radius: var(--radius-lg); padding: var(--space-lg); }+.brainstudio__modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2xs); }+.brainstudio__modal-head h2 { margin: 0; font-size: var(--text-lg); color: var(--ink-bright); }+.brainstudio__modal-x { border: 0; background: transparent; color: var(--ink-dim); font-size: var(--text-xl); cursor: pointer; line-height: 1; }+.brainstudio__modal-sub { margin: 0 0 var(--space-md); color: var(--ink-dim); font-size: var(--text-sm); }+.brainstudio__behavior-meta { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-md); font-size: var(--text-sm); color: var(--ink-dim); }+.brainstudio__behavior-meta b { color: var(--ink); font-weight: var(--weight-medium); }+.brainstudio__diff { white-space: pre-wrap; word-break: break-word; background: var(--bg-0); border: 1px solid var(--surface-2); border-radius: var(--radius-md); padding: var(--space-md); font-size: var(--text-sm); line-height: var(--leading-normal); max-height: 50vh; overflow: auto; color: var(--ink); }+.diff-add { color: var(--node-market); }+.diff-del { color: var(--node-output); text-decoration: line-through; opacity: .8; }+.diff-muted { color: var(--ink-faint); }++/* ── Responsive ─────────────────────────────────────────────────────────── */+@media (max-width: 1024px) {+ .brainstudio__main { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; }+ .brainstudio__side { flex-direction: row; }+ .brainstudio__inspector { max-height: none; flex: 1; }+ .brainstudio__test { flex: 1; }+}+@media (max-width: 720px) {+ .brainstudio__side { flex-direction: column; }+}+@media (prefers-reduced-motion: reduce) {+ .bedge.is-flow { animation: none; }+ .bnode.is-pulse, .bnode.is-busy .bnode__head::after { animation: none; }+}diff --git a/public/changelog.json b/public/changelog.jsonindex a696068ef..bc4b35b8c 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T11:34:06.212Z",+ "generated_at": "2026-06-19T11:44:24.666Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -67,6 +67,16 @@"fix"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "Brain Studio — build your agent’s mind as a visual circuit",+ "summary": "The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change.",+ "link": "/agent-studio",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-19","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex b8c24152f..3d00f1c42 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -54,6 +54,14 @@<category>improvement</category><description>Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter.</description></item>+ <item>+ <title>Brain Studio — build your agent’s mind as a visual circuit</title>+ <link>https://three.ws/agent-studio</link>+ <guid isPermaLink="false">2026-06-19:Brain Studio — build your agent’s mind as a visual circuit</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change.</description>+ </item><item><title>Clearer IRL onboarding and copy</title><link>https://three.ws/irl</link>diff --git a/public/features.json b/public/features.jsonindex 343e8005a..6bdbe44d3 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T11:34:06.197Z",+ "generated_at": "2026-06-19T11:44:24.654Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/studio/agent-studio-store.js b/src/studio/agent-studio-store.jsindex cb7ac002f..126c98cd9 100644--- a/src/studio/agent-studio-store.js+++ b/src/studio/agent-studio-store.js@@ -32,6 +32,22 @@* `studio.onMarket(fn)` and are mapped to avatar reactions by `<agent-presence>`.** The store is framework-agnostic (no React/DOM deps) so it works on every page.+ *+ * ── P0 FOUNDATION ADDENDUM (routing, presence, server contract) ──────────────+ * • Route: the Studio shell lives at /agent-studio (pages/agent-studio.html →+ * src/studio/studio-shell.js). Each tab is an empty <section+ * data-studio-mount="brain|memory|body|money|skills"> with a designed empty+ * state — mount your sub-studio there and remove its `.studio-empty`. The shell+ * fires document `studio-shell:ready` (detail:{ studio, agent }) once loaded.+ * • Presence: <agent-presence> (src/studio/agent-presence.js) renders this same+ * live agent anywhere (modes: stage|companion|mini) and auto-syncs to this+ * store. It maps `studio.emitMarket({ type })` events to avatar reactions — so+ * P4/P5 only need to emit (e.g. 'snipe:filled', 'position:down'); the avatar+ * celebrates/worries with no extra wiring.+ * • Server: PUT /api/agents/:id persists meta.studio. Write ONLY your domain+ * namespace (brain|memory|body|money|trading|skills) — the server whitelists+ * top-level keys (api/agents.js validateStudioMeta) and size-limits the bag;+ * an unknown key 400s. The decorated record exposes `updated_at` for reconcile.*/import { AgentIdentity } from '../agent-identity.js';diff --git a/vite.config.js b/vite.config.jsindex d1eb75513..9196fc118 100644--- a/vite.config.js+++ b/vite.config.js@@ -376,6 +376,7 @@ const appConfig = {'avatar-page': resolve(__dirname, 'pages/avatar-page.html'),'avatar-sdk': resolve(__dirname, 'pages/avatar-sdk.html'),brain: resolve(__dirname, 'pages/brain.html'),+ 'agent-studio': resolve(__dirname, 'pages/agent-studio.html'),voice: resolve(__dirname, 'pages/voice.html'),galaxy: resolve(__dirname, 'pages/galaxy.html'),'ar-page': resolve(__dirname, 'pages/ar.html'),