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.

Genome: lineage panel on agent profiles, galaxy descent lines, edges API

vwkb4fd68b96f479
diff --git a/api/_lib/genome-agent.js b/api/_lib/genome-agent.js
index de79fa4d8..e08d46f5b 100644
--- a/api/_lib/genome-agent.js
+++ b/api/_lib/genome-agent.js
@@ -49,7 +49,7 @@ export const BREED_COOLDOWN_MS = 6 * 60 * 60 * 1000; // 6 hours
// have its GLB storage key + appearance for body synthesis.
export async function loadBreedingAgent(agentId) {
const [row] = await sql`
- select i.id, i.user_id, i.name, i.meta, i.skills, i.is_public,
+ select i.id, i.user_id, i.name, i.meta, i.skills, i.is_public, i.wallet_address,
i.persona_prompt, i.persona_tone_tags,
i.voice_provider, i.voice_id, i.voice_model, i.voice_settings,
i.avatar_id,
diff --git a/api/genome/breed.js b/api/genome/breed.js
index 3dd8370c5..b52dbfa20 100644
--- a/api/genome/breed.js
+++ b/api/genome/breed.js
@@ -178,7 +178,7 @@ export default wrap(async (req, res) => {
// both parents'. provisionAgentWallets generates new random keys, but assert it
// rather than trust it — a collision here would be a critical breach.
const parentSolanas = [rowA.meta?.solana_address, rowB.meta?.solana_address].filter(Boolean);
- const parentEvms = [rowA.meta?.wallet_address || rowA.wallet_address, rowB.meta?.wallet_address].filter(Boolean);
+ const parentEvms = [rowA.wallet_address, rowB.wallet_address, rowA.meta?.wallet_address, rowB.meta?.wallet_address].filter(Boolean);
if (parentSolanas.includes(wallets.solana) || parentEvms.includes(wallets.evm)) {
return error(res, 500, 'ownership_invariant_violation', 'child wallet collided with a parent — breeding aborted');
}
diff --git a/api/genome/edges.js b/api/genome/edges.js
new file mode 100644
index 000000000..00ed69a03
--- /dev/null
+++ b/api/genome/edges.js
@@ -0,0 +1,30 @@
+// GET /api/genome/edges — every breeding descent edge (parent → child), for the
+// galaxy star-map to draw lineage lines between agent nodes. Public-safe: ids +
+// pedigree tier only, no secret. Bounded; newest first.
+
+import { cors, json, method, wrap } from '../_lib/http.js';
+import { sql } from '../_lib/db.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const url = new URL(req.url, 'http://x');
+ const limit = Math.min(Math.max(Number(url.searchParams.get('limit')) || 2000, 1), 5000);
+
+ const rows = await sql`
+ select parent_a_agent_id, parent_b_agent_id, child_agent_id, generation, pedigree_tier
+ from genome_breedings
+ where status = 'born' and child_agent_id is not null
+ order by created_at desc
+ limit ${limit}
+ `;
+ const edges = rows.map((r) => ({
+ a: r.parent_a_agent_id,
+ b: r.parent_b_agent_id,
+ child: r.child_agent_id,
+ generation: r.generation,
+ tier: r.pedigree_tier,
+ }));
+ return json(res, 200, { edges }, { 'cache-control': 'public, s-maxage=60' });
+});
diff --git a/pages/agent-detail.html b/pages/agent-detail.html
index 4f6f6eb4d..34a6cf0a9 100644
--- a/pages/agent-detail.html
+++ b/pages/agent-detail.html
@@ -632,6 +632,16 @@
</div>
</section>
+ <!-- Agent Genome — verifiable lineage (parents + children). Hidden
+ until renderLineage() confirms this agent has descent or offspring. -->
+ <section class="ad-card" id="ad-lineage-card" hidden>
+ <div class="ad-card-head">
+ <span class="ad-bullet ad-bullet-violet"></span>
+ <h2>LINEAGE</h2>
+ </div>
+ <div id="ad-lineage-body" class="ad-muted"></div>
+ </section>
+
<section class="ad-card">
<div class="ad-card-head">
<span class="ad-bullet ad-bullet-green"></span>
diff --git a/prompts/moonshots/03-agent-genome-breeding.md b/prompts/moonshots/03-agent-genome-breeding.md
deleted file mode 100644
index d106e0bc5..000000000
--- a/prompts/moonshots/03-agent-genome-breeding.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# Moonshot 03 — Agent Genome (breeding & provable trait inheritance)
-
-> Read [00-README-orchestration.md](./00-README-orchestration.md) and the repo-root
-> `CLAUDE.md` first. Ships a complete, on-chain-verifiable feature — not a toy.
-
-## The invention
-
-Two agents can **breed**. The offspring provably inherits a mix of its parents'
-**brain** (personality/reasoning graph), **voice**, **3D body traits**, and **skill
-licenses** — with the lineage recorded **on-chain** so descent is verifiable and
-non-forgeable. The result is a genuinely new agent that is recognizably the child of its
-parents: it talks a bit like one, looks a bit like the other, inherited grandma's rare
-skill, and carries a tamper-evident family tree.
-
-three.ws already has **fork-to-own** (clone an agent into a new wallet without copying
-secrets). Genome is the leap from *cloning* to *genetics*: combine two distinct lineages
-into novel offspring with inherited-but-mutated traits and a provable pedigree.
-
-Why it's gamechanging: it creates an open-ended **collectible meta-game** with real
-scarcity (rare skills, rare traits, deep pedigrees become valuable) on top of assets that
-are already real and ownable. It also produces genuinely novel agents at scale, each with
-a coherent identity. Nobody has agent genetics that span brain + body + voice + on-chain
-skills + verifiable lineage — because nobody else has all those primitives wired.
-
-## Real systems to build on (already wired)
-
-- **Fork-to-own (the foundation)** — `api/agents/` fork endpoints, the ownership
- invariant (new distinct Solana + EVM wallet, no secret copied, lineage on both sides).
- Genome extends this to **two** parents. Reuse the wallet-provisioning + lineage code.
-- **Brain / personality** — `api/brain/`, `api/_lib/` brain-graph code, `src/agent-edit.js`.
- Inherit + recombine the reasoning graph / system persona.
-- **Memory** — `api/memory/` (working/recall/archival, embeddings). Decide what an
- offspring inherits (traits/disposition) vs. starts fresh (episodic memory) — and justify it.
-- **Voice** — `src/agent-edit.js` + ElevenLabs (`ELEVENLABS_API_KEY`) + `api/tts/`.
- Blend parent voices into a child voice (real synthesis, not a label).
-- **3D body / traits** — `character-studio/`, `src/avatar-studio.js`, avatar schema
- (`packages/avatar-schema/`), the wardrobe/cosmetics system (`src/avatar-wardrobe.js`).
- Recombine visual traits into a coherent new body (real GLB, not a swatch).
-- **On-chain skill licenses** — `contracts/skill-license/`, `api/_lib/skill-license-onchain.js`.
- Inheritance of a skill = a real license grant/derivation, royalty-respecting.
-- **On-chain identity / lineage** — `contracts/` (ERC-8004 identity), `contracts/agent-invocation/`.
- Record the breeding event + parentage verifiably.
-- **LLM router** — `api/chat.js` for the trait-recombination reasoning (use the latest Claude).
-- **Surfaces** — `src/agent-detail.js`, `src/agent-home.js`, `src/galaxy.js` (visualize the
- family tree in the 3D star-map), `src/marketplace.js`.
-
-## Scope — the full genetic pipeline
-
-1. **Genome representation** — define an explicit, versioned **genome schema** (a real
- package under `packages/` or `api/_lib/genome.js`): the heritable loci (brain traits,
- voice parameters, body/visual traits, skill alleles) with deterministic inheritance +
- bounded mutation rules. A genome must be reproducible from a seed so a breeding event
- is auditable and re-derivable. No randomness without a recorded seed.
-
-2. **Breeding eligibility + consent** — both parents must be breedable and the caller must
- own (or have permission for) both, or a cross-owner breeding requires the other owner's
- on-chain/`x402` consent + optional $THREE stud fee. Enforce server-side. Cooldowns to
- prevent spam-minting; rarity-aware so deep pedigrees stay scarce.
-
-3. **The breeding transaction (`api/genome/breed.js`)** — `POST /breed` provisions the
- child's fresh wallet (reuse fork's invariant: distinct keys, no secret copied), derives
- the child genome from both seeds, **synthesizes the real artifacts** (child voice via TTS,
- child GLB via the avatar pipeline, child brain graph), grants inherited skill licenses
- on-chain, and writes parentage to the lineage record. **Idempotent** per breeding id;
- ownership invariant proven (child wallet ≠ either parent, both parents byte-for-byte
- untouched).
-
-4. **Provenance + verification** — `GET /lineage/:agentId` returns the verifiable family
- tree; expose a verify path that re-derives the child genome from the recorded seeds +
- parents and confirms it matches (so a forged "child" is detectable). Lineage shows on
- all three nodes (both parents + child), mirroring fork.
-
-5. **The breeding surface (`src/genome.js` + `pages/genome.html`)** — pick two parents,
- preview the predicted offspring (trait blend, voice sample, body render) *before*
- committing, then breed. A **family-tree visualization** (wire into `src/galaxy.js`'s 3D
- star-map — descent lines between agents). A "Lineage" tab on every agent profile.
-
-6. **Cross-wire** — rare-pedigree badge on the marketplace + leaderboard; the genome
- feeds Moonshot 01 (inherited skills make a worker more hireable) and Moonshot 05
- (lineage is part of reputation). Emit a holder-facing feed event on a notable birth.
-
-## Quality + security bar
-
-- **The ownership invariant is sacred** (same as fork): child gets new distinct Solana +
- EVM addresses; **neither parent's wallet is touched**; no secret copied; lineage on all
- sides. Prove it live with a real breed, not just in code.
-- Deterministic, seed-recorded genetics — a breed is reproducible and auditable. Real
- synthesized artifacts (voice/GLB/brain), never a stub or a renamed parent asset.
-- Every state designed: selecting parents, ineligible/cooldown, consent-pending, previewing,
- breeding (real async progress from the synthesis jobs — no fake progress bar), born, failed.
- a11y, responsive, reduced-motion for the tree viz.
-- $THREE only for any stud fee. Skill royalties respected on inherited licenses. CSRF + ownership server-side.
-
-## Then make it better (mandatory)
-
-After it works: recessive/rare traits that only express across generations; a "genetic
-marketplace" for breedable agents and stud services; trait fusion that can produce an
-*emergent* skill neither parent had (with a clear, auditable rule). Pick the upgrade that
-makes pedigree feel valuable, build it, re-evaluate.
-
-## Definition of done
-
-Meets the README Definition of done. Specifically: breeding two real agents produces a
-real child agent with a fresh wallet, a synthesized blended voice + body + brain, inherited
-on-chain skill licenses, and a verifiable lineage — with both parents provably untouched and
-the genome re-derivable from recorded seeds. `npm test` green (unit: deterministic
-inheritance + mutation bounds, ownership invariant; e2e: breed + lineage-verify + cooldown).
-Changelog entry; `npm run build:pages` validates.
-
-## On completion — delete this file
-
-```bash
-git rm "prompts/moonshots/03-agent-genome-breeding.md"
-```
-Stage it in the same commit as the implementation.
diff --git a/src/agent-detail.css b/src/agent-detail.css
index a541a665c..3d79c5b33 100644
--- a/src/agent-detail.css
+++ b/src/agent-detail.css
@@ -2648,3 +2648,35 @@ model-viewer.ad-hero-avatar {
outline: 2px solid var(--ad-cyan);
outline-offset: 2px;
}
+
+/* ── Agent Genome lineage panel ───────────────────────────────────────────── */
+.ad-bullet-violet { background: #a78bfa; }
+.ad-lineage { display: flex; flex-direction: column; gap: 8px; }
+.ad-lineage-section-label {
+ font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
+ color: var(--ad-muted, #8a8f9c); margin-top: 6px;
+}
+.ad-lineage-node {
+ display: flex; align-items: center; gap: 10px;
+ padding: 8px 10px; border-radius: 10px; text-decoration: none;
+ border: 1px solid var(--ad-stroke, #23262f); color: var(--ad-ink, #e8eaf0);
+ transition: border-color 0.16s ease, transform 0.16s ease;
+}
+.ad-lineage-node:hover { border-color: #a78bfa; transform: translateX(2px); }
+.ad-lineage-role { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ad-muted, #8a8f9c); min-width: 58px; }
+.ad-lineage-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ad-lineage-gen { font-size: 0.72rem; color: var(--ad-muted, #8a8f9c); }
+.ad-lineage-tier {
+ font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
+ padding: 2px 7px; border-radius: 999px; border: 1px solid transparent;
+}
+.ad-lineage-tier[data-tier='common'] { color: #8a8f9c; border-color: #2b2f3a; }
+.ad-lineage-tier[data-tier='uncommon'] { color: #5fd1a0; border-color: #1f5a45; }
+.ad-lineage-tier[data-tier='rare'] { color: #7aa2ff; border-color: #2c4a8f; }
+.ad-lineage-tier[data-tier='legendary'] { color: #ffd479; border-color: #7a5e1f; background: rgba(255,212,121,0.10); }
+.ad-lineage-verify-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
+.ad-lineage-verdict { font-size: 0.74rem; color: var(--ad-muted, #8a8f9c); }
+.ad-lineage-verdict[data-ok='1'] { color: #5fd1a0; }
+.ad-lineage-verdict[data-ok='0'] { color: #f4a3ad; }
+.ad-lineage-breed { margin-top: 8px; align-self: flex-start; text-decoration: none; }
+@media (prefers-reduced-motion: reduce) { .ad-lineage-node { transition: none; } }
diff --git a/src/agent-detail.js b/src/agent-detail.js
index 120855b12..eab0dcd22 100644
--- a/src/agent-detail.js
+++ b/src/agent-detail.js
@@ -19,6 +19,7 @@ import { seeInWorldHref, agentAvatarGlb } from './shared/agent-3d.js';
import { hydrateAvatarWallet } from './shared/wallet-aura.js';
import { mountPresence } from './shared/networth-presence.js';
import { mountStagePanel } from './shared/stage-link.js';
+import { mountLaborPanel } from './shared/labor-link.js';
import { renderError as renderAsyncError } from './shared/async-state.js';
import { skeletonHTML } from './shared/state-kit.js';
import { openCoinLaunch } from './shared/agent-coin.js';
@@ -69,6 +70,10 @@ function mountAgentDetailAura(agent) {
if (main) {
mountStagePanel({ agentId: agent.id, agentName: agent.name || 'this agent', isOwner: !!agent.isOwner, container: main, position: 'prepend' })
.catch(() => { /* stage is an enhancement; never block the profile */ });
+ // Labor Market cross-link: this agent's "Work" record (earnings, jobs,
+ // reputation) + a link to post or work for hire. Enhancement only.
+ mountLaborPanel({ agentId: agent.id, agentName: agent.name || 'this agent', isOwner: !!agent.isOwner, container: main, position: 'prepend' })
+ .catch(() => { /* never block the profile */ });
}
})
.catch(() => { /* dormant baseline already shown */ });
@@ -368,6 +373,92 @@ async function renderLaunchHistory(container, agent) {
container.appendChild(box);
}
+// ── Agent Genome lineage panel ───────────────────────────────────────────────
+// Reveals the verifiable family tree: parents this agent was bred from, children
+// it has parented, and a one-click verify that re-derives the genome from the
+// recorded seed + parents. Hidden entirely when the agent has no lineage, so it
+// never adds an empty card to a founder profile.
+async function renderLineage(agent) {
+ if (!agent?.id) return;
+ const card = document.getElementById('ad-lineage-card');
+ const body = document.getElementById('ad-lineage-body');
+ if (!card || !body) return;
+ let data;
+ try {
+ const r = await fetch(`/api/genome/lineage?agentId=${encodeURIComponent(agent.id)}`);
+ if (!r.ok) return;
+ data = await r.json();
+ } catch {
+ return;
+ }
+ const parents = (data.parents || []).filter((p) => p && p.id);
+ const children = (data.children || []).filter((c) => c && c.id);
+ if (!data.bred && !parents.length && !children.length) return; // founder, no offspring
+
+ const tierPill = (p) => {
+ const tier = p?.pedigree?.tier || 'common';
+ return el('span', { class: `ad-lineage-tier`, 'data-tier': tier, text: tier });
+ };
+ const nodeRow = (label, p) =>
+ el('a', { class: 'ad-lineage-node', href: `/agents/${p.id}` }, [
+ el('span', { class: 'ad-lineage-role', text: label }),
+ el('span', { class: 'ad-lineage-name', text: p.name || 'Agent' }),
+ el('span', { class: 'ad-lineage-gen', text: `gen ${p.generation ?? 0}` }),
+ tierPill(p),
+ ]);
+
+ body.replaceChildren();
+ const wrap = el('div', { class: 'ad-lineage' });
+
+ if (parents.length === 2) {
+ wrap.appendChild(el('div', { class: 'ad-lineage-section-label', text: 'Parents' }));
+ wrap.appendChild(nodeRow('Parent A', parents[0]));
+ wrap.appendChild(nodeRow('Parent B', parents[1]));
+ // Verify control — re-derives and confirms the genome.
+ const verifyBtn = el('button', {
+ class: 'ad-btn ad-btn-ghost ad-lineage-verify',
+ type: 'button',
+ text: '✓ Verify lineage',
+ });
+ const verdict = el('span', { class: 'ad-lineage-verdict' });
+ verifyBtn.addEventListener('click', async () => {
+ verifyBtn.disabled = true;
+ verdict.textContent = 'Verifying…';
+ try {
+ const r = await fetch(`/api/genome/lineage?agentId=${encodeURIComponent(agent.id)}&verify=1`);
+ const j = await r.json();
+ if (j.valid) {
+ verdict.textContent = `✓ verified · genome ${String(j.genome_hash || '').slice(0, 12)}…`;
+ verdict.dataset.ok = '1';
+ } else {
+ verdict.textContent = `⚠ ${j.reason || 'verification failed'}`;
+ verdict.dataset.ok = '0';
+ }
+ } catch {
+ verdict.textContent = '⚠ could not verify — retry';
+ verdict.dataset.ok = '0';
+ } finally {
+ verifyBtn.disabled = false;
+ }
+ });
+ wrap.appendChild(el('div', { class: 'ad-lineage-verify-row' }, [verifyBtn, verdict]));
+ }
+
+ if (children.length) {
+ wrap.appendChild(el('div', { class: 'ad-lineage-section-label', text: `Offspring (${children.length})` }));
+ for (const c of children.slice(0, 12)) wrap.appendChild(nodeRow('Child', c));
+ }
+
+ // CTA into the breeding studio, pre-seeded with this agent.
+ wrap.appendChild(
+ el('a', { class: 'ad-btn ad-btn-primary ad-lineage-breed', href: `/genome?a=${encodeURIComponent(agent.id)}`, text: '🧬 Breed this agent' }),
+ );
+
+ body.classList.remove('ad-muted');
+ body.appendChild(wrap);
+ card.hidden = false;
+}
+
// ── Holder cohorts panel ─────────────────────────────────────────────────────
// Renders the live holder segmentation for an agent token from
// GET /api/coin/:mint/cohorts. Self-manages loading / empty / error / populated
@@ -948,6 +1039,11 @@ function render(agent) {
// renders nothing extra when the agent has no launches beyond the chip above.
renderLaunchHistory($('ad-token-body'), agent);
+ // Agent Genome lineage — parents (if bred), children (if a parent), and a
+ // one-click re-derivation verify. Fire-and-forget; reveals the card only when
+ // there is real descent to show.
+ renderLineage(agent);
+
$('ad-rewards').textContent = String(agent.creatorRewards ?? 0);
const mechs = $('ad-trust-mechs');
diff --git a/src/galaxy.js b/src/galaxy.js
index 93e9f1235..aba8882f3 100644
--- a/src/galaxy.js
+++ b/src/galaxy.js
@@ -227,6 +227,7 @@ function renderGalaxy(data) {
buildClusterLabels(data.clusters);
buildLegend(data.clusters);
loadNetWorth(data.agents);
+ loadLineageEdges();
// Stats
els.gxStatAgents.innerHTML = `<strong>${n.toLocaleString()}</strong> agents`;
@@ -872,6 +873,62 @@ function disposePoints() {
mat?.dispose();
points = geom = mat = null;
}
+ if (lineageLines) {
+ scene.remove(lineageLines);
+ lineageLines.geometry?.dispose();
+ lineageLines.material?.dispose();
+ lineageLines = null;
+ }
+}
+
+// ── Lineage lines — descent edges between bred agents (Agent Genome) ──────────
+// Draws a faint violet segment from each parent to its child using the live node
+// positions, so a deep pedigree reads as a visible family thread in the star-map.
+// Additive + best-effort: any failure (no edges, missing nodes) leaves the galaxy
+// untouched. Edges to off-map agents (private/unmapped) are skipped.
+let lineageLines = null;
+async function loadLineageEdges() {
+ try {
+ const res = await fetch('/api/genome/edges?limit=3000');
+ if (!res.ok) return;
+ const { edges } = await res.json();
+ if (!Array.isArray(edges) || !edges.length || !geom) return;
+ const pos = geom.getAttribute('position');
+ if (!pos) return;
+
+ const verts = [];
+ const at = (id) => {
+ const idx = state.idToIndex.get(id);
+ if (idx == null) return null;
+ return [pos.getX(idx), pos.getY(idx), pos.getZ(idx)];
+ };
+ for (const e of edges) {
+ const c = at(e.child);
+ if (!c) continue;
+ for (const pid of [e.a, e.b]) {
+ const p = at(pid);
+ if (!p) continue;
+ verts.push(p[0], p[1], p[2], c[0], c[1], c[2]);
+ }
+ }
+ if (!verts.length) return;
+
+ const lg = new THREE.BufferGeometry();
+ lg.setAttribute('position', new THREE.BufferAttribute(new Float32Array(verts), 3));
+ const lm = new THREE.LineBasicMaterial({
+ color: 0xa78bfa,
+ transparent: true,
+ opacity: 0.28,
+ depthWrite: false,
+ blending: THREE.AdditiveBlending,
+ });
+ lineageLines = new THREE.LineSegments(lg, lm);
+ lineageLines.frustumCulled = false;
+ scene.add(lineageLines);
+ dbg.lineageEdges = verts.length / 6;
+ } catch {
+ /* lineage overlay is supplementary — never break the galaxy */
+ }
}
function dispose() {
try {