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.

fix: add agent_identities.avatar_id migration; switch pump launch to V2 SDK; dashboard polish

nirholasa88748aeef94
diff --git a/agent-detail.html b/agent-detail.html
index f49ea06fe..bb7cf84b1 100644
--- a/agent-detail.html
+++ b/agent-detail.html
@@ -1,5 +1,6 @@
<link rel="stylesheet" href="/fonts/fonts.css" />
<link rel="stylesheet" href="/src/agent-detail.css" />
+ <link rel="stylesheet" href="/src/pump/launch-token-modal.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
<style>
.ad-main.loading .ad-hero-avatar,
diff --git a/api/_lib/avatars.js b/api/_lib/avatars.js
index aa3fa3ba2..922da5e42 100644
--- a/api/_lib/avatars.js
+++ b/api/_lib/avatars.js
@@ -33,7 +33,7 @@ export async function listAvatars({
from avatars a
left join lateral (
select id, wallet_address from agent_identities
- where avatar_id = a.id and deleted_at is null
+ where avatar_id = a.id and user_id = $1 and deleted_at is null
order by created_at asc limit 1
) ai on true
where ${conds.join(' and ')}
@@ -54,7 +54,7 @@ export async function getAvatar({ id, requesterId = null }) {
from avatars a
left join lateral (
select id, wallet_address from agent_identities
- where avatar_id = a.id and deleted_at is null
+ where avatar_id = a.id and user_id = ${requesterId} and deleted_at is null
order by created_at asc limit 1
) ai on true
where a.id = ${id} and a.deleted_at is null limit 1
diff --git a/api/_lib/migrations/2026-05-13-agent-identities-avatar-id.sql b/api/_lib/migrations/2026-05-13-agent-identities-avatar-id.sql
new file mode 100644
index 000000000..03f3dcda2
--- /dev/null
+++ b/api/_lib/migrations/2026-05-13-agent-identities-avatar-id.sql
@@ -0,0 +1,9 @@
+-- Add avatar_id to agent_identities so the pump.fun launch flow can resolve
+-- an existing agent from an avatar without querying avatars separately.
+-- resolveLaunchAgentId in api/pump/[action].js depends on this column.
+
+alter table agent_identities
+ add column if not exists avatar_id uuid references avatars(id) on delete set null;
+
+create index if not exists agent_identities_avatar
+ on agent_identities(avatar_id) where avatar_id is not null;
diff --git a/api/_lib/pump.js b/api/_lib/pump.js
index 9613a3994..a973c93a4 100644
--- a/api/_lib/pump.js
+++ b/api/_lib/pump.js
@@ -57,12 +57,19 @@ export async function getPumpSdk({ network = 'mainnet' } = {}) {
// the full surface — required by the studio launch flow.
const offline = new PumpSdk();
const online = OnlinePumpSdk ? new OnlinePumpSdk(connection) : null;
+ // Compose offline + online so callers see a unified `sdk`. Offline owns the
+ // instruction builders (createV2Instruction, …); online owns the fetch*
+ // helpers. Prefer offline for any method that exists on it — the previous
+ // `prop in target` check resolved class-prototype methods on `online` to
+ // `undefined`, surfacing as "sdk.createInstruction is not a function" at
+ // runtime even though the method existed on `offline`.
const sdk = online
? new Proxy(online, {
get(target, prop, receiver) {
- if (prop in target) return Reflect.get(target, prop, receiver);
- const fallback = offline[prop];
- return typeof fallback === 'function' ? fallback.bind(offline) : fallback;
+ const offlineVal = offline[prop];
+ if (typeof offlineVal === 'function') return offlineVal.bind(offline);
+ if (offlineVal !== undefined) return offlineVal;
+ return Reflect.get(target, prop, receiver);
},
})
: offline;
diff --git a/api/agents.js b/api/agents.js
index d431fbb2c..a6f64b391 100644
--- a/api/agents.js
+++ b/api/agents.js
@@ -38,6 +38,8 @@ const animationEntrySchema = z.object({
const animationsSchema = z.array(animationEntrySchema).max(30);
+const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
+
export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: true })) return;
if (!method(req, res, ['GET', 'POST'])) return;
@@ -171,6 +173,19 @@ async function handleCreate(req, res) {
if (!name) return error(res, 400, 'validation_error', 'name is required');
+ let avatarId = null;
+ if (body.avatar_id) {
+ const raw = String(body.avatar_id);
+ if (!UUID_RE.test(raw)) return error(res, 400, 'validation_error', 'avatar_id must be a UUID');
+ const [av] = await sql`
+ SELECT id FROM avatars
+ WHERE id = ${raw} AND owner_id = ${auth.userId} AND deleted_at IS NULL
+ LIMIT 1
+ `;
+ if (!av) return error(res, 404, 'not_found', 'avatar not found');
+ avatarId = av.id;
+ }
+
const wallet = await generateAgentWallet();
const sol = await generateSolanaAgentWallet();
const meta = {
@@ -181,14 +196,15 @@ async function handleCreate(req, res) {
};
const [agent] = await sql`
- INSERT INTO agent_identities (user_id, name, description, skills, wallet_address, meta)
+ INSERT INTO agent_identities (user_id, name, description, skills, wallet_address, meta, avatar_id)
VALUES (
${auth.userId},
${name},
${body.description ? String(body.description).slice(0, 500) : null},
${body.skills || ['greet', 'present-model', 'validate-model', 'remember', 'think']},
${wallet.address},
- ${JSON.stringify(meta)}::jsonb
+ ${JSON.stringify(meta)}::jsonb,
+ ${avatarId}
)
RETURNING *
`;
@@ -198,8 +214,6 @@ async function handleCreate(req, res) {
// ── Get One ───────────────────────────────────────────────────────────────
-const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
-
export async function handleGetOne(req, res, id) {
if (cors(req, res, { methods: 'GET,PUT,PATCH,DELETE,OPTIONS', credentials: true })) return;
if (!method(req, res, ['GET', 'PUT', 'PATCH', 'DELETE'])) return;
diff --git a/api/agents/tokens/[action].js b/api/agents/tokens/[action].js
index 0ba0d1636..7cc998488 100644
--- a/api/agents/tokens/[action].js
+++ b/api/agents/tokens/[action].js
@@ -20,7 +20,7 @@ import { limits, clientIp } from '../../_lib/rate-limit.js';
import { parse } from '../../_lib/validate.js';
import { randomToken } from '../../_lib/crypto.js';
import { env } from '../../_lib/env.js';
-import { r2 } from '../../_lib/r2.js';
+import { r2, publicUrl } from '../../_lib/r2.js';
// Heavy SDKs (Solana web3, Pump.fun, AWS S3 commands) are dynamic-imported
// inside the handlers that need them. Loading them at module top-level was
@@ -108,7 +108,6 @@ async function pinTokenMetadata({ name, symbol, description, image }) {
}
}
const hash = createHash('sha256').update(bytes).digest('hex');
- const stub = `bafkreigenerated${hash.slice(0, 40)}`;
const key = `token-metadata/${Date.now()}-${Math.random().toString(36).slice(2)}.json`;
const { PutObjectCommand } = await loadS3Commands();
await r2.send(
@@ -119,7 +118,8 @@ async function pinTokenMetadata({ name, symbol, description, image }) {
ContentType: 'application/json',
}),
);
- return { cid: stub, uri: `ipfs://${stub}` };
+ const uri = publicUrl(key);
+ return { cid: hash, uri };
}
async function handleLaunchPrep(req, res) {
@@ -198,7 +198,7 @@ async function handleLaunchPrep(req, res) {
bondingCurve: null,
amount: lamports,
});
- const launchIxs = await sdk.createAndBuyInstructions({
+ const launchIxs = await sdk.createV2AndBuyInstructions({
global,
mint: mintKeypair.publicKey,
name: body.name,
diff --git a/api/pump/[action].js b/api/pump/[action].js
index f09decaec..03ba37657 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -491,8 +491,10 @@ const buildMetadataSchema = z.object({
description: z.string().trim().max(500).default(''),
avatar_id: z.string().uuid().optional(),
agent_id: z.string().uuid().optional(),
- // Base64 data URL: "data:image/png;base64,..." — max 4 MB raw (≈5.5 MB base64).
- image_data_url: z.string().max(5_500_000).optional(),
+ // Base64 data URL: "data:image/png;base64,..." — max 4 MB raw.
+ // Cap the string at 6 MB chars to safely cover 4 MB raw (base64 inflates ~4/3 → ~5.59 M)
+ // plus the data URL header. Raw-byte ceiling is re-checked after decode.
+ image_data_url: z.string().max(6_000_000).optional(),
});
async function handleBuildMetadata(req, res) {
@@ -505,7 +507,18 @@ async function handleBuildMetadata(req, res) {
const rl = await limits.authIp(clientIp(req));
if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
- const body = parse(buildMetadataSchema, await readJson(req));
+ let body;
+ try {
+ body = parse(buildMetadataSchema, await readJson(req));
+ } catch (err) {
+ if (err.code === 'validation_error') {
+ console.warn('[pump/build-metadata] validation_error', {
+ userId: user.id,
+ issues: err.issues,
+ });
+ }
+ throw err;
+ }
const uid = user.id;
const ts = Date.now().toString(36);
const prefix = `pump/meta/${uid}/${ts}`;
@@ -562,50 +575,39 @@ async function handleBuildMetadata(req, res) {
// ── shared launch helpers ──────────────────────────────────────────────────
// Build the pump.fun launch instructions for the requested coin variant.
-// Mayhem coins go through createV2* (token-2022 + mayhem program accounts).
-// Regular / agent coins keep the legacy V1 path; agent binding (PumpAgent.create)
-// is appended by the caller when applicable.
+// All variants now go through createV2* (token-2022). Pump.fun no longer
+// accepts V1 (SPL Token) launches — calling the deprecated createInstruction /
+// createAndBuyInstructions paths returned tokens the pump.fun program rejected.
+// mayhemMode toggles the high-volatility curve; agent binding is appended by
+// the caller when applicable.
async function buildLaunchInstructions({
sdk, BN, mint, creator, name, symbol, uri, solBuyIn, isMayhem,
}) {
const LAMPORTS = 1_000_000_000;
const hasBuy = solBuyIn > 0;
- if (isMayhem) {
- if (hasBuy && sdk.createV2AndBuyInstructions) {
- const global = await sdk.fetchGlobal();
- const solAmount = new BN(Math.floor(solBuyIn * LAMPORTS));
- const pumpSdk = await import('@pump-fun/pump-sdk');
- const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
- const ixs = await sdk.createV2AndBuyInstructions({
- global, mint, name, symbol, uri,
- creator, user: creator,
- solAmount, amount: tokenAmount,
- mayhemMode: true,
- });
- return Array.isArray(ixs) ? [...ixs] : [ixs];
- }
- const ix = await sdk.createV2Instruction({
- mint, name, symbol, uri, creator, user: creator, mayhemMode: true,
- });
- return [ix];
- }
-
- // Regular / agent — legacy V1 path (TOKEN_PROGRAM_ID).
- if (hasBuy && sdk.createAndBuyInstructions) {
+ if (hasBuy) {
const global = await sdk.fetchGlobal();
const solAmount = new BN(Math.floor(solBuyIn * LAMPORTS));
const pumpSdk = await import('@pump-fun/pump-sdk');
- const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
- const ixs = await sdk.createAndBuyInstructions({
+ const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount({
+ global,
+ feeConfig: null,
+ mintSupply: null,
+ bondingCurve: null,
+ amount: solAmount,
+ });
+ const ixs = await sdk.createV2AndBuyInstructions({
global, mint, name, symbol, uri,
creator, user: creator,
solAmount, amount: tokenAmount,
+ mayhemMode: !!isMayhem,
});
return Array.isArray(ixs) ? [...ixs] : [ixs];
}
- const ix = await sdk.createInstruction({
- mint, name, symbol, uri, creator, user: creator,
+
+ const ix = await sdk.createV2Instruction({
+ mint, name, symbol, uri, creator, user: creator, mayhemMode: !!isMayhem,
});
return [ix];
}
@@ -1626,11 +1628,23 @@ async function handleQuote(req, res) {
const sol = Number(solRaw);
if (!(sol > 0)) return error(res, 400, 'validation_error', 'sol must be > 0');
const lamports = new BN(Math.floor(sol * LAMPORTS_PER_SOL_Q));
- const tokens = pumpSdk.getBuyTokenAmountFromSolAmount(global, curve, lamports);
+ const tokens = pumpSdk.getBuyTokenAmountFromSolAmount({
+ global,
+ feeConfig: null,
+ mintSupply: null,
+ bondingCurve: curve,
+ amount: lamports,
+ });
quote = { sol_in: sol, tokens_out: tokens.toString(), source: 'bonding_curve' };
} else if (direction === 'sell' && tokenRaw) {
const tokens = new BN(tokenRaw);
- const lamports = pumpSdk.getSellSolAmountFromTokenAmount(global, curve, tokens);
+ const lamports = pumpSdk.getSellSolAmountFromTokenAmount({
+ global,
+ feeConfig: null,
+ mintSupply: null,
+ bondingCurve: curve,
+ amount: tokens,
+ });
quote = {
tokens_in: tokenRaw,
sol_out: Number(lamports.toString()) / LAMPORTS_PER_SOL_Q,
diff --git a/api/widgets/_demo-fixtures.js b/api/widgets/_demo-fixtures.js
index d5afab3f9..a3398b0d0 100644
--- a/api/widgets/_demo-fixtures.js
+++ b/api/widgets/_demo-fixtures.js
@@ -114,7 +114,7 @@ export const DEMO_WIDGETS = {
id: 'wdgt_demo_hotspot',
type: 'hotspot-tour',
name: 'Hotspot Tour',
- modelUrl: SOLDIER,
+ modelUrl: CZ,
config: {
background: '#0a0a0a',
accent: '#8b5cf6',
@@ -122,7 +122,26 @@ export const DEMO_WIDGETS = {
showControls: false,
autoRotate: false,
envPreset: 'neutral',
- hotspots: [],
+ hotspots: [
+ {
+ id: 'head',
+ label: 'Head',
+ position: [0, 0.75, 0.1],
+ body: 'The agent\'s head — face mesh, eyes, and the empathy layer that drives six real-time emotion states.',
+ },
+ {
+ id: 'chest',
+ label: 'Chest',
+ position: [0.15, 0.2, 0.18],
+ body: 'Torso anchor — bone the camera tracks during conversation and where overlay badges (ERC-8004 passport, reputation) attach.',
+ },
+ {
+ id: 'hand',
+ label: 'Hand',
+ position: [-0.35, -0.15, 0.1],
+ body: 'Right hand — drives wave, point, and reach gestures triggered by the agent\'s skill layer (wave, lookAt, playClip).',
+ },
+ ],
},
}),
diff --git a/docs/contributing.md b/docs/contributing.md
index d7650815e..774751df7 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -289,4 +289,4 @@ Core team response times: typically 2–3 business days on GitHub, faster in Dis
## License
-By contributing, you agree that your contributions will be licensed under the [MIT License](../../LICENSE).
+By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](../../LICENSE).
diff --git a/docs/introduction.md b/docs/introduction.md
index 0f60fe3a6..9b439e9e9 100644
--- a/docs/introduction.md
+++ b/docs/introduction.md
@@ -8,7 +8,7 @@ The result is an agent that doesn't just respond in a chat box. It occupies a th
**Key facts:**
-- **License:** MIT — use it, fork it, self-host it
+- **License:** Apache-2.0 — use it, fork it, self-host it
- **Hosted platform:** [https://three.ws/](https://three.ws/)
- **CDN library:** `https://cdn.three.wsagent-3d.js`
- **No server required** for basic use — the viewer, agent runtime, and skill system all run in the browser via WebGL 2.0
@@ -44,7 +44,7 @@ For developers who don't need any of this, on-chain identity is entirely optiona
### Open
-The platform is MIT licensed. You can self-host the full application, publish the library to your own CDN, or fork and modify any layer. The manifest format, embed protocol, and agent spec are all documented in the `/specs` directory of the repository.
+The platform is Apache-2.0 licensed. You can self-host the full application, publish the library to your own CDN, or fork and modify any layer. The manifest format, embed protocol, and agent spec are all documented in the `/specs` directory of the repository.
---
diff --git a/docs/sdk.md b/docs/sdk.md
index 364c070a8..31df4724c 100644
--- a/docs/sdk.md
+++ b/docs/sdk.md
@@ -7,7 +7,7 @@ This document covers programmatic use of three.ws beyond simple embedding. There
| **Web component bundle** | `agent-3d.js` (CDN or `TARGET=lib` build) | Drop-in `<agent-3d>` element + programmatic viewer/runtime APIs |
| **AgentKit SDK** | `@nirholas/agent-kit` | Ship an ERC-8004 agent: chat panel, on-chain registration, `.well-known` manifests |
-Both are MIT-licensed. Neither requires the other.
+Both are Apache-2.0 licensed. Neither requires the other.
---
diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.js
index 8c36baa24..7851eb620 100644
--- a/public/dashboard/dashboard.js
+++ b/public/dashboard/dashboard.js
@@ -303,6 +303,8 @@ function agentCard(a, onRemoved) {
const wallet = a.wallet_address ? `${a.wallet_address.slice(0, 6)}…${a.wallet_address.slice(-4)}` : '';
const agentIdEnc = encodeURIComponent(a.id);
+ const hasAvatar = Boolean(a.avatar_id);
+ const embedDisabledAttr = hasAvatar ? '' : 'disabled title="Link an avatar (Edit → Avatar) to enable embed"';
el.innerHTML = `
<div class="preview" data-agent-preview></div>
<h3>${esc(a.name || 'Agent')}</h3>
@@ -328,31 +330,110 @@ function agentCard(a, onRemoved) {
</details>
<div class="footer">
<div class="actions">
- <a class="btn sec" href="/agent/${agentIdEnc}">Open</a>
- <a class="btn sec" href="/agent-edit.html?id=${agentIdEnc}">Edit</a>
+ <a class="btn sec" href="/agent/${agentIdEnc}" title="Open public agent page">Open</a>
+ <a class="btn sec" href="/agent-edit.html?id=${agentIdEnc}" title="Edit name, persona, avatar, skills">Edit</a>
+ <button class="btn sec" data-share type="button" title="Copy public agent link">Share</button>
+ <button class="btn sec" data-embed type="button" ${embedDisabledAttr}>Embed</button>
${a.is_registered ? '' : `<a class="btn sec" href="/deploy${a.avatar_id ? '?avatar=' + encodeURIComponent(a.avatar_id) : ''}" title="Mint as ERC-8004 agent">Deploy on-chain</a>`}
- <button class="btn sec danger" data-del>Delete</button>
+ <div class="more-menu-wrap"><button class="btn sec" data-more type="button" aria-haspopup="menu" aria-expanded="false">More ▾</button></div>
</div>
</div>
`;
mountAgentAvatarPreview(el.querySelector('[data-agent-preview]'), a);
- el.querySelector('[data-del]').addEventListener('click', async () => {
- if (!confirm(`Delete "${a.name}"? This cannot be undone.`)) return;
- try {
- await api.deleteAgent(a.id);
- el.remove();
- toast(`Deleted "${a.name}"`);
- onRemoved?.();
- } catch (err) {
- toast(err.message || 'Delete failed', true);
+ el.querySelector('[data-share]').addEventListener('click', (e) => {
+ copyToClipboard(`${location.origin}/agent/${a.id}`, e.currentTarget);
+ });
+ el.querySelector('[data-embed]').addEventListener('click', (e) => {
+ if (e.currentTarget.disabled) return;
+ openAgentEmbedModal(a);
+ });
+ el.querySelector('[data-more]').addEventListener('click', (e) => {
+ const btn = e.currentTarget;
+ if (_openMoreMenu?.triggerBtn === btn) {
+ closeMoreMenu();
+ return;
}
+ openMoreMenu(btn, agentMoreItems(a, el, onRemoved));
});
return el;
}
+// Items shown in an agent card's "More ▾" dropdown. Each item is wired to a
+// real action — no placeholders.
+function agentMoreItems(a, el, onRemoved) {
+ const agentIdEnc = encodeURIComponent(a.id);
+ const items = [
+ {
+ label: 'Open public page ↗',
+ run: () => window.open(`/agent/${agentIdEnc}`, '_blank', 'noopener'),
+ },
+ {
+ label: 'View manifest JSON ↗',
+ run: () => window.open(`/api/agents/${agentIdEnc}/manifest`, '_blank', 'noopener'),
+ },
+ {
+ label: 'Show QR code',
+ run: () => openQrModal(`${location.origin}/agent/${a.id}`, a.name || 'Agent'),
+ },
+ {
+ label: 'Duplicate',
+ run: () => duplicateAgent(a, el),
+ },
+ ];
+ if (a.is_registered) {
+ items.push({
+ label: 'View on-chain passport ↗',
+ run: () => {
+ const meta = a.meta || {};
+ const asset = meta.solana_asset || meta.metaplex_asset || a.solana_asset;
+ const url = asset
+ ? `/agent-passport.html?asset=${encodeURIComponent(asset)}`
+ : `/agent-badge.html?id=${agentIdEnc}`;
+ window.open(url, '_blank', 'noopener');
+ },
+ });
+ }
+ items.push({
+ label: 'Delete',
+ danger: true,
+ run: async () => {
+ if (!confirm(`Delete "${a.name}"? This cannot be undone.`)) return;
+ try {
+ await api.deleteAgent(a.id);
+ el.remove();
+ toast(`Deleted "${a.name}"`);
+ onRemoved?.();
+ } catch (err) {
+ toast(err.message || 'Delete failed', true);
+ }
+ },
+ });
+ return items;
+}
+
+async function duplicateAgent(a, sourceEl) {
+ const baseName = a.name || 'Agent';
+ const newName = `${baseName} copy`.slice(0, 100);
+ try {
+ const payload = { name: newName };
+ if (a.description) payload.description = a.description;
+ if (a.skills?.length) payload.skills = a.skills;
+ if (a.avatar_id) payload.avatar_id = a.avatar_id;
+ const { agent } = await api.createAgent(payload);
+ const list = sourceEl.parentElement;
+ if (list) {
+ const newCard = agentCard(agent, () => maybeRenderEmpty(list, list.previousElementSibling || list));
+ sourceEl.insertAdjacentElement('afterend', newCard);
+ }
+ toast(`Created "${agent.name}"`);
+ } catch (err) {
+ toast(err.message || 'Duplicate failed', true);
+ }
+}
+
// Mount a 3D model-viewer (or thumbnail fallback) for an agent card.
// Lazy-loads when the card scrolls into view. For private linked avatars,
// fetches a short-lived signed URL via /api/avatars/:id.
@@ -543,6 +624,10 @@ function avatarCard(a) {
const copyDisabledAttr = isPrivate
? 'disabled title="Private avatars have no public link. Switch to unlisted or public to share."'
: '';
+ const hasAgent = Boolean(a.agent_id);
+ const makeAgentAttrs = hasAgent
+ ? 'disabled title="This avatar already has an agent linked"'
+ : 'title="Create a new agent linked to this avatar"';
el.innerHTML = `
<div class="preview" data-preview></div>
<h3>${esc(a.name)}</h3>
@@ -554,11 +639,9 @@ function avatarCard(a) {
<a class="btn" href="${attr(studioUrl)}" title="Open this avatar in Studio to build an embeddable widget">Studio</a>
<button class="btn" data-embed ${embedDisabledAttr}>Embed</button>
<a class="btn sec" href="${attr(viewUrl)}" target="_blank" rel="noopener" title="Open the public viewer in a new tab">View</a>
- <button class="btn sec" data-copy-url ${copyDisabledAttr}>Copy URL</button>
- <a class="btn sec" href="/dashboard/edit/${encodeURIComponent(a.id)}">Edit</a>
- <button class="btn sec" data-replace>Replace GLB</button>
- <a class="btn sec" href="/deploy?avatar=${encodeURIComponent(a.id)}" title="Mint as ERC-8004 agent">Deploy on-chain</a>
- <button class="btn sec danger" data-del>Delete</button>
+ <button class="btn sec" data-make-agent type="button" ${makeAgentAttrs}>Make agent</button>
+ <button class="btn sec" data-download type="button" title="Download the .glb file">Download</button>
+ <div class="more-menu-wrap"><button class="btn sec" data-more type="button" aria-haspopup="menu" aria-expanded="false">More ▾</button></div>
</div>
</div>
<div data-wallet-host></div>
@@ -596,27 +679,131 @@ function avatarCard(a) {
e.target.value = a.visibility;
}
});
- el.querySelector('[data-del]').addEventListener('click', async () => {
- if (!confirm(`Delete "${a.name}"?`)) return;
- try {
- await api.deleteAvatar(a.id);
- el.remove();
- } catch (err) {
- alert(err.message);
- }
- });
- el.querySelector('[data-replace]').addEventListener('click', () => replaceGlbFlow(a, el));
el.querySelector('[data-embed]').addEventListener('click', (e) => {
if (e.currentTarget.disabled) return;
openAvatarEmbedModal(a);
});
- el.querySelector('[data-copy-url]').addEventListener('click', (e) => {
+ el.querySelector('[data-make-agent]').addEventListener('click', async (e) => {
if (e.currentTarget.disabled) return;
- copyToClipboard(`${location.origin}/avatars/${a.id}`, e.currentTarget);
+ await makeAgentFromAvatar(a, e.currentTarget);
+ });
+ el.querySelector('[data-download]').addEventListener('click', async (e) => {
+ await downloadAvatarGlb(a, e.currentTarget);
+ });
+ el.querySelector('[data-more]').addEventListener('click', (e) => {
+ const btn = e.currentTarget;
+ if (_openMoreMenu?.triggerBtn === btn) {
+ closeMoreMenu();
+ return;
+ }
+ openMoreMenu(btn, avatarMoreItems(a, el));
});
return el;
}
+function avatarMoreItems(a, el) {
+ const isPrivate = a.visibility === 'private';
+ const items = [];
+ if (!isPrivate) {
+ items.push({
+ label: 'Copy public URL',
+ run: () => copyToClipboard(`${location.origin}/avatars/${a.id}`),
+ });
+ }
+ items.push({
+ label: 'Show QR code',
+ run: () => openQrModal(`${location.origin}/avatars/${a.id}`, a.name || 'Avatar'),
+ });
+ items.push({
+ label: 'Edit details',
+ run: () => goto(`edit/${encodeURIComponent(a.id)}`),
+ });
+ items.push({
+ label: 'Replace GLB…',
+ run: () => replaceGlbFlow(a, el),
+ });
+ items.push({
+ label: 'Deploy on-chain',
+ run: () => { location.href = `/deploy?avatar=${encodeURIComponent(a.id)}`; },
+ });
+ items.push({
+ label: 'Delete',
+ danger: true,
+ run: async () => {
+ if (!confirm(`Delete "${a.name}"?`)) return;
+ try {
+ await api.deleteAvatar(a.id);
+ el.remove();
+ toast(`Deleted "${a.name}"`);
+ } catch (err) {
+ toast(err.message || 'Delete failed', true);
+ }
+ },
+ });
+ return items;
+}
+
+async function makeAgentFromAvatar(a, btn) {
+ const original = btn.textContent;
+ btn.disabled = true;
+ btn.textContent = 'Creating…';
+ try {
+ const baseName = a.name || 'Agent';
+ const { agent } = await api.createAgent({
+ name: baseName.slice(0, 100),
+ avatar_id: a.id,
+ });
+ toast(`Created agent "${agent.name}"`);
+ // Swap the button for a plain link so the original click handler that
+ // calls makeAgentFromAvatar can't fire again and race a second create.
+ const link = document.createElement('a');
+ link.className = 'btn sec';
+ link.href = `/agent-edit.html?id=${encodeURIComponent(agent.id)}`;
+ link.textContent = 'Open agent →';
+ link.title = 'Open the newly-created agent';
+ btn.replaceWith(link);
+ } catch (err) {
+ btn.disabled = false;
+ btn.textContent = original;
+ toast(err.message || 'Failed to create agent', true);
+ }
+}
+
+async function downloadAvatarGlb(a, btn) {
+ const original = btn.textContent;
+ btn.disabled = true;
+ btn.textContent = 'Preparing…';
+ try {
+ let url = a.model_url;
+ if (!url) {
+ const { avatar } = await api.getAvatar(a.id);
+ url = avatar?.url || avatar?.model_url;
+ }
+ if (!url) throw new Error('No download URL available');
+ const resp = await fetch(url, { credentials: 'omit' });
+ if (!resp.ok) throw new Error(`Download failed (${resp.status})`);
+ const blob = await resp.blob();
+ const safeName = (a.name || 'avatar').replace(/[^a-z0-9._-]+/gi, '_').slice(0, 80) || 'avatar';
+ const link = document.createElement('a');
+ const objectUrl = URL.createObjectURL(blob);
+ link.href = objectUrl;
+ link.download = `${safeName}.glb`;
+ document.body.appendChild(link);
+ link.click();
+ link.remove();
+ setTimeout(() => URL.revokeObjectURL(objectUrl), 5000);
+ btn.textContent = 'Downloaded';
+ setTimeout(() => {
+ btn.textContent = original;
+ btn.disabled = false;
+ }, 1200);
+ } catch (err) {
+ btn.textContent = original;
+ btn.disabled = false;
+ toast(err.message || 'Download failed', true);
+ }
+}
+
// Mount the agent's wallet card under an avatar. If the avatar has no linked
// agent, show a "Create agent" CTA pointing at the on-chain deploy flow.
function mountAvatarWalletSection(host, a) {
@@ -4067,6 +4254,158 @@ function openAvatarEmbedModal(avatar) {
refresh();
}
+// ── Agent embed modal ──────────────────────────────────────────────────────
+// Reuses the avatar embed flow against the agent's linked avatar. Requires
+// avatar_id; callers gate the button when no avatar is linked.
+function openAgentEmbedModal(agent) {
+ if (!agent?.avatar_id) {
+ toast('Link an avatar to the agent first', true);
+ return;
+ }
+ openAvatarEmbedModal({
+ id: agent.avatar_id,
+ name: agent.name || 'Agent',
+ });
+}
+
+// ── QR modal ────────────────────────────────────────────────────────────────
+// Renders a scannable QR code for a URL. Uses the qrcode library via esm.sh,
+// matching the existing pattern in src/marketplace.js and dashboard/portfolio.html.
+async function openQrModal(url, title) {
+ const overlay = document.createElement('div');
+ overlay.className = 'modal-overlay';
+ overlay.innerHTML = `
+ <div class="modal" role="dialog" aria-label="QR code" style="width:min(380px,calc(100vw - 32px))">
+ <h2>${esc(title || 'Share')}</h2>
+ <p class="sub" style="margin:0 0 16px">Scan to open on another device.</p>
+ <div id="qr-host" style="display:grid;place-items:center;padding:14px;background:#fff;border-radius:10px;margin-bottom:14px;min-height:240px">
+ <div class="muted" style="color:#666">Generating…</div>
+ </div>
+ <div style="background:#0f0f17;border:1px solid var(--border);border-radius:8px;padding:8px 10px;font-size:11px;word-break:break-all;color:#bbb;margin-bottom:14px">${esc(url)}</div>
+ <div class="row" style="justify-content:space-between;gap:8px">
+ <button class="btn sec" id="qr-copy" type="button">Copy URL</button>
+ <button class="btn sec" id="qr-close" type="button">Close</button>
+ </div>
+ </div>
+ `;
+ document.body.appendChild(overlay);
+ requestAnimationFrame(() => overlay.classList.add('open'));
+
+ const close = () => {
+ overlay.classList.remove('open');
+ setTimeout(() => {
+ overlay.remove();
+ document.removeEventListener('keydown', onKey);
+ }, 200);
+ };
+ const onKey = (e) => {
+ if (e.key === 'Escape') close();
+ };
+ document.addEventListener('keydown', onKey);
+ overlay.addEventListener('click', (e) => {
+ if (e.target === overlay) close();
+ });
+ overlay.querySelector('#qr-close').addEventListener('click', close);
+ overlay
+ .querySelector('#qr-copy')
+ .addEventListener('click', (e) => copyToClipboard(url, e.currentTarget));
+
+ const host = overlay.querySelector('#qr-host');
+ try {
+ const mod = await import('https://esm.sh/[email protected]');
+ const QRCode = mod.default || mod;
+ const canvas = document.createElement('canvas');
+ await QRCode.toCanvas(canvas, url, {
+ width: 240,
+ margin: 1,
+ color: { dark: '#000000', light: '#ffffff' },
+ });
+ host.innerHTML = '';
+ host.appendChild(canvas);
+ } catch (err) {
+ host.innerHTML = `<div style="color:#a33;font-size:12px">QR generation failed: ${esc(err.message || 'error')}</div>`;
+ }
+}
+
+// ── Dropdown "More ▾" menu ──────────────────────────────────────────────────
+// Anchors a small menu to the trigger button. Each item is { label, run, danger? }.
+// One menu open at a time; closes on outside click, Escape, or item click.
+let _openMoreMenu = null;
+function openMoreMenu(triggerBtn, items) {
+ closeMoreMenu();
+ if (!items?.length) return;
+
+ const menu = document.createElement('div');
+ menu.className = 'more-menu';
+ menu.setAttribute('role', 'menu');
+ items.forEach((item, i) => {
+ const btn = document.createElement('button');
+ btn.type = 'button';
+ btn.setAttribute('role', 'menuitem');
+ btn.className = 'more-menu-item' + (item.danger ? ' danger' : '');
+ btn.textContent = item.label;
+ btn.addEventListener('click', (e) => {
+ e.stopPropagation();
+ closeMoreMenu();
+ try {
+ item.run();
+ } catch (err) {
+ toast(err.message || 'Action failed', true);
+ }
+ });
+ menu.appendChild(btn);
+ if (i === 0) requestAnimationFrame(() => btn.focus());
+ });
+
+ document.body.appendChild(menu);
+ const rect = triggerBtn.getBoundingClientRect();
+ const menuRect = menu.getBoundingClientRect();
+ let left = rect.right - menuRect.width;
+ if (left < 8) left = 8;
+ let top = rect.bottom + 4;
+ if (top + menuRect.height > window.innerHeight - 8) {
+ top = rect.top - menuRect.height - 4;
+ }
+ menu.style.left = `${Math.round(left + window.scrollX)}px`;
+ menu.style.top = `${Math.round(top + window.scrollY)}px`;
+
+ triggerBtn.setAttribute('aria-expanded', 'true');
+
+ const onDocClick = (e) => {
+ if (menu.contains(e.target)) return;
+ if (triggerBtn.contains(e.target)) return;
+ closeMoreMenu();
+ };
+ const onKey = (e) => {
+ if (e.key === 'Escape') closeMoreMenu();
+ };
+ const onScroll = () => closeMoreMenu();
+ document.addEventListener('click', onDocClick, { capture: true });
+ document.addEventListener('keydown', onKey);
+ window.addEventListener('scroll', onScroll, { capture: true, passive: true });
+ window.addEventListener('resize', onScroll);
+
+ _openMoreMenu = {
+ menu,
+ triggerBtn,
+ cleanup: () => {
+ document.removeEventListener('click', onDocClick, { capture: true });
+ document.removeEventListener('keydown', onKey);
+ window.removeEventListener('scroll', onScroll, { capture: true });
+ window.removeEventListener('resize', onScroll);
+ },
+ };
+}
+
+function closeMoreMenu() {
+ if (!_openMoreMenu) return;
+ const { menu, triggerBtn, cleanup } = _openMoreMenu;
+ _openMoreMenu = null;
+ triggerBtn.setAttribute('aria-expanded', 'false');
+ cleanup();
+ menu.remove();
+}
+
// ── shared widget UI helpers ────────────────────────────────────────────────
async function copyToClipboard(text, btn) {
try {
diff --git a/public/dashboard/index.html b/public/dashboard/index.html
index 2a74dfe64..710288a94 100644
--- a/public/dashboard/index.html
+++ b/public/dashboard/index.html
@@ -240,6 +240,49 @@
.card .actions .danger:hover {
background: rgba(204, 64, 64, 0.18);
}
+ .more-menu-wrap {
+ display: inline-flex;
+ margin-left: auto;
+ }
+ .more-menu {
+ position: absolute;
+ z-index: 80;
+ min-width: 180px;
+ background: #14141c;
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 6px;
+ box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ }
+ .more-menu-item {
+ appearance: none;
+ background: transparent;
+ border: none;
+ color: #ddd;
+ font: inherit;
+ font-size: 13px;
+ padding: 7px 10px;
+ text-align: left;
+ border-radius: 6px;
+ cursor: pointer;
+ }
+ .more-menu-item:hover,
+ .more-menu-item:focus {
+ background: #1d1d28;
+ color: #fff;
+ outline: none;
+ }
+ .more-menu-item.danger {
+ color: #ffb3b3;
+ }
+ .more-menu-item.danger:hover,
+ .more-menu-item.danger:focus {
+ background: rgba(204, 64, 64, 0.18);
+ color: #ffd0d0;
+ }
.card h3 {
overflow: hidden;
text-overflow: ellipsis;
diff --git a/public/docs/contributing.md b/public/docs/contributing.md
index d7650815e..774751df7 100644
--- a/public/docs/contributing.md
+++ b/public/docs/contributing.md
@@ -289,4 +289,4 @@ Core team response times: typically 2–3 business days on GitHub, faster in Dis
## License
-By contributing, you agree that your contributions will be licensed under the [MIT License](../../LICENSE).
+By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](../../LICENSE).
diff --git a/public/docs/introduction.md b/public/docs/introduction.md
index 0f60fe3a6..9b439e9e9 100644
--- a/public/docs/introduction.md
+++ b/public/docs/introduction.md
@@ -8,7 +8,7 @@ The result is an agent that doesn't just respond in a chat box. It occupies a th
**Key facts:**
-- **License:** MIT — use it, fork it, self-host it
+- **License:** Apache-2.0 — use it, fork it, self-host it
- **Hosted platform:** [https://three.ws/](https://three.ws/)
- **CDN library:** `https://cdn.three.wsagent-3d.js`
- **No server required** for basic use — the viewer, agent runtime, and skill system all run in the browser via WebGL 2.0
@@ -44,7 +44,7 @@ For developers who don't need any of this, on-chain identity is entirely optiona
### Open
-The platform is MIT licensed. You can self-host the full application, publish the library to your own CDN, or fork and modify any layer. The manifest format, embed protocol, and agent spec are all documented in the `/specs` directory of the repository.
+The platform is Apache-2.0 licensed. You can self-host the full application, publish the library to your own CDN, or fork and modify any layer. The manifest format, embed protocol, and agent spec are all documented in the `/specs` directory of the repository.
---
diff --git a/public/docs/sdk.md b/public/docs/sdk.md
index 364c070a8..31df4724c 100644
--- a/public/docs/sdk.md
+++ b/public/docs/sdk.md
@@ -7,7 +7,7 @@ This document covers programmatic use of three.ws beyond simple embedding. There
| **Web component bundle** | `agent-3d.js` (CDN or `TARGET=lib` build) | Drop-in `<agent-3d>` element + programmatic viewer/runtime APIs |
| **AgentKit SDK** | `@nirholas/agent-kit` | Ship an ERC-8004 agent: chat panel, on-chain registration, `.well-known` manifests |
-Both are MIT-licensed. Neither requires the other.
+Both are Apache-2.0 licensed. Neither requires the other.
---
diff --git a/public/my-agents/index.html b/public/my-agents/index.html
index 0cfca534f..6bc4a52af 100644
--- a/public/my-agents/index.html
+++ b/public/my-agents/index.html
@@ -9,6 +9,12 @@
<link rel="canonical" href="https://three.ws/my-agents" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/my-agents/my-agents.css" />
+ <script
+ type="module"
+ src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"
+ integrity="sha384-sr9b4Ux0WhAUGclJ0ym0FSY2zSOMmNSn0bP/SA0e6bNCrpn/5W3QL8mm+LdlQMKw"
+ crossorigin="anonymous"
+ ></script>
</head>
<body>
<header class="my-agents-header">
diff --git a/public/my-agents/my-agents.css b/public/my-agents/my-agents.css
index 41360ec25..3c98d4a3b 100644
--- a/public/my-agents/my-agents.css
+++ b/public/my-agents/my-agents.css
@@ -173,6 +173,14 @@ a:hover {
display: block;
}
+.my-agents-card__thumb model-viewer {
+ width: 100%;
+ height: 100%;
+ display: block;
+ background: #0f0f17;
+ --poster-color: #0f0f17;
+}
+
.my-agents-card__body {
padding: 14px 16px;
display: flex;
diff --git a/public/my-agents/my-agents.js b/public/my-agents/my-agents.js
index b0ef24a67..f0042f972 100644
--- a/public/my-agents/my-agents.js
+++ b/public/my-agents/my-agents.js
@@ -168,10 +168,21 @@ function buildCard(agent) {
card.className = 'my-agents-card';
card.setAttribute('aria-label', `Agent: ${agent.name}`);
- const thumbSrc = agent.glbUrl || agent.image;
- const thumbHtml = thumbSrc
- ? `<img src="${escapeHtml(thumbSrc)}" alt="${escapeHtml(agent.name)} preview" loading="lazy" />`
- : `<span aria-hidden="true">🤖</span>`;
+ const thumbHtml = agent.glbUrl
+ ? `<model-viewer
+ src="${escapeHtml(agent.glbUrl)}"
+ alt="${escapeHtml(agent.name)} 3D avatar"
+ camera-controls
+ auto-rotate
+ shadow-intensity="1"
+ exposure="1"
+ tone-mapping="aces"
+ loading="lazy"
+ reveal="auto"
+ ></model-viewer>`
+ : agent.image
+ ? `<img src="${escapeHtml(agent.image)}" alt="${escapeHtml(agent.name)} preview" loading="lazy" />`
+ : `<span aria-hidden="true">🤖</span>`;
card.innerHTML = `
<div class="my-agents-card__thumb">${thumbHtml}</div>
diff --git a/src/agent-detail.css b/src/agent-detail.css
index 368513358..6f7dd945c 100644
--- a/src/agent-detail.css
+++ b/src/agent-detail.css
@@ -138,6 +138,27 @@ a { color: inherit; text-decoration: none; }
font-weight: 500;
color: var(--ad-text);
}
+.ad-token-cta {
+ display: inline-flex; align-items: center; gap: 6px;
+ margin-top: 12px;
+ padding: 9px 14px;
+ border-radius: 9px;
+ background: rgba(120, 200, 140, 0.16);
+ border: 1px solid rgba(120, 200, 140, 0.42);
+ color: #c6f0d6;
+ font-size: 13px; font-weight: 600;
+ letter-spacing: -0.005em;
+ text-decoration: none;
+ cursor: pointer;
+ transition: background 0.15s, border-color 0.15s, color 0.15s;
+}
+.ad-token-cta:hover:not(:disabled) {
+ background: rgba(120, 200, 140, 0.26);
+ border-color: rgba(120, 200, 140, 0.65);
+ color: #d8f5e2;
+}
+.ad-token-cta:disabled { opacity: 0.55; cursor: wait; }
+
.ad-bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--ad-cyan); }
.ad-bullet-amber { background: var(--ad-amber); }
.ad-bullet-green { background: var(--ad-green); }
diff --git a/src/agent-detail.js b/src/agent-detail.js
index f8aa15530..6e5b72b30 100644
--- a/src/agent-detail.js
+++ b/src/agent-detail.js
@@ -154,12 +154,60 @@ function render(agent) {
if (agent.token) {
$('ad-token-body').classList.remove('ad-muted');
$('ad-token-body').textContent = '';
- $('ad-token-body').appendChild(
- el('div', { class: 'ad-row ad-row-split' }, [
- el('span', { text: agent.token.symbol || 'TOKEN' }),
- el('span', { class: 'ad-mono', text: shortAddr(agent.token.mint) }),
- ]),
- );
+ const tokenRow = el('div', { class: 'ad-row ad-row-split' }, [
+ el('span', { text: agent.token.symbol || 'TOKEN' }),
+ el('span', { class: 'ad-mono', text: shortAddr(agent.token.mint) }),
+ ]);
+ $('ad-token-body').appendChild(tokenRow);
+ const dashLink = agent.token.pumpfun_url
+ || (agent.token.cluster === 'devnet'
+ ? `https://explorer.solana.com/address/${agent.token.mint}?cluster=devnet`
+ : `https://pump.fun/${agent.token.mint}`);
+ const viewBtn = el('a', {
+ class: 'ad-token-cta',
+ href: dashLink,
+ target: '_blank',
+ rel: 'noopener noreferrer',
+ text: `View on ${agent.token.cluster === 'devnet' ? 'Solana Explorer' : 'pump.fun'} →`,
+ });
+ $('ad-token-body').appendChild(viewBtn);
+ } else if (agent.isOwner) {
+ $('ad-token-body').classList.remove('ad-muted');
+ $('ad-token-body').textContent = '';
+ const launchBtn = el('button', {
+ class: 'ad-token-cta',
+ type: 'button',
+ text: '🚀 Launch agent token',
+ });
+ launchBtn.addEventListener('click', async () => {
+ launchBtn.disabled = true;
+ try {
+ const { openLaunchTokenModal } = await import('/src/pump/launch-token-modal.js');
+ const rec = agent.rawMetadata || {};
+ const onchain = rec.onchain || rec.meta?.onchain || null;
+ const needsDeploy = !onchain || onchain.family !== 'solana';
+ const imageUrl =
+ rec.avatar_thumbnail_url || rec.meta?.thumbnail_url || agent.avatar || '';
+ openLaunchTokenModal({
+ agentId: agent.id,
+ agentName: agent.name,
+ imageUrl,
+ needsDeploy,
+ agentForDeploy: needsDeploy
+ ? {
+ id: agent.id,
+ name: rec.name || agent.name,
+ description: rec.description || '',
+ avatar_id: rec.avatar_id || null,
+ skills: rec.skills || undefined,
+ }
+ : null,
+ });
+ } finally {
+ launchBtn.disabled = false;
+ }
+ });
+ $('ad-token-body').appendChild(launchBtn);
}
$('ad-rewards').textContent = String(agent.creatorRewards ?? 0);
@@ -600,6 +648,9 @@ function normalize(rec, avatar) {
tradeUrl: rec.token?.mint ? `https://magiceden.io/marketplace/${rec.token.mint}` : '#',
token: rec.token || null,
services,
+ // The /api/agents/:id endpoint only includes `user_id` in the response when
+ // the requester is the owner — see api/agents.js decorate(row, isOwner).
+ isOwner: !!rec.user_id,
rawMetadata: rec,
};
}
diff --git a/vercel.json b/vercel.json
index 4c1938561..2d74aefb6 100644
--- a/vercel.json
+++ b/vercel.json
@@ -572,6 +572,10 @@
"src": "/api/onboarding/link-avatar",
"dest": "/api/onboarding/[action]?action=link-avatar"
},
+ {
+ "src": "/api/pump/build-metadata",
+ "dest": "/api/pump/[action]?action=build-metadata"
+ },
{
"src": "/api/pump/channel-feed",
"dest": "/api/pump/[action]?action=channel-feed"