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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title data-i18n="agent_index.meta_title">Agent Home — three.ws</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="An embodied 3D AI agent — body, place, identity, memory."
data-i18n-attr="content:agent_index.meta_description"/>
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="/style.css" />
<link rel="stylesheet" href="/fonts/fonts.css" />
<!-- unfurl (populated at runtime from identity) -->
<meta property="og:type" content="website" />
<meta property="og:title" content="Agent" id="og-title" data-i18n-attr="content:agent_index.meta_og_title"/>
<meta property="og:description" content="An embodied three.ws." id="og-description" data-i18n-attr="content:agent_index.meta_og_description"/>
<meta property="og:image" content="" id="og-image" />
<meta property="og:url" content="" id="og-url" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Agent" id="tw-title" data-i18n-attr="content:agent_index.meta_twitter_title"/>
<meta name="twitter:description" content="" id="tw-description" />
<meta name="twitter:image" content="" id="tw-image" />
<link
rel="alternate"
type="application/json+oembed"
id="oembed-link"
title="Agent oEmbed"
/>
<style>
body {
overflow: auto;
display: flex;
flex-direction: column;
}
.agent-page-header {
display: flex;
align-items: center;
gap: 1rem;
padding: 1rem 1.618rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.agent-page-header a {
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
font-size: 0.764rem;
}
.agent-page-header a:hover {
color: rgba(255, 255, 255, 0.8);
}
.agent-page-hero {
max-width: 520px;
margin: 4rem auto 2rem;
padding: 0 1rem;
text-align: center;
}
.agent-page-title {
font-size: 1.618rem;
font-weight: 300;
color: #e5e5e5;
letter-spacing: -0.02em;
margin: 0 0 0.618rem;
}
.agent-page-subtitle {
font-size: 0.764rem;
color: rgba(255, 255, 255, 0.35);
line-height: 1.618;
}
.agent-page-card-wrap {
max-width: 420px;
margin: 0 auto;
padding: 0 1rem 4rem;
}
/* Expand the timeline on standalone page */
.agent-page-card-wrap .agent-home-timeline {
max-height: 320px;
}
/* Expand the panel to fill the card */
.agent-page-card-wrap .agent-home-panel {
background: rgba(12, 12, 18, 0.98);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
}
.agent-embed-hint {
max-width: 420px;
margin: 1.618rem auto 0;
padding: 0 1rem;
}
.agent-embed-tabs {
display: flex;
gap: 0.382rem;
margin-bottom: 0.618rem;
}
.agent-embed-tab {
background: transparent;
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.5);
font-size: 0.618rem;
padding: 0.236rem 0.618rem;
border-radius: 999px;
cursor: pointer;
font-family: inherit;
}
.agent-embed-tab.active {
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.9);
border-color: rgba(255, 255, 255, 0.2);
}
.agent-embed-code-wrap {
position: relative;
}
.agent-embed-code {
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 8px;
padding: 0.618rem 1rem;
padding-right: 3.8rem;
font-family: monospace;
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.55);
word-break: break-all;
line-height: 1.5;
}
.agent-embed-copy {
position: absolute;
top: 0.382rem;
right: 0.382rem;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.6);
font-size: 0.618rem;
padding: 0.236rem 0.618rem;
border-radius: 6px;
cursor: pointer;
font-family: inherit;
}
.agent-embed-copy:hover {
color: rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.1);
}
.agent-embed-copy.copied {
color: #86efac;
border-color: rgba(134, 239, 172, 0.3);
}
.agent-embed-label {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.25);
margin-bottom: 0.382rem;
}
.agent-embed-preview-link {
display: inline-block;
margin-top: 0.618rem;
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.35);
text-decoration: none;
}
.agent-embed-preview-link:hover {
color: rgba(255, 255, 255, 0.7);
}
.agent-skills-full {
max-width: 420px;
margin: 1.618rem auto 0;
padding: 0 1rem;
}
.agent-skills-title {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.25);
margin-bottom: 0.618rem;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.agent-skills-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 0.618rem;
}
.agent-skill-card {
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 8px;
padding: 0.618rem;
}
.agent-skill-card-name {
font-size: 0.764rem;
font-weight: 500;
color: rgba(255, 255, 255, 0.7);
margin-bottom: 0.236rem;
}
.agent-skill-card-desc {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.3);
line-height: 1.382;
}
.loading-placeholder {
color: rgba(255, 255, 255, 0.2);
font-size: 0.764rem;
text-align: center;
padding: 2rem;
}
/* ── Hub actions row ────────────────────────────────────────────────── */
.agent-hub-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
padding: 0.75rem 1rem;
border-top: 1px solid rgba(255, 255, 255, 0.06);
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.agent-hub-btn {
display: inline-flex;
align-items: center;
gap: 0.382rem;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
font-size: 0.718rem;
font-family: inherit;
padding: 0.382rem 0.75rem;
border-radius: 999px;
cursor: pointer;
transition:
background var(--duration-fast),
border-color var(--duration-fast),
color var(--duration-fast);
white-space: nowrap;
}
.agent-hub-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.2);
color: rgba(255, 255, 255, 0.95);
}
.agent-hub-btn:disabled {
opacity: 0.5;
cursor: default;
}
.agent-hub-btn svg {
flex-shrink: 0;
opacity: 0.7;
}
.agent-hub-opt {
font-size: 0.618rem;
opacity: 0.45;
}
.hub-btn--deployed {
border-color: rgba(134, 239, 172, 0.25);
color: #86efac;
}
.hub-btn--deployed svg {
opacity: 0.9;
}
/* ── Embed modal ────────────────────────────────────────────────────── */
.aem-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 9000;
opacity: 0;
transition: opacity var(--duration-fast);
}
.aem-overlay.aem-open {
opacity: 1;
}
.aem-modal {
background: #101010;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
width: min(480px, calc(100vw - 2rem));
max-height: calc(100vh - 4rem);
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.aem-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.25rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.aem-title {
font-size: 0.875rem;
font-weight: 500;
color: rgba(255, 255, 255, 0.85);
}
.aem-close {
background: none;
border: none;
color: rgba(255, 255, 255, 0.4);
font-size: 1.25rem;
line-height: 1;
cursor: pointer;
padding: 0.25rem;
border-radius: 4px;
}
.aem-close:hover {
color: rgba(255, 255, 255, 0.8);
}
.aem-body {
padding: 1rem 1.25rem 1.25rem;
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.aem-tabs {
display: flex;
gap: 0.382rem;
}
.aem-tab {
background: transparent;
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.45);
font-size: 0.618rem;
padding: 0.236rem 0.618rem;
border-radius: 999px;
cursor: pointer;
font-family: inherit;
transition:
background var(--duration-fast),
color var(--duration-fast);
}
.aem-tab.active {
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.9);
border-color: rgba(255, 255, 255, 0.2);
}
.aem-snippet-wrap {
position: relative;
}
.aem-snippet {
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 8px;
padding: 0.75rem 1rem;
padding-right: 4rem;
font-family: monospace;
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.6);
white-space: pre-wrap;
word-break: break-all;
line-height: 1.6;
margin: 0;
}
.aem-copy {
position: absolute;
top: 0.382rem;
right: 0.382rem;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.6);
font-size: 0.618rem;
padding: 0.236rem 0.618rem;
border-radius: 6px;
cursor: pointer;
font-family: inherit;
transition:
background var(--duration-fast),
color var(--duration-fast);
}
.aem-copy:hover {
color: rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.1);
}
.aem-copy.aem-copied {
color: #86efac;
border-color: rgba(134, 239, 172, 0.3);
}
.aem-size-row {
display: flex;
align-items: center;
gap: 0.5rem;
}
.aem-size-label {
display: flex;
align-items: center;
gap: 0.382rem;
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.4);
}
.aem-size-input {
width: 64px;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 6px;
color: rgba(255, 255, 255, 0.85);
font-size: 0.764rem;
font-family: monospace;
padding: 0.2rem 0.4rem;
text-align: center;
-moz-appearance: textfield;
}
.aem-size-input::-webkit-inner-spin-button,
.aem-size-input::-webkit-outer-spin-button {
-webkit-appearance: none;
}
.aem-size-input:focus {
outline: none;
border-color: rgba(255, 255, 255, 0.3);
}
.aem-size-sep,
.aem-size-unit {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.25);
}
.aem-note {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.25);
margin: 0;
line-height: 1.5;
}
/* ── Manage Permissions Panel ────────────────────────────────────────── */
.mp-panel {
max-width: 420px;
margin: 1.618rem auto 0;
padding: 0 1rem;
}
.mp-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 0.618rem;
}
.mp-title {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.25);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.mp-refresh-btn {
background: none;
border: none;
color: rgba(255, 255, 255, 0.3);
cursor: pointer;
padding: 0.2rem;
border-radius: 4px;
line-height: 0;
transition: color var(--duration-fast);
}
.mp-refresh-btn:hover {
color: rgba(255, 255, 255, 0.7);
}
.mp-header-actions {
display: flex;
align-items: center;
gap: 0.382rem;
}
.mp-grant-header-btn {
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
font-size: 0.65rem;
font-family: inherit;
padding: 0.18rem 0.55rem;
border-radius: 999px;
cursor: pointer;
transition:
background var(--duration-fast),
color var(--duration-fast);
}
.mp-grant-header-btn:hover {
background: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.95);
}
.mp-empty-hint {
font-size: 0.7rem;
color: rgba(255, 255, 255, 0.35);
margin: 0.382rem 0 0;
font-style: italic;
}
.mp-loading,
.mp-error {
font-size: 0.764rem;
color: rgba(255, 255, 255, 0.3);
padding: 1rem 0;
}
.mp-error {
color: #fca5a5;
}
.mp-empty {
font-size: 0.764rem;
color: rgba(255, 255, 255, 0.3);
padding: 1rem 0;
text-align: center;
}
.mp-empty p {
margin: 0 0 0.618rem;
}
.mp-grant-btn {
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
font-size: 0.718rem;
font-family: inherit;
padding: 0.382rem 0.75rem;
border-radius: 999px;
cursor: pointer;
transition:
background var(--duration-fast),
color var(--duration-fast);
}
.mp-grant-btn:hover {
background: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.95);
}
.mp-card {
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 10px;
padding: 0.75rem 1rem;
margin-bottom: 0.618rem;
transition: border-color var(--duration-base);
}
.mp-card--active {
border-color: rgba(134, 239, 172, 0.15);
}
.mp-card--revoked {
opacity: 0.5;
}
.mp-card--expired {
border-color: rgba(251, 191, 36, 0.15);
}
.mp-card-top {
display: flex;
align-items: center;
gap: 0.382rem;
margin-bottom: 0.382rem;
}
.mp-badge {
font-size: 0.618rem;
padding: 0.1rem 0.45rem;
border-radius: 999px;
font-weight: 500;
}
.mp-badge--active {
background: rgba(134, 239, 172, 0.15);
color: #86efac;
}
.mp-badge--revoked {
background: rgba(255, 255, 255, 0.07);
color: rgba(255, 255, 255, 0.4);
}
.mp-badge--expired {
background: rgba(251, 191, 36, 0.12);
color: var(--warn);
}
.mp-chain-chip {
font-size: 0.618rem;
background: rgba(255, 255, 255, 0.07);
color: rgba(255, 255, 255, 0.5);
padding: 0.1rem 0.45rem;
border-radius: 999px;
}
.mp-indexer-pending {
font-size: 0.618rem;
color: rgba(251, 191, 36, 0.7);
font-style: italic;
}
.mp-card-scope {
font-size: 0.764rem;
color: rgba(255, 255, 255, 0.8);
margin-bottom: 0.236rem;
line-height: 1.4;
}
.mp-card-hash {
font-size: 0.618rem;
font-family: monospace;
color: rgba(255, 255, 255, 0.25);
margin-bottom: 0.236rem;
}
.mp-card-usage {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.35);
margin-bottom: 0.5rem;
}
.mp-card-addresses {
display: flex;
align-items: center;
gap: 0.382rem;
margin-bottom: 0.5rem;
}
.mp-addr-link {
font-size: 0.618rem;
font-family: monospace;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
}
.mp-addr-link:hover {
color: rgba(255, 255, 255, 0.8);
}
.mp-addr-arrow {
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.2);
}
.mp-card-actions {
display: flex;
gap: 0.5rem;
}
.mp-revoke-btn {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.25);
color: var(--danger);
font-size: 0.718rem;
font-family: inherit;
padding: 0.3rem 0.7rem;
border-radius: 999px;
cursor: pointer;
transition: background var(--duration-fast);
}
.mp-revoke-btn:hover:not(:disabled) {
background: rgba(239, 68, 68, 0.2);
}
.mp-revoke-btn:disabled {
opacity: 0.5;
cursor: default;
}
.mp-card-error {
font-size: 0.618rem;
color: #fca5a5;
margin-top: 0.382rem;
}
.mp-card-pending {
display: flex;
align-items: center;
gap: 0.382rem;
font-size: 0.618rem;
color: rgba(255, 255, 255, 0.5);
margin-top: 0.382rem;
}
.mp-tx-link {
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
}
.mp-tx-link:hover {
color: rgba(255, 255, 255, 0.8);
}
@keyframes mp-spin {
to {
transform: rotate(360deg);
}
}
.mp-spinner {
display: inline-block;
width: 10px;
height: 10px;
border: 1.5px solid rgba(255, 255, 255, 0.15);
border-top-color: rgba(255, 255, 255, 0.6);
border-radius: 50%;
animation: mp-spin 0.7s linear infinite;
}
/* ── Narrow screens: tighten the hero/identity + embed columns so the
standalone agent page is explicitly designed for phones, not just
left to degrade. ── */
@media (max-width: 640px) {
.agent-page-header {
padding: 0.764rem 1rem;
gap: 0.618rem;
}
.agent-page-hero {
margin: 2rem auto 1.5rem;
}
.agent-page-title {
font-size: 1.382rem;
}
.agent-page-card-wrap,
.agent-embed-hint,
.agent-skills-full {
max-width: 100%;
padding-left: 1rem;
padding-right: 1rem;
}
.agent-page-card-wrap .agent-home-timeline {
max-height: 260px;
}
.agent-skills-grid {
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
.agent-embed-code {
font-size: 0.58rem;
}
}
@media (max-width: 380px) {
.agent-embed-tabs {
flex-wrap: wrap;
}
}
</style>
</head>
<body>
<div class="agent-page-header">
<a href="/" data-i18n="agent_index.three_ws">← three.ws</a>
</div>
<div class="agent-page-hero">
<h1 class="agent-page-title" id="page-agent-name" data-i18n="agent_index.agent">Agent</h1>
<p class="agent-page-subtitle" id="page-agent-desc" data-i18n="agent_index.embodied_present_persistent">Embodied. Present. Persistent.</p>
</div>
<!-- Agent home card rendered by AgentHome -->
<div class="agent-page-card-wrap">
<div id="agent-home-container">
<div class="loading-placeholder">Loading agent…</div>
</div>
</div>
<!-- $AGENT pump.fun token widget (rendered when this agent has a launched mint) -->
<div id="agent-token-widget"></div>
<!-- Permissions panel (owner only, mounted by JS) -->
<div id="agent-permissions-mount"></div>
<!-- Skills catalog -->
<div class="agent-skills-full" id="agent-skills-section" style="display: none">
<div class="agent-skills-title">Skills</div>
<div class="agent-skills-grid" id="agent-skills-grid"></div>
</div>
<!-- Embed code -->
<div class="agent-embed-hint" id="agent-embed-section" style="display: none">
<div class="agent-embed-label">Share & embed</div>
<div class="agent-embed-tabs" role="tablist">
<button class="agent-embed-tab active" data-tab="iframe" data-i18n="agent_index.iframe">iframe</button>
<button class="agent-embed-tab" data-tab="link" data-i18n="agent_index.link">link</button>
<button class="agent-embed-tab" data-tab="webcomponent" data-i18n="agent_index.text"><agent-3d></button>
</div>
<div class="agent-embed-code-wrap">
<div class="agent-embed-code" id="agent-embed-code"></div>
<button class="agent-embed-copy" id="agent-embed-copy" data-i18n="agent_index.copy">copy</button>
</div>
<a
class="agent-embed-preview-link"
id="agent-embed-preview"
target="_blank"
rel="noopener"
data-i18n="agent_index.preview_embed">preview embed →</a
>
<a
class="agent-embed-preview-link"
id="agent-embed-settings"
target="_blank"
rel="noopener"
data-i18n="agent_index.embed_settings">embed settings →</a
>
</div>
<script type="module">
import { AgentIdentity } from '/src/agent-identity.js';
import { AgentMemory } from '/src/agent-memory.js';
import { AgentSkills } from '/src/agent-skills.js';
import { AgentHome } from '/src/agent-home.js';
import { protocol } from '/src/agent-protocol.js';
import { renderHubActions } from '/src/agent-hub-actions.js';
import { mountManagePanel } from '/src/permissions/manage-panel.js';
import { AgentTokenWidget } from '/src/pump/agent-token-widget.js';
import { mountPumpModals } from '/src/pump/pump-modals.js';
// Pull agent id from URL: /agent/:id
const agentId = location.pathname.split('/').filter(Boolean).pop();
async function main() {
// Fetch raw API response first — it includes user_id only for owners.
let rawAgent = null;
if (agentId) {
try {
const resp = await fetch(`/api/agents/${agentId}`, {
credentials: 'include',
});
if (resp.ok) {
const data = await resp.json();
rawAgent = data.agent || null;
}
} catch {}
}
const identity = new AgentIdentity({
agentId: agentId || undefined,
autoLoad: false,
});
await identity.load();
// Update hero
document.getElementById('page-agent-name').textContent = identity.name;
if (identity.description) {
document.getElementById('page-agent-desc').textContent = identity.description;
}
// Inject hub actions if the viewer is the owner (user_id present = owner)
const isOwner = Boolean(rawAgent?.user_id);
// Render the agent home card. Pass isOwner explicitly so owner-only
// cards (Solana wallet, ETH vanity, vanity grinder) only mount for
// the owner — AgentIdentity may not know ownership at render time.
const container = document.getElementById('agent-home-container');
container.innerHTML = '';
const home = new AgentHome(container, identity, protocol, null, { isOwner });
await home.render();
// Mount the $AGENT pump.fun token widget. Renders empty-state for
// not-yet-launched agents (with a "Launch" CTA for owners) and full
// live state when a mint exists. Wires avatar emotion to bus events.
const tokenMount = document.getElementById('agent-token-widget');
if (tokenMount && agentId) {
const widget = new AgentTokenWidget({
mount: tokenMount,
agentId,
isOwner,
protocol,
identity,
});
widget.render().catch(() => {});
// Avatar reactions: a new payment is curiosity+celebration; a
// graduation is a one-shot celebration emote.
protocol.on?.('pump-payment', () => {
protocol.emit?.('emote', { trigger: 'celebration', weight: 0.6 });
protocol.emit?.('emote', { trigger: 'curiosity', weight: 0.4 });
});
protocol.on?.('pump-graduated', () => {
protocol.emit?.('emote', { trigger: 'celebration', weight: 0.95 });
protocol.emit?.('gesture', { name: 'celebrate', duration: 2400 });
});
// Pay / governance / withdraw modals listen on window CustomEvents.
mountPumpModals({ identity, agentId });
}
if (isOwner) {
const panel = container.querySelector('.agent-home-panel');
if (panel) renderHubActions(panel, identity, rawAgent);
// Mount the permissions management panel below the agent card
const permMount = document.getElementById('agent-permissions-mount');
if (permMount) mountManagePanel({ container: permMount, agentId });
}
// Render skills catalog
if (identity.skills?.length) {
const skills = new AgentSkills(protocol, identity.memory);
const section = document.getElementById('agent-skills-section');
const grid = document.getElementById('agent-skills-grid');
section.style.display = '';
skills
.list()
.filter((s) => identity.skills.includes(s.name))
.forEach((skill) => {
const card = document.createElement('div');
card.className = 'agent-skill-card';
card.innerHTML = `
<div class="agent-skill-card-name">${skill.name}</div>
<div class="agent-skill-card-desc">${skill.description}</div>
`;
grid.appendChild(card);
});
}
// Embed code
const embedSection = document.getElementById('agent-embed-section');
const embedCode = document.getElementById('agent-embed-code');
const embedCopy = document.getElementById('agent-embed-copy');
const embedPreview = document.getElementById('agent-embed-preview');
const origin = location.origin;
const embedUrl = `${origin}/agent/${identity.id}/embed`;
const agentUrl = `${origin}/agent/${identity.id}`;
const snippets = {
iframe: `<iframe src="${embedUrl}" width="420" height="520" title="three.ws agent" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" sandbox="allow-scripts allow-same-origin allow-popups" loading="lazy"></iframe>`,
link: agentUrl,
webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
};
let current = 'iframe';
const render = () => {
embedCode.textContent = snippets[current];
};
render();
// Hide the bottom embed section for owners — they have the modal via the hub Embed button.
if (!isOwner) embedSection.style.display = '';
embedPreview.href = embedUrl;
document.getElementById('agent-embed-settings').href =
'/dashboard/api?agent=' + identity.id;
document.querySelectorAll('.agent-embed-tab').forEach((btn) => {
btn.addEventListener('click', () => {
current = btn.dataset.tab;
document
.querySelectorAll('.agent-embed-tab')
.forEach((b) => b.classList.toggle('active', b === btn));
render();
});
});
embedCopy.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(snippets[current]);
embedCopy.textContent = 'copied';
embedCopy.classList.add('copied');
setTimeout(() => {
embedCopy.textContent = 'copy';
embedCopy.classList.remove('copied');
}, 1400);
} catch {}
});
populateUnfurlMeta(identity);
}
function populateUnfurlMeta(identity) {
const id = identity?.id;
if (!id) return;
const origin = location.origin;
const name = identity.name || 'Agent';
const desc = identity.description || 'An embodied three.ws.';
const agentUrl = `${origin}/agent/${id}`;
const img = `${origin}/api/agent/${id}/og`;
const setAttr = (elId, attr, value) => {
const el = document.getElementById(elId);
if (el) el.setAttribute(attr, value);
};
setAttr('og-title', 'content', name);
setAttr('og-description', 'content', desc);
setAttr('og-image', 'content', img);
setAttr('og-url', 'content', agentUrl);
setAttr('tw-title', 'content', name);
setAttr('tw-description', 'content', desc);
setAttr('tw-image', 'content', img);
setAttr(
'oembed-link',
'href',
`${origin}/api/oembed?url=${encodeURIComponent(agentUrl)}`,
);
document.title = `${name} — three.ws`;
}
main().catch((err) => {
document.getElementById('agent-home-container').innerHTML =
`<div class="loading-placeholder">Could not load agent: ${err.message}</div>`;
});
</script>
<script src="/brand.js" defer></script>
<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
<script type="module" src="/i18n.js"></script>
</body>
</html>