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.

chore: remove legacy classic dashboard assets

nirholas84087c871b63
diff --git a/public/dashboard-classic/_dash-shell.css b/public/dashboard-classic/_dash-shell.css
deleted file mode 100644
index 072444d5b..000000000
--- a/public/dashboard-classic/_dash-shell.css
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Shared shell styling for /dashboard sub-pages. Dark theme to match dashboard. */
-:root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #ffffff;
- --border: #1a1a1a;
- --bg: #000000;
- --panel: #111111;
-}
-* { box-sizing: border-box; }
-body {
- font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
-}
-a { color: #cccccc; text-decoration: none; }
-a:hover { text-decoration: underline; }
-.dash-shell { max-width: 980px; margin: 0 auto; padding: 28px; }
-.dash-back { color: #888; font-size: 13px; margin-bottom: 10px; display: inline-block; }
-.dash-back:hover { color: #ccc; }
-h1.dash-title { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.01em; }
-.dash-sub { color: #888; margin: 4px 0 22px; font-size: 14px; }
-.dash-card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- padding: 18px;
- margin-bottom: 14px;
-}
-.dash-card h2 {
- margin: 0 0 14px;
- font-size: 14px;
- letter-spacing: 0.06em;
- text-transform: uppercase;
- color: #aaa;
-}
-.dash-btn {
- background: #1a1a1a;
- color: #eee;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 8px 14px;
- font-size: 13px;
- cursor: pointer;
-}
-.dash-btn:hover { background: #2a2a2a; }
-.dash-btn:disabled { opacity: 0.5; cursor: not-allowed; }
-.dash-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
-.dash-btn.primary:hover { background: #e8e8e8; }
-.dash-btn.danger { color: #ff8a9c; border-color: #3a2530; }
-.dash-btn.danger:hover { background: #2a1820; }
-.dash-input, .dash-textarea, .dash-select {
- background: #0a0a0a;
- color: #eee;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 9px 11px;
- font-size: 13px;
- font-family: inherit;
- width: 100%;
-}
-.dash-textarea { font-family: ui-monospace, Menlo, Consolas, monospace; min-height: 160px; }
-.dash-muted { color: #888; font-size: 13px; }
-.dash-err {
- background: rgba(239, 68, 68, 0.1);
- border: 1px solid #ef4444;
- color: #fca5a5;
- padding: 10px 12px;
- border-radius: 6px;
- font-size: 13px;
- margin: 8px 0;
-}
-.dash-ok {
- background: rgba(34, 197, 94, 0.1);
- border: 1px solid #22c55e;
- color: #86efac;
- padding: 10px 12px;
- border-radius: 6px;
- font-size: 13px;
- margin: 8px 0;
-}
-.dash-row {
- display: flex;
- gap: 10px;
- align-items: center;
- flex-wrap: wrap;
-}
-.dash-pill {
- display: inline-block;
- background: rgba(255, 255, 255, 0.08);
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 999px;
- padding: 3px 10px;
- font-size: 11px;
- color: #cccccc;
-}
-.dash-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #aaa; }
-.dash-list { list-style: none; padding: 0; margin: 0; }
-.dash-list li {
- border-bottom: 1px solid var(--border);
- padding: 12px 0;
-}
-.dash-list li:last-child { border-bottom: 0; }
-.dash-empty {
- text-align: center;
- color: #666;
- padding: 32px 16px;
- font-size: 14px;
-}
diff --git a/public/dashboard-classic/actions.html b/public/dashboard-classic/actions.html
deleted file mode 100644
index 492cf07e2..000000000
--- a/public/dashboard-classic/actions.html
+++ /dev/null
@@ -1,634 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Action Log — three.ws</title>
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 system-ui,
- -apple-system,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #cccccc;
- text-decoration: none;
- }
- .container {
- max-width: 900px;
- margin: 0 auto;
- padding: 28px;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 20px;
- gap: 20px;
- flex-wrap: wrap;
- }
- .agent-info {
- flex: 1;
- min-width: 300px;
- }
- .sub {
- color: #888;
- margin: 4px 0 0;
- font-size: 14px;
- }
- .signer-pill {
- display: inline-block;
- background: rgba(255, 255, 255, 0.15);
- border: 1px solid var(--accent);
- border-radius: 999px;
- padding: 4px 12px;
- font-size: 13px;
- margin-top: 8px;
- color: #aaa;
- font-family: monospace;
- }
- .signer-pill.verified {
- background: rgba(34, 197, 94, 0.1);
- border-color: #22c55e;
- color: #86efac;
- }
- .actions-toolbar {
- display: flex;
- gap: 8px;
- align-items: center;
- margin-bottom: 20px;
- flex-wrap: wrap;
- }
- .filter-chip {
- padding: 6px 14px;
- border: 1px solid var(--border);
- background: transparent;
- color: #aaa;
- border-radius: 999px;
- cursor: pointer;
- font-size: 13px;
- transition: all 0.2s;
- }
- .filter-chip:hover {
- border-color: var(--accent);
- color: #fff;
- }
- .filter-chip.active {
- background: var(--accent);
- border-color: var(--accent);
- color: #fff;
- }
- .export-btn {
- margin-left: auto;
- padding: 6px 14px;
- border: 1px solid var(--border);
- background: transparent;
- color: #aaa;
- border-radius: 4px;
- cursor: pointer;
- font-size: 13px;
- transition: all 0.2s;
- }
- .export-btn:hover {
- border-color: var(--accent);
- color: var(--accent);
- }
- .timeline {
- display: flex;
- flex-direction: column;
- gap: 12px;
- }
- .action-row {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 6px;
- padding: 14px;
- cursor: pointer;
- transition: all 0.2s;
- }
- .action-row:hover {
- border-color: var(--accent);
- background: rgba(255, 255, 255, 0.04);
- }
- .action-row.expanded {
- border-color: var(--accent);
- }
- .action-row-header {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .action-icon {
- width: 20px;
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 12px;
- border-radius: 3px;
- flex-shrink: 0;
- }
- .action-icon.speak {
- background: rgba(255, 255, 255, 0.2);
- color: #a5b4fc;
- }
- .action-icon.remember {
- background: rgba(34, 197, 94, 0.2);
- color: #86efac;
- }
- .action-icon.sign {
- background: rgba(168, 85, 247, 0.2);
- color: #d8b4fe;
- }
- .action-icon.skill-done {
- background: rgba(59, 130, 246, 0.2);
- color: #93c5fd;
- }
- .action-icon.validate {
- background: rgba(249, 115, 22, 0.2);
- color: #fed7aa;
- }
- .action-icon.load-end {
- background: rgba(236, 72, 153, 0.2);
- color: #f472b6;
- }
- .action-summary {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 4px;
- min-width: 0;
- }
- .action-type {
- font-weight: 600;
- font-size: 14px;
- color: #fff;
- }
- .action-preview {
- color: #aaa;
- font-size: 13px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .action-meta {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .verify-badge {
- width: 20px;
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 12px;
- flex-shrink: 0;
- }
- .verify-badge.verified {
- color: #22c55e;
- }
- .verify-badge.unverified {
- color: #888;
- }
- .verify-badge.unsigned {
- color: #666;
- }
- .action-time {
- color: #666;
- font-size: 12px;
- flex-shrink: 0;
- }
- .action-time:hover {
- color: #aaa;
- }
- .action-detail {
- display: none;
- margin-top: 14px;
- padding-top: 14px;
- border-top: 1px solid var(--border);
- }
- .action-row.expanded .action-detail {
- display: block;
- }
- .json-block {
- background: rgba(0, 0, 0, 0.3);
- border: 1px solid var(--border);
- border-radius: 4px;
- padding: 12px;
- font-family: monospace;
- font-size: 12px;
- color: #888;
- overflow-x: auto;
- max-height: 300px;
- overflow-y: auto;
- }
- .empty-state {
- text-align: center;
- color: #666;
- padding: 40px 20px;
- }
- .empty-state-icon {
- font-size: 40px;
- margin-bottom: 12px;
- }
- .loading {
- text-align: center;
- color: #666;
- padding: 40px 20px;
- }
- .error-msg {
- background: rgba(239, 68, 68, 0.1);
- border: 1px solid #ef4444;
- color: #fca5a5;
- padding: 12px 14px;
- border-radius: 6px;
- margin-bottom: 20px;
- }
- .infinite-scroll-trigger {
- height: 1px;
- margin-top: 20px;
- }
- body[data-auth-pending] {
- visibility: hidden;
- }
- </style>
- </head>
- <body data-auth-pending>
- <div class="container">
- <div class="header">
- <div class="agent-info">
- <h1 id="agent-name">Action Log</h1>
- <div class="sub" id="agent-id"></div>
- <div class="signer-pill" id="signer-pill" style="display: none"></div>
- </div>
- </div>
-
- <div id="error-msg"></div>
-
- <div class="actions-toolbar">
- <button class="filter-chip active" data-filter="all">All</button>
- <button class="filter-chip" data-filter="speak">Speak</button>
- <button class="filter-chip" data-filter="remember">Remember</button>
- <button class="filter-chip" data-filter="sign">Sign</button>
- <button class="filter-chip" data-filter="skill-done">Skill Done</button>
- <button class="filter-chip" data-filter="validate">Validate</button>
- <button class="filter-chip" data-filter="load-end">Load End</button>
- <button class="export-btn" id="export-btn">Download JSON</button>
- </div>
-
- <div id="timeline" class="timeline"></div>
- <div class="infinite-scroll-trigger" id="scroll-trigger"></div>
- </div>
-
- <script>
- const pageSize = 50;
- let currentFilter = 'all';
- let allActions = [];
- let nextCursor = null;
- let isLoading = false;
- let hasMore = true;
-
- const params = new URLSearchParams(location.search);
- const agentId = params.get('agent');
-
- if (!agentId) {
- // No agent id in the URL (e.g. the dashboard sidebar "Action log"
- // link). Resolve the user's default agent and redirect.
- (async () => {
- try {
- const r = await fetch('/api/agents/me', { credentials: 'include' });
- if (r.status === 401) {
- window.location.href = '/login?next=' + encodeURIComponent('/dashboard/actions');
- return;
- }
- if (!r.ok) {
- document.body.removeAttribute('data-auth-pending');
- showError(`Could not load your default agent (HTTP ${r.status}).`);
- return;
- }
- const data = await r.json();
- const id = data?.agent?.id;
- if (!id) {
- document.body.removeAttribute('data-auth-pending');
- showError(
- 'No agent found on this account yet. Create one from the dashboard first.',
- );
- return;
- }
- window.location.replace(
- `/dashboard/actions?agent=${encodeURIComponent(id)}`,
- );
- } catch (e) {
- document.body.removeAttribute('data-auth-pending');
- showError(`Could not resolve your default agent: ${e.message}`);
- }
- })();
- } else {
- // Auth check
- (async () => {
- try {
- const r = await fetch(`/api/agents/${agentId}/actions?limit=1`, {
- credentials: 'include',
- });
- if (r.status === 401) {
- window.location.href = `/login?next=/dashboard/actions.html?agent=${agentId}`;
- return;
- }
- if (r.status === 403) {
- showError('Not authorized to view this agent.');
- document.body.removeAttribute('data-auth-pending');
- return;
- }
- if (r.status === 404) {
- showError('Agent not found.');
- document.body.removeAttribute('data-auth-pending');
- return;
- }
- if (!r.ok) {
- showError(`Error ${r.status}`);
- document.body.removeAttribute('data-auth-pending');
- return;
- }
-
- document.body.removeAttribute('data-auth-pending');
- const data = await r.json();
- const { actions, nextCursor: nc } = data;
-
- // Fetch agent info
- const agentR = await fetch(`/api/agents/${agentId}`, {
- credentials: 'include',
- });
- if (agentR.ok) {
- const agentData = await agentR.json();
- const agent = agentData.agent;
- document.getElementById('agent-name').textContent = agent?.name || agentId;
- document.getElementById('agent-id').textContent = `${agentId}${
- agent?.wallet_address ? ` · ${agent.wallet_address.slice(0, 10)}…` : ''
- }`;
-
- if (agent?.wallet_address) {
- const pill = document.getElementById('signer-pill');
- pill.textContent = `Signed by ${agent.wallet_address.slice(0, 10)}…${agent.wallet_address.slice(
- -8,
- )}`;
- pill.className = 'signer-pill verified';
- pill.style.display = 'inline-block';
- }
- }
-
- // Load initial page
- nextCursor = nc;
- await loadMore();
- } catch (e) {
- showError(`Fetch failed: ${e.message}`);
- }
- })();
-
- // IntersectionObserver for infinite scroll
- const observer = new IntersectionObserver(
- (entries) => {
- if (entries[0].isIntersecting && !isLoading && hasMore) {
- loadMore();
- }
- },
- { rootMargin: '200px' },
- );
-
- observer.observe(document.getElementById('scroll-trigger'));
-
- // Filter changes
- document.querySelectorAll('.filter-chip').forEach((btn) => {
- btn.addEventListener('click', () => {
- document
- .querySelectorAll('.filter-chip')
- .forEach((b) => b.classList.remove('active'));
- btn.classList.add('active');
- currentFilter = btn.dataset.filter;
- render();
- });
- });
-
- // Export
- document.getElementById('export-btn').addEventListener('click', () => {
- const filtered = getFiltered();
- const json = JSON.stringify(filtered, null, 2);
- const blob = new Blob([json], { type: 'application/json' });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url;
- a.download = `actions-${agentId}-${new Date().toISOString().split('T')[0]}.json`;
- a.click();
- URL.revokeObjectURL(url);
- });
- }
-
- // Load more actions
- async function loadMore() {
- if (isLoading || !hasMore) return;
- isLoading = true;
-
- try {
- const url = new URL(`/api/agents/${agentId}/actions`, window.location.origin);
- url.searchParams.set('limit', pageSize);
- if (nextCursor) {
- url.searchParams.set('cursor', nextCursor);
- }
-
- const r = await fetch(url, { credentials: 'include' });
- if (!r.ok) {
- hasMore = false;
- return;
- }
-
- const data = await r.json();
- const { actions, nextCursor: nc } = data;
-
- allActions.push(...actions);
- nextCursor = nc;
- hasMore = Boolean(nc);
-
- render();
- } catch (e) {
- console.error('loadMore failed:', e);
- } finally {
- isLoading = false;
- }
- }
-
- function getFiltered() {
- if (currentFilter === 'all') return allActions;
- return allActions.filter((a) => a.type === currentFilter);
- }
-
- function render() {
- const filtered = getFiltered();
- const timeline = document.getElementById('timeline');
-
- if (filtered.length === 0 && allActions.length === 0) {
- timeline.innerHTML =
- '<div class="empty-state"><div class="empty-state-icon">—</div><div>No actions yet.</div></div>';
- return;
- }
-
- if (filtered.length === 0) {
- timeline.innerHTML =
- '<div class="empty-state"><div class="empty-state-icon">—</div><div>No actions match this filter.</div></div>';
- return;
- }
-
- timeline.innerHTML = filtered.map((action) => renderRow(action)).join('');
-
- // Add expand listeners
- document.querySelectorAll('.action-row').forEach((row) => {
- row.addEventListener('click', () => {
- row.classList.toggle('expanded');
- });
- });
- }
-
- function renderRow(action) {
- const type = action.type;
- const preview = summarizePayload(action.payload);
- const timestamp = new Date(action.timestamp);
- const now = new Date();
- const relTime = formatRelativeTime(timestamp, now);
-
- let verifyIcon = '—';
- let verifyClass = 'unsigned';
- if (action.signature) {
- if (action.verified === true) {
- verifyIcon = '✓';
- verifyClass = 'verified';
- } else if (action.verified === false) {
- verifyIcon = '✗';
- verifyClass = 'unverified';
- }
- }
-
- return `
- <div class="action-row" data-id="${action.id}">
- <div class="action-row-header">
- <div class="action-icon ${type}">
- ${getTypeIcon(type)}
- </div>
- <div class="action-summary">
- <div class="action-type">${escapeHtml(type)}</div>
- <div class="action-preview">${escapeHtml(preview)}</div>
- </div>
- <div class="action-meta">
- <div class="verify-badge ${verifyClass}" title="${
- action.verified === true
- ? 'Verified'
- : action.verified === false
- ? 'Invalid signature'
- : 'Unsigned'
- }">${verifyIcon}</div>
- <div class="action-time" title="${timestamp.toISOString()}">${escapeHtml(relTime)}</div>
- </div>
- </div>
- <div class="action-detail">
- <div class="json-block">${escapeHtml(JSON.stringify(action.payload, null, 2))}</div>
- ${
- action.signer
- ? `<div style="margin-top:8px;color:#666;font-size:12px">Signer: <code style="color:#888">${escapeHtml(
- action.signer,
- )}</code></div>`
- : ''
- }
- </div>
- </div>
- `;
- }
-
- function getTypeIcon(type) {
- const icons = {
- speak: '💬',
- remember: '📝',
- sign: '✍️',
- 'skill-done': '✓',
- validate: '✔',
- 'load-end': '📦',
- };
- return icons[type] || '•';
- }
-
- function summarizePayload(payload) {
- if (typeof payload !== 'object' || !payload) return '(empty)';
- const keys = Object.keys(payload);
- if (keys.length === 0) return '(empty)';
-
- // For speak actions, show the text
- if (payload.text) return payload.text.slice(0, 80);
-
- // For remember, show content
- if (payload.content) return payload.content.slice(0, 80);
-
- // Generic: show key=value preview
- const parts = keys.slice(0, 2).map((k) => {
- const v = payload[k];
- if (typeof v === 'string') return `${k}=${v.slice(0, 30)}`;
- if (typeof v === 'number') return `${k}=${v}`;
- if (typeof v === 'boolean') return `${k}=${v}`;
- return `${k}=(object)`;
- });
- return parts.join(', ');
- }
-
- function formatRelativeTime(date, now) {
- const seconds = Math.floor((now - date) / 1000);
-
- if (seconds < 60) return `${seconds}s ago`;
- if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
- if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
- if (seconds < 604800) return `${Math.floor(seconds / 86400)}d ago`;
-
- const months = Math.floor(seconds / 2592000);
- if (months < 12) return `${months}mo ago`;
-
- return `${Math.floor(seconds / 31536000)}y ago`;
- }
-
- function showError(msg) {
- const el = document.getElementById('error-msg');
- el.innerHTML = `<div class="error-msg">${escapeHtml(msg)}</div>`;
- }
-
- function escapeHtml(text) {
- if (!text) return '';
- const map = {
- '&': '&amp;',
- '<': '&lt;',
- '>': '&gt;',
- '"': '&quot;',
- "'": '&#039;',
- };
- return String(text).replace(/[&<>"']/g, (c) => map[c]);
- }
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/agent-pumpfun.html b/public/dashboard-classic/agent-pumpfun.html
deleted file mode 100644
index 08f75c048..000000000
--- a/public/dashboard-classic/agent-pumpfun.html
+++ /dev/null
@@ -1,1841 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent · Pump.fun · Dashboard · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --ok: #4ade80;
- --warn: #fbbf24;
- --err: #f87171;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- --panel2: #1a1a1a;
- --muted: #888;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #9a8cff;
- text-decoration: none;
- }
- a:hover {
- text-decoration: underline;
- }
- header.site-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 18px;
- padding: 14px 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: rgba(0, 0, 0, 0.85);
- backdrop-filter: blur(8px);
- z-index: 5;
- }
- .site-header .brand {
- display: inline-flex;
- align-items: center;
- gap: 8px;
- font-weight: 600;
- letter-spacing: -0.01em;
- color: #fff;
- }
- .site-header .brand img {
- height: 22px;
- width: auto;
- display: block;
- }
- .site-nav {
- display: flex;
- gap: 2px;
- flex-wrap: wrap;
- margin-left: auto;
- }
- .site-nav a {
- font-size: 13px;
- padding: 7px 11px;
- border-radius: 7px;
- color: #bbb;
- }
- .site-nav a:hover {
- background: var(--panel);
- text-decoration: none;
- color: #eee;
- }
- .site-nav a.active {
- background: var(--panel);
- color: #fff;
- }
- .brand {
- font-weight: 600;
- letter-spacing: -0.01em;
- }
- .crumb {
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px 24px;
- border-bottom: 1px solid var(--border);
- background: var(--bg);
- position: sticky;
- top: 53px;
- z-index: 4;
- font-size: 13px;
- }
- .crumb a { color: #9a8cff; }
- .crumb .sep { color: #555; }
- footer.site-footer {
- margin-top: 40px;
- padding: 28px 24px 36px;
- border-top: 1px solid var(--border);
- background: #06060a;
- color: var(--muted);
- font-size: 13px;
- }
- .site-footer-inner {
- max-width: 1280px;
- margin: 0 auto;
- display: flex;
- flex-wrap: wrap;
- gap: 18px;
- align-items: center;
- justify-content: space-between;
- }
- .site-footer-brand {
- display: inline-flex;
- align-items: center;
- gap: 8px;
- color: #ddd;
- font-weight: 600;
- }
- .site-footer-brand img { height: 18px; width: auto; }
- .site-footer-links {
- display: flex;
- gap: 14px;
- flex-wrap: wrap;
- }
- .site-footer-links a { color: #aaa; }
- .site-footer-links a:hover { color: #fff; }
- .site-footer-legal { color: #666; font-size: 12px; }
- main {
- padding: 28px;
- max-width: 1280px;
- margin: 0 auto;
- }
- .layout {
- display: grid;
- grid-template-columns: 360px 1fr;
- gap: 18px;
- align-items: start;
- }
- .layout > .col-side {
- position: sticky;
- top: 110px;
- }
- @media (max-width: 900px) {
- .layout {
- grid-template-columns: 1fr;
- }
- .layout > .col-side {
- position: static;
- }
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: var(--muted);
- margin: 0 0 22px;
- font-size: 14px;
- }
- .panel {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 18px 20px;
- margin: 0 0 18px;
- }
- .panel h2 {
- margin: 0 0 12px;
- font-size: 15px;
- font-weight: 600;
- letter-spacing: 0.02em;
- color: #ddd;
- text-transform: uppercase;
- }
- .row {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-wrap: wrap;
- }
- .col {
- display: flex;
- flex-direction: column;
- gap: 10px;
- }
- label {
- display: block;
- font-size: 12px;
- color: var(--muted);
- margin-bottom: 4px;
- }
- input,
- select {
- background: var(--panel2);
- color: #eee;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 9px 11px;
- font: inherit;
- min-width: 0;
- }
- input:focus,
- select:focus {
- outline: none;
- border-color: var(--accent);
- }
- .field {
- flex: 1 1 180px;
- min-width: 0;
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font: inherit;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- }
- .btn:disabled {
- opacity: 0.45;
- cursor: not-allowed;
- }
- .btn.ghost {
- background: transparent;
- border: 1px solid #222222;
- color: #ddd;
- }
- .btn.ghost:hover:not(:disabled) {
- background: #15151d;
- border-color: #2e2e3e;
- }
- .btn.danger {
- background: #3a1d22;
- color: var(--err);
- border: 1px solid #4a2329;
- }
- .btn.buy {
- background: #16a34a;
- color: #fff;
- }
- .btn.sell {
- background: #3a1d22;
- color: #fca5a5;
- border: 1px solid #6b2530;
- }
- .btn.sell:hover {
- background: #4a2329;
- }
- .subnav {
- display: flex;
- gap: 4px;
- flex-wrap: wrap;
- padding: 8px 24px;
- border-bottom: 1px solid var(--border);
- background: var(--bg);
- position: sticky;
- top: 96px;
- z-index: 4;
- }
- .subnav a {
- font-size: 13px;
- padding: 6px 11px;
- border-radius: 7px;
- color: #bbb;
- }
- .subnav a:hover {
- background: var(--panel);
- text-decoration: none;
- color: #eee;
- }
- .subnav a.active {
- background: var(--panel);
- color: #fff;
- border: 1px solid var(--border);
- }
- .kv {
- display: grid;
- grid-template-columns: 140px 1fr;
- gap: 6px 14px;
- font-size: 13px;
- }
- .kv dt {
- color: var(--muted);
- }
- .kv dd {
- margin: 0;
- word-break: break-all;
- font-family: ui-monospace, Menlo, monospace;
- }
- pre {
- background: var(--panel2);
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 10px 12px;
- overflow-x: auto;
- font-size: 12px;
- color: #cbd5e1;
- white-space: pre-wrap;
- word-break: break-all;
- }
- .toast {
- position: fixed;
- right: 22px;
- bottom: 22px;
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 11px 14px;
- font-size: 13px;
- max-width: 400px;
- box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
- opacity: 0;
- transform: translateY(8px);
- transition:
- opacity 0.18s,
- transform 0.18s;
- pointer-events: none;
- }
- .toast.show {
- opacity: 1;
- transform: none;
- }
- .toast.ok {
- border-color: #1f4232;
- }
- .toast.err {
- border-color: #4a2329;
- color: var(--err);
- }
- table {
- width: 100%;
- border-collapse: collapse;
- font-size: 13px;
- }
- th,
- td {
- padding: 8px 10px;
- border-bottom: 1px solid var(--border);
- text-align: left;
- }
- th {
- color: var(--muted);
- font-weight: 500;
- font-size: 12px;
- text-transform: uppercase;
- letter-spacing: 0.04em;
- }
- td.mono {
- font-family: ui-monospace, Menlo, monospace;
- font-size: 12px;
- }
- .pnl-pos {
- color: var(--ok);
- }
- .pnl-neg {
- color: var(--err);
- }
- .muted {
- color: var(--muted);
- }
- .tag {
- font-size: 11px;
- padding: 2px 7px;
- border-radius: 999px;
- background: var(--panel2);
- border: 1px solid var(--border);
- }
- .tag.devnet {
- color: var(--warn);
- border-color: #4a3a18;
- background: #2a200a;
- }
- .tag.mainnet {
- color: var(--ok);
- border-color: #1f4232;
- background: #0e1f17;
- }
- .net-badge {
- font-size: 11px;
- padding: 2px 8px;
- border-radius: 999px;
- margin-left: 8px;
- vertical-align: middle;
- letter-spacing: 0.04em;
- text-transform: uppercase;
- }
- .skeleton {
- display: inline-block;
- min-width: 80px;
- height: 12px;
- border-radius: 4px;
- background: linear-gradient(90deg, #1a1a1a 0%, #24242e 50%, #1a1a1a 100%);
- background-size: 200% 100%;
- animation: shimmer 1.2s linear infinite;
- vertical-align: middle;
- }
- @keyframes shimmer {
- 0% { background-position: 200% 0; }
- 100% { background-position: -200% 0; }
- }
- .empty-cta {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 6px;
- padding: 24px 12px;
- color: var(--muted);
- font-size: 13px;
- }
- .empty-cta b { color: #ddd; font-weight: 600; }
- details.debug summary {
- cursor: pointer;
- color: var(--muted);
- font-size: 12px;
- text-transform: uppercase;
- letter-spacing: 0.04em;
- user-select: none;
- }
- details.debug[open] summary { margin-bottom: 10px; }
- .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
- .stat-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
- .stat-card.bad { background: #1f1418; border-color: #4a1f23; }
- .stat-card.good { background: #0e1f17; border-color: #1f4232; }
- .stat-card .v { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: #f1f1f1; }
- .stat-card .l { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
- .stat-card .l .delta { text-transform: none; letter-spacing: 0; margin-left: 4px; color: #aaa; }
- </style>
- </head>
- <body>
- <header class="site-header">
- <a class="brand" href="/" aria-label="three.ws home">
- <img src="/three.svg" alt="" aria-hidden="true" />
- <span>three.ws</span>
- </a>
- <nav class="site-nav" aria-label="Primary">
- <a href="/app">Viewer</a>
- <a href="/create">Create</a>
- <a href="/discover">Discover</a>
- <a href="/widgets">Widgets</a>
- <a href="/studio">Studio</a>
- <a href="/docs">Docs</a>
- <a href="/dashboard" class="active" aria-current="page">Dashboard</a>
- </nav>
- <div id="header-user-slot"></div>
- </header>
-
- <div class="crumb">
- <a href="/dashboard">← Dashboard</a>
- <span class="sep">/</span>
- <span class="brand">Agent · Pump.fun</span>
- </div>
-
- <nav class="subnav" aria-label="Agent wallet tools">
- <a href="/dashboard/agent-pumpfun" class="active" aria-current="page">Pump.fun</a>
- <a href="/dashboard/wallets">Wallets</a>
- <a href="/vanity-wallet">Vanity ✦</a>
- <a href="/strategy-lab">Strategy lab</a>
- <a href="/reputation">Reputation</a>
- <a href="/pumpfun" target="_blank" rel="noopener">Live feed ↗</a>
- </nav>
-
- <main>
- <h1>Agent control panel<span class="tag net-badge mainnet" id="net-badge">mainnet</span></h1>
- <p class="sub">
- Each agent has its own Solana wallet. Launch tokens, trade on the bonding curve, and
- watch positions — the agent signs every transaction from its server-held keypair
- (subject to its spend policy).
- </p>
-
- <div class="layout">
- <div class="col-side">
- <section class="panel" id="agent-panel">
- <h2>Agent</h2>
- <div class="row">
- <div class="field">
- <label for="agent-select">Identity</label>
- <select id="agent-select"></select>
- </div>
- <div class="field" style="flex: 0 0 160px">
- <label for="network-select">Network</label>
- <select id="network-select">
- <option value="mainnet">mainnet</option>
- <option value="devnet">devnet</option>
- </select>
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn ghost" id="refresh-btn">Refresh</button>
- </div>
- </div>
- <div style="margin-top: 14px">
- <dl class="kv">
- <dt>Address</dt>
- <dd id="agent-address" class="muted"><span class="skeleton" style="width:180px"></span></dd>
- <dt>Balance</dt>
- <dd id="agent-balance" class="muted"><span class="skeleton" style="width:80px"></span></dd>
- </dl>
- <div class="row" style="margin-top: 10px">
- <button class="btn ghost" id="provision-btn" hidden>
- Provision Solana wallet
- </button>
- <a
- class="btn ghost"
- id="vanity-link"
- href="/vanity-wallet"
- target="_blank"
- rel="noopener"
- >Grind vanity address ✦</a
- >
- <a
- id="explorer-link"
- class="muted"
- href="#"
- target="_blank"
- rel="noopener"
- hidden
- >Open on Solscan ↗</a
- >
- </div>
- </div>
- </section>
-
- <section class="panel" id="sns-panel">
- <h2>
- SNS identity
- <span class="muted" style="font-size: 13px; font-weight: normal"
- >(Solana Name Service)</span
- >
- </h2>
- <p class="muted" style="margin: 0 0 10px; font-size: 13px">
- Attach a <code>.sol</code> domain owned by this agent's wallet so it can be
- referenced by name.
- </p>
- <dl class="kv">
- <dt>Current</dt>
- <dd id="sns-current" class="muted">—</dd>
- </dl>
- <div
- id="sns-domain-list"
- class="row"
- style="margin-top: 8px; flex-wrap: wrap; gap: 6px"
- ></div>
- <div class="row" style="margin-top: 10px">
- <button class="btn ghost" id="sns-refresh-btn">Refresh domains</button>
- <button class="btn ghost" id="sns-clear-btn" hidden>Clear SNS id</button>
- <a
- id="sns-register-link"
- class="muted"
- href="https://www.sns.id"
- target="_blank"
- rel="noopener"
- >Register a name on sns.id</a
- >
- </div>
- <div id="sns-registrar" style="margin-top: 14px">
- <div class="field">
- <label for="sns-register-label">Register a .sol domain</label>
- <div class="row" style="gap: 6px; align-items: center">
- <input id="sns-register-label" placeholder="myagent" maxlength="63" autocomplete="off" />
- <span class="muted" style="font-family: ui-monospace, Menlo, monospace; font-size: 13px">.sol</span>
- </div>
- <p id="sns-check-status" class="muted" style="margin: 6px 0 0; font-size: 12px; min-height: 1.3em">
- Bonfida pricing (1y): 1 char $750 · 2 $700 · 3 $640 · 4 $160 · 5+ $20. Paid in USDC.
- </p>
- </div>
- <div class="row" style="margin-top: 10px; gap: 8px; flex-wrap: wrap">
- <button class="btn" id="sns-register-agent-btn" disabled>Pay with agent wallet</button>
- <button class="btn ghost" id="sns-register-user-btn" disabled>Pay with my wallet</button>
- </div>
- </div>
- </section>
- </div>
-
- <div class="col-main">
- <section class="panel">
- <h2>Launch a pump.fun token</h2>
- <div class="row">
- <div class="field">
- <label for="launch-name">Name</label>
- <input id="launch-name" placeholder="My Agent Coin" />
- </div>
- <div class="field" style="flex: 0 0 160px">
- <label for="launch-symbol">Symbol</label>
- <input id="launch-symbol" placeholder="AGENT" maxlength="10" />
- </div>
- <div class="field" style="flex: 0 0 120px">
- <label for="launch-vanity">Vanity prefix</label>
- <input id="launch-vanity" placeholder="PUMP" maxlength="6" />
- </div>
- <div class="field" style="flex: 0 0 120px">
- <label for="launch-vanity-suffix">Vanity suffix</label>
- <input id="launch-vanity-suffix" placeholder="pump" maxlength="6" />
- </div>
- <div class="field" style="flex: 0 0 130px">
- <label for="launch-sol">Initial buy (SOL)</label>
- <input id="launch-sol" type="number" min="0" step="0.001" placeholder="0" />
- </div>
- <div class="field" style="flex: 0 0 auto; padding-top: 22px">
- <label style="display: flex; align-items: center; gap: 6px; color: #ddd">
- <input type="checkbox" id="launch-vanity-ic" /> ignore case
- </label>
- </div>
- </div>
- <div class="row" style="margin-top: 10px">
- <div class="field">
- <label for="launch-uri"
- >Metadata URI
- <span class="muted">(auto-filled to agent metadata)</span></label
- >
- <input id="launch-uri" />
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn" id="launch-btn">Launch</button>
- </div>
- </div>
- <p class="muted" style="margin: 10px 0 0; font-size: 12px">
- Base58 only (no 0/O/I/l). Combined prefix+suffix length: 3 chars ≈ instant, 4 ≈
- seconds, 5 ≈ minutes, 6+ may time out. Powered by
- <a
- href="https://github.com/nirholas/solana-wallet-toolkit"
- target="_blank"
- rel="noopener"
- >solana-wallet-toolkit</a
- >.
- </p>
- </section>
-
- <section class="panel" id="vanity-panel">
- <h2>Vanity grinder ✦</h2>
- <p class="muted" style="margin: 0 0 10px; font-size: 13px">
- Grind a Solana keypair entirely in your browser — keys never leave this tab.
- Use the result for your next pump.fun launch, or assign it as the agent's wallet.
- Base58 only (no <code>0/O/I/l</code>). 5–6 chars can take minutes; 7+ is impractical.
- </p>
- <div class="row">
- <div class="field" style="flex: 0 0 140px">
- <label for="vg-prefix">Prefix</label>
- <input id="vg-prefix" placeholder="PUMP" maxlength="6" autocomplete="off" />
- </div>
- <div class="field" style="flex: 0 0 140px">
- <label for="vg-suffix">Suffix</label>
- <input id="vg-suffix" placeholder="pump" maxlength="6" autocomplete="off" />
- </div>
- <div class="field" style="flex: 0 0 auto; padding-top: 22px">
- <label style="display:flex;align-items:center;gap:6px;color:#ddd">
- <input type="checkbox" id="vg-ic" /> ignore case
- </label>
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn" id="vg-start">Start grinding</button>
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn ghost" id="vg-stop" hidden>Stop</button>
- </div>
- </div>
- <div id="vg-progress" class="muted" style="margin-top:10px;font-size:13px;font-family:ui-monospace,Menlo,monospace">
- Idle. Estimated attempts shown after you enter a pattern.
- </div>
- <div id="vg-result" hidden style="margin-top:12px">
- <dl class="kv">
- <dt>Address</dt>
- <dd id="vg-address" class="mono"></dd>
- <dt>Attempts</dt>
- <dd id="vg-attempts"></dd>
- <dt>Duration</dt>
- <dd id="vg-duration"></dd>
- </dl>
- <div class="row" style="margin-top:10px;gap:8px;flex-wrap:wrap">
- <button class="btn" id="vg-use-launch">Use for next launch</button>
- <button class="btn ghost" id="vg-assign">Assign as agent wallet</button>
- <button class="btn ghost" id="vg-copy">Copy secret JSON</button>
- <button class="btn ghost" id="vg-discard">Discard</button>
- </div>
- <p class="muted" style="margin:8px 0 0;font-size:12px">
- The secret is held in this tab only. Closing or refreshing this page erases it.
- </p>
- </div>
- </section>
-
- <section class="panel">
- <h2>Trade on the bonding curve</h2>
- <div class="row">
- <div class="field">
- <label for="trade-mint">Mint</label>
- <input id="trade-mint" placeholder="Mint address" />
- </div>
- <div class="field" style="flex: 0 0 140px">
- <label for="trade-slippage">Slippage (bps)</label>
- <input id="trade-slippage" type="number" min="0" max="10000" value="500" />
- </div>
- </div>
- <div class="row" style="margin-top: 10px">
- <div class="field">
- <label for="buy-sol">Buy with SOL</label>
- <input id="buy-sol" type="number" min="0" step="0.001" placeholder="0.05" />
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn buy" id="buy-btn">Buy</button>
- </div>
- <div class="field">
- <label for="sell-tokens">Sell tokens (base units)</label>
- <input id="sell-tokens" placeholder="1000000000" />
- </div>
- <div style="flex: 0 0 auto; padding-top: 19px">
- <button class="btn sell" id="sell-btn">Sell</button>
- </div>
- </div>
- </section>
-
- <section class="panel">
- <div class="row" style="justify-content: space-between">
- <h2 style="margin: 0">Portfolio</h2>
- <button class="btn ghost" id="portfolio-btn">Refresh portfolio</button>
- </div>
- <div id="portfolio-totals" class="muted" style="margin: 10px 0; font-size: 13px">
- —
- </div>
- <div id="portfolio-table-wrap">
- <table id="portfolio-table">
- <thead>
- <tr>
- <th>Mint</th>
- <th>SOL in</th>
- <th>SOL out</th>
- <th>Token bal</th>
- <th>Est. value (SOL)</th>
- <th>Unrealized PnL</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td colspan="7">
- <div class="empty-cta">
- <b>No positions yet.</b>
- <span>Launch a token above, or paste a mint into the trade panel to start tracking.</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </section>
-
- <section class="panel" id="indexer-panel" hidden>
- <div style="display: flex; justify-content: space-between; align-items: center">
- <h2 style="margin: 0">Token indexer</h2>
- <button class="btn ghost" id="indexer-refresh">Refresh</button>
- </div>
- <div class="muted" style="font-size: 13px; margin: 6px 0 12px">
- Live snapshot from <code>/api/cron/pump-agent-stats</code> + price history.
- </div>
- <div id="token-stats">Pick a launched mint above (Trade panel) to see stats.</div>
- <canvas
- id="price-chart"
- width="640"
- height="120"
- style="
- display: block;
- margin-top: 12px;
- max-width: 100%;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: #0a0a12;
- "
- ></canvas>
- </section>
-
- <section class="panel" id="signals-panel">
- <h2>
- Live pump.fun signals
- <span class="muted" style="font-weight:400;font-size:13px">
- — off-chain claim/graduation activity tied to your agent's wallet
- </span>
- </h2>
- <div id="signals-grid" class="muted">No signals yet. The crawler runs every 15 minutes.</div>
- <div class="row" style="margin-top: 12px">
- <a class="btn ghost" id="open-live-feed" href="/pumpfun" target="_blank" rel="noopener">
- Open live feed ↗
- </a>
- <a class="btn ghost" id="open-passport" href="#" target="_blank" rel="noopener">
- Open agent passport ↗
- </a>
- </div>
- </section>
-
- <section class="panel">
- <details class="debug">
- <summary>Debug · last response</summary>
- <pre id="log">—</pre>
- </details>
- </section>
- </div>
- </div>
- </main>
-
- <div class="toast" id="toast"></div>
-
- <footer class="site-footer">
- <div class="site-footer-inner">
- <a class="site-footer-brand" href="/">
- <img src="/three.svg" alt="" aria-hidden="true" />
- <span>three.ws</span>
- </a>
- <nav class="site-footer-links" aria-label="Footer">
- <a href="/discover">Discover</a>
- <a href="/dashboard">Dashboard</a>
- <a href="/dashboard/wallets">Wallets</a>
- <a href="/pumpfun" target="_blank" rel="noopener">Pump.fun feed ↗</a>
- <a href="/docs">Docs</a>
- <a href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener">GitHub</a>
- <a href="/legal/privacy">Privacy</a>
- <a href="/legal/tos">Terms</a>
- </nav>
- <span class="site-footer-legal">© 2026 three.ws</span>
- </div>
- </footer>
-
- <script type="module">
- import { mountHeaderUser } from '/src/header-user.js';
- mountHeaderUser({ slot: '#header-user-slot' }).catch(() => {});
- </script>
-
- <script type="module">
- const $ = (sel) => document.querySelector(sel);
- const els = {
- agentSelect: $('#agent-select'),
- networkSelect: $('#network-select'),
- refreshBtn: $('#refresh-btn'),
- provisionBtn: $('#provision-btn'),
- agentAddress: $('#agent-address'),
- agentBalance: $('#agent-balance'),
- explorerLink: $('#explorer-link'),
- snsCurrent: $('#sns-current'),
- snsDomainList: $('#sns-domain-list'),
- snsRefreshBtn: $('#sns-refresh-btn'),
- snsClearBtn: $('#sns-clear-btn'),
- snsRegisterLink: $('#sns-register-link'),
- snsRegistrar: $('#sns-registrar'),
- snsRegisterLabel: $('#sns-register-label'),
- snsRegisterAgentBtn: $('#sns-register-agent-btn'),
- snsRegisterUserBtn: $('#sns-register-user-btn'),
- snsCheckStatus: $('#sns-check-status'),
- launchName: $('#launch-name'),
- launchSymbol: $('#launch-symbol'),
- launchVanity: $('#launch-vanity'),
- launchVanitySuffix: $('#launch-vanity-suffix'),
- launchVanityIc: $('#launch-vanity-ic'),
- launchSol: $('#launch-sol'),
- launchUri: $('#launch-uri'),
- launchBtn: $('#launch-btn'),
- tradeMint: $('#trade-mint'),
- tradeSlippage: $('#trade-slippage'),
- buySol: $('#buy-sol'),
- buyBtn: $('#buy-btn'),
- sellTokens: $('#sell-tokens'),
- sellBtn: $('#sell-btn'),
- portfolioBtn: $('#portfolio-btn'),
- portfolioTotals: $('#portfolio-totals'),
- portfolioTable: $('#portfolio-table tbody'),
- log: $('#log'),
- toast: $('#toast'),
- };
-
- let toastTimer;
- function toast(msg, kind = 'ok') {
- els.toast.textContent = msg;
- els.toast.className = `toast show ${kind}`;
- clearTimeout(toastTimer);
- toastTimer = setTimeout(() => (els.toast.className = 'toast'), 3500);
- }
-
- function logResponse(label, body) {
- els.log.textContent = `[${label}]\n` + JSON.stringify(body, null, 2);
- }
-
- function explorerTxUrl(sig, network) {
- return `https://solscan.io/tx/${sig}${network === 'devnet' ? '?cluster=devnet' : ''}`;
- }
-
- function explorerAddrUrl(addr, network) {
- return `https://solscan.io/account/${addr}${network === 'devnet' ? '?cluster=devnet' : ''}`;
- }
-
- async function api(path, opts = {}) {
- const res = await fetch(path, {
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- ...opts,
- });
- const body = await res.json().catch(() => ({}));
- if (!res.ok) {
- const code = body.error || res.status;
- const msg = body.error_description || res.statusText;
- throw Object.assign(new Error(`${code}: ${msg}`), { body });
- }
- return body;
- }
-
- function currentAgentId() {
- return els.agentSelect.value || '';
- }
- function currentNetwork() {
- return els.networkSelect.value;
- }
-
- async function loadAgents() {
- try {
- const { agents = [] } = await api('/api/agents');
- els.agentSelect.innerHTML = '';
- if (!agents.length) {
- const opt = document.createElement('option');
- opt.textContent = 'No agents — create one in the dashboard';
- opt.disabled = true;
- els.agentSelect.appendChild(opt);
- return;
- }
- for (const a of agents) {
- const opt = document.createElement('option');
- opt.value = a.id;
- opt.textContent = `${a.name || 'Untitled'} · ${a.id.slice(0, 8)}`;
- els.agentSelect.appendChild(opt);
- }
- } catch (err) {
- toast(err.message, 'err');
- }
- }
-
- async function refreshAgent() {
- const id = currentAgentId();
- if (!id) return;
- const network = currentNetwork();
- const origin = window.location.origin;
- els.launchUri.value = `${origin}/api/agents/pumpfun-metadata?id=${encodeURIComponent(id)}`;
- els.agentAddress.innerHTML = '<span class="skeleton" style="width:200px"></span>';
- els.agentBalance.innerHTML = '<span class="skeleton" style="width:90px"></span>';
- els.explorerLink.hidden = true;
- els.provisionBtn.hidden = true;
- try {
- const { data } = await api(`/api/agents/${id}/solana?network=${network}`);
- els.agentAddress.textContent = data.address;
- els.agentAddress.classList.remove('muted');
- els.agentBalance.textContent =
- data.sol == null ? 'unknown' : `${data.sol.toFixed(6)} SOL`;
- els.agentBalance.classList.remove('muted');
- els.explorerLink.href = explorerAddrUrl(data.address, network);
- els.explorerLink.hidden = false;
- } catch (err) {
- if (err.body?.error === 'not_found') {
- els.agentAddress.textContent = 'No Solana wallet yet';
- els.provisionBtn.hidden = false;
- } else {
- els.agentAddress.textContent = err.message;
- }
- }
- refreshSns();
- refreshSignals();
- }
-
- async function refreshSignals() {
- const grid = document.getElementById('signals-grid');
- const passportLink = document.getElementById('open-passport');
- const id = currentAgentId();
- const network = currentNetwork();
- if (!id) {
- grid.textContent = 'Select an agent.';
- return;
- }
- grid.textContent = 'Loading…';
- try {
- // Resolve the agent's Solana asset pubkey, then pull reputation aggregates.
- const agentRes = await fetch(`/api/agents/${encodeURIComponent(id)}`, { credentials: 'include' });
- const agent = agentRes.ok ? await agentRes.json() : null;
- const asset = agent?.data?.meta?.sol_mint_address || agent?.meta?.sol_mint_address;
- if (!asset) {
- grid.innerHTML =
- '<span class="muted">This agent has no Solana identity yet — register on Solana to start collecting pump.fun signals.</span>';
- passportLink.removeAttribute('href');
- return;
- }
- passportLink.href = `/agent-passport.html?asset=${encodeURIComponent(asset)}&network=${network}`;
- const repRes = await fetch(
- `/api/agents/solana-reputation?asset=${encodeURIComponent(asset)}&network=${network}`,
- );
- const rep = repRes.ok ? await repRes.json() : null;
- const pf = rep?.pumpfun_signals || { count: 0, weight: 0, by_kind: {} };
- if (!pf.count) {
- grid.innerHTML =
- '<span class="muted">No pump.fun signals yet. The crawler runs every 15 minutes; signals appear here when this wallet is the claimer or creator on a pump.fun event.</span>';
- return;
- }
- const wKind = pf.weight > 0 ? ' good' : pf.weight < 0 ? ' bad' : '';
- const cards = [
- `<div class="stat-card"><div class="v">${pf.count}</div><div class="l">Total signals</div></div>`,
- `<div class="stat-card${wKind}"><div class="v">${pf.weight >= 0 ? '+' : ''}${pf.weight.toFixed(2)}</div><div class="l">Aggregate weight</div></div>`,
- ...Object.entries(pf.by_kind).map(
- ([k, info]) => {
- const kk = info.weight > 0 ? ' good' : info.weight < 0 ? ' bad' : '';
- return `<div class="stat-card${kk}"><div class="v">${info.count}</div><div class="l">${k.replace(/_/g, ' ')}<span class="delta">(${info.weight >= 0 ? '+' : ''}${info.weight})</span></div></div>`;
- },
- ),
- ];
- grid.innerHTML = `<div class="stat-grid">${cards.join('')}</div>`;
- } catch (err) {
- grid.innerHTML = `<span class="muted">Could not load signals: ${err.message}</span>`;
- }
- }
-
- function renderSnsList(data) {
- const cur = data.sns_domain;
- if (cur) {
- els.snsCurrent.textContent = `${cur}.sol`;
- els.snsCurrent.classList.remove('muted');
- els.snsClearBtn.hidden = false;
- } else {
- els.snsCurrent.textContent = '— none attached —';
- els.snsCurrent.classList.add('muted');
- els.snsClearBtn.hidden = true;
- }
- const owned = Array.isArray(data.domains) ? data.domains : [];
- if (!owned.length) {
- els.snsDomainList.innerHTML =
- '<span class="muted" style="font-size:13px">This wallet does not own any .sol domains yet. Register one on sns.id, then refresh.</span>';
- return;
- }
- els.snsDomainList.innerHTML = '';
- for (const d of owned) {
- const btn = document.createElement('button');
- btn.className = 'btn ghost';
- btn.style.fontSize = '12px';
- btn.textContent = d === cur ? `★ ${d}.sol` : `${d}.sol`;
- btn.disabled = d === cur;
- btn.addEventListener('click', () => attachSns(d));
- els.snsDomainList.appendChild(btn);
- }
- if (data.favorite && !owned.includes(data.favorite)) {
- const fav = document.createElement('span');
- fav.className = 'muted';
- fav.style.fontSize = '12px';
- fav.textContent = `(favorite: ${data.favorite}.sol)`;
- els.snsDomainList.appendChild(fav);
- }
- }
-
- async function refreshSns() {
- const id = currentAgentId();
- if (!id) return;
- els.snsCurrent.innerHTML = '<span class="skeleton" style="width:120px"></span>';
- els.snsDomainList.innerHTML = '';
- try {
- const { data } = await api(`/api/agents/${id}/sns`);
- renderSnsList(data);
- } catch (err) {
- els.snsCurrent.textContent =
- err.body?.error === 'conflict'
- ? 'Provision a Solana wallet first'
- : err.message;
- els.snsDomainList.innerHTML = '';
- els.snsClearBtn.hidden = true;
- }
- }
-
- function readRegisterLabel() {
- const v = els.snsRegisterLabel.value.trim().toLowerCase().replace(/\.sol$/, '');
- if (!/^[a-z0-9-]{1,63}$/.test(v)) {
- toast('Domain must be a–z, 0–9, or hyphen (max 63 chars)', 'err');
- return null;
- }
- return v;
- }
-
- function snsPriceFor(len) {
- if (len === 1) return 750;
- if (len === 2) return 700;
- if (len === 3) return 640;
- if (len === 4) return 160;
- return 20;
- }
-
- let snsCheckSeq = 0;
- let snsCheckTimer = null;
- function setSnsCheckStatus(html, kind) {
- const el = els.snsCheckStatus;
- el.innerHTML = html;
- el.style.color =
- kind === 'ok' ? '#3ddc84' : kind === 'bad' ? '#ff6b6b' : '';
- if (!kind) el.classList.add('muted');
- else el.classList.remove('muted');
- }
- function setSnsRegisterButtons(enabled) {
- els.snsRegisterAgentBtn.disabled = !enabled;
- els.snsRegisterUserBtn.disabled = !enabled;
- }
- function onSnsLabelInput() {
- clearTimeout(snsCheckTimer);
- const raw = els.snsRegisterLabel.value.trim().toLowerCase().replace(/\.sol$/, '');
- setSnsRegisterButtons(false);
- if (!raw) {
- setSnsCheckStatus(
- 'Bonfida pricing (1y): 1 char $750 · 2 $700 · 3 $640 · 4 $160 · 5+ $20. Paid in USDC.',
- null,
- );
- return;
- }
- if (!/^[a-z0-9-]{1,63}$/.test(raw)) {
- setSnsCheckStatus('Invalid: a–z, 0–9, hyphen only (max 63 chars).', 'bad');
- return;
- }
- const price = snsPriceFor(raw.length);
- setSnsCheckStatus(`Checking ${raw}.sol… ($${price}/yr)`, null);
- const seq = ++snsCheckSeq;
- const id = currentAgentId();
- if (!id) return;
- snsCheckTimer = setTimeout(async () => {
- try {
- const { data } = await api(
- `/api/agents/${id}/sns/check?domain=${encodeURIComponent(raw)}`,
- );
- if (seq !== snsCheckSeq) return;
- if (data.available) {
- setSnsCheckStatus(
- `✓ <strong>${raw}.sol</strong> is available — $${data.price_usdc} USDC for 1 year`,
- 'ok',
- );
- setSnsRegisterButtons(true);
- } else {
- const owner = data.owner ? ` (owner: ${data.owner.slice(0, 4)}…${data.owner.slice(-4)})` : '';
- setSnsCheckStatus(`✗ ${raw}.sol is already registered${owner}`, 'bad');
- }
- } catch (err) {
- if (seq !== snsCheckSeq) return;
- setSnsCheckStatus(`Could not check: ${err.message}`, 'bad');
- }
- }, 400);
- }
-
- async function registerWithAgent() {
- const id = currentAgentId();
- if (!id) return;
- const domain = readRegisterLabel();
- if (!domain) return;
- if (!confirm(`Register ${domain}.sol using the agent's wallet? The agent's USDC balance will be charged.`)) return;
- const btn = els.snsRegisterAgentBtn;
- btn.disabled = true;
- btn.textContent = 'Registering…';
- try {
- const { data } = await api(`/api/agents/${id}/sns/register`, {
- method: 'POST',
- body: JSON.stringify({ domain }),
- });
- toast(`Registered ${data.sns_domain}.sol`);
- els.snsRegisterLabel.value = '';
- onSnsLabelInput();
- await refreshSns();
- } catch (err) {
- toast(err.body?.error_description || err.message, 'err');
- } finally {
- btn.textContent = 'Pay with agent wallet';
- onSnsLabelInput();
- }
- }
-
- async function getConnectedSolanaWallet() {
- // Phantom / Solflare standard: window.solana with isPhantom or window.solflare.
- const provider = window.phantom?.solana || window.solana || window.solflare;
- if (!provider) {
- throw new Error('No Solana wallet found. Install Phantom or Solflare.');
- }
- if (!provider.isConnected) await provider.connect();
- const pubkey = provider.publicKey?.toString();
- if (!pubkey) throw new Error('Wallet did not return a public key');
- return { provider, pubkey };
- }
-
- async function registerWithUserWallet() {
- const id = currentAgentId();
- if (!id) return;
- const domain = readRegisterLabel();
- if (!domain) return;
-
- const btn = els.snsRegisterUserBtn;
- btn.disabled = true;
- btn.textContent = 'Connecting…';
- try {
- const { provider, pubkey } = await getConnectedSolanaWallet();
- btn.textContent = 'Building tx…';
- const { data: prep } = await api(`/api/agents/${id}/sns/register-prep`, {
- method: 'POST',
- body: JSON.stringify({ domain, wallet_address: pubkey }),
- });
-
- const { VersionedTransaction } = await import('https://esm.sh/@solana/[email protected]');
- const tx = VersionedTransaction.deserialize(
- Uint8Array.from(atob(prep.tx_base64), (c) => c.charCodeAt(0)),
- );
-
- btn.textContent = 'Awaiting signature…';
- const { signature } = await provider.signAndSendTransaction(tx);
-
- btn.textContent = 'Confirming…';
- // Poll the confirm endpoint a few times — the RPC needs a beat to index.
- let lastErr;
- for (let i = 0; i < 12; i++) {
- try {
- const { data } = await api(`/api/agents/${id}/sns/register-confirm`, {
- method: 'POST',
- body: JSON.stringify({ domain, signature, wallet_address: pubkey }),
- });
- toast(`Registered ${data.sns_domain}.sol`);
- els.snsRegisterLabel.value = '';
- onSnsLabelInput();
- await refreshSns();
- return;
- } catch (err) {
- lastErr = err;
- if (err.body?.error !== 'not_confirmed') throw err;
- await new Promise((r) => setTimeout(r, 2500));
- }
- }
- throw lastErr || new Error('confirmation timed out');
- } catch (err) {
- toast(err.body?.error_description || err.message, 'err');
- } finally {
- btn.textContent = 'Pay with my wallet';
- onSnsLabelInput();
- }
- }
-
- async function attachSns(domain) {
- const id = currentAgentId();
- if (!id) return;
- try {
- await api(`/api/agents/${id}/sns`, {
- method: 'POST',
- body: JSON.stringify({ domain }),
- });
- toast(`Attached ${domain}.sol`);
- await refreshSns();
- } catch (err) {
- toast(err.message, 'err');
- }
- }
-
- async function clearSns() {
- const id = currentAgentId();
- if (!id) return;
- try {
- await api(`/api/agents/${id}/sns`, { method: 'DELETE' });
- toast('SNS id cleared');
- await refreshSns();
- } catch (err) {
- toast(err.message, 'err');
- }
- }
-
- async function provision() {
- const id = currentAgentId();
- if (!id) return;
- try {
- await api(`/api/agents/${id}/solana`, { method: 'POST' });
- toast('Wallet provisioned');
- await refreshAgent();
- } catch (err) {
- toast(err.message, 'err');
- }
- }
-
- async function launchToken() {
- const id = currentAgentId();
- if (!id) return;
- const body = {
- name: els.launchName.value.trim(),
- symbol: els.launchSymbol.value.trim().toUpperCase(),
- uri: els.launchUri.value.trim(),
- network: currentNetwork(),
- };
- if (!body.name || !body.symbol || !body.uri) {
- toast('Name, symbol, and metadata URI are required', 'err');
- return;
- }
- const vanity = els.launchVanity.value.trim();
- const vanitySuffix = els.launchVanitySuffix.value.trim();
- if (vanity) body.vanityPrefix = vanity;
- if (vanitySuffix) body.vanitySuffix = vanitySuffix;
- if (els.launchVanityIc.checked) body.vanityIgnoreCase = true;
- if (window.__pendingMintSecret) {
- body.mintSecretKey = Array.from(window.__pendingMintSecret);
- }
- const sol = parseFloat(els.launchSol.value);
- if (sol > 0) body.solAmount = sol;
- els.launchBtn.disabled = true;
- els.launchBtn.textContent =
- vanity || vanitySuffix ? 'Grinding & launching…' : 'Launching…';
- try {
- const { data } = await api(`/api/agents/${id}/pumpfun/launch`, {
- method: 'POST',
- body: JSON.stringify(body),
- });
- logResponse('launch', data);
- toast(
- `Launched ${data.mint.slice(0, 12)}… (${data.vanity_iterations.toLocaleString()} attempts in ${data.vanity_duration_ms}ms)`,
- );
- els.tradeMint.value = data.mint;
- if (window.__pendingMintSecret) {
- window.__pendingMintSecret = null;
- const banner = document.getElementById('vg-launch-banner');
- if (banner) banner.remove();
- }
- await refreshAgent();
- await refreshPortfolio();
- } catch (err) {
- logResponse('launch error', err.body || { error: err.message });
- toast(err.message, 'err');
- } finally {
- els.launchBtn.disabled = false;
- els.launchBtn.textContent = 'Launch';
- }
- }
-
- async function buy() {
- const id = currentAgentId();
- const mint = els.tradeMint.value.trim();
- const solAmount = parseFloat(els.buySol.value);
- if (!id || !mint || !solAmount) {
- toast('Mint and SOL amount required', 'err');
- return;
- }
- const slippageBps = parseInt(els.tradeSlippage.value, 10) || 500;
- const network = currentNetwork();
- els.buyBtn.disabled = true;
- try {
- let data;
- try {
- ({ data } = await api(`/api/agents/${id}/pumpfun/swap`, {
- method: 'POST',
- body: JSON.stringify({ mint, side: 'buy', solAmount, slippageBps, network }),
- }));
- } catch (err) {
- if (err.body?.error === 'not_graduated') {
- ({ data } = await api(`/api/agents/${id}/pumpfun/buy`, {
- method: 'POST',
- body: JSON.stringify({ mint, solAmount, slippageBps, network }),
- }));
- data.venue = 'curve';
- } else throw err;
- }
- logResponse('buy', data);
- toast(`Bought ${solAmount} SOL of ${mint.slice(0, 8)}… (${data.venue || 'curve'})`);
- await refreshAgent();
- await refreshPortfolio();
- } catch (err) {
- logResponse('buy error', err.body || { error: err.message });
- toast(err.message, 'err');
- } finally {
- els.buyBtn.disabled = false;
- }
- }
-
- async function sell() {
- const id = currentAgentId();
- const mint = els.tradeMint.value.trim();
- const tokenAmount = els.sellTokens.value.trim();
- if (!id || !mint || !tokenAmount) {
- toast('Mint and token amount required', 'err');
- return;
- }
- const slippageBps = parseInt(els.tradeSlippage.value, 10) || 500;
- const network = currentNetwork();
- els.sellBtn.disabled = true;
- try {
- let data;
- try {
- ({ data } = await api(`/api/agents/${id}/pumpfun/swap`, {
- method: 'POST',
- body: JSON.stringify({ mint, side: 'sell', tokenAmount, slippageBps, network }),
- }));
- } catch (err) {
- if (err.body?.error === 'not_graduated') {
- ({ data } = await api(`/api/agents/${id}/pumpfun/sell`, {
- method: 'POST',
- body: JSON.stringify({ mint, tokenAmount, slippageBps, network }),
- }));
- data.venue = 'curve';
- } else throw err;
- }
- logResponse('sell', data);
- toast(`Sold ${tokenAmount} of ${mint.slice(0, 8)}… (${data.venue || 'curve'})`);
- await refreshAgent();
- await refreshPortfolio();
- } catch (err) {
- logResponse('sell error', err.body || { error: err.message });
- toast(err.message, 'err');
- } finally {
- els.sellBtn.disabled = false;
- }
- }
-
- function pnlClass(n) {
- if (n == null) return 'muted';
- if (n > 0.000001) return 'pnl-pos';
- if (n < -0.000001) return 'pnl-neg';
- return '';
- }
- function fmtSol(n) {
- if (n == null || Number.isNaN(n)) return '—';
- return Number(n).toFixed(6);
- }
-
- async function refreshPortfolio() {
- const id = currentAgentId();
- if (!id) return;
- const network = currentNetwork();
- try {
- const { data } = await api(
- `/api/agents/${id}/pumpfun/portfolio?network=${network}`,
- );
- logResponse('portfolio', data);
- const t = data.totals || {};
- els.portfolioTotals.innerHTML =
- `SOL in: <b>${fmtSol(t.sol_in)}</b> · SOL out: <b>${fmtSol(t.sol_out)}</b> · ` +
- `Est. value: <b>${fmtSol(t.estimated_value_sol)}</b> · Unrealized: ` +
- `<b class="${pnlClass(t.unrealized_pnl_sol)}">${fmtSol(t.unrealized_pnl_sol)}</b>`;
-
- const tbody = els.portfolioTable;
- if (!data.positions.length) {
- tbody.innerHTML =
- '<tr><td colspan="7"><div class="empty-cta"><b>No positions yet.</b><span>Launch a token above, or paste a mint into the trade panel to start tracking.</span></div></td></tr>';
- return;
- }
- tbody.innerHTML = '';
- for (const p of data.positions) {
- const tr = document.createElement('tr');
- const grad = p.graduated ? ' <span class="tag">graduated</span>' : '';
- const err = p.error
- ? ` <span class="tag" style="color:var(--err)">${p.error}</span>`
- : '';
- tr.innerHTML =
- `<td class="mono"><a href="https://pump.fun/${p.mint}" target="_blank" rel="noopener">${p.mint.slice(0, 12)}…</a>${grad}${err}</td>` +
- `<td>${fmtSol(p.sol_in)}</td>` +
- `<td>${fmtSol(p.sol_out)}</td>` +
- `<td class="mono">${p.token_balance}</td>` +
- `<td>${fmtSol(p.estimated_sol_value)}</td>` +
- `<td class="${pnlClass(p.unrealized_pnl_sol)}">${fmtSol(p.unrealized_pnl_sol)}</td>` +
- `<td><button class="btn ghost" data-mint="${p.mint}" data-action="use">Use</button></td>`;
- tbody.appendChild(tr);
- }
- tbody.querySelectorAll('button[data-action="use"]').forEach((b) => {
- b.addEventListener('click', () => {
- els.tradeMint.value = b.dataset.mint;
- toast('Mint copied to trade panel');
- });
- });
- } catch (err) {
- els.portfolioTotals.textContent = err.message;
- }
- }
-
- els.agentSelect.addEventListener('change', async () => {
- await refreshAgent();
- await refreshPortfolio();
- });
- function syncNetBadge() {
- const net = currentNetwork();
- const badge = document.getElementById('net-badge');
- if (badge) {
- badge.textContent = net;
- badge.className = `tag net-badge ${net === 'devnet' ? 'devnet' : 'mainnet'}`;
- }
- }
- els.networkSelect.addEventListener('change', async () => {
- syncNetBadge();
- await refreshAgent();
- await refreshPortfolio();
- });
- syncNetBadge();
- els.refreshBtn.addEventListener('click', () => {
- refreshAgent();
- refreshPortfolio();
- });
- els.provisionBtn.addEventListener('click', provision);
- els.snsRefreshBtn.addEventListener('click', refreshSns);
- els.snsClearBtn.addEventListener('click', clearSns);
- els.snsRegisterAgentBtn.addEventListener('click', registerWithAgent);
- els.snsRegisterUserBtn.addEventListener('click', registerWithUserWallet);
- els.snsRegisterLabel.addEventListener('input', onSnsLabelInput);
- els.launchBtn.addEventListener('click', launchToken);
- els.buyBtn.addEventListener('click', buy);
- els.sellBtn.addEventListener('click', sell);
- els.portfolioBtn.addEventListener('click', refreshPortfolio);
-
- // ── Token indexer panel ──────────────────────────────────────────
- const indexerPanel = document.getElementById('indexer-panel');
- const tokenStatsEl = document.getElementById('token-stats');
- const chartEl = document.getElementById('price-chart');
-
- function fmtSolLamports(s) {
- if (s == null) return '—';
- return (Number(s) / 1e9).toFixed(4) + ' SOL';
- }
-
- async function refreshIndexer() {
- const mint = els.tradeMint.value.trim();
- const network = currentNetwork();
- if (!mint) {
- indexerPanel.hidden = true;
- return;
- }
- indexerPanel.hidden = false;
- tokenStatsEl.innerHTML = '<div class="muted">Loading…</div>';
- try {
- const card = await fetch(`/api/agents/solana-card?asset=${mint}`)
- .then((r) => (r.ok ? r.json() : null))
- .catch(() => null);
- const ts = card?.token_stats;
- if (!ts) {
- tokenStatsEl.innerHTML =
- '<div class="muted">No indexed stats yet — pump-agent-stats cron runs every 10 min after launch.</div>';
- } else {
- const refreshedAgo = ts.refreshed_at
- ? `${Math.max(0, Math.round((Date.now() - new Date(ts.refreshed_at)) / 60000))}m ago`
- : '—';
- let body;
- if (ts.graduated) {
- const a = ts.amm || {};
- body =
- `<span class="tag" style="background:#5c8fff22;color:#9bf;border-color:#2a3a55">graduated · AMM</span>` +
- ` <span class="muted">refreshed ${refreshedAgo}</span>` +
- `<div class="stat-grid" style="margin-top:10px">` +
- `<div class="stat-card"><div class="v">${fmtSolLamports(a.quote_reserve)}</div><div class="l">Pool quote</div></div>` +
- `<div class="stat-card"><div class="v">${a.base_reserve ? Number(a.base_reserve).toExponential(2) : '—'}</div><div class="l">Pool base (tokens)</div></div>` +
- `<div class="stat-card"><div class="v">${ts.recent_tx_count || 0}</div><div class="l">Recent tx (50-tail)</div></div>` +
- `</div>`;
- } else if (ts.bonding_curve) {
- const c = ts.bonding_curve;
- const pct = Number(c.progress_pct || 0);
- body =
- `<div>Curve · <b>${pct.toFixed(1)}%</b> to graduation <span class="muted">refreshed ${refreshedAgo}</span></div>` +
- `<div style="background:#222;border-radius:6px;height:10px;overflow:hidden;margin:6px 0 10px"><div style="background:linear-gradient(90deg,#5c8fff,#00d4ff);width:${Math.min(100, pct)}%;height:100%"></div></div>` +
- `<div class="stat-grid">` +
- `<div class="stat-card"><div class="v">${fmtSolLamports(c.real_sol)}</div><div class="l">Real SOL reserves</div></div>` +
- `<div class="stat-card"><div class="v">${c.real_token ? Number(c.real_token).toExponential(2) : '—'}</div><div class="l">Real token reserves</div></div>` +
- `<div class="stat-card"><div class="v">${ts.recent_tx_count || 0}</div><div class="l">Recent tx (50-tail)</div></div>` +
- `</div>`;
- } else {
- body = `<div class="muted">No bonding curve or AMM pool detected.</div>`;
- }
- tokenStatsEl.innerHTML = body;
- }
-
- const hist = await fetch(
- `/api/agents/solana-price-history?asset=${mint}&network=${network}&hours=72`,
- )
- .then((r) => (r.ok ? r.json() : null))
- .catch(() => null);
- drawSparkline(chartEl, hist?.points || []);
- } catch (e) {
- tokenStatsEl.innerHTML = `<div class="muted">${e.message}</div>`;
- }
- }
-
- function drawSparkline(canvas, points) {
- const ctx = canvas.getContext('2d');
- const w = canvas.width,
- h = canvas.height;
- ctx.clearRect(0, 0, w, h);
- if (!points.length) {
- ctx.fillStyle = '#666';
- ctx.font = '12px system-ui';
- ctx.fillText('No price points yet (cron runs every 10 min).', 10, h / 2);
- return;
- }
- const xs = points.map((_, i) => i);
- const ys = points.map((p) => Number(p.sol_per_token) || 0);
- const min = Math.min(...ys),
- max = Math.max(...ys);
- const span = max - min || 1;
- const sx = (i) => (i / Math.max(1, xs.length - 1)) * (w - 16) + 8;
- const sy = (v) => h - 8 - ((v - min) / span) * (h - 16);
- ctx.strokeStyle = '#ffffff';
- ctx.lineWidth = 2;
- ctx.beginPath();
- ys.forEach((v, i) => {
- const x = sx(i),
- y = sy(v);
- if (i === 0) ctx.moveTo(x, y);
- else ctx.lineTo(x, y);
- });
- ctx.stroke();
- ctx.fillStyle = '#888';
- ctx.font = '11px system-ui';
- ctx.fillText(
- `${ys[0].toExponential(2)} → ${ys[ys.length - 1].toExponential(2)} SOL/tok`,
- 8,
- 14,
- );
- }
-
- document.getElementById('indexer-refresh').addEventListener('click', refreshIndexer);
- els.tradeMint.addEventListener('change', refreshIndexer);
-
- // ── Vanity grinder (browser-side) ───────────────────────────────
- const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
- const BASE58_SET = new Set(BASE58);
- const vg = {
- prefix: document.getElementById('vg-prefix'),
- suffix: document.getElementById('vg-suffix'),
- ic: document.getElementById('vg-ic'),
- start: document.getElementById('vg-start'),
- stop: document.getElementById('vg-stop'),
- progress: document.getElementById('vg-progress'),
- result: document.getElementById('vg-result'),
- address: document.getElementById('vg-address'),
- attempts: document.getElementById('vg-attempts'),
- duration: document.getElementById('vg-duration'),
- useLaunch: document.getElementById('vg-use-launch'),
- assign: document.getElementById('vg-assign'),
- copy: document.getElementById('vg-copy'),
- discard: document.getElementById('vg-discard'),
- };
- let vgRunning = false;
- let vgAbort = false;
- let vgHit = null; // { address, secretKey: Uint8Array, iterations, durationMs, prefix, suffix, ignoreCase }
-
- function vgValidPattern(p) {
- if (!p) return true;
- if (p.length > 6) return false;
- for (const c of p) if (!BASE58_SET.has(c)) return false;
- return true;
- }
- function vgEstimate(prefix, suffix, ic) {
- const len = (prefix?.length || 0) + (suffix?.length || 0);
- if (!len) return 1;
- return Math.pow(ic ? 33 : 58, len);
- }
- function vgUpdateIdle() {
- if (vgRunning) return;
- const p = vg.prefix.value.trim();
- const s = vg.suffix.value.trim();
- if (!vgValidPattern(p) || !vgValidPattern(s)) {
- vg.progress.textContent = 'Invalid pattern: base58 only (no 0/O/I/l), max 6 chars each.';
- return;
- }
- if (!p && !s) {
- vg.progress.textContent = 'Idle. Enter a prefix and/or suffix.';
- return;
- }
- const est = vgEstimate(p, s, vg.ic.checked);
- vg.progress.textContent = `Estimated ~${Math.round(est).toLocaleString()} attempts.`;
- }
- vg.prefix.addEventListener('input', vgUpdateIdle);
- vg.suffix.addEventListener('input', vgUpdateIdle);
- vg.ic.addEventListener('change', vgUpdateIdle);
- vgUpdateIdle();
-
- async function vgRun() {
- const prefix = vg.prefix.value.trim();
- const suffix = vg.suffix.value.trim();
- const ic = vg.ic.checked;
- if (!vgValidPattern(prefix) || !vgValidPattern(suffix)) {
- toast('Invalid pattern', 'err');
- return;
- }
- if (!prefix && !suffix) {
- toast('Enter a prefix or suffix', 'err');
- return;
- }
- const { Keypair } = await import('https://esm.sh/@solana/[email protected]');
- vgRunning = true;
- vgAbort = false;
- vg.start.hidden = true;
- vg.stop.hidden = false;
- vg.result.hidden = true;
- vgHit = null;
- const target = { p: ic ? prefix.toLowerCase() : prefix, s: ic ? suffix.toLowerCase() : suffix };
- const pLen = prefix.length, sLen = suffix.length;
- const start = performance.now();
- let attempts = 0;
- let lastTick = start;
- let lastAttempts = 0;
- const BATCH = 1500;
- try {
- while (!vgAbort) {
- for (let i = 0; i < BATCH; i++) {
- attempts++;
- const kp = Keypair.generate();
- const addr = kp.publicKey.toBase58();
- if (pLen) {
- const head = ic ? addr.slice(0, pLen).toLowerCase() : addr.slice(0, pLen);
- if (head !== target.p) continue;
- }
- if (sLen) {
- const tail = ic ? addr.slice(-sLen).toLowerCase() : addr.slice(-sLen);
- if (tail !== target.s) continue;
- }
- const dur = performance.now() - start;
- vgHit = {
- address: addr,
- secretKey: kp.secretKey,
- iterations: attempts,
- durationMs: Math.round(dur),
- prefix, suffix, ignoreCase: ic,
- };
- vg.address.textContent = addr;
- vg.attempts.textContent = attempts.toLocaleString();
- vg.duration.textContent = `${(dur / 1000).toFixed(2)}s`;
- vg.result.hidden = false;
- vg.progress.textContent = `Found a match in ${attempts.toLocaleString()} attempts.`;
- vgRunning = false;
- vg.start.hidden = false;
- vg.stop.hidden = true;
- return;
- }
- const now = performance.now();
- if (now - lastTick > 250) {
- const rate = ((attempts - lastAttempts) / (now - lastTick)) * 1000;
- lastTick = now;
- lastAttempts = attempts;
- vg.progress.textContent =
- `Grinding… ${attempts.toLocaleString()} attempts · ${Math.round(rate).toLocaleString()}/s · ${((now - start) / 1000).toFixed(1)}s elapsed`;
- await new Promise((r) => setTimeout(r, 0));
- }
- }
- vg.progress.textContent = `Stopped after ${attempts.toLocaleString()} attempts.`;
- } catch (err) {
- vg.progress.textContent = `Error: ${err.message}`;
- } finally {
- vgRunning = false;
- vg.start.hidden = false;
- vg.stop.hidden = true;
- }
- }
-
- vg.start.addEventListener('click', vgRun);
- vg.stop.addEventListener('click', () => { vgAbort = true; });
-
- vg.useLaunch.addEventListener('click', () => {
- if (!vgHit) return;
- window.__pendingMintSecret = vgHit.secretKey;
- els.launchVanity.value = vgHit.prefix || '';
- els.launchVanitySuffix.value = vgHit.suffix || '';
- els.launchVanityIc.checked = !!vgHit.ignoreCase;
- let banner = document.getElementById('vg-launch-banner');
- if (!banner) {
- banner = document.createElement('div');
- banner.id = 'vg-launch-banner';
- banner.style.cssText =
- 'margin-top:10px;padding:8px 12px;background:#0e1f17;border:1px solid #1f4232;border-radius:8px;font-size:13px;color:var(--ok)';
- els.launchBtn.closest('.panel').appendChild(banner);
- }
- banner.innerHTML = `✦ Pre-ground mint <code>${vgHit.address.slice(0, 12)}…</code> will be used for the next launch.`;
- toast('Pre-ground mint armed for launch');
- els.launchName.scrollIntoView({ behavior: 'smooth', block: 'center' });
- });
-
- vg.copy.addEventListener('click', async () => {
- if (!vgHit) return;
- const s = JSON.stringify(Array.from(vgHit.secretKey));
- try {
- await navigator.clipboard.writeText(s);
- toast('Secret JSON copied');
- } catch {
- toast('Clipboard blocked — secret in console', 'err');
- console.log(s);
- }
- });
-
- vg.discard.addEventListener('click', () => {
- if (vgHit) vgHit.secretKey.fill(0);
- vgHit = null;
- vg.result.hidden = true;
- vg.progress.textContent = 'Discarded.';
- });
-
- vg.assign.addEventListener('click', async () => {
- if (!vgHit) return;
- const id = currentAgentId();
- if (!id) return toast('Select an agent first', 'err');
- const ok = confirm(
- `Assign ${vgHit.address.slice(0, 16)}… as this agent's wallet?\n\n` +
- `If the agent already has a wallet, you must remove it first ` +
- `(this dialog will tell you to). Funds in the old wallet are NOT migrated automatically.`,
- );
- if (!ok) return;
- vg.assign.disabled = true;
- vg.assign.textContent = 'Assigning…';
- try {
- const body = { secret_key: Array.from(vgHit.secretKey) };
- if (vgHit.prefix) body.vanity_prefix = vgHit.prefix;
- await api(`/api/agents/${id}/solana`, {
- method: 'POST',
- body: JSON.stringify(body),
- });
- toast('Wallet assigned');
- vgHit.secretKey.fill(0);
- vgHit = null;
- vg.result.hidden = true;
- await refreshAgent();
- } catch (err) {
- if (err.body?.error === 'conflict') {
- toast('Agent already has a wallet — remove it first via DELETE', 'err');
- } else {
- toast(err.body?.error_description || err.message, 'err');
- }
- } finally {
- vg.assign.disabled = false;
- vg.assign.textContent = 'Assign as agent wallet';
- }
- });
-
- (async () => {
- await loadAgents();
- if (currentAgentId()) {
- await refreshAgent();
- await refreshPortfolio();
- }
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/avaturn-sdk.js b/public/dashboard-classic/avaturn-sdk.js
deleted file mode 100644
index e3ded471c..000000000
--- a/public/dashboard-classic/avaturn-sdk.js
+++ /dev/null
@@ -1,432 +0,0 @@
-function e(t, s) {
- return (
- (e = Object.setPrototypeOf
- ? Object.setPrototypeOf.bind()
- : function (e, t) {
- return (e.__proto__ = t), e;
- }),
- e(t, s)
- );
-}
-var t, s;
-!(function (e) {
- (e.AuthError = 'auth_error'),
- (e.AvatarLoadError = 'avatar_load_error'),
- (e.SceneError = 'scene_error');
-})(t || (t = {})),
- (function (e) {
- (e.AskForDefaults = 'ask_for_defaults'),
- (e.SDKHandshake = 'sdk_handshake'),
- (e.SDKHandshakeConfirmation = 'sdk_handshake_confirmation'),
- (e.CallbackEvent = 'callback_event'),
- (e.ReportError = 'report_error'),
- (e.GetAssetList = 'get_assets_list'),
- (e.GetActiveAssets = 'get_active_assets'),
- (e.SetAvailableAssets = 'set_assets_list'),
- (e.SetActiveAsset = 'set_active_asset'),
- (e.GetBodyList = 'get_bodies_list'),
- (e.GetActiveBody = 'get_avatar_info'),
- (e.SetAvailableBodies = 'set_bodies_list'),
- (e.SetActiveBody = 'set_active_body'),
- (e.GetAnimationList = 'get_animation_list'),
- (e.GetActiveAnimation = 'get_animation_info'),
- (e.SetActiveAnimation = 'set_active_animation'),
- (e.ExportAvatar = 'export_avatar'),
- (e.GenerateThumbnail = 'generate_thumbnail'),
- (e.SetParam = 'set_param'),
- (e.SetEyeColor = 'set_eye_color'),
- (e.SetHairColor = 'set_hair_color'),
- (e.SetEyewearColor = 'set_eyewear_color'),
- (e.SetBodyProportions = 'set_body_proportions'),
- (e.SetSkinTone = 'set_skin_tone'),
- (e.GetEyeColor = 'get_eye_color'),
- (e.GetHairColor = 'get_hair_color'),
- (e.GetEyewearColor = 'get_eyewear_color'),
- (e.GetBodyProportions = 'get_body_proportions'),
- (e.GetSkinTone = 'get_skin_tone'),
- (e.GetAvatarId = 'get_avatar_id');
- })(s || (s = {}));
-var r = /*#__PURE__*/ (function () {
- function e() {
- this.listeners = {};
- }
- var t = e.prototype;
- return (
- (t.watch = function (e, t) {
- this.listeners[e] = t;
- }),
- (t.unwatch = function (e) {
- delete this.listeners[e];
- }),
- e
- );
- })(),
- n = /*#__PURE__*/ (function () {
- function e(e, t) {
- (this.handshakeData = {}),
- (this.recipient = void 0),
- (this.thisSourceName = 'v1.avaturn-sdk'),
- (this.expectedIncomingSourceName = 'v1.avaturn-sdk-server'),
- (this._queue = new r()),
- (this._messageHandler = this.messageHandler.bind(this)),
- e && (this.thisSourceName = e),
- t && (this.expectedIncomingSourceName = t);
- }
- var t = e.prototype;
- return (
- (t.sendMessage = function (e, t, s, r) {
- var n = this;
- return (
- void 0 === r && (r = !0),
- new Promise(function (o, i) {
- var a,
- c = Date.now(),
- u = s || e + c;
- r &&
- n._queue.watch(u, function (e, t) {
- var s = null != t ? t : null;
- e ? o(s) : i(s), n._queue.unwatch(u);
- }),
- null == (a = n.recipient) ||
- a.postMessage(
- {
- type: 'MESSAGE',
- source: n.thisSourceName,
- eventName: e,
- key: u,
- date: c,
- data: t,
- isOk: !0,
- },
- '*',
- ),
- r || o(null);
- })
- );
- }),
- (t.messageHandler = function (e) {
- var t = e.data;
- this.expectedIncomingSourceName == t.source &&
- ('RESPONSE' === t.type &&
- ('sdk_handshake' === t.key &&
- this.sendMessage(
- s.SDKHandshakeConfirmation,
- this.handshakeData,
- void 0,
- !1,
- ),
- this._queue.listeners[t.key] &&
- this._queue.listeners[t.key](t.isOk, t.data)),
- 'MESSAGE' === t.type && this.handleMessage(t));
- }),
- (t.setupMessaging = function () {
- window.addEventListener('message', this._messageHandler);
- }),
- (t.destroyMessaging = function () {
- console.log('destroy'), window.removeEventListener('message', this._messageHandler);
- }),
- (t.sendResponse = function (e, t, s) {
- var r,
- n = void 0 === s ? { isOk: !0 } : s,
- o = n.isOk,
- i = n.data;
- if (this.recipient) {
- var a = {
- type: 'RESPONSE',
- source: this.thisSourceName,
- eventName: e,
- key: t,
- date: Date.now(),
- data: i,
- isOk: o,
- };
- null == (r = this.recipient) || r.postMessage(a, '*');
- } else console.log('Recipient is not set.');
- }),
- (t.handleMessage = function (e) {}),
- e
- );
- })(),
- o = /*#__PURE__*/ (function (t) {
- function r() {
- var e;
- return (
- ((e = t.call(this) || this)._version = '1.1.4'),
- (e.defaultAssets = void 0),
- (e.sceneRef = null),
- (e.callbacks = {}),
- (e.suppressCallbacks = void 0),
- e
- );
- }
- var n, o;
- (o = t),
- ((n = r).prototype = Object.create(o.prototype)),
- (n.prototype.constructor = n),
- e(n, o);
- var i = r.prototype;
- return (
- (i.applyStyles = function (e) {
- (e.style.width = '100%'), (e.style.height = '100%');
- }),
- (i.validateDefaultAssets = function (e) {
- return (
- 'object' == typeof e &&
- 'boolean' == typeof e.overrideSaved &&
- !!Array.isArray(e.assets)
- );
- }),
- (i.setupDOM = function (e, t, s) {
- var r,
- n = document.querySelector('#avaturn-sdk-iframe');
- n && n.remove();
- var o = document.createElement('iframe');
- o.setAttribute('src', t),
- o.setAttribute('id', 'avaturn-sdk-iframe'),
- o.setAttribute('allow', 'camera *; clipboard-write'),
- o.setAttribute('allowfullscreen', ''),
- o.setAttribute('frameborder', '0'),
- s ? o.setAttribute('class', s) : this.applyStyles(o),
- e.appendChild(o),
- (this.sceneRef = document.querySelector('#avaturn-sdk-iframe')),
- (this.recipient = null == (r = this.sceneRef) ? void 0 : r.contentWindow);
- }),
- (i.handleMessage = function (e) {
- var t, r, n, o;
- switch (e.eventName) {
- case s.AskForDefaults:
- this.sendResponse(s.AskForDefaults, e.key, {
- isOk: !0,
- data: this.defaultAssets,
- });
- break;
- case s.CallbackEvent:
- null == (t = (r = this.callbacks)[e.key]) || t.call(r, e.data);
- break;
- case s.ReportError:
- null == (n = (o = this.callbacks).error) || n.call(o, e.data);
- }
- }),
- (i.init = function (e, t) {
- var r = t.url,
- n = t.iframeClassName,
- o = t.disableUi,
- i = t.defaultAssets;
- try {
- var a = this;
- if (((a.suppressCallbacks = o), i && !a.validateDefaultAssets(i)))
- throw new Error("Field 'defaultAssets' has an invalid format");
- a.defaultAssets = i;
- var c = new URL(
- r ||
- 'https://preview.avaturn.dev/editor?avatar_link=https%3A%2F%2Fassets.avaturn.me%2Feditor_resources%2Fdefault_male.glb',
- );
- return (
- c.searchParams.append('sdk', 'true'),
- o && c.searchParams.append('noui', 'true'),
- e ? a.setupDOM(e, c.toString(), n) : (a.recipient = window),
- (a.handshakeData = {
- url: document.location.href,
- environment: window.avaturnSDKEnvironment,
- version: a._version,
- }),
- a.setupMessaging(),
- Promise.resolve(
- a
- .sendMessage(s.SDKHandshake, a.handshakeData, 'sdk_handshake')
- .then(function () {
- try {
- return Promise.resolve(
- a.sendMessage(
- s.SDKHandshakeConfirmation,
- a.handshakeData,
- void 0,
- !1,
- ),
- ).then(function () {
- return a;
- });
- } catch (e) {
- return Promise.reject(e);
- }
- })
- .catch(function (e) {
- throw new Error(e);
- }),
- )
- );
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.destroy = function () {
- this.destroyMessaging(), (this.callbacks = {});
- }),
- (i.on = function (e, t) {
- return this.suppressCallbacks && 'load' != e
- ? (console.log(
- "Can't use callbacks for " +
- e +
- ' in disableUi mode. Use <action>.then(...) instead.',
- ),
- this)
- : ((this.callbacks[e] = t), this);
- }),
- (i.getAssetList = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetAssetList));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setAvailableAssets = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetAvailableAssets, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getActiveAssets = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetActiveAssets));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setActiveAsset = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetActiveAsset, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setActiveBody = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetActiveBody, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getBodyList = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetBodyList));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getActiveBody = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetActiveBody));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setActiveAnimation = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetActiveAnimation, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getActiveAnimation = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetActiveAnimation));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getAnimationList = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetAnimationList));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.exportAvatar = function () {
- try {
- return Promise.resolve(
- this.sendMessage(s.ExportAvatar, void 0, 'export_avatar'),
- );
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setEyeColor = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetEyeColor, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setHairColor = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetHairColor, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setEyewearColor = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetEyewearColor, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setBodyProportions = function (e, t) {
- try {
- return Promise.resolve(
- this.sendMessage(s.SetBodyProportions, { key: e, value: t }),
- );
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.setSkinToneCorrection = function (e) {
- try {
- return Promise.resolve(this.sendMessage(s.SetSkinTone, e));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getEyeColor = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetEyeColor));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getHairColor = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetHairColor));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getEyewearColor = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetEyewearColor));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getBodyProportions = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetBodyProportions));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getSkinToneCorrection = function () {
- try {
- return Promise.resolve(this.sendMessage(s.GetSkinTone));
- } catch (e) {
- return Promise.reject(e);
- }
- }),
- (i.getAvatarId = function () {
- return this.sendMessage(s.GetAvatarId);
- }),
- r
- );
- })(n);
-export { o as AvaturnSDK, s as MessageType, n as Messaging, t as SDKErrors };
diff --git a/public/dashboard-classic/delegation.html b/public/dashboard-classic/delegation.html
deleted file mode 100644
index 369b6de5b..000000000
--- a/public/dashboard-classic/delegation.html
+++ /dev/null
@@ -1,142 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent Delegation · three.ws</title>
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- </head>
- <body>
- <div class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <h1 class="dash-title">Agent Delegation</h1>
- <p class="dash-sub">
- Send a message from one of your agents to any other agent. Calls
- <code class="dash-mono">/api/agent-delegate</code>. Nested calls are rejected — depth is
- capped at 1 to prevent recursion.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </div>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const contentEl = document.getElementById('content');
- let allAgents = [];
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- }
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[c],
- );
- }
-
- async function callDelegate(fromAgentId, toAgentId, message) {
- const r = await fetch('/api/agent-delegate', {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ fromAgentId, toAgentId, message }),
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- async function fetchAllAgents() {
- const r = await fetch('/api/agents', { credentials: 'include' });
- if (!r.ok) return [];
- const data = await r.json();
- return data.agents || [];
- }
-
- function render(fromAgentId) {
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>Send message</h2>
- <form id="del-form" style="display:grid;gap:12px">
- <label>
- <div class="dash-muted" style="margin-bottom:4px">From (this agent)</div>
- <input class="dash-input" readonly value="${escapeHtml(fromAgentId)}" />
- </label>
- <label>
- <div class="dash-muted" style="margin-bottom:4px">To (target agent)</div>
- <select class="dash-select" name="to" required>
- <option value="">Pick a target agent…</option>
- ${allAgents
- .filter((a) => a.id !== fromAgentId)
- .map(
- (a) =>
- `<option value="${escapeHtml(a.id)}">${escapeHtml(a.name || 'Agent')} · ${escapeHtml(a.id.slice(0, 8))}…</option>`,
- )
- .join('')}
- </select>
- <div class="dash-muted" style="margin-top:4px;font-size:11px">
- Pasting any UUID works too — targets need not belong to you.
- </div>
- <input class="dash-input" name="to_manual" placeholder="…or paste any agent UUID" style="margin-top:6px" />
- </label>
- <label>
- <div class="dash-muted" style="margin-bottom:4px">Message</div>
- <textarea class="dash-textarea" name="message" required maxlength="8000" placeholder="What should the target agent respond to?"></textarea>
- </label>
- <div class="dash-row">
- <button class="dash-btn primary" type="submit">Send</button>
- <span class="dash-muted" id="del-status"></span>
- </div>
- </form>
- </div>
- <div class="dash-card" id="reply-card" style="display:none">
- <h2>Reply</h2>
- <div id="reply-body" style="white-space:pre-wrap;color:#ddd"></div>
- </div>
- `;
-
- document.getElementById('del-form').addEventListener('submit', async (e) => {
- e.preventDefault();
- const fd = new FormData(e.target);
- const toAgentId = String(fd.get('to_manual') || fd.get('to') || '').trim();
- const message = String(fd.get('message') || '').trim();
- if (!toAgentId || !message) return;
- const replyCard = document.getElementById('reply-card');
- const replyBody = document.getElementById('reply-body');
- const delStatus = document.getElementById('del-status');
- delStatus.textContent = 'Sending…';
- replyCard.style.display = 'none';
- try {
- const { response } = await callDelegate(fromAgentId, toAgentId, message);
- replyBody.textContent = response || '(empty response)';
- replyCard.style.display = 'block';
- delStatus.textContent = '';
- } catch (err) {
- delStatus.textContent = '';
- showStatus(err.message || 'Delegate failed', 'err');
- }
- });
- }
-
- async function refresh(agentId) {
- contentEl.innerHTML = '<div class="dash-empty">Loading agents…</div>';
- if (!allAgents.length) allAgents = await fetchAllAgents();
- render(agentId);
- }
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => refresh(agentId),
- });
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/embed-policy.html b/public/dashboard-classic/embed-policy.html
deleted file mode 100644
index e24e3d334..000000000
--- a/public/dashboard-classic/embed-policy.html
+++ /dev/null
@@ -1,724 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Embed policy · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- body[data-auth-pending] {
- visibility: hidden;
- }
- </style>
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #9a8cff;
- text-decoration: none;
- }
- header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: var(--bg);
- z-index: 5;
- }
- .brand {
- font-weight: 600;
- letter-spacing: -0.01em;
- }
- main {
- padding: 28px;
- max-width: 720px;
- margin: 0 auto;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: #888;
- margin: 0 0 22px;
- font-size: 14px;
- }
- .card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 20px;
- margin-bottom: 20px;
- }
- fieldset {
- border: 0;
- padding: 0;
- margin: 0;
- }
- legend {
- font-size: 13px;
- font-weight: 600;
- color: #ccc;
- margin-bottom: 12px;
- letter-spacing: 0.02em;
- text-transform: uppercase;
- }
- label {
- display: block;
- margin: 14px 0 6px;
- font-size: 13px;
- color: #bbb;
- }
- label.check {
- display: flex;
- align-items: center;
- gap: 8px;
- margin: 8px 0;
- cursor: pointer;
- color: #ccc;
- }
- label.check input {
- width: auto;
- margin: 0;
- }
- input,
- select,
- textarea {
- background: #0f0f17;
- border: 1px solid var(--border);
- color: #eee;
- padding: 9px 11px;
- border-radius: 8px;
- font-size: 14px;
- font-family: inherit;
- width: 100%;
- }
- textarea {
- min-height: 120px;
- font-family:
- ui-monospace,
- SF Mono,
- Menlo,
- monospace;
- font-size: 13px;
- }
- input:focus,
- textarea:focus,
- select:focus {
- outline: none;
- border-color: var(--accent);
- }
- input[type='checkbox'] {
- width: 16px;
- height: 16px;
- accent-color: var(--accent);
- }
- input[type='number'] {
- -moz-appearance: textfield;
- }
- .row {
- display: flex;
- gap: 10px;
- align-items: center;
- }
- .col2 {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 12px;
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- }
- .btn.sec {
- background: #15151d;
- color: #ddd;
- border-color: #222222;
- }
- .btn.sec:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .btn.danger {
- background: #15151d;
- border-color: rgba(204, 64, 64, 0.4);
- color: #ff9c9c;
- }
- .btn.danger:hover:not(:disabled) {
- background: rgba(204, 64, 64, 0.12);
- border-color: rgba(204, 64, 64, 0.6);
- }
- .muted {
- color: #888;
- font-size: 13px;
- }
- .err {
- padding: 12px;
- background: rgba(255, 92, 92, 0.1);
- border: 1px solid rgba(255, 92, 92, 0.3);
- border-radius: 8px;
- color: #ffb3b3;
- margin-bottom: 14px;
- }
- .ok {
- padding: 12px;
- background: rgba(92, 255, 140, 0.07);
- border: 1px solid rgba(92, 255, 140, 0.2);
- border-radius: 8px;
- color: #b6f2c6;
- margin-bottom: 14px;
- }
- code {
- font-family:
- ui-monospace,
- SF Mono,
- Menlo,
- monospace;
- background: #0f0f17;
- border: 1px solid var(--border);
- border-radius: 4px;
- padding: 1px 6px;
- font-size: 12px;
- }
- .actions {
- display: flex;
- gap: 10px;
- margin-top: 22px;
- }
- hr {
- border: 0;
- border-top: 1px solid var(--border);
- margin: 22px 0;
- }
- .hidden {
- display: none !important;
- }
- body[data-auth-pending] {
- visibility: hidden;
- }
- </style>
- </head>
- <body data-auth-pending>
- <header>
- <div class="brand"><a href="/dashboard">← Dashboard</a></div>
- <div class="muted"><span id="agent-name">Agent</span></div>
- </header>
- <main>
- <h1>Embed policy</h1>
- <p class="sub">
- Control how <code id="embed-url"></code> can be embedded across the web.
- </p>
-
- <div id="status"></div>
-
- <!-- Origins -->
- <div class="card">
- <fieldset>
- <legend>Origins</legend>
- <label for="mode">Policy mode</label>
- <select id="mode">
- <option value="off">Off — allow all embeds</option>
- <option value="allowlist">Allowlist — only these hosts</option>
- <option value="denylist">Denylist — everywhere except these hosts</option>
- </select>
-
- <div id="hosts-wrap">
- <label for="hosts">Hosts (one per line)</label>
- <textarea
- id="hosts"
- placeholder="example.com&#10;*.substack.com"
- ></textarea>
- <div class="muted" style="margin-top: 6px">
- One host per line. Use <code>*.example.com</code> to match all
- subdomains.
- </div>
- </div>
- </fieldset>
- </div>
-
- <!-- Surfaces -->
- <div class="card">
- <fieldset>
- <legend>Surfaces</legend>
- <div class="muted" style="margin-bottom: 12px">
- Choose which embed surfaces are enabled for this agent.
- </div>
- <label class="check"
- ><input type="checkbox" id="surf-script" />
- <span
- ><strong>Script tag</strong> — <code>&lt;agent-3d&gt;</code> on
- third-party pages</span
- ></label
- >
- <label class="check"
- ><input type="checkbox" id="surf-iframe" />
- <span
- ><strong>iframe</strong> —
- <code>&lt;iframe src="/agent/:id/embed"&gt;</code></span
- ></label
- >
- <label class="check"
- ><input type="checkbox" id="surf-widget" />
- <span
- ><strong>Widget</strong> — <code>/w/:id</code> widget pages</span
- ></label
- >
- <label class="check"
- ><input type="checkbox" id="surf-mcp" />
- <span
- ><strong>MCP</strong> — exposed as an MCP tool over
- <code>/api/mcp</code></span
- ></label
- >
- </fieldset>
- </div>
-
- <!-- Brain -->
- <div class="card">
- <fieldset>
- <legend>Brain / LLM</legend>
- <label for="brain-mode">Payment mode</label>
- <select id="brain-mode">
- <option value="we-pay">
- We-pay — three.ws covers API costs (quota-limited)
- </option>
- <option value="key-proxy">
- Key-proxy — calls routed through your proxy URL
- </option>
- <option value="wallet-gated">
- Wallet-gated — user pays via connected wallet
- </option>
- <option value="none">None — LLM disabled for this agent</option>
- </select>
-
- <div id="proxy-url-wrap">
- <label for="brain-proxy-url">Proxy URL</label>
- <input
- type="url"
- id="brain-proxy-url"
- placeholder="https://owner.example/llm"
- />
- </div>
-
- <div class="col2" style="margin-top: 14px">
- <div>
- <label for="brain-quota">Monthly quota (completions)</label>
- <input
- type="number"
- id="brain-quota"
- min="0"
- placeholder="1000 (blank = unlimited)"
- />
- </div>
- <div>
- <label for="brain-rate">Rate limit (req / min)</label>
- <input
- type="number"
- id="brain-rate"
- min="0"
- placeholder="10 (blank = unlimited)"
- />
- </div>
- </div>
-
- <label for="brain-model">Model</label>
- <select id="brain-model">
- <optgroup label="Free — host-paid (recommended)">
- <option value="meta-llama/llama-3.3-70b-instruct:free">
- OpenRouter · Llama 3.3 70B (free) — default
- </option>
- <option value="openai/gpt-oss-120b:free">
- OpenRouter · GPT-OSS 120B (free)
- </option>
- <option value="nousresearch/hermes-3-llama-3.1-405b:free">
- OpenRouter · Hermes 3 405B (free)
- </option>
- <option value="llama-3.3-70b-versatile">
- Groq · Llama 3.3 70B (free, sub-second)
- </option>
- <option value="llama-3.1-8b-instant">
- Groq · Llama 3.1 8B (free, fastest)
- </option>
- </optgroup>
- <optgroup label="Paid Claude — uses host's Anthropic key">
- <option value="claude-haiku-4-5-20251001">Claude Haiku 4.5</option>
- <option value="claude-sonnet-4-6">Claude Sonnet 4.6</option>
- <option value="claude-opus-4-6">Claude Opus 4.6</option>
- <option value="claude-opus-4-7">Claude Opus 4.7</option>
- </optgroup>
- </select>
- </fieldset>
- </div>
-
- <!-- Storage -->
- <div class="card">
- <fieldset>
- <legend>Storage</legend>
- <label for="storage-primary">Primary storage</label>
- <select id="storage-primary">
- <option value="r2">R2 (Cloudflare) — default</option>
- <option value="ipfs">IPFS — decentralised</option>
- </select>
-
- <label class="check" style="margin-top: 14px">
- <input type="checkbox" id="storage-ipfs" disabled />
- <span
- ><strong>IPFS pin</strong> — avatar pinned to IPFS
- <em class="muted">(pin flow coming soon)</em></span
- >
- </label>
- <label class="check">
- <input type="checkbox" id="storage-attested" disabled />
- <span
- ><strong>On-chain attestation</strong> — content hash recorded on-chain
- <em class="muted">(coming soon)</em></span
- >
- </label>
- </fieldset>
- </div>
-
- <div class="actions">
- <button class="btn" id="save">Save</button>
- <button class="btn sec" id="reload">Reload</button>
- <button class="btn danger" id="clear" style="margin-left: auto">
- Clear policy
- </button>
- </div>
-
- <hr />
-
- <div class="muted">
- Signed-in owners can preview the embed bypassing this policy by appending
- <code>?preview=1</code> to the embed URL.
- </div>
- </main>
- <script type="module">
- const params = new URL(location.href).searchParams;
- let agentId = params.get('agent');
- const statusEl = document.getElementById('status');
- const modeSel = document.getElementById('mode');
- const hostsEl = document.getElementById('hosts');
- const hostsWrap = document.getElementById('hosts-wrap');
- const nameEl = document.getElementById('agent-name');
- const urlEl = document.getElementById('embed-url');
- const brainModeSel = document.getElementById('brain-mode');
- const proxyWrap = document.getElementById('proxy-url-wrap');
- const formEls = document.querySelectorAll(
- 'main > .card, main > .actions, main > hr, main > .muted',
- );
-
- function setFormVisible(visible) {
- for (const el of formEls) el.style.display = visible ? '' : 'none';
- }
-
- async function api(method, path, body) {
- const res = await fetch(path, {
- method,
- credentials: 'include',
- headers: body ? { 'content-type': 'application/json' } : {},
- body: body ? JSON.stringify(body) : undefined,
- });
- const ct = res.headers.get('content-type') || '';
- const data = ct.includes('application/json') ? await res.json() : null;
- if (!res.ok)
- throw Object.assign(
- new Error((data && data.error_description) || res.statusText),
- { status: res.status, fields: data?.fields },
- );
- return data;
- }
-
- function setStatus(html) {
- statusEl.innerHTML = html;
- }
-
- function updateOriginVisibility() {
- hostsWrap.style.display = modeSel.value === 'off' ? 'none' : '';
- }
-
- function updateBrainVisibility() {
- proxyWrap.classList.toggle('hidden', brainModeSel.value !== 'key-proxy');
- }
-
- async function loadMe() {
- let data;
- try {
- data = await api('GET', '/api/auth/me');
- } catch {
- data = null;
- }
- if (!data?.user) {
- location.href =
- '/login?next=' + encodeURIComponent(location.pathname + location.search);
- throw new Error('redirecting');
- }
- document.body.removeAttribute('data-auth-pending');
- }
-
- async function loadAgent() {
- try {
- const { agent } = await api('GET', `/api/agents/${agentId}`);
- nameEl.textContent = agent.name || 'Agent';
- } catch (e) {
- setStatus(
- `<div class="err">Could not load agent: ${escapeHtml(e.message)}</div>`,
- );
- }
- }
-
- function populateForm(policy) {
- if (!policy) {
- modeSel.value = 'off';
- hostsEl.value = '';
- document.getElementById('surf-script').checked = true;
- document.getElementById('surf-iframe').checked = true;
- document.getElementById('surf-widget').checked = true;
- document.getElementById('surf-mcp').checked = false;
- brainModeSel.value = 'we-pay';
- document.getElementById('brain-proxy-url').value = '';
- document.getElementById('brain-quota').value = '1000';
- document.getElementById('brain-rate').value = '10';
- document.getElementById('brain-model').value =
- 'meta-llama/llama-3.3-70b-instruct:free';
- document.getElementById('storage-primary').value = 'r2';
- document.getElementById('storage-ipfs').checked = false;
- document.getElementById('storage-attested').checked = false;
- updateOriginVisibility();
- updateBrainVisibility();
- return;
- }
-
- const orig = policy.origins || {};
- modeSel.value = orig.mode === 'denylist' ? 'denylist' : 'allowlist';
- hostsEl.value = (orig.hosts || []).join('\n');
-
- const surf = policy.surfaces || {};
- document.getElementById('surf-script').checked = surf.script !== false;
- document.getElementById('surf-iframe').checked = surf.iframe !== false;
- document.getElementById('surf-widget').checked = surf.widget !== false;
- document.getElementById('surf-mcp').checked = !!surf.mcp;
-
- const brain = policy.brain || {};
- brainModeSel.value = brain.mode || 'we-pay';
- document.getElementById('brain-proxy-url').value = brain.proxy_url || '';
- document.getElementById('brain-quota').value =
- brain.monthly_quota != null ? String(brain.monthly_quota) : '';
- document.getElementById('brain-rate').value =
- brain.rate_limit_per_min != null ? String(brain.rate_limit_per_min) : '';
- document.getElementById('brain-model').value =
- brain.model || 'meta-llama/llama-3.3-70b-instruct:free';
-
- const storage = policy.storage || {};
- document.getElementById('storage-primary').value = storage.primary || 'r2';
- document.getElementById('storage-ipfs').checked = !!storage.pinned_ipfs;
- document.getElementById('storage-attested').checked = !!storage.onchain_attested;
-
- updateOriginVisibility();
- updateBrainVisibility();
- }
-
- async function loadPolicy() {
- try {
- const { policy } = await api('GET', `/api/agents/${agentId}/embed-policy`);
- populateForm(policy);
- } catch (e) {
- setStatus(
- `<div class="err">Could not load policy: ${escapeHtml(e.message)}</div>`,
- );
- }
- }
-
- function buildPolicy() {
- const numOrNull = (id) => {
- const v = document.getElementById(id).value.trim();
- return v === '' ? null : parseInt(v, 10);
- };
-
- return {
- version: 1,
- origins: {
- mode: modeSel.value === 'off' ? 'allowlist' : modeSel.value,
- hosts:
- modeSel.value === 'off'
- ? []
- : hostsEl.value
- .split(/\r?\n/)
- .map((s) => s.trim())
- .filter(Boolean),
- },
- surfaces: {
- script: document.getElementById('surf-script').checked,
- iframe: document.getElementById('surf-iframe').checked,
- widget: document.getElementById('surf-widget').checked,
- mcp: document.getElementById('surf-mcp').checked,
- },
- brain: {
- mode: brainModeSel.value,
- proxy_url: document.getElementById('brain-proxy-url').value.trim() || null,
- monthly_quota: numOrNull('brain-quota'),
- rate_limit_per_min: numOrNull('brain-rate'),
- model:
- document.getElementById('brain-model').value.trim() ||
- 'meta-llama/llama-3.3-70b-instruct:free',
- },
- storage: {
- primary: document.getElementById('storage-primary').value,
- pinned_ipfs: document.getElementById('storage-ipfs').checked,
- onchain_attested: document.getElementById('storage-attested').checked,
- },
- };
- }
-
- async function save() {
- setStatus('');
- try {
- const { policy } = await api(
- 'PUT',
- `/api/agents/${agentId}/embed-policy`,
- buildPolicy(),
- );
- populateForm(policy);
- setStatus('<div class="ok">Policy saved.</div>');
- } catch (e) {
- let msg = escapeHtml(e.message);
- if (e.fields && e.fields.length) {
- msg +=
- '<br><small>' +
- e.fields
- .map((f) => escapeHtml(f.path?.join('.') + ': ' + f.message))
- .join('<br>') +
- '</small>';
- }
- setStatus(`<div class="err">${msg}</div>`);
- }
- }
-
- async function clearPolicy() {
- if (!confirm('Clear the embed policy? Defaults will apply.')) return;
- try {
- await api('DELETE', `/api/agents/${agentId}/embed-policy`);
- populateForm(null);
- setStatus('<div class="ok">Policy cleared.</div>');
- } catch (e) {
- setStatus(`<div class="err">${escapeHtml(e.message)}</div>`);
- }
- }
-
- function escapeHtml(s) {
- return String(s ?? '').replace(
- /[&<>"']/g,
- (c) =>
- ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[
- c
- ],
- );
- }
-
- modeSel.addEventListener('change', updateOriginVisibility);
- brainModeSel.addEventListener('change', updateBrainVisibility);
- document.getElementById('save').addEventListener('click', save);
- document.getElementById('reload').addEventListener('click', loadPolicy);
- document.getElementById('clear').addEventListener('click', clearPolicy);
-
- async function pickAgent() {
- let list = [];
- try {
- const { agents } = await api('GET', '/api/agents');
- list = Array.isArray(agents) ? agents : [];
- } catch (e) {
- setStatus(
- `<div class="err">Could not load your agents: ${escapeHtml(e.message)}</div>`,
- );
- return null;
- }
-
- if (list.length === 0) {
- setFormVisible(false);
- setStatus(
- `<div class="err">You don't have any agents yet. <a href="/dashboard/create">Create one</a> to configure an embed policy.</div>`,
- );
- return null;
- }
-
- if (list.length === 1) {
- const u = new URL(location.href);
- u.searchParams.set('agent', list[0].id);
- location.replace(u.toString());
- return null;
- }
-
- setFormVisible(false);
- const opts = list
- .map(
- (a) =>
- `<option value="${escapeHtml(a.id)}">${escapeHtml(a.name || a.id)}</option>`,
- )
- .join('');
- setStatus(
- `<div class="card"><label for="agent-pick">Choose an agent</label>` +
- `<select id="agent-pick">${opts}</select>` +
- `<div class="actions"><button class="btn" id="agent-pick-go">Continue</button></div></div>`,
- );
- return await new Promise((resolve) => {
- document
- .getElementById('agent-pick-go')
- .addEventListener('click', () => {
- const id = document.getElementById('agent-pick').value;
- const u = new URL(location.href);
- u.searchParams.set('agent', id);
- location.replace(u.toString());
- resolve(null);
- });
- });
- }
-
- (async () => {
- await loadMe();
- if (!agentId) {
- await pickAgent();
- return;
- }
- urlEl.textContent = `/agent/${agentId}/embed`;
- await loadAgent();
- await loadPolicy();
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/index.html b/public/dashboard-classic/index.html
deleted file mode 100644
index 6d5ef48c7..000000000
--- a/public/dashboard-classic/index.html
+++ /dev/null
@@ -1,1439 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Dashboard · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <link rel="stylesheet" href="/fonts/fonts.css" />
- <link rel="stylesheet" href="/footer.css" />
- <link rel="stylesheet" href="/src/pump/launch-token-modal.css" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #cccccc;
- text-decoration: none;
- }
- header {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: 0 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: rgba(11, 11, 16, 0.92);
- backdrop-filter: blur(16px);
- -webkit-backdrop-filter: blur(16px);
- z-index: 5;
- height: 60px;
- }
- header h1 {
- margin: 0;
- font-size: inherit;
- font-weight: inherit;
- flex-shrink: 0;
- }
- header h1 a {
- display: flex;
- align-items: center;
- }
- .wordmark-logo {
- height: 1.55rem;
- width: auto;
- display: block;
- }
- .dash-header-nav {
- display: flex;
- align-items: center;
- gap: 2px;
- margin-left: 4px;
- flex: 1;
- overflow-x: auto;
- scrollbar-width: none;
- }
- .dash-header-nav::-webkit-scrollbar {
- display: none;
- }
- .dash-header-nav a {
- padding: 6px 10px;
- border-radius: 6px;
- color: #888;
- font-size: 13px;
- text-decoration: none;
- transition:
- color 0.15s,
- background 0.15s;
- white-space: nowrap;
- }
- .dash-header-nav a:hover {
- color: #eee;
- background: rgba(255, 255, 255, 0.05);
- }
- .dash-header-nav a.active {
- color: #fff;
- background: rgba(255, 255, 255, 0.12);
- }
- .dash-header-user {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-shrink: 0;
- margin-left: auto;
- }
- .layout {
- display: grid;
- grid-template-columns: 220px 1fr;
- min-height: calc(100vh - 60px);
- }
- aside {
- border-right: 1px solid var(--border);
- padding: 20px 0;
- }
- aside a {
- display: block;
- padding: 9px 20px;
- color: #aaa;
- font-size: 14px;
- border-left: 2px solid transparent;
- }
- aside a.active {
- color: #fff;
- background: rgba(255, 255, 255, 0.08);
- border-left-color: var(--accent);
- }
- main {
- padding: 28px;
- max-width: 1100px;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: #888;
- margin: 0 0 22px;
- font-size: 14px;
- }
- .cards {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
- gap: 14px;
- }
- .card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 16px;
- }
- .card h3 {
- margin: 0 0 4px;
- font-size: 15px;
- }
- .card .meta {
- font-size: 12px;
- color: #888;
- margin: 0 0 10px;
- }
- .preview {
- aspect-ratio: 1/1;
- background: #0f0f17;
- border-radius: 10px;
- margin-bottom: 10px;
- overflow: hidden;
- display: grid;
- place-items: center;
- color: #555;
- font-size: 12px;
- position: relative;
- }
- .preview model-viewer {
- width: 100%;
- height: 100%;
- }
- .preview img.thumb {
- width: 100%;
- height: 100%;
- object-fit: cover;
- display: block;
- }
- .preview .ph {
- padding: 12px;
- text-align: center;
- color: #666;
- }
- .preview .ph button {
- margin-top: 8px;
- padding: 6px 12px;
- border-radius: 6px;
- border: 1px solid #222222;
- background: #15151d;
- color: #ddd;
- font-size: 12px;
- cursor: pointer;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .preview .ph button:hover {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .preview .spinner {
- width: 22px;
- height: 22px;
- border: 2px solid #2a2a36;
- border-top-color: var(--accent);
- border-radius: 50%;
- animation: spin 0.7s linear infinite;
- }
- @keyframes spin {
- to {
- transform: rotate(360deg);
- }
- }
- .card .footer {
- display: flex;
- flex-direction: column;
- gap: 8px;
- }
- .card .footer select[data-vis] {
- align-self: flex-start;
- padding: 6px 10px;
- font-size: 12px;
- }
- .card .actions {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- }
- .card .actions .btn,
- .card .actions a.btn {
- padding: 6px 11px;
- font-size: 12px;
- border-radius: 6px;
- font-weight: 500;
- }
- .card .actions .danger {
- color: #ffb3b3;
- }
- .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: #141414;
- 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;
- white-space: nowrap;
- }
- .card .meta {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .card .tag {
- max-width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .card .confirm {
- display: flex;
- align-items: center;
- gap: 6px;
- flex-wrap: wrap;
- margin-top: 8px;
- padding: 8px 10px;
- background: rgba(204, 64, 64, 0.08);
- border: 1px solid rgba(204, 64, 64, 0.3);
- border-radius: 8px;
- font-size: 12px;
- color: #ffb3b3;
- }
- .card .confirm .grow {
- flex: 1;
- min-width: 120px;
- }
- .card .confirm .btn {
- padding: 5px 10px;
- font-size: 12px;
- }
- .load-more {
- grid-column: 1 / -1;
- display: flex;
- justify-content: center;
- padding: 14px 0;
- }
- .load-more button {
- padding: 8px 18px;
- border-radius: 6px;
- border: 1px solid #222222;
- background: #15151d;
- color: #ddd;
- font-size: 13px;
- cursor: pointer;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .load-more button:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .load-more button:disabled {
- opacity: 0.6;
- cursor: default;
- }
- .row {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- .tag {
- font-size: 11px;
- padding: 2px 7px;
- border-radius: 99px;
- background: #20202c;
- color: #ccc;
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- filter: none;
- }
- .btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- .btn.sec {
- background: #15151d;
- color: #ddd;
- border-color: #222222;
- }
- .btn.sec:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .empty {
- text-align: center;
- padding: 60px 20px;
- border: 1px dashed var(--border);
- border-radius: 14px;
- color: #888;
- }
- .toolbar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 18px;
- }
- .err {
- padding: 12px;
- background: rgba(255, 92, 92, 0.1);
- border: 1px solid rgba(255, 92, 92, 0.3);
- border-radius: 8px;
- color: #ffb3b3;
- margin-bottom: 14px;
- }
- pre {
- background: #0f0f17;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 10px 12px;
- overflow: auto;
- font-size: 12px;
- }
- code {
- font-family:
- ui-monospace,
- SF Mono,
- Menlo,
- monospace;
- }
- .key-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10px 0;
- border-bottom: 1px solid var(--border);
- }
- .key-row:last-child {
- border: 0;
- }
- .muted {
- color: #888;
- font-size: 13px;
- }
- .section {
- margin-top: 34px;
- }
- input,
- textarea,
- select {
- background: #0f0f17;
- border: 1px solid var(--border);
- color: #eee;
- padding: 9px 11px;
- border-radius: 8px;
- font-size: 14px;
- font-family: inherit;
- }
- input:focus,
- textarea:focus,
- select:focus {
- outline: none;
- border-color: var(--accent);
- }
-
- /* ── Widgets tab ─────────────────────────────────────────────────────── */
- .btn-primary {
- display: inline-block;
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- text-decoration: none;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn-primary:hover {
- border-color: #3d3d52;
- background: #0a0a12;
- filter: none;
- }
- .btn-danger {
- background: #15151d;
- border-color: rgba(204, 64, 64, 0.4);
- color: #ffb3b3;
- }
- .btn-danger:hover {
- background: rgba(204, 64, 64, 0.12);
- border-color: rgba(204, 64, 64, 0.6);
- }
- .widgets-header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- gap: 14px;
- margin-bottom: 18px;
- flex-wrap: wrap;
- }
- .widgets-header h1 {
- margin-bottom: 6px;
- }
- .widget-toolbar {
- display: flex;
- gap: 10px;
- align-items: center;
- margin-bottom: 18px;
- flex-wrap: wrap;
- }
- .widget-toolbar input,
- .widget-toolbar select {
- padding: 7px 10px;
- font-size: 13px;
- }
- .widget-toolbar input[type='search'] {
- min-width: 200px;
- }
- .widget-card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 14px;
- display: flex;
- flex-direction: column;
- gap: 10px;
- position: relative;
- transition: border-color 0.15s;
- }
- .widget-card:hover {
- border-color: #2c2c40;
- }
- .widget-card .frame {
- aspect-ratio: 1/1;
- background: #0f0f17;
- border-radius: 10px;
- overflow: hidden;
- position: relative;
- }
- .widget-card .frame iframe {
- width: 100%;
- height: 100%;
- border: 0;
- display: block;
- }
- .widget-card .frame .placeholder {
- display: grid;
- place-items: center;
- height: 100%;
- color: #555;
- font-size: 12px;
- padding: 10px;
- text-align: center;
- }
- .widget-card .title {
- display: flex;
- align-items: baseline;
- gap: 8px;
- min-height: 22px;
- }
- .widget-card .title h3 {
- margin: 0;
- font-size: 14px;
- cursor: text;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .widget-card .title input {
- flex: 1;
- padding: 3px 6px;
- font-size: 14px;
- font-weight: 600;
- }
- .widget-card .pill {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- font-size: 11px;
- padding: 2px 8px;
- border-radius: 99px;
- background: #20202c;
- color: #ccc;
- white-space: nowrap;
- }
- .widget-card .pill .dot {
- width: 7px;
- height: 7px;
- border-radius: 50%;
- }
- .widget-card .meta {
- font-size: 12px;
- color: #888;
- }
- .widget-card .actions {
- display: flex;
- gap: 6px;
- flex-wrap: wrap;
- margin-top: auto;
- }
- .widget-card .actions button,
- .widget-card .actions a {
- padding: 6px 10px;
- border-radius: 7px;
- border: 1px solid var(--border);
- background: #1a1a1a;
- color: #ddd;
- font-size: 12px;
- cursor: pointer;
- text-decoration: none;
- }
- .widget-card .actions button:hover,
- .widget-card .actions a:hover {
- background: #222222;
- }
- .widget-card .actions .danger:hover {
- background: rgba(204, 64, 64, 0.18);
- border-color: rgba(204, 64, 64, 0.5);
- color: #ffb3b3;
- }
- .toggle {
- position: relative;
- display: inline-flex;
- align-items: center;
- gap: 6px;
- cursor: pointer;
- user-select: none;
- }
- .toggle input {
- position: absolute;
- opacity: 0;
- width: 0;
- height: 0;
- }
- .toggle .track {
- width: 30px;
- height: 17px;
- background: #2a2a36;
- border-radius: 99px;
- position: relative;
- transition: background 0.15s;
- }
- .toggle .track::after {
- content: '';
- position: absolute;
- top: 2px;
- left: 2px;
- width: 13px;
- height: 13px;
- background: #aaa;
- border-radius: 50%;
- transition:
- transform 0.15s,
- background 0.15s;
- }
- .toggle input:checked + .track {
- background: rgba(255, 255, 255, 0.55);
- }
- .toggle input:checked + .track::after {
- transform: translateX(13px);
- background: #fff;
- }
- .toggle input:focus-visible + .track {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
- }
- .toggle .label {
- font-size: 11px;
- color: #888;
- }
-
- /* Drawer */
- .drawer-overlay {
- position: fixed;
- inset: 0;
- background: rgba(0, 0, 0, 0.55);
- z-index: 50;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.18s;
- }
- .drawer-overlay.open {
- opacity: 1;
- pointer-events: auto;
- }
- .drawer {
- position: fixed;
- right: 0;
- top: 0;
- bottom: 0;
- width: min(560px, 100vw);
- background: #0e0e16;
- border-left: 1px solid var(--border);
- transform: translateX(100%);
- transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
- z-index: 51;
- overflow-y: auto;
- }
- .drawer.open {
- transform: none;
- }
- .drawer header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 20px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: #0e0e16;
- z-index: 1;
- }
- .drawer header h2 {
- margin: 0;
- font-size: 16px;
- }
- .drawer .body {
- padding: 20px;
- display: flex;
- flex-direction: column;
- gap: 18px;
- }
- .drawer .frame-lg {
- aspect-ratio: 1/1;
- background: #0f0f17;
- border-radius: 10px;
- overflow: hidden;
- }
- .drawer .frame-lg iframe {
- width: 100%;
- height: 100%;
- border: 0;
- }
- .drawer .stat-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 10px;
- }
- .drawer .stat {
- background: #13131c;
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 12px 14px;
- }
- .drawer .stat .n {
- font-size: 22px;
- font-weight: 600;
- }
- .drawer .stat .l {
- font-size: 11px;
- color: #888;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }
- .spark {
- width: 100%;
- height: 60px;
- }
- .spark path.area {
- fill: rgba(255, 255, 255, 0.18);
- }
- .spark path.line {
- fill: none;
- stroke: var(--accent);
- stroke-width: 2;
- }
- .spark .axis {
- stroke: #222222;
- stroke-width: 1;
- }
- details summary {
- cursor: pointer;
- padding: 6px 0;
- color: #aaa;
- font-size: 13px;
- }
- details[open] summary {
- color: #eee;
- }
- .danger-zone {
- border: 1px solid rgba(204, 64, 64, 0.4);
- border-radius: 10px;
- padding: 14px;
- background: rgba(204, 64, 64, 0.05);
- }
- .danger-zone h3 {
- margin: 0 0 6px;
- color: #ffb3b3;
- font-size: 13px;
- }
-
- /* Modal */
- .modal-overlay {
- position: fixed;
- inset: 0;
- background: rgba(0, 0, 0, 0.6);
- z-index: 60;
- display: grid;
- place-items: center;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.15s;
- }
- .modal-overlay.open {
- opacity: 1;
- pointer-events: auto;
- }
- .modal {
- background: #0e0e16;
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 22px;
- width: min(560px, calc(100vw - 32px));
- max-height: calc(100vh - 32px);
- overflow-y: auto;
- }
- .modal h2 {
- margin: 0 0 4px;
- font-size: 17px;
- }
- .modal .sub {
- margin: 0 0 18px;
- }
- .size-presets {
- display: flex;
- gap: 6px;
- flex-wrap: wrap;
- margin-bottom: 14px;
- }
- .size-presets button {
- padding: 6px 12px;
- border-radius: 99px;
- border: 1px solid var(--border);
- background: #13131c;
- color: #ccc;
- font-size: 12px;
- cursor: pointer;
- }
- .size-presets button.active {
- border-color: var(--accent);
- color: #fff;
- background: rgba(255, 255, 255, 0.15);
- }
- .size-inputs {
- display: flex;
- gap: 8px;
- align-items: center;
- margin-bottom: 14px;
- }
- .size-inputs input {
- width: 90px;
- }
- .modal-header {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- margin-bottom: 4px;
- }
- .modal-header h2 {
- margin: 0;
- }
- .modal-close-x {
- background: none;
- border: none;
- color: #666;
- font-size: 22px;
- line-height: 1;
- cursor: pointer;
- padding: 0 2px;
- margin: -2px -2px 0 8px;
- flex-shrink: 0;
- }
- .modal-close-x:hover { color: #fff; }
- .section-label {
- font-size: 11px;
- text-transform: uppercase;
- letter-spacing: 0.06em;
- color: #666;
- margin-bottom: 8px;
- }
- .preview-wrap {
- background: #0f0f17;
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 12px;
- margin-bottom: 12px;
- }
- .preview-checkered {
- background-image:
- linear-gradient(45deg, #2a2a3a 25%, transparent 25%),
- linear-gradient(-45deg, #2a2a3a 25%, transparent 25%),
- linear-gradient(45deg, transparent 75%, #2a2a3a 75%),
- linear-gradient(-45deg, transparent 75%, #2a2a3a 75%);
- background-size: 10px 10px;
- background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
- background-color: #1a1a28;
- }
- .preview-frame-wrap {
- overflow: hidden;
- position: relative;
- margin: 0 auto;
- }
-
- .toast {
- position: fixed;
- bottom: 24px;
- left: 50%;
- transform: translateX(-50%);
- background: #1a1a1a;
- border: 1px solid var(--border);
- padding: 10px 18px;
- border-radius: 99px;
- font-size: 13px;
- color: #ddd;
- z-index: 70;
- box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
- animation: toast-in 0.2s;
- }
- .toast.toast-undo {
- display: inline-flex;
- align-items: center;
- gap: 14px;
- padding: 8px 8px 8px 16px;
- }
- .toast-undo-btn {
- background: rgba(255, 255, 255, 0.18);
- border: 1px solid rgba(255, 255, 255, 0.45);
- color: #cfc6ff;
- padding: 5px 12px;
- border-radius: 99px;
- font-size: 12px;
- font-weight: 600;
- cursor: pointer;
- font-family: inherit;
- }
- .toast-undo-btn:hover {
- background: rgba(255, 255, 255, 0.3);
- color: #fff;
- }
- @keyframes toast-in {
- from {
- opacity: 0;
- transform: translate(-50%, 8px);
- }
- to {
- opacity: 1;
- transform: translateX(-50%);
- }
- }
-
- @media (max-width: 768px) {
- .layout {
- grid-template-columns: 1fr;
- }
- aside {
- border-right: none;
- border-bottom: 1px solid var(--border);
- padding: 8px 0;
- display: flex;
- flex-wrap: wrap;
- overflow-x: auto;
- }
- aside a {
- padding: 8px 14px;
- border-left: none;
- border-bottom: 2px solid transparent;
- white-space: nowrap;
- }
- aside a.active {
- border-left: none;
- border-bottom-color: var(--accent);
- }
- main {
- padding: 18px 16px;
- }
- }
-
- /* ── Animations tab ──────────────────────────────────────────────── */
- .anim-cols {
- display: grid;
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
- gap: 28px;
- align-items: start;
- }
- @media (max-width: 880px) {
- .anim-cols {
- grid-template-columns: 1fr;
- }
- }
- .anim-cols h3 {
- margin: 0 0 12px;
- font-size: 14px;
- font-weight: 600;
- color: #ddd;
- }
- .anim-notice {
- background: rgba(255, 255, 255, 0.08);
- border: 1px solid rgba(255, 255, 255, 0.35);
- color: #d6cffd;
- border-radius: 10px;
- padding: 12px 14px;
- margin-bottom: 18px;
- font-size: 13px;
- line-height: 1.55;
- }
- .anim-notice strong {
- color: #fff;
- }
- .clip-row {
- display: grid;
- grid-template-columns: minmax(0, 1fr) auto auto auto;
- align-items: center;
- gap: 10px;
- padding: 10px 12px;
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- margin-bottom: 8px;
- }
- .clip-row .clip-name {
- font-size: 13px;
- color: #eee;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .clip-row .clip-source {
- font-size: 11px;
- padding: 2px 8px;
- border-radius: 99px;
- background: #20202c;
- color: #aaa;
- text-transform: capitalize;
- }
- .clip-row .loop-toggle {
- display: inline-flex;
- align-items: center;
- gap: 5px;
- font-size: 12px;
- color: #aaa;
- cursor: pointer;
- user-select: none;
- }
- .clip-row .loop-toggle input {
- margin: 0;
- accent-color: var(--accent);
- }
- .clip-row .clip-actions {
- display: inline-flex;
- gap: 6px;
- }
- .clip-row .clip-actions button {
- padding: 5px 10px;
- border-radius: 7px;
- border: 1px solid var(--border);
- background: #1a1a1a;
- color: #ddd;
- font-size: 12px;
- cursor: pointer;
- }
- .clip-row .clip-actions button:hover {
- background: #222222;
- }
- .clip-row .clip-actions button.danger:hover {
- background: rgba(204, 64, 64, 0.18);
- border-color: rgba(204, 64, 64, 0.5);
- color: #ffb3b3;
- }
- .preset-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
- gap: 10px;
- }
- .preset-tile {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 12px 8px;
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 6px;
- cursor: pointer;
- transition:
- border-color 0.15s,
- background 0.15s,
- transform 0.15s;
- user-select: none;
- position: relative;
- }
- .preset-tile:hover {
- border-color: var(--accent);
- background: rgba(255, 255, 255, 0.08);
- transform: translateY(-1px);
- }
- .preset-tile .icon {
- font-size: 26px;
- line-height: 1;
- }
- .preset-tile .label {
- font-size: 12px;
- color: #ddd;
- text-align: center;
- }
- .preset-tile.attached {
- opacity: 0.45;
- cursor: default;
- }
- .preset-tile.attached:hover {
- border-color: var(--border);
- background: var(--panel);
- transform: none;
- }
- .preset-tile.attached::after {
- content: '✓';
- position: absolute;
- top: 4px;
- right: 6px;
- font-size: 11px;
- color: #ffffff;
- }
- .anim-upload {
- display: flex;
- flex-direction: column;
- gap: 6px;
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 14px;
- }
- .anim-upload label {
- font-size: 12px;
- color: #aaa;
- }
- .anim-upload input[type='text'],
- .anim-upload input[type='file'] {
- font-size: 13px;
- }
- .anim-inline-err {
- color: #ffb3b3;
- font-size: 12px;
- min-height: 16px;
- }
- /* presets header row */
- .presets-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 10px;
- }
- .add-all-btn {
- padding: 4px 10px;
- font-size: 12px;
- border-radius: 7px;
- }
- /* drag handle + reorder indicators */
- .drag-handle {
- color: #555;
- cursor: grab;
- font-size: 14px;
- padding: 0 4px;
- user-select: none;
- flex-shrink: 0;
- }
- .drag-handle:active {
- cursor: grabbing;
- }
- .clip-row.dragging {
- opacity: 0.4;
- }
- .clip-row.drop-above {
- border-top: 2px solid var(--accent);
- }
- .clip-row.drop-below {
- border-bottom: 2px solid var(--accent);
- }
- /* inline clip rename */
- .clip-name {
- cursor: pointer;
- }
- .clip-name:hover {
- color: #fff;
- text-decoration: underline dotted;
- }
- .clip-name-input {
- padding: 2px 6px;
- font-size: 13px;
- width: 100%;
- min-width: 80px;
- }
- /* clip-row grid: handle name source loop actions */
- .clip-row {
- grid-template-columns: auto minmax(0, 1fr) auto auto auto;
- }
- .preview-stage {
- width: 100%;
- aspect-ratio: 1 / 1;
- background: #0f0f17;
- border: 1px solid var(--border);
- border-radius: 10px;
- overflow: hidden;
- display: grid;
- place-items: center;
- }
- .preview-stage agent-3d {
- width: 100%;
- height: 100%;
- }
-
- /* visually-hidden utility for screen-reader-only labels */
- .sr-only {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- border: 0;
- }
- </style>
- <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>
- <script type="module" src="/session-client.js"></script>
- </head>
- <body>
- <div id="dn-next-banner" style="
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- padding: 9px 20px;
- background: linear-gradient(90deg, rgba(154,124,255,0.12), rgba(255, 255, 255,0.08));
- border-bottom: 1px solid rgba(154,124,255,0.25);
- font-size: 13px;
- color: #c8bfff;
-">
- <span>
- &#10022; You're on the classic dashboard &mdash;
- <a href="/dashboard" style="color:#b39bff;font-weight:600;text-decoration:underline">try the new version</a>
- </span>
- <button onclick="document.getElementById('dn-next-banner').remove();localStorage.setItem('dn-classic-dismissed','1')"
- style="background:none;border:none;color:#888;font-size:18px;cursor:pointer;line-height:1;padding:0 2px"
- aria-label="Dismiss">&times;</button>
-</div>
-<script>
- if (localStorage.getItem('dn-classic-dismissed') === '1') {
- var __dnb = document.getElementById('dn-next-banner');
- if (__dnb) __dnb.style.display = 'none';
- }
-</script>
- <header>
- <h1>
- <a href="/"><img src="/three.svg" alt="three.ws" class="wordmark-logo" /></a>
- </h1>
- <nav class="dash-header-nav" aria-label="Primary">
- <a href="/app">Viewer</a>
- <a href="/create">Create</a>
- <a href="/discover">Discover</a>
- <a href="/widgets">Widgets</a>
- <a href="/studio">Studio</a>
- <a href="/docs">Docs</a>
- <a href="/my-agents" title="ERC-8004 agents controlled by your linked wallets">My Agents</a>
- <a href="/dashboard" class="active" aria-current="page">Dashboard</a>
- </nav>
- <div class="dash-header-user" id="header-user-slot"></div>
- </header>
- <div class="layout">
- <aside>
- <a href="/dashboard-classic/portfolio">Portfolio &amp; NFTs</a>
- <a href="/dashboard-classic/avatars" class="active" data-tab="avatars">Avatars</a>
- <a href="/dashboard-classic/agents" data-tab="agents">Agents</a>
- <a href="/dashboard-classic/create" data-tab="create">Create from selfie</a>
- <a href="/dashboard-classic/upload" data-tab="upload">Upload</a>
- <a href="/dashboard-classic/animations" data-tab="animations">Animations</a>
- <a href="/dashboard-classic/widgets" data-tab="widgets">Widgets</a>
- <a href="/dashboard-classic/embed" data-tab="embed">Embed</a>
- <a href="/dashboard-classic/keys" data-tab="keys">API keys</a>
- <a href="/dashboard-classic/mcp" data-tab="mcp">MCP</a>
- <a href="/dashboard-classic/monetization" data-tab="monetization">Monetization</a>
- <a href="/dashboard-classic/payments" data-tab="payments">Payments</a>
- <a href="/dashboard-classic/subscriptions" data-tab="subscriptions">Subscriptions</a>
- <a href="/dashboard-classic/billing" data-tab="billing">Plan &amp; usage</a>
- <a href="/dashboard-classic/revenue" data-tab="revenue">Revenue</a>
- <a href="/dashboard-classic/withdrawals" data-tab="withdrawals">Withdrawals</a>
- <a href="/dashboard-classic/earnings" data-tab="earnings">Earnings</a>
- <a href="/dashboard-classic/account" data-tab="account">Account</a>
- <a href="/dashboard-classic/wallets">Wallets</a>
- <a href="/vanity-wallet">Vanity wallet ✦</a>
- <a href="/eth-vanity">ETH vanity (CREATE2) ✦</a>
- <a href="/dashboard-classic/memory">Memory</a>
- <a href="/dashboard-classic/strategy">Strategy</a>
- <a href="/dashboard-classic/voice">Voice</a>
- <a href="/dashboard-classic/sns">SNS domains</a>
- <a href="/dashboard-classic/delegation">Delegation</a>
- <a href="/dashboard-classic/tokens">Tokens (Pump.fun)</a>
- <a href="/dashboard-classic/actions">Action log</a>
- <a href="/dashboard-classic/usage">LLM usage</a>
- <a href="/dashboard-classic/embed-policy">Embed policy</a>
- <a href="/dashboard-classic/sessions">Sessions</a>
- <a href="/dashboard-classic/storage">Storage</a>
- <a href="/dashboard-classic/agent-pumpfun">Agent · Pump.fun</a>
- <a href="/strategy-lab">Strategy lab</a>
- <a href="/reputation">Reputation</a>
- <a href="/settings">Settings</a>
- <a href="/admin" id="admin-link" style="display:none">Admin</a>
- <a href="/my-agents" title="ERC-8004 agents controlled by your linked wallets"
- >On-chain (ERC-8004) ↗</a
- >
- <a href="/discover" title="Browse on-chain agents across every supported chain"
- >Discover on-chain ↗</a
- >
- </aside>
- <main id="main"></main>
- </div>
- <footer class="h-footer-horizon">
- <div class="h-footer-glow-line" aria-hidden="true"></div>
- <div class="h-footer-floor" aria-hidden="true"></div>
- <div class="h-footer-haze" aria-hidden="true"></div>
- <div class="h-footer-watermark" aria-hidden="true">three.ws</div>
- <div class="h-footer-avatar" aria-hidden="true">
- <model-viewer
- src="/animations/robotexpressive.glb"
- auto-rotate
- auto-rotate-delay="0"
- rotation-per-second="20deg"
- interaction-prompt="none"
- camera-controls="false"
- disable-zoom
- shadow-intensity="0"
- exposure="0.7"
- environment-image="neutral"
- camera-orbit="0deg 80deg 9m"
- field-of-view="35deg"
- loading="lazy"
- ></model-viewer>
- </div>
- <div class="h-footer-inner">
- <div class="h-footer-brand-col">
- <div class="h-footer-brand">
- <img class="wordmark-logo" src="/three.svg" alt="" aria-hidden="true" />
- <span class="wordmark-dot" aria-hidden="true"></span>
- <span>three.ws</span>
- </div>
- <p class="h-footer-tagline">Give your AI a body.</p>
- </div>
- <nav class="h-footer-links" aria-label="Footer">
- <a href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener"
- >GitHub</a
- >
- <a href="/create">Create</a>
- <a href="/studio">Studio</a>
- <a href="/widgets">Widgets</a>
- <a href="/discover">Discover</a>
- <a href="/showcase">Showcase</a>
- <a href="/docs">Docs</a>
- <a href="/legal/privacy">Privacy</a>
- <a href="/legal/tos">Terms</a>
- </nav>
- </div>
- <div class="h-footer-bottom">
- <p class="h-footer-legal">© 2026 three.ws — All rights reserved.</p>
- <div class="h-footer-badges">
- <span class="h-footer-badge" aria-label="System status">
- <span class="h-footer-status-dot" aria-hidden="true"></span>
- <span>All systems normal</span>
- </span>
- <span class="h-footer-badge">
- <svg viewBox="0 0 16 16" aria-hidden="true">
- <path
- fill="currentColor"
- d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm0 14.5A6.5 6.5 0 1 1 8 1.5a6.5 6.5 0 0 1 0 13zm-1-9.25a1 1 0 1 1 2 0v3.5a1 1 0 1 1-2 0v-3.5zm1 6.5a1.1 1.1 0 1 1 0-2.2 1.1 1.1 0 0 1 0 2.2z"
- />
- </svg>
- <span>Transparent by default</span>
- </span>
- <a
- class="h-footer-badge"
- href="https://github.com/nirholas/three.ws"
- target="_blank"
- rel="noopener"
- aria-label="View source on GitHub"
- >
- <svg viewBox="0 0 16 16" aria-hidden="true">
- <path
- fill="currentColor"
- d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"
- />
- </svg>
- <span>Open source</span>
- </a>
- </div>
- </div>
- </footer>
-
- <script type="module">
- import { state, api, navigate, installRouting, signOut } from '/src/dashboard/dashboard.js';
- import { renderHeaderUser } from '/src/header-user.js';
- window.signOut = signOut;
-
- (async () => {
- let me;
- try {
- me = await api.me();
- } catch {
- me = null;
- }
- if (!me?.user) {
- location.href =
- '/login?next=' + encodeURIComponent(location.pathname + location.search + location.hash);
- return;
- }
- state.user = me.user;
- renderHeaderUser(document.getElementById('header-user-slot'), me.user, { activePath: '/dashboard' });
- if (me.user.is_admin) document.getElementById('admin-link').style.display = '';
- installRouting();
- navigate();
-
- fetch('/api/agent-3d/versions')
- .then((r) => r.ok ? r.json() : null)
- .then((data) => {
- if (!data?.latest) return;
- const badge = document.createElement('a');
- badge.href = 'https://three.ws/agent-3d/versions.json';
- badge.target = '_blank';
- badge.rel = 'noopener';
- badge.textContent = 'agent-3d v' + data.latest;
- badge.style.cssText =
- 'display:block;padding:9px 20px;font-size:11px;color:#555;text-decoration:none;';
- badge.addEventListener('mouseenter', () => (badge.style.color = '#888'));
- badge.addEventListener('mouseleave', () => (badge.style.color = '#555'));
- document.querySelector('aside').appendChild(badge);
- })
- .catch(() => {});
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/memory.html b/public/dashboard-classic/memory.html
deleted file mode 100644
index b6bcfe961..000000000
--- a/public/dashboard-classic/memory.html
+++ /dev/null
@@ -1,841 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent Memory · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <link rel="stylesheet" href="/nav.css" />
- <link rel="stylesheet" href="/fonts/fonts.css" />
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- <style>
- .skip-link { position: absolute; left: -9999px; }
- .skip-link:focus { left: 1rem; top: 1rem; padding: .5rem 1rem; background: #0c0c0c; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; z-index: 9999; color: #fff; text-decoration: none; }
-
- /* ── Stats bar ─────────────────────────────────────────────── */
- .mem-stats {
- display: flex;
- gap: 10px;
- margin-bottom: 18px;
- flex-wrap: wrap;
- }
- .mem-stat {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 10px 16px;
- display: flex;
- flex-direction: column;
- gap: 2px;
- min-width: 80px;
- }
- .mem-stat-val { font-size: 22px; font-weight: 700; line-height: 1; }
- .mem-stat-label { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .06em; }
-
- /* ── Toolbar ────────────────────────────────────────────────── */
- .mem-toolbar {
- display: flex;
- gap: 10px;
- margin-bottom: 16px;
- flex-wrap: wrap;
- align-items: center;
- }
- .mem-search {
- flex: 1;
- min-width: 180px;
- background: #0f0f17;
- color: #eee;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 8px 12px;
- font-size: 13px;
- font-family: inherit;
- }
- .mem-search:focus { outline: none; border-color: var(--accent); }
- .mem-filter-tabs {
- display: flex;
- gap: 4px;
- flex-wrap: wrap;
- }
- .mem-tab {
- background: transparent;
- color: #888;
- border: 1px solid transparent;
- border-radius: 20px;
- padding: 5px 12px;
- font-size: 12px;
- cursor: pointer;
- font-family: inherit;
- transition: all .15s;
- }
- .mem-tab:hover { color: #ddd; border-color: var(--border); }
- .mem-tab.active { border-color: var(--accent); color: #cccccc; background: rgba(255, 255, 255,.1); }
-
- /* ── Memory cards ───────────────────────────────────────────── */
- .mem-card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 14px 16px;
- margin-bottom: 8px;
- transition: border-color .15s;
- }
- .mem-card:hover { border-color: #2f2f40; }
- .mem-card-header {
- display: flex;
- align-items: flex-start;
- gap: 10px;
- margin-bottom: 6px;
- }
- .mem-type-badge {
- display: inline-block;
- border-radius: 4px;
- padding: 2px 8px;
- font-size: 10px;
- font-weight: 600;
- letter-spacing: .06em;
- text-transform: uppercase;
- flex-shrink: 0;
- margin-top: 2px;
- }
- .mem-type-user { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
- .mem-type-feedback{ background: rgba(168,85,247,.15); color: #d8b4fe; border: 1px solid rgba(168,85,247,.3); }
- .mem-type-project { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
- .mem-type-reference{background: rgba(251,146,60,.15); color: #fdba74; border: 1px solid rgba(251,146,60,.3); }
-
- .mem-name {
- font-size: 14px;
- font-weight: 600;
- color: #eee;
- flex: 1;
- }
- .mem-description {
- font-size: 12px;
- color: #888;
- margin-bottom: 8px;
- font-style: italic;
- }
- .mem-content {
- font-size: 13px;
- color: #ccc;
- white-space: pre-wrap;
- word-break: break-word;
- line-height: 1.5;
- }
- .mem-content.collapsed {
- display: -webkit-box;
- -webkit-line-clamp: 3;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
- .mem-expand-btn {
- background: none;
- border: none;
- color: var(--accent);
- font-size: 12px;
- cursor: pointer;
- padding: 2px 0;
- font-family: inherit;
- margin-top: 4px;
- }
- .mem-expand-btn:hover { text-decoration: underline; }
-
- .mem-footer {
- display: flex;
- align-items: center;
- gap: 8px;
- margin-top: 10px;
- flex-wrap: wrap;
- }
- .mem-meta { font-size: 11px; color: #555; }
-
- .mem-salience-bar {
- height: 3px;
- border-radius: 2px;
- background: var(--border);
- width: 60px;
- overflow: hidden;
- flex-shrink: 0;
- }
- .mem-salience-fill {
- height: 100%;
- border-radius: 2px;
- }
-
- .mem-actions {
- margin-left: auto;
- display: flex;
- gap: 6px;
- }
- .mem-action-btn {
- background: transparent;
- border: 1px solid transparent;
- border-radius: 6px;
- color: #666;
- font-size: 12px;
- cursor: pointer;
- padding: 4px 9px;
- font-family: inherit;
- transition: all .12s;
- }
- .mem-action-btn:hover { background: #1f1f2c; border-color: var(--border); color: #ccc; }
- .mem-action-btn.danger:hover { color: #ff8a9c; border-color: #3a2530; background: #2a1820; }
-
- /* ── Edit form (inline) ─────────────────────────────────────── */
- .mem-edit-form {
- display: grid;
- gap: 10px;
- margin-top: 10px;
- }
- .mem-edit-row { display: grid; gap: 4px; }
- .mem-edit-label { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .06em; }
- .mem-edit-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
- .mem-edit-actions { display: flex; gap: 8px; margin-top: 4px; }
-
- /* ── Add form card ──────────────────────────────────────────── */
- .mem-add-toggle {
- display: flex;
- align-items: center;
- justify-content: space-between;
- cursor: pointer;
- user-select: none;
- }
- .mem-add-body { display: none; margin-top: 14px; }
- .mem-add-body.open { display: block; }
-
- /* ── Export/Import bar ──────────────────────────────────────── */
- .mem-io-bar {
- display: flex;
- gap: 8px;
- margin-bottom: 18px;
- flex-wrap: wrap;
- }
-
- /* ── Salience slider ────────────────────────────────────────── */
- .mem-slider-row {
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .mem-slider-row input[type=range] {
- flex: 1;
- accent-color: var(--accent);
- }
- .mem-slider-val { font-size: 12px; color: #aaa; width: 28px; text-align: right; }
-
- /* ── Empty state ────────────────────────────────────────────── */
- .mem-empty {
- text-align: center;
- color: #555;
- padding: 48px 16px;
- font-size: 14px;
- }
-
- /* ── Sort control ───────────────────────────────────────────── */
- .mem-sort {
- background: #0f0f17;
- color: #aaa;
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 6px 10px;
- font-size: 12px;
- font-family: inherit;
- cursor: pointer;
- }
- </style>
- </head>
- <body>
- <a href="#main-content" class="skip-link">Skip to main content</a>
- <header>
- <div id="nav-container"></div>
- </header>
- <script src="/nav.js"></script>
-
- <main id="main-content" class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <div style="display:flex;align-items:baseline;gap:14px;margin-bottom:4px">
- <h1 class="dash-title" style="margin:0">Agent Memory</h1>
- </div>
- <p class="dash-sub">
- Browse, search, edit, and manage long-term memories your agent uses for context.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </main>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const TYPES = ['user', 'feedback', 'project', 'reference'];
- const TYPE_LABELS = { user: 'User', feedback: 'Feedback', project: 'Project', reference: 'Reference' };
-
- const $ = (id) => document.getElementById(id);
- const statusEl = $('status');
- const contentEl = $('content');
-
- let allEntries = [];
- let activeType = 'all';
- let searchQuery = '';
- let sortMode = 'salience';
- let currentAgentId = null;
- let addFormOpen = false;
-
- // ── HTML helpers ──────────────────────────────────────────────
-
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[c],
- );
- }
-
- function fmtTime(ms) {
- if (!ms) return '';
- const d = new Date(ms);
- const now = Date.now();
- const diff = now - ms;
- if (diff < 60000) return 'just now';
- if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;
- if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`;
- if (diff < 7 * 86400000) return `${Math.floor(diff / 86400000)}d ago`;
- return d.toLocaleDateString();
- }
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- if (msg) setTimeout(() => { statusEl.innerHTML = ''; }, 4000);
- }
-
- function salienceColor(v) {
- const r = Math.round(255 * (1 - v));
- const g = Math.round(180 * v);
- return `rgb(${r},${g},80)`;
- }
-
- // ── API ───────────────────────────────────────────────────────
-
- async function loadMemories(agentId) {
- const r = await fetch(
- `/api/agent-memory?agentId=${encodeURIComponent(agentId)}&limit=500`,
- { credentials: 'include' },
- );
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- const data = await r.json();
- return data.entries || [];
- }
-
- async function deleteMemory(id) {
- const r = await fetch(`/api/agent-memory/${encodeURIComponent(id)}`, {
- method: 'DELETE',
- credentials: 'include',
- });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- return r.json();
- }
-
- async function saveMemory(agentId, entry) {
- const r = await fetch('/api/agent-memory', {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ agentId, entry }),
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- // ── Filter + sort ─────────────────────────────────────────────
-
- function filteredEntries() {
- let list = allEntries;
- if (activeType !== 'all') list = list.filter((e) => e.type === activeType);
- if (searchQuery) {
- const q = searchQuery.toLowerCase();
- list = list.filter((e) => {
- const name = (e.context?.name || '').toLowerCase();
- const desc = (e.context?.description || '').toLowerCase();
- const content = (e.content || '').toLowerCase();
- const tags = (e.tags || []).join(' ').toLowerCase();
- return name.includes(q) || desc.includes(q) || content.includes(q) || tags.includes(q);
- });
- }
- if (sortMode === 'salience') list = [...list].sort((a, b) => (b.salience || 0) - (a.salience || 0));
- if (sortMode === 'newest') list = [...list].sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0));
- if (sortMode === 'oldest') list = [...list].sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0));
- if (sortMode === 'updated') list = [...list].sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));
- return list;
- }
-
- // ── Render ────────────────────────────────────────────────────
-
- function renderAll(agentId) {
- const entries = filteredEntries();
- const counts = { all: allEntries.length };
- for (const t of TYPES) counts[t] = allEntries.filter((e) => e.type === t).length;
-
- contentEl.innerHTML = `
- <div class="mem-stats">
- <div class="mem-stat">
- <div class="mem-stat-val">${counts.all}</div>
- <div class="mem-stat-label">Total</div>
- </div>
- ${TYPES.map((t) => `
- <div class="mem-stat">
- <div class="mem-stat-val" style="color:${typeColor(t)}">${counts[t]}</div>
- <div class="mem-stat-label">${TYPE_LABELS[t]}</div>
- </div>
- `).join('')}
- </div>
-
- <div class="mem-io-bar">
- <button class="dash-btn" id="export-btn">Export JSON</button>
- <label class="dash-btn" style="cursor:pointer">
- Import JSON
- <input type="file" id="import-file" accept=".json" style="display:none" />
- </label>
- </div>
-
- <div class="dash-card" id="add-card">
- <div class="mem-add-toggle" id="add-toggle">
- <h2 style="margin:0">Add memory</h2>
- <span id="add-caret" style="font-size:18px;color:#666;transition:transform .2s">${addFormOpen ? '▲' : '▼'}</span>
- </div>
- <div class="mem-add-body ${addFormOpen ? 'open' : ''}" id="add-body">
- <form id="add-form" class="mem-edit-form">
- <div class="mem-edit-grid2">
- <div class="mem-edit-row">
- <label class="mem-edit-label">Name</label>
- <input class="dash-input" name="name" placeholder="Brief title (e.g. "Preferred response tone")" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Type</label>
- <select class="dash-select" name="type">
- ${TYPES.map((t) => `<option value="${t}">${TYPE_LABELS[t]}</option>`).join('')}
- </select>
- </div>
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Description <span class="mem-meta">(one-line summary for retrieval)</span></label>
- <input class="dash-input" name="description" placeholder="Used by the AI to judge relevance when building context" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Content</label>
- <textarea class="dash-textarea" name="content" required maxlength="10000" placeholder="What the agent should remember — include Why and How to apply for feedback memories."></textarea>
- </div>
- <div class="mem-edit-grid2">
- <div class="mem-edit-row">
- <label class="mem-edit-label">Tags <span class="mem-meta">(comma-separated)</span></label>
- <input class="dash-input" name="tags" placeholder="trading, defi" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Expires</label>
- <input class="dash-input" type="date" name="expiresAt" />
- </div>
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Salience <span class="mem-meta">(how strongly to weight this memory)</span></label>
- <div class="mem-slider-row">
- <input type="range" name="salience" min="0" max="1" step="0.05" value="0.5" id="add-salience" />
- <span class="mem-slider-val" id="add-salience-val">0.5</span>
- </div>
- </div>
- <div class="mem-edit-actions">
- <button class="dash-btn primary" type="submit">Save memory</button>
- <span class="dash-muted" id="add-form-status"></span>
- </div>
- </form>
- </div>
- </div>
-
- <div class="mem-toolbar">
- <input class="mem-search" id="mem-search" placeholder="Search name, content, tags…" value="${escapeHtml(searchQuery)}" />
- <div class="mem-filter-tabs">
- <button class="mem-tab ${activeType === 'all' ? 'active' : ''}" data-type="all">All (${counts.all})</button>
- ${TYPES.map((t) => `<button class="mem-tab ${activeType === t ? 'active' : ''}" data-type="${t}">${TYPE_LABELS[t]} (${counts[t]})</button>`).join('')}
- </div>
- <select class="mem-sort" id="mem-sort">
- <option value="salience" ${sortMode === 'salience' ? 'selected' : ''}>Sort: Salience</option>
- <option value="newest" ${sortMode === 'newest' ? 'selected' : ''}>Sort: Newest</option>
- <option value="oldest" ${sortMode === 'oldest' ? 'selected' : ''}>Sort: Oldest</option>
- <option value="updated" ${sortMode === 'updated' ? 'selected' : ''}>Sort: Updated</option>
- </select>
- </div>
-
- <div id="mem-list">
- ${entries.length === 0
- ? `<div class="mem-empty">${allEntries.length === 0 ? 'No memories yet. Add the first one above.' : 'No memories match your search.'}</div>`
- : entries.map((m) => renderMemoryCard(m)).join('')
- }
- </div>
- `;
-
- // Wire up events
- wireAddForm(agentId);
- wireToolbar(agentId);
- wireExportImport(agentId);
- wireCardEvents(agentId);
- }
-
- function typeColor(t) {
- return { user: '#93c5fd', feedback: '#d8b4fe', project: '#86efac', reference: '#fdba74' }[t] || '#aaa';
- }
-
- function renderMemoryCard(m, editing = false) {
- const name = m.context?.name || '';
- const description = m.context?.description || '';
- const isLong = (m.content || '').length > 300;
- const salience = m.salience ?? 0.5;
- const tags = (m.tags || []).filter(Boolean);
- const expiry = m.expiresAt ? `· expires ${fmtTime(m.expiresAt)}` : '';
-
- if (editing) {
- return `
- <div class="mem-card" data-id="${escapeHtml(m.id)}">
- <form class="mem-edit-form" data-edit="${escapeHtml(m.id)}">
- <div class="mem-edit-grid2">
- <div class="mem-edit-row">
- <label class="mem-edit-label">Name</label>
- <input class="dash-input" name="name" value="${escapeHtml(name)}" placeholder="Brief title" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Type</label>
- <select class="dash-select" name="type">
- ${TYPES.map((t) => `<option value="${t}" ${m.type === t ? 'selected' : ''}>${TYPE_LABELS[t]}</option>`).join('')}
- </select>
- </div>
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Description</label>
- <input class="dash-input" name="description" value="${escapeHtml(description)}" placeholder="One-line summary for retrieval" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Content</label>
- <textarea class="dash-textarea" name="content" required maxlength="10000">${escapeHtml(m.content || '')}</textarea>
- </div>
- <div class="mem-edit-grid2">
- <div class="mem-edit-row">
- <label class="mem-edit-label">Tags</label>
- <input class="dash-input" name="tags" value="${escapeHtml((m.tags || []).join(', '))}" />
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Expires</label>
- <input class="dash-input" type="date" name="expiresAt" value="${m.expiresAt ? new Date(m.expiresAt).toISOString().slice(0,10) : ''}" />
- </div>
- </div>
- <div class="mem-edit-row">
- <label class="mem-edit-label">Salience</label>
- <div class="mem-slider-row">
- <input type="range" name="salience" min="0" max="1" step="0.05" value="${salience}" class="edit-salience-slider" data-id="${escapeHtml(m.id)}" />
- <span class="mem-slider-val edit-salience-val" data-id="${escapeHtml(m.id)}">${salience.toFixed(2)}</span>
- </div>
- </div>
- <div class="mem-edit-actions">
- <button class="dash-btn primary" type="submit">Save changes</button>
- <button class="dash-btn cancel-edit" type="button" data-id="${escapeHtml(m.id)}">Cancel</button>
- <span class="dash-muted edit-status" data-id="${escapeHtml(m.id)}"></span>
- </div>
- </form>
- </div>
- `;
- }
-
- return `
- <div class="mem-card" data-id="${escapeHtml(m.id)}">
- <div class="mem-card-header">
- <span class="mem-type-badge mem-type-${escapeHtml(m.type)}">${escapeHtml(TYPE_LABELS[m.type] || m.type)}</span>
- <div class="mem-name">${name ? escapeHtml(name) : '<span style="color:#555;font-weight:400;font-style:italic">Untitled</span>'}</div>
- </div>
- ${description ? `<div class="mem-description">${escapeHtml(description)}</div>` : ''}
- <div class="mem-content ${isLong ? 'collapsed' : ''}" data-id="${escapeHtml(m.id)}">${escapeHtml(m.content || '')}</div>
- ${isLong ? `<button class="mem-expand-btn" data-expand="${escapeHtml(m.id)}">Show more</button>` : ''}
- <div class="mem-footer">
- <div class="mem-salience-bar" title="Salience: ${salience.toFixed(2)}">
- <div class="mem-salience-fill" style="width:${(salience * 100).toFixed(0)}%;background:${salienceColor(salience)}"></div>
- </div>
- ${tags.length ? tags.map((t) => `<span class="dash-pill">${escapeHtml(t)}</span>`).join('') : ''}
- <span class="mem-meta">${fmtTime(m.createdAt)} ${expiry}</span>
- <div class="mem-actions">
- <button class="mem-action-btn edit-mem-btn" data-id="${escapeHtml(m.id)}">Edit</button>
- <button class="mem-action-btn danger forget-mem-btn" data-id="${escapeHtml(m.id)}">Forget</button>
- </div>
- </div>
- </div>
- `;
- }
-
- // ── Wire: toolbar ─────────────────────────────────────────────
-
- function wireToolbar(agentId) {
- const search = $('mem-search');
- if (search) {
- search.addEventListener('input', () => {
- searchQuery = search.value;
- renderAll(agentId);
- });
- }
-
- document.querySelectorAll('.mem-tab').forEach((btn) => {
- btn.addEventListener('click', () => {
- activeType = btn.dataset.type;
- renderAll(agentId);
- });
- });
-
- const sortEl = $('mem-sort');
- if (sortEl) {
- sortEl.addEventListener('change', () => {
- sortMode = sortEl.value;
- renderAll(agentId);
- });
- }
- }
-
- // ── Wire: add form ────────────────────────────────────────────
-
- function wireAddForm(agentId) {
- const toggle = $('add-toggle');
- const body = $('add-body');
- const caret = $('add-caret');
- if (toggle) {
- toggle.addEventListener('click', () => {
- addFormOpen = !addFormOpen;
- body.classList.toggle('open', addFormOpen);
- caret.textContent = addFormOpen ? '▲' : '▼';
- });
- }
-
- const salienceInput = $('add-salience');
- const salienceVal = $('add-salience-val');
- if (salienceInput) {
- salienceInput.addEventListener('input', () => {
- salienceVal.textContent = Number(salienceInput.value).toFixed(2);
- });
- }
-
- const form = $('add-form');
- if (!form) return;
- form.addEventListener('submit', async (e) => {
- e.preventDefault();
- const fd = new FormData(form);
- const tags = String(fd.get('tags') || '').split(',').map((t) => t.trim()).filter(Boolean);
- const expiresRaw = fd.get('expiresAt');
- const entry = {
- type: String(fd.get('type')),
- content: String(fd.get('content')),
- tags,
- salience: Number(fd.get('salience')) || 0.5,
- context: {
- name: String(fd.get('name') || '').trim(),
- description: String(fd.get('description') || '').trim(),
- },
- createdAt: Date.now(),
- updatedAt: Date.now(),
- expiresAt: expiresRaw ? new Date(expiresRaw).getTime() : undefined,
- };
- const formStatus = $('add-form-status');
- formStatus.textContent = 'Saving…';
- try {
- await saveMemory(agentId, entry);
- formStatus.textContent = '';
- form.reset();
- if ($('add-salience-val')) $('add-salience-val').textContent = '0.5';
- await refresh(agentId);
- showStatus('Memory saved.', 'ok');
- } catch (err) {
- formStatus.textContent = err.message || 'Save failed';
- }
- });
- }
-
- // ── Wire: card events (edit, delete, expand) ──────────────────
-
- function wireCardEvents(agentId) {
- // Expand/collapse
- document.querySelectorAll('[data-expand]').forEach((btn) => {
- btn.addEventListener('click', () => {
- const id = btn.dataset.expand;
- const el = document.querySelector(`.mem-content[data-id="${id}"]`);
- if (!el) return;
- const collapsed = el.classList.toggle('collapsed');
- btn.textContent = collapsed ? 'Show more' : 'Show less';
- });
- });
-
- // Edit salience sliders (edit mode)
- document.querySelectorAll('.edit-salience-slider').forEach((slider) => {
- slider.addEventListener('input', () => {
- const val = document.querySelector(`.edit-salience-val[data-id="${slider.dataset.id}"]`);
- if (val) val.textContent = Number(slider.value).toFixed(2);
- });
- });
-
- // Edit buttons — replace card with edit form
- document.querySelectorAll('.edit-mem-btn').forEach((btn) => {
- btn.addEventListener('click', () => {
- const id = btn.dataset.id;
- const m = allEntries.find((e) => e.id === id);
- if (!m) return;
- const card = document.querySelector(`.mem-card[data-id="${id}"]`);
- if (card) card.outerHTML = renderMemoryCard(m, true);
- // Re-wire after DOM replacement
- wireEditForm(agentId, id);
- });
- });
-
- // Cancel edit — .cancel-edit buttons in wireCardEvents are only on
- // read-only cards (which have none); the edit form's cancel is wired
- // exclusively in wireEditForm. This block is intentionally empty to
- // avoid double-registration.
-
- // Forget buttons
- document.querySelectorAll('.forget-mem-btn').forEach((btn) => {
- btn.addEventListener('click', async () => {
- const id = btn.dataset.id;
- if (!confirm('Forget this memory? This cannot be undone.')) return;
- btn.disabled = true;
- try {
- await deleteMemory(id);
- allEntries = allEntries.filter((e) => e.id !== id);
- renderAll(agentId);
- } catch (err) {
- showStatus(err.message || 'Delete failed', 'err');
- btn.disabled = false;
- }
- });
- });
- }
-
- function wireEditForm(agentId, id) {
- const form = document.querySelector(`[data-edit="${id}"]`);
- if (!form) return;
-
- const slider = form.querySelector('.edit-salience-slider');
- const val = form.querySelector('.edit-salience-val');
- if (slider && val) {
- slider.addEventListener('input', () => {
- val.textContent = Number(slider.value).toFixed(2);
- });
- }
-
- const cancelBtn = form.querySelector('.cancel-edit');
- if (cancelBtn) {
- cancelBtn.addEventListener('click', () => renderAll(agentId));
- }
-
- form.addEventListener('submit', async (e) => {
- e.preventDefault();
- const fd = new FormData(form);
- const tags = String(fd.get('tags') || '').split(',').map((t) => t.trim()).filter(Boolean);
- const expiresRaw = fd.get('expiresAt');
- const existing = allEntries.find((en) => en.id === id);
- const entry = {
- id,
- type: String(fd.get('type')),
- content: String(fd.get('content')),
- tags,
- salience: Number(fd.get('salience')) || 0.5,
- context: {
- name: String(fd.get('name') || '').trim(),
- description: String(fd.get('description') || '').trim(),
- },
- createdAt: existing?.createdAt || Date.now(),
- updatedAt: Date.now(),
- expiresAt: expiresRaw ? new Date(expiresRaw).getTime() : undefined,
- };
- const statusSpan = form.querySelector(`.edit-status[data-id="${id}"]`);
- if (statusSpan) statusSpan.textContent = 'Saving…';
- try {
- const result = await saveMemory(agentId, entry);
- // Update in local list
- const idx = allEntries.findIndex((en) => en.id === id);
- if (idx >= 0) allEntries[idx] = result.entry;
- renderAll(agentId);
- showStatus('Memory updated.', 'ok');
- } catch (err) {
- if (statusSpan) statusSpan.textContent = err.message || 'Save failed';
- }
- });
- }
-
- // ── Wire: export / import ─────────────────────────────────────
-
- function wireExportImport(agentId) {
- const exportBtn = $('export-btn');
- if (exportBtn) {
- exportBtn.addEventListener('click', () => {
- const blob = new Blob([JSON.stringify(allEntries, null, 2)], { type: 'application/json' });
- const url = URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.href = url;
- a.download = `agent-memory-${agentId.slice(0, 8)}-${Date.now()}.json`;
- a.click();
- URL.revokeObjectURL(url);
- });
- }
-
- const importFile = $('import-file');
- if (importFile) {
- importFile.addEventListener('change', async (e) => {
- const file = e.target.files[0];
- if (!file) return;
- let entries;
- try {
- entries = JSON.parse(await file.text());
- if (!Array.isArray(entries)) throw new Error('Expected JSON array');
- } catch (err) {
- showStatus('Invalid JSON file: ' + err.message, 'err');
- importFile.value = '';
- return;
- }
- let ok = 0, fail = 0;
- for (const entry of entries) {
- try {
- // Strip old id so we get a fresh one (avoids id conflicts)
- const { id: _drop, agent_id: _drop2, ...rest } = entry;
- await saveMemory(agentId, rest);
- ok++;
- } catch { fail++; }
- }
- importFile.value = '';
- await refresh(agentId);
- showStatus(`Imported ${ok} memories${fail ? `, ${fail} failed` : ''}.`, fail ? 'err' : 'ok');
- });
- }
- }
-
- // ── Refresh ───────────────────────────────────────────────────
-
- async function refresh(agentId) {
- try {
- allEntries = await loadMemories(agentId);
- renderAll(agentId);
- } catch (e) {
- showStatus(e.message || 'Failed to load memories', 'err');
- }
- }
-
- // ── Boot ──────────────────────────────────────────────────────
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => {
- currentAgentId = agentId;
- contentEl.innerHTML = '<div class="mem-empty">Loading memories…</div>';
- refresh(agentId);
- },
- });
-
- </script>
-
- <div id="footer-container"></div>
- <script src="/footer.js" defer></script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/portfolio-asset.html b/public/dashboard-classic/portfolio-asset.html
deleted file mode 100644
index 9dcd86c33..000000000
--- a/public/dashboard-classic/portfolio-asset.html
+++ /dev/null
@@ -1,792 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Asset · Portfolio · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --ok: #2ed4a3;
- --warn: #ffb35c;
- --err: #ff6a6a;
- --border: #161620;
- --border-2: #1f1f2c;
- --bg: #000;
- --panel: #0c0c12;
- --panel-2: #10101a;
- --text: #f3f3f7;
- --muted: #7c7c8a;
- }
- * { box-sizing: border-box; }
- html, body { background: var(--bg); }
- body {
- font: 15px/1.55 -apple-system, system-ui, Segoe UI, Roboto, sans-serif;
- color: var(--text);
- margin: 0; min-height: 100vh;
- }
- a { color: #cccccc; text-decoration: none; }
- header {
- display: flex; align-items: center; justify-content: space-between;
- padding: 16px 24px; border-bottom: 1px solid var(--border);
- position: sticky; top: 0; background: var(--bg); z-index: 5;
- backdrop-filter: blur(8px);
- }
- .brand { font-weight: 600; letter-spacing: -0.01em; }
- .row { display: flex; align-items: center; gap: 8px; }
- main { padding: 28px; max-width: 1180px; margin: 0 auto; }
- .back {
- display: inline-flex; align-items: center; gap: 6px;
- color: var(--muted); font-size: 13px; margin-bottom: 16px;
- }
- .back:hover { color: #ccc; }
-
- .btn {
- padding: 9px 14px; border-radius: 9px; border: 0;
- font-size: 13px; font-weight: 600; cursor: pointer;
- background: var(--accent); color: #fff;
- font-family: inherit;
- }
- .btn:hover { filter: brightness(1.08); }
- .btn.sec { background: #1a1a26; color: #ddd; }
- .btn.ghost { background: transparent; color: #ccc; border: 1px solid var(--border-2); }
- .btn:disabled { opacity: 0.5; cursor: not-allowed; }
- .btn.sm { padding: 6px 10px; font-size: 12px; }
-
- .pill {
- display: inline-flex; align-items: center; gap: 6px;
- font-size: 10.5px; padding: 3px 8px; border-radius: 99px;
- background: #15151f; color: #ccc; white-space: nowrap;
- text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
- }
- .pill.sol { background: rgba(20,241,149,0.12); color: var(--ok); }
- .pill.evm { background: rgba(255, 255, 255,0.16); color: #cccccc; }
- .chip {
- display: inline-flex; align-items: center; gap: 4px;
- padding: 4px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
- font-variant-numeric: tabular-nums;
- }
- .chip.up { background: rgba(46,212,163,0.12); color: var(--ok); }
- .chip.down { background: rgba(255,106,106,0.12); color: var(--err); }
- .chip.flat { background: #1a1a26; color: #aaa; }
-
- .hero {
- background:
- radial-gradient(900px 240px at 20% -40%, rgba(255, 255, 255,0.16), transparent 60%),
- radial-gradient(600px 200px at 90% -20%, rgba(255, 255, 255,0.12), transparent 60%),
- #06060a;
- border: 1px solid var(--border-2);
- border-radius: 18px;
- padding: 26px;
- margin-bottom: 18px;
- }
- .hero-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
- .tok-logo {
- width: 56px; height: 56px; border-radius: 50%;
- background: #161620; flex-shrink: 0;
- display: inline-flex; align-items: center; justify-content: center;
- font-size: 18px; font-weight: 700; color: #ccc;
- overflow: hidden;
- border: 1px solid var(--border-2);
- }
- .tok-logo img { width: 100%; height: 100%; object-fit: cover; }
- .tok-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
- .tok-title h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
- .tok-title .name { color: var(--muted); font-size: 14px; }
- .hero-spacer { flex: 1; }
- .hero-price { text-align: right; }
- .hero-price .px { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
- .hero-price .ch { margin-top: 4px; }
-
- .tok-meta {
- margin-top: 18px;
- display: grid; grid-template-columns: repeat(4, 1fr);
- gap: 8px; padding-top: 18px; border-top: 1px solid var(--border);
- }
- .tok-meta .m { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
- .tok-meta .v { font-size: 14px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
- @media (max-width: 720px) {
- .tok-meta { grid-template-columns: repeat(2, 1fr); }
- }
-
- .cols {
- display: grid; grid-template-columns: 2fr 1fr;
- gap: 14px;
- }
- @media (max-width: 960px) { .cols { grid-template-columns: 1fr; } }
-
- .panel {
- background: var(--panel); border: 1px solid var(--border);
- border-radius: 14px; padding: 18px;
- }
- .panel h2 {
- margin: 0 0 14px; font-size: 12px; color: var(--muted);
- text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
- }
- .panel .head-row { display: flex; align-items: center; justify-content: space-between; }
-
- .chart-wrap { position: relative; }
- #chart { height: 320px; margin: 0 -18px -8px; }
- #chart-tooltip {
- position: absolute; top: 8px; left: 8px;
- background: rgba(8,8,12,0.85); border: 1px solid var(--border-2);
- border-radius: 8px; padding: 8px 12px;
- font-size: 12px; pointer-events: none; opacity: 0;
- transition: opacity 0.12s;
- }
- #chart-tooltip .tt-date { color: var(--muted); font-size: 11px; }
- #chart-tooltip .tt-val { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
- #chart-empty {
- height: 320px; display: none; align-items: center; justify-content: center;
- color: #444; font-size: 13px; margin: 0 -18px;
- }
- .range-tabs {
- display: flex; gap: 4px; padding-top: 10px;
- justify-content: flex-end;
- }
- .range-tab {
- background: transparent; border: 0; cursor: pointer;
- color: var(--muted); font-size: 12px; font-weight: 600;
- padding: 6px 10px; border-radius: 7px;
- font-family: inherit;
- }
- .range-tab:hover { color: #ccc; }
- .range-tab[aria-pressed="true"] { background: #16161f; color: var(--text); }
-
- .holding-summary { padding: 14px; border-radius: 10px; background: #08080d; margin-bottom: 14px; border: 1px solid var(--border); }
- .holding-summary .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
- .holding-summary .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
- .holding-summary .s { color: var(--muted); font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; }
-
- .wallet-row {
- display: flex; align-items: center; justify-content: space-between;
- gap: 10px; padding: 10px 12px; border-radius: 9px;
- border: 1px solid var(--border); background: #08080d;
- margin-bottom: 8px;
- }
- .wallet-row:last-child { margin-bottom: 0; }
- .wallet-row .nm { font-size: 13px; font-weight: 600; }
- .wallet-row .ad {
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
- font-size: 11px; color: var(--muted); margin-top: 2px;
- }
- .wallet-row .vu { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
- .wallet-row .vs { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
-
- .actions-row { display: flex; gap: 8px; margin-top: 14px; }
- .actions-row .btn { flex: 1; }
-
- .desc {
- font-size: 13px; line-height: 1.6; color: #b8b8c4;
- }
- .desc a { color: #cccccc; }
- .address {
- display: flex; align-items: center; gap: 6px; margin-top: 10px;
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
- font-size: 11.5px; color: var(--muted);
- padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
- background: #08080d;
- }
- .copy-btn {
- background: none; border: none; color: #555; cursor: pointer;
- padding: 0 2px; font-size: 12px; margin-left: auto;
- }
- .copy-btn:hover { color: #aaa; }
-
- .err-banner {
- padding: 12px 14px; background: rgba(255,92,92,0.1);
- border: 1px solid rgba(255,92,92,0.3); border-radius: 10px;
- color: #ffb3b3; margin-bottom: 14px; display: none; font-size: 13px;
- }
- .muted { color: var(--muted); font-size: 13px; }
- body[data-auth-pending] { visibility: hidden; }
- .header-logo { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
-
- .scrim {
- position: fixed; inset: 0; background: rgba(0,0,0,0.78);
- display: none; align-items: center; justify-content: center;
- z-index: 50; padding: 20px;
- backdrop-filter: blur(4px);
- }
- .scrim[data-open="true"] { display: flex; }
- .modal {
- background: var(--panel); border: 1px solid var(--border-2);
- border-radius: 14px; padding: 22px;
- width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
- }
- .modal h3 { margin: 0 0 4px; font-size: 17px; }
- .modal .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
- .modal label { display: block; margin-bottom: 10px; }
- .modal label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
- .modal input, .modal select {
- width: 100%; padding: 10px 12px; border-radius: 8px;
- border: 1px solid var(--border-2); background: #08080d; color: #eee;
- font-size: 14px; font-family: inherit;
- }
- .modal input[data-mono] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
- .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
- .qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0; }
- .qr-wrap canvas { background: #fff; padding: 10px; border-radius: 10px; }
- .qr-addr {
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
- font-size: 12px; color: #ccc; word-break: break-all; text-align: center; max-width: 100%;
- }
- </style>
- </head>
- <body data-auth-pending>
- <header>
- <div class="brand"><a href="/"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a></div>
- <div class="row">
- <a href="/dashboard" class="muted" style="font-size:13px">← Dashboard</a>
- <div id="header-user-slot"></div>
- </div>
- </header>
- <main>
- <a href="/dashboard/portfolio" class="back">← Portfolio</a>
-
- <div id="error" class="err-banner"></div>
- <div id="root">
- <div class="hero">
- <div class="hero-head">
- <div class="tok-logo">⏳</div>
- <div class="tok-title"><h1>Loading…</h1></div>
- </div>
- </div>
- </div>
- </main>
-
- <div id="scrim" class="scrim" role="dialog" aria-modal="true">
- <div class="modal" id="modal-body"></div>
- </div>
-
- <script type="module">
- import { renderHeaderUser } from '/src/header-user.js';
-
- const apiUrl = '/api';
- const params = new URLSearchParams(location.search);
- const chain = params.get('chain') || '';
- const id = params.get('id') || '';
-
- let csrfToken = null;
- let chart = null;
- let series = null;
- let chartEl = null;
- let chartTooltip = null;
- let currentAsset = null;
- let activeDays = 30;
-
- const $ = (sel) => document.querySelector(sel);
- const $$ = (id) => document.getElementById(id);
-
- function fmtUsd(n, opts = {}) {
- if (!Number.isFinite(n)) return '$0.00';
- const abs = Math.abs(n);
- if (abs >= 1_000_000_000) return '$' + (n / 1_000_000_000).toFixed(2) + 'B';
- if (abs >= 1_000_000) return '$' + (n / 1_000_000).toFixed(2) + 'M';
- if (abs >= 10_000) return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 0 });
- if (abs >= 1) return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 2 });
- if (abs > 0) {
- if (opts.precise) {
- if (abs < 0.0001) return '$' + n.toExponential(3);
- return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 8 });
- }
- return '$' + n.toFixed(abs < 0.01 ? 4 : 2);
- }
- return '$0.00';
- }
- function fmtPct(n) {
- if (!Number.isFinite(n)) return '—';
- const sign = n >= 0 ? '+' : '';
- return sign + n.toFixed(2) + '%';
- }
- function fmtAmt(n) {
- if (!Number.isFinite(n) || n === 0) return '0';
- if (n < 0.0001) return n.toExponential(2);
- if (n < 1) return n.toFixed(4);
- if (n < 1000) return n.toFixed(3);
- return n.toLocaleString('en-US', { maximumFractionDigits: 2 });
- }
- function shortAddr(a) {
- if (!a) return '';
- return a.length > 14 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a;
- }
- function escapeHtml(s) {
- return String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;' }[c]));
- }
- function setError(msg) {
- const el = $$('error');
- if (!msg) { el.style.display = 'none'; return; }
- el.textContent = msg;
- el.style.display = 'block';
- }
- function chainLabel(c) {
- if (c === 'solana') return 'Solana';
- return 'EVM';
- }
-
- async function fetchUser() {
- const res = await fetch(`${apiUrl}/auth/me`, { credentials: 'include' });
- const data = res.ok ? await res.json() : null;
- if (!data?.user) {
- location.href = '/login?next=' + encodeURIComponent(location.pathname + location.search);
- return null;
- }
- document.body.removeAttribute('data-auth-pending');
- return data;
- }
-
- async function getCsrf() {
- if (csrfToken) return csrfToken;
- const r = await fetch(`${apiUrl}/csrf-token`, { credentials: 'include' });
- if (!r.ok) throw new Error('csrf failed');
- const d = await r.json();
- csrfToken = d?.data?.token;
- return csrfToken;
- }
-
- async function loadAsset(days) {
- const u = `${apiUrl}/portfolio/asset?chain=${encodeURIComponent(chain)}&id=${encodeURIComponent(id)}&days=${days || 30}`;
- const r = await fetch(u, { credentials: 'include' });
- if (!r.ok) {
- const e = await r.json().catch(() => ({}));
- throw new Error(e.error_description || 'failed to load asset');
- }
- return r.json();
- }
-
- // ── Render ────────────────────────────────────────────────────────
-
- function render(asset) {
- const m = asset.market || {};
- const change = m.change_24h_pct;
- const changeCls = change == null ? 'flat' : change >= 0 ? 'up' : 'down';
- const logoInner = asset.logo
- ? `<img src="${escapeHtml(asset.logo)}" alt="" onerror="this.style.display='none';this.parentElement.textContent='${escapeHtml((asset.symbol || '?').slice(0,3))}'" />`
- : escapeHtml((asset.symbol || '?').slice(0, 3));
- const name = m.name || asset.symbol || asset.id;
- const isAddr = !asset.is_native;
- const explorerHref = isAddr
- ? (asset.chain === 'solana' ? `https://solscan.io/token/${asset.id}` : `https://etherscan.io/token/${asset.id}`)
- : null;
-
- $$('root').innerHTML = `
- <div class="hero">
- <div class="hero-head">
- <div class="tok-logo">${logoInner}</div>
- <div class="tok-title">
- <h1>${escapeHtml(asset.symbol)} <span class="pill ${asset.chain === 'solana' ? 'sol' : 'evm'}">${escapeHtml(chainLabel(asset.chain))}</span></h1>
- <div class="name">${escapeHtml(name)}</div>
- </div>
- <div class="hero-spacer"></div>
- <div class="hero-price">
- <div class="px">${m.price_usd != null ? fmtUsd(m.price_usd, { precise: true }) : '—'}</div>
- <div class="ch"><span class="chip ${changeCls}">${change == null ? '—' : fmtPct(change)} <span style="opacity:0.6">24h</span></span></div>
- </div>
- </div>
- <div class="tok-meta">
- <div><div class="m">Market cap</div><div class="v">${m.market_cap_usd != null ? fmtUsd(m.market_cap_usd) : '—'}</div></div>
- <div><div class="m">24h volume</div><div class="v">${m.total_volume_usd != null ? fmtUsd(m.total_volume_usd) : '—'}</div></div>
- <div><div class="m">24h high</div><div class="v">${m.high_24h_usd != null ? fmtUsd(m.high_24h_usd, { precise: true }) : '—'}</div></div>
- <div><div class="m">24h low</div><div class="v">${m.low_24h_usd != null ? fmtUsd(m.low_24h_usd, { precise: true }) : '—'}</div></div>
- </div>
- </div>
-
- <div class="cols">
- <section>
- <div class="panel">
- <div class="head-row">
- <h2>Price · ${asset.symbol}/USD</h2>
- <div id="chart-change" class="muted" style="font-size:12px"></div>
- </div>
- <div class="chart-wrap">
- <div id="chart"></div>
- <div id="chart-empty">No price history available.</div>
- <div id="chart-tooltip">
- <div class="tt-date"></div>
- <div class="tt-val"></div>
- </div>
- </div>
- <div class="range-tabs" id="range-tabs">
- <button class="range-tab" data-days="1">24H</button>
- <button class="range-tab" data-days="7">7D</button>
- <button class="range-tab" data-days="30" aria-pressed="true">30D</button>
- <button class="range-tab" data-days="90">90D</button>
- <button class="range-tab" data-days="365">1Y</button>
- </div>
- </div>
-
- ${m.description ? `
- <div class="panel" style="margin-top:14px">
- <h2>About ${escapeHtml(name)}</h2>
- <div class="desc">${escapeHtml(m.description)}</div>
- ${m.homepage ? `<p style="margin-top:10px"><a href="${escapeHtml(m.homepage)}" target="_blank" rel="noopener noreferrer">${escapeHtml(m.homepage)} ↗</a></p>` : ''}
- ${isAddr ? `
- <div class="address">
- <span>${escapeHtml(asset.id)}</span>
- <button class="copy-btn" id="copy-contract" title="Copy address">📋</button>
- ${explorerHref ? `<a href="${explorerHref}" target="_blank" rel="noopener noreferrer" style="margin-left:8px;font-size:11.5px">explorer ↗</a>` : ''}
- </div>` : ''}
- </div>
- ` : isAddr ? `
- <div class="panel" style="margin-top:14px">
- <h2>Contract</h2>
- <div class="address">
- <span>${escapeHtml(asset.id)}</span>
- <button class="copy-btn" id="copy-contract" title="Copy address">📋</button>
- ${explorerHref ? `<a href="${explorerHref}" target="_blank" rel="noopener noreferrer" style="margin-left:8px;font-size:11.5px">explorer ↗</a>` : ''}
- </div>
- </div>
- ` : ''}
- </section>
-
- <aside>
- <div class="panel">
- <h2>Your holdings</h2>
- <div class="holding-summary">
- <div class="lbl">Total value</div>
- <div class="v">${fmtUsd(asset.total_usd)}</div>
- <div class="s">${fmtAmt(asset.total_amount)} ${escapeHtml(asset.symbol)}${asset.unit_price_usd ? ' · avg ' + fmtUsd(asset.unit_price_usd, { precise: true }) : ''}</div>
- </div>
- ${asset.holdings.length ? `
- <div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em;font-weight:600;margin-bottom:8px">By wallet</div>
- ${asset.holdings.map((h) => `
- <div class="wallet-row">
- <div style="min-width:0">
- <div class="nm">${escapeHtml(h.agent_name)}</div>
- <div class="ad">${shortAddr(h.address)}</div>
- </div>
- <div style="text-align:right">
- <div class="vu">${fmtUsd(h.usd)}</div>
- <div class="vs">${fmtAmt(h.amount)}</div>
- </div>
- </div>
- `).join('')}
- ` : '<div class="muted" style="text-align:center;padding:12px 0">No wallets hold this asset.</div>'}
- ${asset.holdings.length ? `
- <div class="actions-row">
- <button class="btn sec sm" id="send-btn">Send</button>
- <button class="btn ghost sm" id="receive-btn">Receive</button>
- </div>
- ` : ''}
- </div>
-
- ${m.ath_usd != null ? `
- <div class="panel" style="margin-top:14px">
- <h2>Performance</h2>
- <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
- <div><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em;font-weight:600">7d</div><div style="font-weight:600;color:${m.change_7d_pct == null ? 'inherit' : m.change_7d_pct >= 0 ? 'var(--ok)' : 'var(--err)'}">${m.change_7d_pct == null ? '—' : fmtPct(m.change_7d_pct)}</div></div>
- <div><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em;font-weight:600">30d</div><div style="font-weight:600;color:${m.change_30d_pct == null ? 'inherit' : m.change_30d_pct >= 0 ? 'var(--ok)' : 'var(--err)'}">${m.change_30d_pct == null ? '—' : fmtPct(m.change_30d_pct)}</div></div>
- <div><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em;font-weight:600">ATH</div><div style="font-weight:600">${fmtUsd(m.ath_usd, { precise: true })}</div></div>
- <div><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em;font-weight:600">From ATH</div><div style="font-weight:600;color:${m.ath_change_pct == null ? 'inherit' : m.ath_change_pct >= 0 ? 'var(--ok)' : 'var(--err)'}">${m.ath_change_pct == null ? '—' : fmtPct(m.ath_change_pct)}</div></div>
- </div>
- </div>
- ` : ''}
- </aside>
- </div>
- `;
-
- const copyEl = $$('copy-contract');
- if (copyEl) {
- copyEl.addEventListener('click', () => {
- navigator.clipboard.writeText(asset.id);
- const orig = copyEl.textContent;
- copyEl.textContent = '✓';
- setTimeout(() => (copyEl.textContent = orig), 1200);
- });
- }
- const sendBtn = $$('send-btn');
- if (sendBtn) sendBtn.addEventListener('click', () => openSend(asset));
- const recvBtn = $$('receive-btn');
- if (recvBtn) recvBtn.addEventListener('click', () => openReceive(asset));
-
- $$('range-tabs').addEventListener('click', async (e) => {
- const btn = e.target.closest('.range-tab');
- if (!btn) return;
- const days = parseInt(btn.dataset.days, 10);
- if (days === activeDays && asset.chart?.points?.length) {
- renderChart(asset.chart.points);
- return;
- }
- activeDays = days;
- document.querySelectorAll('.range-tab').forEach((b) => b.removeAttribute('aria-pressed'));
- btn.setAttribute('aria-pressed', 'true');
- try {
- const updated = await loadAsset(days);
- currentAsset = updated;
- renderChart(updated.chart?.points || []);
- } catch (err) {
- setError(err.message);
- }
- });
-
- renderChart(asset.chart?.points || []);
- }
-
- async function ensureChart() {
- if (chart) return;
- const mod = await import('https://esm.sh/[email protected]');
- const { createChart, AreaSeries } = mod;
- chartEl = $$('chart');
- chartTooltip = $$('chart-tooltip');
- chart = createChart(chartEl, {
- layout: { background: { color: 'transparent' }, textColor: '#666', fontFamily: 'inherit', fontSize: 11 },
- grid: { vertLines: { visible: false }, horzLines: { color: '#0e0e16' } },
- rightPriceScale: { borderVisible: false, scaleMargins: { top: 0.15, bottom: 0.05 } },
- timeScale: { borderVisible: false, timeVisible: false, secondsVisible: false },
- crosshair: {
- vertLine: { color: '#2a2a36', style: 0, width: 1, labelVisible: false },
- horzLine: { color: '#2a2a36', style: 0, width: 1, labelVisible: true },
- },
- handleScroll: false,
- handleScale: false,
- });
- const seriesOpts = {
- lineColor: '#cccccc',
- topColor: 'rgba(154,140,255,0.35)',
- bottomColor: 'rgba(154,140,255,0)',
- lineWidth: 2,
- priceFormat: { type: 'price', precision: 6, minMove: 0.000001 },
- crosshairMarkerRadius: 5,
- crosshairMarkerBorderColor: '#cccccc',
- crosshairMarkerBackgroundColor: '#fff',
- };
- series = chart.addAreaSeries
- ? chart.addAreaSeries(seriesOpts)
- : chart.addSeries(AreaSeries, seriesOpts);
-
- chart.subscribeCrosshairMove((param) => {
- if (!param.time || !param.seriesData?.size) {
- chartTooltip.style.opacity = '0';
- return;
- }
- const pt = param.seriesData.get(series);
- if (!pt) { chartTooltip.style.opacity = '0'; return; }
- const date = new Date(param.time * 1000);
- chartTooltip.querySelector('.tt-date').textContent = date.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' });
- chartTooltip.querySelector('.tt-val').textContent = fmtUsd(pt.value, { precise: true });
- chartTooltip.style.opacity = '1';
- });
-
- new ResizeObserver(() => {
- if (chartEl.clientWidth) chart.applyOptions({ width: chartEl.clientWidth, height: chartEl.clientHeight });
- }).observe(chartEl);
- }
-
- async function renderChart(points) {
- if (!points || points.length < 1) {
- $$('chart').style.display = 'none';
- $$('chart-empty').style.display = 'flex';
- $$('chart-change').textContent = '';
- return;
- }
- $$('chart').style.display = 'block';
- $$('chart-empty').style.display = 'none';
- await ensureChart();
- const sorted = [...points]
- .map((p) => ({ time: Math.floor(new Date(p.t).getTime() / 1000), value: Number(p.price) }))
- // lightweight-charts rejects NaN/null values — drop bad rows from upstream
- .filter((d) => Number.isFinite(d.time) && Number.isFinite(d.value))
- .sort((a, b) => a.time - b.time)
- .filter((d, i, arr) => i === 0 || d.time !== arr[i - 1].time);
- if (!sorted.length) {
- $$('chart').style.display = 'none';
- $$('chart-empty').style.display = 'flex';
- $$('chart-change').textContent = '';
- return;
- }
- series.setData(sorted);
- chart.timeScale().fitContent();
-
- const first = sorted[0].value;
- const last = sorted[sorted.length - 1].value;
- const pct = first > 0 ? ((last - first) / first) * 100 : 0;
- const cls = pct >= 0 ? 'up' : 'down';
- $$('chart-change').innerHTML = `<span class="chip ${cls}">${fmtPct(pct)}</span>`;
- }
-
- // ── Send / Receive ────────────────────────────────────────────────
-
- function openModal(html, after) {
- $$('modal-body').innerHTML = html;
- $$('scrim').setAttribute('data-open', 'true');
- if (after) after();
- }
- function closeModal() { $$('scrim').removeAttribute('data-open'); }
- $$('scrim').addEventListener('click', (e) => { if (e.target.id === 'scrim') closeModal(); });
-
- function openReceive(asset) {
- const w = asset.holdings[0];
- if (!w) return;
- openModal(`
- <h3>Receive ${escapeHtml(asset.symbol)}</h3>
- <p class="sub">${escapeHtml(w.agent_name)} · ${chainLabel(asset.chain)}</p>
- <div class="qr-wrap">
- <canvas id="qr-canvas" width="220" height="220"></canvas>
- <div class="qr-addr">${escapeHtml(w.address)}</div>
- <button class="btn sec sm" id="qr-copy">Copy address</button>
- </div>
- <div class="modal-actions">
- <button class="btn ghost" id="close">Done</button>
- </div>
- `, async () => {
- $$('close').onclick = closeModal;
- $$('qr-copy').onclick = () => navigator.clipboard.writeText(w.address);
- const mod = await import('https://esm.sh/[email protected]');
- const QR = mod.default ?? mod;
- await QR.toCanvas($$('qr-canvas'), w.address, { width: 220, margin: 1, color: { dark: '#000', light: '#ffffff' } });
- });
- }
-
- function openSend(asset) {
- const opts = asset.holdings.map((h) => ({ value: h.agent_id, label: `${h.agent_name} · ${fmtAmt(h.amount)} ${asset.symbol}`, address: h.address }));
- if (!opts.length) return;
- const placeholder = asset.chain === 'solana' ? 'Solana address or yourname.sol' : '0x…';
- openModal(`
- <h3>Send ${escapeHtml(asset.symbol)}</h3>
- <p class="sub">${chainLabel(asset.chain)}</p>
- <form id="send-form">
- <label><span>From wallet</span>
- <select name="agent_id">${opts.map((o) => `<option value="${escapeHtml(o.value)}">${escapeHtml(o.label)}</option>`).join('')}</select>
- </label>
- <label><span>Recipient${asset.chain === 'solana' ? ' address or .sol name' : ' address'}</span>
- <input name="recipient" data-mono required placeholder="${placeholder}" autocomplete="off" spellcheck="false" />
- <small id="recipient-resolved" class="muted" style="display:none;margin-top:6px;font-family:ui-monospace,monospace;font-size:11.5px;word-break:break-all"></small>
- </label>
- <label><span>Amount</span>
- <input name="amount" inputmode="decimal" required placeholder="0.0" pattern="[0-9]*\\.?[0-9]*" />
- </label>
- <div class="modal-actions">
- <button type="button" class="btn ghost" id="cancel">Cancel</button>
- <button type="submit" class="btn">Send</button>
- </div>
- <p id="send-err" class="muted" style="color:#ff9a9a;display:none;margin-top:10px"></p>
- </form>
- `, () => {
- $$('cancel').onclick = closeModal;
- const form = $$('send-form');
- form.addEventListener('submit', (e) => onSendSubmit(e, asset));
- if (asset.chain === 'solana') {
- const input = form.querySelector('input[name="recipient"]');
- const status = $$('recipient-resolved');
- attachSnsTypeahead(input, status);
- }
- });
- }
-
- const SOL_NAME_RE = /^[a-z0-9-]{1,63}(?:\.[a-z0-9-]{1,63})*(?:\.sol)?$/i;
- const SOL_ADDR_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
- function attachSnsTypeahead(input, status) {
- let seq = 0;
- function setStatus(kind, text) {
- status.style.display = text ? '' : 'none';
- status.textContent = text || '';
- status.style.color = kind === 'ok'
- ? '#7be07b'
- : kind === 'warn'
- ? '#ff9a9a'
- : 'var(--muted)';
- }
- async function lookup(name) {
- const myId = ++seq;
- try {
- const r = await fetch(`/api/sns?name=${encodeURIComponent(name)}`);
- if (myId !== seq) return;
- if (r.status === 404) { setStatus('warn', `${name} does not resolve`); return; }
- if (!r.ok) {
- const j = await r.json().catch(() => ({}));
- setStatus('warn', j.error_description || `lookup failed (${r.status})`);
- return;
- }
- const { data } = await r.json();
- if (myId !== seq) return;
- setStatus('ok', `→ ${data.address}`);
- } catch (err) {
- if (myId === seq) setStatus('warn', err.message || 'lookup failed');
- }
- }
- input.addEventListener('input', () => {
- const raw = input.value.trim();
- seq++;
- if (!raw) { setStatus('', ''); return; }
- if (SOL_ADDR_RE.test(raw)) { setStatus('', ''); return; }
- if (/\.sol$/i.test(raw) || (SOL_NAME_RE.test(raw) && !SOL_ADDR_RE.test(raw))) {
- setStatus('', 'Resolving .sol…');
- const myId = seq;
- setTimeout(() => { if (myId === seq) lookup(raw); }, 300);
- return;
- }
- setStatus('warn', 'Not a valid Solana address or .sol name');
- });
- }
-
- async function onSendSubmit(e, asset) {
- e.preventDefault();
- const f = e.target;
- const agentId = f.agent_id.value;
- const recipient = f.recipient.value.trim();
- const amount = f.amount.value.trim();
- const submit = f.querySelector('button[type="submit"]');
- submit.disabled = true;
- $$('send-err').style.display = 'none';
- try {
- const token = await getCsrf();
- const r = await fetch(`${apiUrl}/portfolio/send`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json', 'x-csrf-token': token },
- body: JSON.stringify({
- agent_id: agentId,
- chain: asset.chain,
- asset: asset.is_native ? 'native' : asset.id,
- recipient,
- amount,
- }),
- });
- const d = await r.json();
- if (!r.ok) throw new Error(d.error_description || 'send failed');
- csrfToken = null;
- closeModal();
- await refresh();
- } catch (err) {
- $$('send-err').textContent = err.message;
- $$('send-err').style.display = 'block';
- csrfToken = null;
- } finally {
- submit.disabled = false;
- }
- }
-
- async function refresh() {
- try {
- const asset = await loadAsset(activeDays);
- currentAsset = asset;
- render(asset);
- } catch (err) {
- setError(err.message);
- }
- }
-
- (async () => {
- if (!chain || !id) {
- setError('Missing chain or asset id in URL');
- return;
- }
- const me = await fetchUser();
- if (!me) return;
- renderHeaderUser($$('header-user-slot'), me.user, { activePath: '/dashboard/portfolio' });
- try {
- const asset = await loadAsset(activeDays);
- currentAsset = asset;
- document.title = `${asset.symbol} · Portfolio · three.ws`;
- render(asset);
- } catch (err) {
- setError(err.message);
- }
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/portfolio.html b/public/dashboard-classic/portfolio.html
deleted file mode 100644
index c707d4ecd..000000000
--- a/public/dashboard-classic/portfolio.html
+++ /dev/null
@@ -1,1398 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="robots" content="noindex" />
- <meta name="referrer" content="strict-origin-when-cross-origin" />
- <title>Portfolio · Dashboard · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <link rel="stylesheet" href="/fonts/fonts.css" />
- <link rel="stylesheet" href="/footer.css" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --ok: #2ed4a3;
- --warn: #ffb35c;
- --err: #ff6a6a;
- --border: #1c1c28;
- --border-2: #232336;
- --bg: #000;
- --panel: #0b0b13;
- --panel-2: #0f0f1a;
- --text: #f0f0f5;
- --muted: #6e6e82;
- --muted-2: #9a9ab0;
- }
- * { box-sizing: border-box; }
- html, body { background: var(--bg); }
- body {
- font: 14px/1.6 'Inter', -apple-system, system-ui, Segoe UI, Roboto, sans-serif;
- color: var(--text);
- margin: 0;
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- }
- a { color: #cccccc; text-decoration: none; }
-
- /* ── Site header ───────────────────────────────────────────────── */
- .site-header {
- display: flex;
- align-items: center;
- gap: 12px;
- padding: 0 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: rgba(0, 0, 0, 0.88);
- backdrop-filter: blur(18px);
- -webkit-backdrop-filter: blur(18px);
- z-index: 20;
- height: 58px;
- flex-shrink: 0;
- }
- .site-header::after {
- content: '';
- position: absolute;
- left: 0; right: 0; bottom: -1px;
- height: 1px;
- background: linear-gradient(90deg, transparent 0%, rgba(154,140,255,0.4) 35%, rgba(99,102,241,0.35) 60%, rgba(34,211,238,0.25) 80%, transparent 100%);
- pointer-events: none;
- }
- .site-brand {
- display: flex;
- align-items: center;
- gap: 8px;
- flex-shrink: 0;
- color: var(--text);
- font-weight: 600;
- font-size: 15px;
- letter-spacing: -0.01em;
- }
- .site-brand:hover { opacity: 0.85; }
- .wordmark-logo { height: 22px; width: auto; display: block; }
-
- .site-nav {
- display: flex;
- align-items: center;
- gap: 2px;
- margin-left: 6px;
- flex: 1;
- overflow-x: auto;
- scrollbar-width: none;
- }
- .site-nav::-webkit-scrollbar { display: none; }
- .site-nav a {
- padding: 6px 10px;
- border-radius: 6px;
- color: var(--muted);
- font-size: 13px;
- transition: color 0.14s, background 0.14s;
- white-space: nowrap;
- }
- .site-nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); }
- .site-nav a.active { color: #fff; background: rgba(255, 255, 255,0.14); }
-
- .site-header-right {
- display: flex;
- align-items: center;
- gap: 8px;
- margin-left: auto;
- flex-shrink: 0;
- }
-
- /* ── Layout wrapper ────────────────────────────────────────────── */
- .page-wrap {
- display: flex;
- flex: 1;
- min-height: 0;
- align-items: flex-start;
- }
-
- /* ── Left sidebar ──────────────────────────────────────────────── */
- .dash-sidebar {
- width: 210px;
- flex-shrink: 0;
- border-right: 1px solid var(--border);
- position: sticky;
- top: 58px;
- height: calc(100vh - 58px);
- overflow-y: auto;
- padding: 18px 10px 40px;
- scrollbar-width: thin;
- scrollbar-color: var(--border-2) transparent;
- background: rgba(5,5,10,0.5);
- }
- .dash-sidebar::-webkit-scrollbar { width: 5px; }
- .dash-sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
-
- .sidebar-section { margin-bottom: 22px; }
- .sidebar-label {
- font-size: 10.5px;
- font-weight: 600;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: var(--muted);
- padding: 0 8px 6px;
- }
- .sidebar-link {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 7px 9px;
- border-radius: 7px;
- color: var(--muted-2);
- font-size: 13px;
- transition: color 0.13s, background 0.13s;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .sidebar-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
- .sidebar-link.active {
- color: #fff;
- background: rgba(255, 255, 255,0.14);
- box-shadow: inset 2px 0 0 var(--accent);
- }
- .sidebar-link svg { flex-shrink: 0; opacity: 0.65; }
- .sidebar-link.active svg { opacity: 1; color: #cccccc; }
-
- /* ── Main content ──────────────────────────────────────────────── */
- .dash-main {
- flex: 1;
- min-width: 0;
- padding: 28px 28px 64px;
- max-width: 1060px;
- }
- .page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
- .page-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
-
- /* ── Buttons ───────────────────────────────────────────────────── */
- .btn {
- padding: 8px 14px; border-radius: 8px; border: 0;
- font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
- background: rgba(255,255,255,0.06); color: var(--text);
- border: 1px solid var(--border-2);
- transition: all 0.13s ease;
- display: inline-flex; align-items: center; gap: 6px;
- }
- .btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); }
- .btn:active { transform: scale(0.98); }
- .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
- .btn.primary:hover { background: #7d70ff; border-color: #7d70ff; }
- .btn.sec { background: #16161f; color: #d0d0e0; border-color: var(--border); }
- .btn.sec:hover { background: #1e1e2a; }
- .btn.ghost { background: transparent; border-color: transparent; color: var(--muted-2); }
- .btn.ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }
- .btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
- .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
-
- /* ── Hero card ─────────────────────────────────────────────────── */
- .hero {
- background:
- radial-gradient(900px 280px at 10% -30%, rgba(255, 255, 255,0.15), transparent 60%),
- radial-gradient(600px 200px at 90% -10%, rgba(255, 255, 255,0.1), transparent 60%),
- var(--panel);
- border: 1px solid var(--border-2);
- border-radius: 16px;
- padding: 24px 24px 0;
- margin-bottom: 16px;
- overflow: hidden;
- position: relative;
- }
- .hero-top {
- display: flex; align-items: flex-start; justify-content: space-between;
- gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
- }
- .tot-label {
- font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
- text-transform: uppercase; color: var(--muted);
- }
- .tot-value {
- font-size: 42px; font-weight: 700; letter-spacing: -0.03em;
- line-height: 1.05; margin-top: 6px; font-variant-numeric: tabular-nums;
- background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- background-clip: text;
- }
- .tot-change {
- display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px;
- }
- .chip {
- display: inline-flex; align-items: center; gap: 5px;
- padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
- font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
- }
- .chip.up { background: rgba(46,212,163,0.13); color: var(--ok); border: 1px solid rgba(46,212,163,0.2); }
- .chip.down { background: rgba(255,106,106,0.12); color: var(--err); border: 1px solid rgba(255,106,106,0.2); }
- .chip.flat { background: rgba(255,255,255,0.05); color: var(--muted-2); border: 1px solid var(--border-2); }
- .tot-meta { color: var(--muted); font-size: 13px; }
- .tot-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; padding-top: 4px; }
-
- /* ── Chart ─────────────────────────────────────────────────────── */
- .chart-wrap { position: relative; }
- #chart { height: 260px; margin: 0 -24px; }
- #chart-tooltip {
- position: absolute; top: 14px; left: 14px;
- background: rgba(6,6,12,0.88); border: 1px solid var(--border-2);
- border-radius: 8px; padding: 8px 12px;
- font-size: 12px; pointer-events: none; opacity: 0;
- transition: opacity 0.12s; min-width: 150px;
- backdrop-filter: blur(8px);
- }
- #chart-tooltip .tt-date { color: var(--muted); font-size: 11px; }
- #chart-tooltip .tt-val { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
- #chart-empty {
- height: 260px; display: none; align-items: center; justify-content: center;
- color: var(--muted); font-size: 13px; flex-direction: column; gap: 8px;
- margin: 0 -24px;
- }
- .range-tabs {
- display: flex; gap: 3px; padding: 8px 0 14px;
- border-top: 1px solid var(--border); margin-top: 12px;
- justify-content: flex-end;
- }
- .range-tab {
- background: transparent; border: 0; cursor: pointer;
- color: var(--muted); font-size: 12px; font-weight: 600;
- padding: 5px 10px; border-radius: 6px; font-family: inherit;
- transition: all 0.12s;
- }
- .range-tab:hover { color: var(--muted-2); background: rgba(255,255,255,0.04); }
- .range-tab[aria-pressed="true"] {
- background: rgba(255, 255, 255,0.18); color: #cccccc;
- border: 0;
- }
-
- /* ── Stat cards ────────────────────────────────────────────────── */
- .stats-row {
- display: grid; grid-template-columns: repeat(4, 1fr);
- gap: 10px; margin: 0 0 18px;
- }
- .stat {
- background: var(--panel); border: 1px solid var(--border);
- border-radius: 12px; padding: 14px 16px;
- position: relative; overflow: hidden;
- transition: border-color 0.14s, box-shadow 0.14s;
- }
- .stat:hover { border-color: var(--border-2); box-shadow: 0 4px 18px -8px rgba(255, 255, 255,0.18); }
- .stat-icon {
- width: 28px; height: 28px; border-radius: 8px;
- display: grid; place-items: center;
- margin-bottom: 10px; font-size: 14px;
- }
- .stat-icon.purple { background: rgba(255, 255, 255,0.14); }
- .stat-icon.teal { background: rgba(46,212,163,0.12); }
- .stat-icon.green { background: rgba(46,212,163,0.12); }
- .stat-icon.red { background: rgba(255,106,106,0.1); }
- .stat-label { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
- .stat-value { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
- .stat-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
-
- /* ── Section headers ───────────────────────────────────────────── */
- .section-head {
- display: flex; align-items: center; justify-content: space-between;
- margin: 26px 0 12px;
- }
- .section-head h2 {
- font-size: 11.5px; margin: 0; color: var(--muted);
- text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
- display: flex; align-items: center; gap: 7px;
- }
- .section-actions { display: flex; gap: 6px; align-items: center; }
- .count-badge {
- display: inline-flex; align-items: center; padding: 1px 7px;
- border-radius: 99px; background: rgba(255,255,255,0.05);
- border: 1px solid var(--border); color: var(--muted);
- font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
- }
-
- /* ── Holdings table ────────────────────────────────────────────── */
- .holdings {
- background: var(--panel); border: 1px solid var(--border);
- border-radius: 14px; overflow: hidden;
- }
- .h-head, .h-row {
- display: grid; grid-template-columns: 2.4fr 1fr 1fr 1.1fr 1fr;
- gap: 10px; align-items: center; padding: 11px 16px;
- }
- .h-head {
- font-size: 10.5px; color: var(--muted); text-transform: uppercase;
- letter-spacing: 0.08em; font-weight: 600;
- border-bottom: 1px solid var(--border);
- background: rgba(255,255,255,0.015);
- }
- .h-head button {
- background: none; border: 0; padding: 0; cursor: pointer;
- color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit;
- text-align: inherit; display: inline-flex; align-items: center; gap: 4px;
- transition: color 0.12s;
- }
- .h-head button:hover { color: var(--muted-2); }
- .h-row {
- border-bottom: 1px solid var(--border);
- cursor: pointer;
- transition: background 0.08s;
- text-decoration: none; color: inherit;
- }
- .h-row:last-child { border-bottom: 0; }
- .h-row:hover { background: rgba(255,255,255,0.026); }
- .tok-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
- .tok-logo {
- width: 32px; height: 32px; border-radius: 50%;
- background: var(--panel-2); flex-shrink: 0;
- display: inline-flex; align-items: center; justify-content: center;
- font-size: 10px; font-weight: 700; color: var(--muted-2);
- overflow: hidden; border: 1px solid var(--border);
- }
- .tok-logo img { width: 100%; height: 100%; object-fit: cover; }
- .tok-info { min-width: 0; }
- .tok-name {
- font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px;
- white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
- }
- .tok-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
- .cell-num { font-variant-numeric: tabular-nums; font-size: 13.5px; font-weight: 500; }
- .cell-num.muted { color: var(--muted); font-size: 12.5px; font-weight: 400; }
- .cell-right { text-align: right; }
- .alloc-bar { height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 6px; }
- .alloc-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; }
- .chain-pill {
- display: inline-flex; align-items: center; gap: 5px;
- font-size: 10px; padding: 2px 7px; border-radius: 99px;
- background: rgba(255,255,255,0.05); color: var(--muted-2);
- white-space: nowrap; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
- border: 1px solid var(--border);
- }
- .chain-pill.sol { background: rgba(20,241,149,0.1); color: var(--ok); border-color: rgba(20,241,149,0.15); }
- .chain-pill.evm { background: rgba(255, 255, 255,0.12); color: #cccccc; border-color: rgba(255, 255, 255,0.2); }
-
- /* ── Wallet cards ──────────────────────────────────────────────── */
- .wallet-list { display: flex; flex-direction: column; gap: 10px; }
- .wcard {
- background: var(--panel); border: 1px solid var(--border);
- border-radius: 12px; padding: 16px 18px;
- transition: border-color 0.13s, box-shadow 0.13s;
- }
- .wcard:hover { border-color: var(--border-2); box-shadow: 0 4px 18px -8px rgba(0,0,0,0.35); }
- .wcard-head {
- display: flex; align-items: flex-start; justify-content: space-between;
- gap: 14px; flex-wrap: wrap;
- }
- .wcard-name {
- font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px;
- }
- .wcard-addr {
- font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
- font-size: 11.5px; color: var(--muted);
- display: inline-flex; align-items: center; gap: 6px; margin-top: 5px;
- }
- .copy-btn {
- background: none; border: none; color: var(--muted); cursor: pointer;
- padding: 2px 4px; font-size: 12px; border-radius: 4px;
- transition: color 0.12s, background 0.12s;
- }
- .copy-btn:hover { color: var(--muted-2); background: rgba(255,255,255,0.06); }
- .wcard-usd {
- font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums;
- text-align: right; letter-spacing: -0.015em;
- }
- .wcard-actions {
- display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px;
- }
-
- /* ── Empty & error states ──────────────────────────────────────── */
- .empty {
- text-align: center; padding: 44px 20px;
- border: 1px dashed var(--border-2); border-radius: 12px;
- color: var(--muted);
- }
- .empty p { margin: 0 0 6px; font-size: 13.5px; }
- .empty p:first-child { font-weight: 600; font-size: 15px; color: var(--muted-2); }
- .empty .btn { margin-top: 14px; }
- .err-banner {
- padding: 12px 14px; background: rgba(255,80,80,0.08);
- border: 1px solid rgba(255,80,80,0.22); border-radius: 10px;
- color: #ffb0b0; margin-bottom: 14px; display: none; font-size: 13px;
- }
-
- /* ── Skeleton loader ───────────────────────────────────────────── */
- .skeleton {
- background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%);
- background-size: 200% 100%;
- animation: shimmer 1.5s ease-in-out infinite;
- border-radius: 10px;
- }
- @keyframes shimmer {
- from { background-position: 200% 0; }
- to { background-position: -200% 0; }
- }
-
- /* ── Modal / scrim ─────────────────────────────────────────────── */
- .scrim {
- position: fixed; inset: 0; background: rgba(0,0,0,0.75);
- display: none; align-items: center; justify-content: center;
- z-index: 100; padding: 20px;
- backdrop-filter: blur(6px);
- -webkit-backdrop-filter: blur(6px);
- }
- .scrim[data-open="true"] { display: flex; }
- .modal {
- background: #0d0d17; border: 1px solid var(--border-2);
- border-radius: 14px; padding: 24px;
- width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
- box-shadow: 0 20px 60px rgba(0,0,0,0.6);
- }
- .modal h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.01em; }
- .modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
- .modal label { display: block; margin-bottom: 12px; }
- .modal label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
- .modal input, .modal select {
- width: 100%; padding: 10px 12px; border-radius: 8px;
- border: 1px solid var(--border-2); background: #080810; color: #eee;
- font-size: 14px; font-family: inherit;
- transition: border-color 0.13s, box-shadow 0.13s;
- }
- .modal input:focus, .modal select:focus {
- outline: none; border-color: rgba(255, 255, 255,0.55);
- box-shadow: 0 0 0 3px rgba(255, 255, 255,0.12);
- }
- .modal input[data-mono] { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }
- .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
- .qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 0; }
- .qr-wrap canvas { background: #fff; padding: 10px; border-radius: 10px; }
- .qr-addr {
- font-family: 'JetBrains Mono', ui-monospace, monospace;
- font-size: 11.5px; color: #ccc; word-break: break-all;
- text-align: center; max-width: 100%;
- }
-
- /* ── Responsive ────────────────────────────────────────────────── */
- @media (max-width: 1024px) {
- .dash-sidebar { width: 180px; }
- }
- @media (max-width: 820px) {
- .dash-sidebar { display: none; }
- .dash-main { padding: 18px 16px 60px; }
- .h-head, .h-row { grid-template-columns: 2fr 1.2fr 1.2fr; }
- .h-head .col-amount, .h-row .col-amount,
- .h-head .col-alloc, .h-row .col-alloc { display: none; }
- .stats-row { grid-template-columns: repeat(2, 1fr); }
- .tot-value { font-size: 34px; }
- .site-nav { display: none; }
- }
- @media (max-width: 500px) {
- .stats-row { grid-template-columns: 1fr 1fr; }
- .stat-value { font-size: 17px; }
- }
-
- body[data-auth-pending] { visibility: hidden; }
- </style>
- </head>
- <body data-auth-pending>
-
- <!-- Site header -->
- <header class="site-header">
- <a href="/" class="site-brand">
- <img src="/three.svg" alt="three.ws" class="wordmark-logo" />
- </a>
- <nav class="site-nav" aria-label="Primary">
- <a href="/app">Viewer</a>
- <a href="/create">Create</a>
- <a href="/discover">Discover</a>
- <a href="/widgets">Widgets</a>
- <a href="/studio">Studio</a>
- <a href="/docs">Docs</a>
- <a href="/my-agents">My Agents</a>
- <a href="/dashboard" class="active" aria-current="page">Dashboard</a>
- </nav>
- <div class="site-header-right" id="header-user-slot"></div>
- </header>
-
- <div class="page-wrap">
- <!-- Left sidebar -->
- <aside class="dash-sidebar" aria-label="Dashboard navigation">
- <div class="sidebar-section">
- <div class="sidebar-label">Finances</div>
- <a href="/dashboard/portfolio" class="sidebar-link active" aria-current="page">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"/><path d="m19 9-5 5-4-4-3 3"/></svg>
- Portfolio
- </a>
- <a href="/dashboard/tokens" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M15 9.354a4 4 0 1 0 0 5.292"/></svg>
- Tokens
- </a>
- <a href="/dashboard/wallets" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><path d="M18 12a2 2 0 0 0 0 4h4v-4Z"/></svg>
- Wallets
- </a>
- <a href="/dashboard/payments" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
- Payments
- </a>
- <a href="/dashboard/revenue" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" x2="12" y1="2" y2="22"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
- Revenue
- </a>
- <a href="/dashboard/earnings" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20V10"/><path d="M18 20V4"/><path d="M6 20v-6"/></svg>
- Earnings
- </a>
- <a href="/dashboard/withdrawals" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
- Withdrawals
- </a>
- </div>
- <div class="sidebar-section">
- <div class="sidebar-label">Agents</div>
- <a href="/dashboard/agents" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="5"/><path d="M20 21a8 8 0 1 0-16 0"/></svg>
- Agents
- </a>
- <a href="/dashboard/avatars" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a5 5 0 1 0 5 5"/><path d="M20 21a8 8 0 1 0-16 0"/></svg>
- Avatars
- </a>
- <a href="/dashboard/widgets" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg>
- Widgets
- </a>
- <a href="/my-agents" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/></svg>
- On-chain (ERC-8004)
- </a>
- </div>
- <div class="sidebar-section">
- <div class="sidebar-label">Tools</div>
- <a href="/dashboard/strategy" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 20h.01"/><path d="M7 20v-4"/><path d="M12 20v-8"/><path d="M17 20V8"/><path d="M22 4v16"/></svg>
- Strategy
- </a>
- <a href="/dashboard/memory" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"/><path d="M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"/></svg>
- Memory
- </a>
- <a href="/dashboard/keys" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/></svg>
- API keys
- </a>
- <a href="/dashboard/sns" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="12" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>
- SNS domains
- </a>
- <a href="/dashboard/actions" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3L14.5 4z"/><circle cx="12" cy="13" r="3"/></svg>
- Action log
- </a>
- <a href="/dashboard/sessions" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
- Sessions
- </a>
- <a href="/dashboard/account" class="sidebar-link">
- <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41M2 12h2m16 0h2M4.93 19.07l1.41-1.41m11.32-11.32 1.41-1.41"/></svg>
- Account
- </a>
- </div>
- </aside>
-
- <!-- Main content -->
- <main class="dash-main" id="main">
- <h1 class="page-title">Portfolio</h1>
- <p class="page-sub">Real-time value across every agent wallet under your account.</p>
-
- <div id="error" class="err-banner" role="alert"></div>
-
- <!-- Hero chart card -->
- <div class="hero">
- <div class="hero-top">
- <div>
- <div class="tot-label">Total value</div>
- <div class="tot-value" id="tot-value">—</div>
- <div class="tot-change">
- <span class="chip flat" id="tot-change-chip">—</span>
- <span class="tot-meta" id="tot-meta">Loading live balances…</span>
- </div>
- </div>
- <div class="tot-actions">
- <button id="refresh-btn" class="btn primary">
- <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>
- Refresh
- </button>
- </div>
- </div>
- <div class="chart-wrap">
- <div id="chart"></div>
- <div id="chart-empty">
- <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="opacity:0.25"><path d="M3 3v18h18"/><path d="m19 9-5 5-4-4-3 3"/></svg>
- Hit Refresh to capture your first snapshot.
- </div>
- <div id="chart-tooltip">
- <div class="tt-date"></div>
- <div class="tt-val"></div>
- </div>
- </div>
- <div class="range-tabs" id="range-tabs" role="group" aria-label="Time range">
- <button class="range-tab" data-days="1">1D</button>
- <button class="range-tab" data-days="7">7D</button>
- <button class="range-tab" data-days="30" aria-pressed="true">30D</button>
- <button class="range-tab" data-days="90">90D</button>
- <button class="range-tab" data-days="365">1Y</button>
- <button class="range-tab" data-days="0">All</button>
- </div>
- </div>
-
- <!-- Stat cards -->
- <div class="stats-row">
- <div class="stat">
- <div class="stat-icon purple">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#cccccc" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M15 9.354a4 4 0 1 0 0 5.292"/></svg>
- </div>
- <div class="stat-label">Assets</div>
- <div class="stat-value" id="stat-assets">—</div>
- <div class="stat-sub" id="stat-assets-sub">across all wallets</div>
- </div>
- <div class="stat">
- <div class="stat-icon teal">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#2ed4a3" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><path d="M18 12a2 2 0 0 0 0 4h4v-4Z"/></svg>
- </div>
- <div class="stat-label">Wallets</div>
- <div class="stat-value" id="stat-wallets">—</div>
- <div class="stat-sub" id="stat-wallets-sub">solana + evm</div>
- </div>
- <div class="stat">
- <div class="stat-icon green">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#2ed4a3" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 7 13.5 15.5 8.5 10.5 2 17"/><path d="M16 7h6v6"/></svg>
- </div>
- <div class="stat-label">Best 24h</div>
- <div class="stat-value" id="stat-best">—</div>
- <div class="stat-sub" id="stat-best-sub"></div>
- </div>
- <div class="stat">
- <div class="stat-icon red">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#ff6a6a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 17 13.5 8.5 8.5 13.5 2 7"/><path d="M16 17h6v-6"/></svg>
- </div>
- <div class="stat-label">Worst 24h</div>
- <div class="stat-value" id="stat-worst">—</div>
- <div class="stat-sub" id="stat-worst-sub"></div>
- </div>
- </div>
-
- <!-- Holdings -->
- <div class="section-head">
- <h2>
- <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"/><path d="m19 9-5 5-4-4-3 3"/></svg>
- All holdings
- </h2>
- <div class="section-actions">
- <span class="count-badge" id="holding-count" style="display:none"></span>
- </div>
- </div>
- <div id="holdings" class="holdings">
- <div style="padding:22px 16px">
- <div class="skeleton" style="height:38px;margin-bottom:10px"></div>
- <div class="skeleton" style="height:38px;margin-bottom:10px"></div>
- <div class="skeleton" style="height:38px"></div>
- </div>
- </div>
-
- <!-- Wallets -->
- <div class="section-head">
- <h2>
- <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><path d="M18 12a2 2 0 0 0 0 4h4v-4Z"/></svg>
- Wallets
- </h2>
- <span class="count-badge" id="wallet-count" style="display:none"></span>
- </div>
- <div id="wallets" class="wallet-list">
- <div style="padding:22px 0">
- <div class="skeleton" style="height:80px;margin-bottom:10px;border-radius:12px"></div>
- <div class="skeleton" style="height:80px;border-radius:12px"></div>
- </div>
- </div>
- </main>
- </div>
-
- <!-- Send / Receive modal -->
- <div id="scrim" class="scrim" role="dialog" aria-modal="true" aria-label="Wallet action">
- <div class="modal" id="modal-body"></div>
- </div>
-
- <!-- Footer -->
- <footer class="h-footer-horizon">
- <div class="h-footer-glow-line" aria-hidden="true"></div>
- <div class="h-footer-floor" aria-hidden="true"></div>
- <div class="h-footer-haze" aria-hidden="true"></div>
- <div class="h-footer-watermark" aria-hidden="true">three.ws</div>
- <div class="h-footer-inner">
- <div class="h-footer-brand-col">
- <div class="h-footer-brand">
- <img class="wordmark-logo" src="/three.svg" alt="" aria-hidden="true" />
- <span>three.ws</span>
- </div>
- <p class="h-footer-tagline">Give your AI a body.</p>
- </div>
- <nav class="h-footer-links" aria-label="Footer">
- <a href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener noreferrer">GitHub</a>
- <a href="/create">Create</a>
- <a href="/studio">Studio</a>
- <a href="/widgets">Widgets</a>
- <a href="/discover">Discover</a>
- <a href="/docs">Docs</a>
- <a href="/legal/privacy">Privacy</a>
- <a href="/legal/tos">Terms</a>
- </nav>
- </div>
- <div class="h-footer-bottom">
- <p class="h-footer-legal">© 2026 three.ws — All rights reserved.</p>
- <div class="h-footer-badges">
- <span class="h-footer-badge" aria-label="System status">
- <span class="h-footer-status-dot" aria-hidden="true"></span>
- <span>All systems normal</span>
- </span>
- <span class="h-footer-badge">
- <svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm0 14.5A6.5 6.5 0 1 1 8 1.5a6.5 6.5 0 0 1 0 13zm-1-9.25a1 1 0 1 1 2 0v3.5a1 1 0 1 1-2 0v-3.5zm1 6.5a1.1 1.1 0 1 1 0-2.2 1.1 1.1 0 0 1 0 2.2z"/></svg>
- Transparent by default
- </span>
- <a class="h-footer-badge" href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener noreferrer" aria-label="View source on GitHub">
- <svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
- Open source
- </a>
- </div>
- </div>
- </footer>
-
- <script type="module">
- import { renderHeaderUser } from '/src/header-user.js';
-
- const apiUrl = '/api';
- let csrfToken = null;
- let chart = null;
- let series = null;
- let chartEl = null;
- let chartTooltip = null;
- let currentSummary = null;
- let currentHistory = [];
- let activeDays = 30;
- let sortBy = 'usd';
- let sortDir = 'desc';
-
- const $ = (id) => document.getElementById(id);
-
- function fmtUsd(n, opts = {}) {
- if (!Number.isFinite(n)) return '$0.00';
- const abs = Math.abs(n);
- if (abs >= 1_000_000) return '$' + (n / 1_000_000).toFixed(2) + 'M';
- if (abs >= 10_000) return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 0 });
- if (abs >= 1) return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 2 });
- if (abs > 0) {
- if (opts.precise) return '$' + n.toLocaleString('en-US', { maximumFractionDigits: 6 });
- return '$' + n.toFixed(abs < 0.01 ? 4 : 2);
- }
- return '$0.00';
- }
- function fmtPct(n) {
- if (!Number.isFinite(n)) return '—';
- const sign = n >= 0 ? '+' : '';
- return sign + n.toFixed(2) + '%';
- }
- function fmtAmt(n) {
- if (!Number.isFinite(n) || n === 0) return '0';
- if (n < 0.0001) return n.toExponential(2);
- if (n < 1) return n.toFixed(4);
- if (n < 1000) return n.toFixed(3);
- return n.toLocaleString('en-US', { maximumFractionDigits: 2 });
- }
- function shortAddr(a) {
- if (!a) return '';
- return a.length > 14 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a;
- }
- function escapeHtml(s) {
- return String(s ?? '').replace(/[&<>"']/g, (c) => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
- }
- function chainLabel(chain, chain_id) {
- if (chain === 'solana') return 'Solana';
- if (chain_id === 8453) return 'Base';
- return 'Ethereum';
- }
- function setError(msg) {
- const el = $('error');
- if (!msg) { el.style.display = 'none'; return; }
- el.textContent = msg;
- el.style.display = 'block';
- }
-
- // ── Auth ──────────────────────────────────────────────────────────
-
- async function fetchUser() {
- const res = await fetch(`${apiUrl}/auth/me`, { credentials: 'include' });
- const data = res.ok ? await res.json() : null;
- if (!data?.user) {
- location.href = '/login?next=' + encodeURIComponent(location.pathname);
- return null;
- }
- document.body.removeAttribute('data-auth-pending');
- return data;
- }
-
- async function getCsrf() {
- if (csrfToken) return csrfToken;
- const r = await fetch(`${apiUrl}/csrf-token`, { credentials: 'include' });
- if (!r.ok) throw new Error('CSRF token fetch failed');
- const d = await r.json();
- csrfToken = d?.data?.token;
- return csrfToken;
- }
-
- // ── Data loading ──────────────────────────────────────────────────
-
- async function loadHistory(days) {
- const q = days && days > 0 ? `?days=${days}` : '?days=365';
- const r = await fetch(`${apiUrl}/portfolio/history${q}`, { credentials: 'include' });
- if (!r.ok) return [];
- const d = await r.json();
- return d.points || [];
- }
-
- async function loadSummary({ snapshot = false } = {}) {
- const url = `${apiUrl}/portfolio/summary${snapshot ? '?snapshot=1' : ''}`;
- const r = await fetch(url, { credentials: 'include' });
- if (!r.ok) {
- const e = await r.json().catch(() => ({}));
- throw new Error(e.error_description || 'Failed to load portfolio');
- }
- return r.json();
- }
-
- // ── Holdings aggregation ──────────────────────────────────────────
-
- function aggregateHoldings(summary) {
- const map = new Map();
- for (const w of summary.wallets) {
- if (!w.ok) continue;
- const native = w.native;
- if (native && (native.amount > 0 || native.usd > 0)) {
- const key = `${w.chain}:native`;
- let entry = map.get(key);
- if (!entry) {
- entry = { key, chain: w.chain, id: 'native', is_native: true, symbol: native.symbol, name: native.name || native.symbol, logo: null, price: native.price || 0, change24h: native.change24h ?? null, amount: 0, usd: 0, wallets: [] };
- map.set(key, entry);
- }
- entry.amount += Number(native.amount || 0);
- entry.usd += Number(native.usd || 0);
- entry.wallets.push({ agent_id: w.agent_id, agent_name: w.agent_name, address: w.address, amount: Number(native.amount || 0), usd: Number(native.usd || 0) });
- }
- for (const t of (w.tokens || [])) {
- const id = t.mint || t.contract;
- if (!id) continue;
- const key = `${w.chain}:${id.toLowerCase()}`;
- let entry = map.get(key);
- if (!entry) {
- entry = { key, chain: w.chain, id, is_native: false, symbol: t.symbol || id.slice(0, 6), name: t.name || t.symbol || id.slice(0, 8), logo: t.logo || null, price: t.price || 0, change24h: t.change24h ?? null, amount: 0, usd: 0, wallets: [] };
- map.set(key, entry);
- }
- entry.amount += Number(t.amount || 0);
- entry.usd += Number(t.usd || 0);
- entry.wallets.push({ agent_id: w.agent_id, agent_name: w.agent_name, address: w.address, amount: Number(t.amount || 0), usd: Number(t.usd || 0) });
- }
- }
- return Array.from(map.values());
- }
-
- function sortHoldings(rows) {
- const dir = sortDir === 'asc' ? 1 : -1;
- const cmp = {
- usd: (a, b) => (a.usd - b.usd) * dir,
- amount: (a, b) => (a.amount - b.amount) * dir,
- change: (a, b) => ((a.change24h ?? -Infinity) - (b.change24h ?? -Infinity)) * dir,
- symbol: (a, b) => a.symbol.localeCompare(b.symbol) * dir,
- }[sortBy] || ((a, b) => (a.usd - b.usd) * dir);
- return [...rows].sort(cmp);
- }
-
- // ── Render ────────────────────────────────────────────────────────
-
- function renderTotal(summary) {
- $('tot-value').textContent = fmtUsd(summary.total_usd);
- const at = new Date(summary.captured_at);
- $('tot-meta').textContent = `Updated ${at.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
- }
-
- function renderHistoryChange(points, totalNow) {
- const chip = $('tot-change-chip');
- if (!points.length) { chip.className = 'chip flat'; chip.textContent = '—'; return; }
- const first = points[0].usd;
- const delta = totalNow - first;
- const pct = first > 0 ? (delta / first) * 100 : 0;
- const cls = delta > 0 ? 'up' : delta < 0 ? 'down' : 'flat';
- chip.className = 'chip ' + cls;
- const sign = delta > 0 ? '+' : delta < 0 ? '−' : '';
- chip.innerHTML = `${sign}${fmtUsd(Math.abs(delta))} <span style="opacity:0.7">${fmtPct(pct)}</span>`;
- }
-
- function renderStats(summary, holdings) {
- const countEl = $('stat-assets');
- const walletEl = $('stat-wallets');
- countEl.textContent = holdings.length;
- walletEl.textContent = summary.wallets.length;
- const sol = summary.wallets.filter((w) => w.chain === 'solana').length;
- const evm = summary.wallets.filter((w) => w.chain === 'evm').length;
- $('stat-wallets-sub').textContent = `${sol} solana · ${evm} evm`;
- $('stat-assets-sub').textContent = 'across all wallets';
-
- const withChange = holdings.filter((h) => Number.isFinite(h.change24h) && h.usd > 0.5);
- if (withChange.length) {
- const sorted = [...withChange].sort((a, b) => b.change24h - a.change24h);
- const best = sorted[0];
- const worst = sorted[sorted.length - 1];
- $('stat-best').textContent = fmtPct(best.change24h);
- $('stat-best').style.color = best.change24h >= 0 ? 'var(--ok)' : 'var(--err)';
- $('stat-best-sub').textContent = best.symbol;
- $('stat-worst').textContent = fmtPct(worst.change24h);
- $('stat-worst').style.color = worst.change24h >= 0 ? 'var(--ok)' : 'var(--err)';
- $('stat-worst-sub').textContent = worst.symbol;
- } else {
- ['stat-best','stat-worst'].forEach((id) => { $(id).textContent = '—'; $(id).style.color = ''; });
- $('stat-best-sub').textContent = '';
- $('stat-worst-sub').textContent = '';
- }
- }
-
- function renderHoldings(summary) {
- const rows = aggregateHoldings(summary);
- const totalUsd = summary.total_usd || rows.reduce((s, r) => s + (r.usd || 0), 0);
- renderStats(summary, rows);
- const sorted = sortHoldings(rows);
-
- const cntEl = $('holding-count');
- if (rows.length) { cntEl.textContent = `${rows.length} assets`; cntEl.style.display = ''; }
- else { cntEl.style.display = 'none'; }
-
- const container = $('holdings');
- if (!rows.length) {
- container.innerHTML = `
- <div class="empty">
- <p>No holdings yet.</p>
- <p style="color:var(--muted)">Fund any agent wallet to see live balances here.</p>
- <a href="/dashboard/agents" class="btn sec sm">Manage agents</a>
- </div>`;
- return;
- }
- const arrow = (key) => sortBy === key ? (sortDir === 'asc' ? ' ↑' : ' ↓') : '';
- const head = `
- <div class="h-head">
- <div><button data-sort="symbol">Asset${arrow('symbol')}</button></div>
- <div class="cell-right"><button data-sort="usd">Value${arrow('usd')}</button></div>
- <div class="cell-right col-amount"><button data-sort="amount">Holdings${arrow('amount')}</button></div>
- <div class="cell-right"><button data-sort="change">24h${arrow('change')}</button></div>
- <div class="cell-right col-alloc">Alloc.</div>
- </div>`;
- const body = sorted.map((r) => {
- const alloc = totalUsd > 0 ? (r.usd / totalUsd) * 100 : 0;
- const changeColor = r.change24h == null ? 'var(--muted)' : (r.change24h >= 0 ? 'var(--ok)' : 'var(--err)');
- const logoInner = r.logo
- ? `<img src="${escapeHtml(r.logo)}" alt="" loading="lazy" onerror="this.style.display='none';this.parentElement.textContent='${escapeHtml((r.symbol || '?').slice(0,3))}'" />`
- : escapeHtml((r.symbol || '?').slice(0, 3));
- const chainCls = r.chain === 'solana' ? 'sol' : 'evm';
- const chainText = r.chain === 'solana' ? 'SOL' : 'EVM';
- const href = `/dashboard/portfolio/asset?chain=${encodeURIComponent(r.chain)}&id=${encodeURIComponent(r.is_native ? 'native' : r.id)}`;
- return `
- <a class="h-row" href="${escapeHtml(href)}">
- <div class="tok-cell">
- <span class="tok-logo">${logoInner}</span>
- <div class="tok-info">
- <div class="tok-name">${escapeHtml(r.symbol)} <span class="chain-pill ${chainCls}">${chainText}</span></div>
- <div class="tok-sub">${escapeHtml(r.name || r.symbol)}${r.price ? ' · ' + fmtUsd(r.price, { precise: true }) : ''}</div>
- </div>
- </div>
- <div class="cell-num cell-right">${fmtUsd(r.usd)}</div>
- <div class="cell-num cell-right muted col-amount">${fmtAmt(r.amount)} ${escapeHtml(r.symbol)}</div>
- <div class="cell-num cell-right" style="color:${changeColor}">${r.change24h == null ? '—' : fmtPct(r.change24h)}</div>
- <div class="cell-right col-alloc">
- <div style="font-size:12.5px;font-weight:500">${alloc.toFixed(1)}%</div>
- <div class="alloc-bar"><span style="width:${Math.min(100, alloc).toFixed(2)}%"></span></div>
- </div>
- </a>`;
- }).join('');
- container.innerHTML = head + body;
- container.querySelectorAll('[data-sort]').forEach((btn) => {
- btn.addEventListener('click', (e) => {
- e.preventDefault();
- const key = btn.dataset.sort;
- if (sortBy === key) sortDir = sortDir === 'asc' ? 'desc' : 'asc';
- else { sortBy = key; sortDir = key === 'symbol' ? 'asc' : 'desc'; }
- renderHoldings(currentSummary);
- });
- });
- }
-
- function renderWallets(summary) {
- const container = $('wallets');
- const cntEl = $('wallet-count');
- if (summary.wallets.length) { cntEl.textContent = `${summary.wallets.length}`; cntEl.style.display = ''; }
- else { cntEl.style.display = 'none'; }
-
- if (!summary.wallets.length) {
- container.innerHTML = `
- <div class="empty">
- <p>No agent wallets yet.</p>
- <p style="color:var(--muted)">Create an agent and you'll get a Solana + EVM custodial wallet automatically.</p>
- <a href="/dashboard/agents" class="btn sec sm">Manage agents</a>
- </div>`;
- return;
- }
- container.innerHTML = summary.wallets.map(walletCard).join('');
- for (const w of summary.wallets) {
- const id = `w-${w.chain}-${w.address}`.replace(/[^a-z0-9-]/gi, '_');
- document.querySelectorAll(`[data-wid="${id}"]`).forEach((b) => {
- b.addEventListener('click', () => onAction(b.dataset.kind, w));
- });
- }
- container.querySelectorAll('.copy-btn').forEach((b) =>
- b.addEventListener('click', () => {
- navigator.clipboard.writeText(b.dataset.copy);
- const orig = b.textContent;
- b.textContent = '✓';
- setTimeout(() => (b.textContent = orig), 1200);
- }),
- );
- }
-
- function walletCard(w) {
- const id = `w-${w.chain}-${w.address}`.replace(/[^a-z0-9-]/gi, '_');
- const chainCls = w.ok === false ? '' : (w.chain === 'solana' ? 'sol' : 'evm');
- const chainText = w.ok === false
- ? `<span class="chain-pill" style="background:rgba(255,80,80,0.12);color:var(--err);border-color:rgba(255,80,80,0.2)" title="${escapeHtml(w.error || '')}">${escapeHtml(w.chain)} · error</span>`
- : `<span class="chain-pill ${chainCls}">${chainLabel(w.chain, w.chain_id)}</span>`;
- const tokenCount = (w.tokens || []).length + (w.native?.amount > 0 ? 1 : 0);
- const snsLine = w.sns
- ? `<span style="color:#a08cff;font-family:inherit">${escapeHtml(w.sns)}</span><span style="color:var(--border-2);margin:0 2px">·</span>`
- : '';
- return `
- <div class="wcard">
- <div class="wcard-head">
- <div style="min-width:0">
- <div class="wcard-name">${escapeHtml(w.agent_name)} ${chainText}</div>
- <div class="wcard-addr">
- ${snsLine}
- <span>${shortAddr(w.address)}</span>
- <button class="copy-btn" data-copy="${escapeHtml(w.address)}" title="Copy address" aria-label="Copy wallet address">📋</button>
- <span style="color:var(--border-2);margin:0 2px">·</span>
- <span>${tokenCount} ${tokenCount === 1 ? 'asset' : 'assets'}</span>
- </div>
- </div>
- <div>
- <div class="wcard-usd">${fmtUsd(w.usd || 0)}</div>
- <div class="wcard-actions">
- <button class="btn ghost sm" data-wid="${id}" data-kind="receive">Receive</button>
- <button class="btn sec sm" data-wid="${id}" data-kind="send">Send</button>
- </div>
- </div>
- </div>
- </div>`;
- }
-
- // ── Chart ─────────────────────────────────────────────────────────
-
- async function ensureChart() {
- if (chart) return;
- const mod = await import('https://esm.sh/[email protected]');
- const { createChart, AreaSeries } = mod;
- chartEl = $('chart');
- chartTooltip = $('chart-tooltip');
- chart = createChart(chartEl, {
- layout: { background: { color: 'transparent' }, textColor: '#555', fontFamily: 'inherit', fontSize: 11 },
- grid: { vertLines: { visible: false }, horzLines: { color: '#0e0e1a' } },
- rightPriceScale: { borderVisible: false, scaleMargins: { top: 0.15, bottom: 0.05 } },
- timeScale: { borderVisible: false, timeVisible: false, secondsVisible: false },
- crosshair: {
- vertLine: { color: '#2a2a40', style: 0, width: 1, labelVisible: false },
- horzLine: { color: '#2a2a40', style: 0, width: 1, labelVisible: true },
- },
- handleScroll: false,
- handleScale: false,
- });
- const seriesOpts = {
- lineColor: '#7c6fff',
- topColor: 'rgba(124,111,255,0.32)',
- bottomColor: 'rgba(124,111,255,0)',
- lineWidth: 2,
- priceFormat: { type: 'price', precision: 2, minMove: 0.01 },
- crosshairMarkerRadius: 5,
- crosshairMarkerBorderColor: '#cccccc',
- crosshairMarkerBackgroundColor: '#fff',
- };
- series = chart.addAreaSeries
- ? chart.addAreaSeries(seriesOpts)
- : chart.addSeries(AreaSeries, seriesOpts);
-
- chart.subscribeCrosshairMove((param) => {
- if (!param.time || !param.seriesData?.size) { chartTooltip.style.opacity = '0'; return; }
- const pt = param.seriesData.get(series);
- if (!pt) { chartTooltip.style.opacity = '0'; return; }
- const date = new Date(param.time * 1000);
- chartTooltip.querySelector('.tt-date').textContent = date.toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' });
- chartTooltip.querySelector('.tt-val').textContent = fmtUsd(pt.value);
- chartTooltip.style.opacity = '1';
- });
-
- new ResizeObserver(() => {
- if (chartEl.clientWidth) chart.applyOptions({ width: chartEl.clientWidth, height: chartEl.clientHeight });
- }).observe(chartEl);
- }
-
- function filterPointsByDays(points, days) {
- if (!days || days <= 0) return points;
- const cutoff = Date.now() - days * 86400_000;
- return points.filter((p) => new Date(p.t).getTime() >= cutoff);
- }
-
- async function renderChart(points, totalNow) {
- const filtered = filterPointsByDays(points, activeDays);
- renderHistoryChange(filtered, totalNow);
- if (!filtered || filtered.length < 1) {
- $('chart').style.display = 'none';
- $('chart-empty').style.display = 'flex';
- return;
- }
- $('chart').style.display = 'block';
- $('chart-empty').style.display = 'none';
- await ensureChart();
- const data = filtered
- .map((p) => ({ time: Math.floor(new Date(p.t).getTime() / 1000), value: Number(p.usd) }))
- .filter((d) => Number.isFinite(d.time) && Number.isFinite(d.value))
- .sort((a, b) => a.time - b.time)
- .filter((d, i, arr) => i === 0 || d.time !== arr[i - 1].time);
- if (!data.length) {
- $('chart').style.display = 'none';
- $('chart-empty').style.display = 'flex';
- return;
- }
- series.setData(data);
- chart.timeScale().fitContent();
- }
-
- // ── Modal actions ─────────────────────────────────────────────────
-
- function openModal(html, after) {
- $('modal-body').innerHTML = html;
- $('scrim').setAttribute('data-open', 'true');
- if (after) after();
- }
- function closeModal() { $('scrim').removeAttribute('data-open'); }
- $('scrim').addEventListener('click', (e) => { if (e.target.id === 'scrim') closeModal(); });
- document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeModal(); });
-
- async function onAction(kind, w) {
- if (kind === 'receive') return openReceive(w);
- if (kind === 'send') return openSend(w);
- }
-
- async function openReceive(w) {
- openModal(`
- <h3>Receive ${w.chain === 'solana' ? 'Solana' : 'EVM'}</h3>
- <p class="sub">Send tokens to this address from any wallet or exchange.</p>
- <div class="qr-wrap">
- <canvas id="qr-canvas" width="220" height="220"></canvas>
- <div class="qr-addr">${escapeHtml(w.address)}</div>
- <button class="btn sec sm" id="qr-copy">Copy address</button>
- </div>
- <div class="modal-actions">
- <button class="btn ghost" id="modal-close">Done</button>
- </div>
- `, async () => {
- $('modal-close').onclick = closeModal;
- $('qr-copy').onclick = () => navigator.clipboard.writeText(w.address);
- const mod = await import('https://esm.sh/[email protected]');
- const QR = mod.default ?? mod;
- await QR.toCanvas($('qr-canvas'), w.address, { width: 220, margin: 1, color: { dark: '#000', light: '#ffffff' } });
- });
- }
-
- function openSend(w) {
- const assets = [{ value: 'native', label: w.native?.symbol || (w.chain === 'solana' ? 'SOL' : 'ETH') }];
- for (const t of w.tokens || []) {
- const id = t.mint || t.contract;
- if (id) assets.push({ value: id, label: t.symbol });
- }
- const placeholder = w.chain === 'solana' ? 'Solana address or yourname.sol' : '0x…';
- openModal(`
- <h3>Send from ${escapeHtml(w.agent_name)}</h3>
- <p class="sub">${chainLabel(w.chain, w.chain_id)} · ${shortAddr(w.address)}</p>
- <form id="send-form" autocomplete="off">
- <label><span>Asset</span>
- <select name="asset">${assets.map((a) => `<option value="${escapeHtml(a.value)}">${escapeHtml(a.label)}</option>`).join('')}</select>
- </label>
- <label><span>Recipient${w.chain === 'solana' ? ' address or .sol name' : ' address'}</span>
- <input name="recipient" data-mono required placeholder="${escapeHtml(placeholder)}" autocomplete="off" spellcheck="false" />
- <small id="recipient-resolved" style="display:none;margin-top:6px;font-family:ui-monospace,monospace;font-size:11.5px;word-break:break-all;display:block"></small>
- </label>
- <label><span>Amount</span>
- <input name="amount" inputmode="decimal" required placeholder="0.0" pattern="[0-9]*\\.?[0-9]*" autocomplete="off" />
- </label>
- <div class="modal-actions">
- <button type="button" class="btn ghost" id="modal-cancel">Cancel</button>
- <button type="submit" class="btn primary">Send</button>
- </div>
- <p id="send-err" style="color:#ff9a9a;display:none;margin-top:10px;font-size:13px"></p>
- </form>
- `, () => {
- $('modal-cancel').onclick = closeModal;
- const form = $('send-form');
- form.addEventListener('submit', (e) => onSendSubmit(e, w));
- if (w.chain === 'solana') {
- const input = form.querySelector('input[name="recipient"]');
- const status = $('recipient-resolved');
- attachSnsTypeahead(input, status);
- }
- });
- }
-
- // .sol name typeahead
- const SOL_NAME_RE = /^[a-z0-9-]{1,63}(?:\.[a-z0-9-]{1,63})*(?:\.sol)?$/i;
- const SOL_ADDR_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
- function attachSnsTypeahead(input, status) {
- let seq = 0;
- function setStatus(kind, text) {
- status.style.display = text ? '' : 'none';
- status.textContent = text || '';
- status.style.color = kind === 'ok' ? '#7be07b' : kind === 'warn' ? '#ff9a9a' : 'var(--muted)';
- }
- async function lookup(name) {
- const myId = ++seq;
- try {
- const r = await fetch(`/api/sns?name=${encodeURIComponent(name)}`);
- if (myId !== seq) return;
- if (r.status === 404) { setStatus('warn', `${name} does not resolve`); return; }
- if (!r.ok) {
- const j = await r.json().catch(() => ({}));
- setStatus('warn', j.error_description || `Lookup failed (${r.status})`);
- return;
- }
- const { data } = await r.json();
- if (myId !== seq) return;
- setStatus('ok', `→ ${data.address}`);
- } catch (err) {
- if (myId === seq) setStatus('warn', err.message || 'Lookup failed');
- }
- }
- input.addEventListener('input', () => {
- const raw = input.value.trim();
- seq++;
- if (!raw) { setStatus('', ''); return; }
- if (SOL_ADDR_RE.test(raw)) { setStatus('', ''); return; }
- if (/\.sol$/i.test(raw) || (SOL_NAME_RE.test(raw) && !SOL_ADDR_RE.test(raw))) {
- setStatus('', 'Resolving .sol…');
- const myId = seq;
- setTimeout(() => { if (myId === seq) lookup(raw); }, 300);
- return;
- }
- setStatus('warn', 'Not a valid Solana address or .sol name');
- });
- }
-
- async function onSendSubmit(e, w) {
- e.preventDefault();
- const f = e.target;
- const asset = f.asset.value;
- const recipient = f.recipient.value.trim();
- const amount = f.amount.value.trim();
- const submit = f.querySelector('button[type="submit"]');
- const errEl = $('send-err');
- submit.disabled = true;
- errEl.style.display = 'none';
- try {
- const token = await getCsrf();
- const r = await fetch(`${apiUrl}/portfolio/send`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json', 'x-csrf-token': token },
- body: JSON.stringify({ agent_id: w.agent_id, chain: w.chain, asset, recipient, amount }),
- });
- const d = await r.json();
- if (!r.ok) throw new Error(d.error_description || 'Send failed');
- csrfToken = null;
- closeModal();
- await refresh({ snapshot: true });
- } catch (err) {
- errEl.textContent = err.message;
- errEl.style.display = 'block';
- csrfToken = null;
- } finally {
- submit.disabled = false;
- }
- }
-
- // ── Page lifecycle ────────────────────────────────────────────────
-
- function bindRangeTabs() {
- $('range-tabs').addEventListener('click', (e) => {
- const btn = e.target.closest('.range-tab');
- if (!btn) return;
- activeDays = parseInt(btn.dataset.days, 10);
- document.querySelectorAll('.range-tab').forEach((b) => b.removeAttribute('aria-pressed'));
- btn.setAttribute('aria-pressed', 'true');
- if (currentSummary) renderChart(currentHistory, currentSummary.total_usd);
- });
- }
-
- async function refresh({ snapshot = true } = {}) {
- setError('');
- const btn = $('refresh-btn');
- btn.disabled = true;
- btn.textContent = 'Loading…';
- try {
- const [summary, history] = await Promise.all([
- loadSummary({ snapshot }),
- loadHistory(activeDays || 365),
- ]);
- currentSummary = summary;
- currentHistory = [...history];
- if (snapshot || !history.length) {
- currentHistory.push({ t: summary.captured_at, usd: summary.total_usd });
- }
- renderTotal(summary);
- renderHoldings(summary);
- renderWallets(summary);
- await renderChart(currentHistory, summary.total_usd);
- } catch (err) {
- setError(err.message);
- } finally {
- btn.disabled = false;
- btn.innerHTML = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>Refresh`;
- }
- }
-
- (async () => {
- const me = await fetchUser();
- if (!me) return;
- renderHeaderUser($('header-user-slot'), me.user, { activePath: '/dashboard/portfolio' });
- $('refresh-btn').addEventListener('click', () => refresh({ snapshot: true }));
- bindRangeTabs();
- try {
- const [summary, history] = await Promise.all([loadSummary({ snapshot: false }), loadHistory(365)]);
- currentSummary = summary;
- currentHistory = [...history];
- if (summary.total_usd > 0) {
- const last = currentHistory[currentHistory.length - 1];
- if (!last || Math.abs(new Date(last.t).getTime() - new Date(summary.captured_at).getTime()) > 60_000) {
- currentHistory.push({ t: summary.captured_at, usd: summary.total_usd });
- }
- }
- renderTotal(summary);
- renderHoldings(summary);
- renderWallets(summary);
- await renderChart(currentHistory, summary.total_usd);
- } catch (err) {
- setError(err.message);
- $('holdings').innerHTML = '<div style="padding:20px 16px;color:var(--muted)">Failed to load holdings.</div>';
- $('wallets').innerHTML = '<div style="padding:20px 0;color:var(--muted)">Failed to load wallets.</div>';
- }
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/sessions.html b/public/dashboard-classic/sessions.html
deleted file mode 100644
index 9a68ca19d..000000000
--- a/public/dashboard-classic/sessions.html
+++ /dev/null
@@ -1,470 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Sessions · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #cccccc;
- text-decoration: none;
- }
- header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: var(--bg);
- z-index: 5;
- }
- .brand {
- font-weight: 600;
- letter-spacing: -0.01em;
- }
- .row {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- main {
- padding: 28px;
- max-width: 800px;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: #888;
- margin: 0 0 22px;
- font-size: 14px;
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- }
- .btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- .btn.sec {
- background: #15151d;
- color: #ddd;
- border-color: #222222;
- }
- .btn.sec:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .btn.danger {
- background: #15151d;
- border-color: rgba(204, 64, 64, 0.4);
- color: #ffb3b3;
- }
- .btn.danger:hover:not(:disabled) {
- background: rgba(204, 64, 64, 0.12);
- border-color: rgba(204, 64, 64, 0.6);
- }
- .btn-group {
- display: flex;
- gap: 8px;
- margin-bottom: 20px;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- border: 1px solid var(--border);
- border-radius: 10px;
- overflow: hidden;
- background: var(--panel);
- }
- thead {
- background: #0f0f17;
- border-bottom: 1px solid var(--border);
- }
- th {
- padding: 12px 16px;
- text-align: left;
- font-size: 12px;
- font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- color: #888;
- }
- td {
- padding: 12px 16px;
- border-bottom: 1px solid var(--border);
- font-size: 14px;
- }
- tr:last-child td {
- border-bottom: 0;
- }
- .pill {
- display: inline-block;
- font-size: 11px;
- padding: 3px 8px;
- border-radius: 99px;
- background: rgba(255, 255, 255, 0.2);
- color: #a8a0ff;
- white-space: nowrap;
- }
- .agent-cell {
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: #bbb;
- font-size: 13px;
- }
- .time-cell {
- color: #999;
- font-size: 13px;
- }
- .actions {
- text-align: right;
- }
- .empty {
- text-align: center;
- padding: 40px 20px;
- color: #888;
- }
- .toast {
- position: fixed;
- bottom: 24px;
- left: 50%;
- transform: translateX(-50%);
- background: #1a1a1a;
- border: 1px solid var(--border);
- padding: 10px 18px;
- border-radius: 99px;
- font-size: 13px;
- color: #ddd;
- z-index: 70;
- box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
- animation: toast-in 0.2s;
- }
- .toast.error {
- background: rgba(204, 64, 64, 0.15);
- border-color: rgba(204, 64, 64, 0.3);
- color: #ffb3b3;
- }
- @keyframes toast-in {
- from {
- opacity: 0;
- transform: translate(-50%, 8px);
- }
- to {
- opacity: 1;
- transform: translateX(-50%);
- }
- }
- .btn-sec {
- background: #222230;
- color: #ddd;
- }
- body[data-auth-pending] {
- visibility: hidden;
- }
- .header-logo {
- width: 14px;
- height: 14px;
- vertical-align: -2px;
- margin-right: 6px;
- }
- </style>
- </head>
- <body data-auth-pending>
- <header>
- <div class="brand"><a href="/"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a></div>
- <div id="header-user-slot"></div>
- </header>
- <main>
- <h1>Sessions</h1>
- <p class="sub">Manage your active login sessions across devices.</p>
-
- <div class="btn-group">
- <button class="btn danger" id="signOutBtn" style="display: none">
- Sign out of all other devices
- </button>
- </div>
-
- <table id="sessionsTable" style="display: none">
- <thead>
- <tr>
- <th>Device / User Agent</th>
- <th>IP Address</th>
- <th>Created</th>
- <th>Last Seen</th>
- <th class="actions">Actions</th>
- </tr>
- </thead>
- <tbody id="sessionsList"></tbody>
- </table>
-
- <div class="empty" id="loadingMessage">Loading sessions...</div>
- </main>
-
- <script type="module">
- import { mountHeaderUser } from '/src/header-user.js';
- mountHeaderUser({ slot: '#header-user-slot', activePath: '/dashboard/sessions' });
- </script>
- <script>
- function showToast(message, isError = false) {
- const toast = document.createElement('div');
- toast.className = 'toast' + (isError ? ' error' : '');
- toast.textContent = message;
- document.body.appendChild(toast);
- setTimeout(() => {
- toast.remove();
- }, 3000);
- }
-
- function formatRelativeTime(date) {
- const now = new Date();
- const diff = now - new Date(date);
- const seconds = Math.floor(diff / 1000);
- const minutes = Math.floor(seconds / 60);
- const hours = Math.floor(minutes / 60);
- const days = Math.floor(hours / 24);
-
- if (seconds < 60) return 'Just now';
- if (minutes < 60) return `${minutes}m ago`;
- if (hours < 24) return `${hours}h ago`;
- if (days < 7) return `${days}d ago`;
-
- return new Date(date).toLocaleDateString('en-US', {
- month: 'short',
- day: 'numeric',
- });
- }
-
- function formatAbsoluteDate(date) {
- return new Date(date).toLocaleDateString('en-US', {
- month: 'short',
- day: 'numeric',
- year: 'numeric',
- hour: '2-digit',
- minute: '2-digit',
- });
- }
-
- function truncateUA(ua) {
- if (!ua) return 'Unknown';
- if (ua.length > 50) return ua.substring(0, 47) + '…';
- return ua;
- }
-
- async function loadSessions() {
- try {
- const res = await fetch('/api/auth/me', { credentials: 'include' });
- if (!res.ok) throw new Error('Failed to verify auth');
- const { user } = await res.json();
- if (!user) {
- location.href = '/login?next=' + encodeURIComponent(location.pathname);
- return;
- }
- document.body.removeAttribute('data-auth-pending');
-
- const sessionsRes = await fetch('/api/auth/sessions', {
- credentials: 'include',
- });
- if (!sessionsRes.ok) throw new Error('Failed to load sessions');
-
- const { sessions } = await sessionsRes.json();
-
- const tbody = document.getElementById('sessionsList');
- tbody.innerHTML = '';
-
- if (sessions.length === 0) {
- document.getElementById('loadingMessage').textContent =
- 'No active sessions';
- return;
- }
-
- document.getElementById('sessionsTable').style.display = 'table';
- document.getElementById('loadingMessage').style.display = 'none';
-
- const hasMultiple = sessions.length > 1;
- document.getElementById('signOutBtn').style.display = hasMultiple
- ? 'block'
- : 'none';
-
- sessions.forEach((session) => {
- const row = document.createElement('tr');
- row.id = `session-${session.id}`;
-
- const isCurrentSession = session.current;
- const uaCell = document.createElement('td');
- uaCell.className = 'agent-cell';
- uaCell.textContent = truncateUA(session.user_agent);
-
- const ipCell = document.createElement('td');
- ipCell.className = 'agent-cell';
- ipCell.textContent = session.ip || 'Unknown';
-
- const createdCell = document.createElement('td');
- createdCell.className = 'time-cell';
- createdCell.textContent = formatAbsoluteDate(session.created_at);
-
- const lastSeenCell = document.createElement('td');
- lastSeenCell.className = 'time-cell';
- if (isCurrentSession) {
- lastSeenCell.innerHTML = '<span class="pill">This device</span>';
- } else {
- lastSeenCell.textContent = formatRelativeTime(session.last_seen_at);
- }
-
- const actionsCell = document.createElement('td');
- actionsCell.className = 'actions';
- if (!isCurrentSession) {
- const revokeBtn = document.createElement('button');
- revokeBtn.className = 'btn sec';
- revokeBtn.style.padding = '6px 12px';
- revokeBtn.style.fontSize = '12px';
- revokeBtn.textContent = 'Revoke';
- revokeBtn.onclick = () => revokeSession(session.id, row);
- actionsCell.appendChild(revokeBtn);
- } else {
- const placeholder = document.createElement('span');
- placeholder.style.color = '#666';
- placeholder.style.fontSize = '12px';
- placeholder.textContent = '—';
- actionsCell.appendChild(placeholder);
- }
-
- row.appendChild(uaCell);
- row.appendChild(ipCell);
- row.appendChild(createdCell);
- row.appendChild(lastSeenCell);
- row.appendChild(actionsCell);
- tbody.appendChild(row);
- });
- } catch (err) {
- console.error(err);
- document.getElementById('loadingMessage').textContent =
- 'Error loading sessions';
- }
- }
-
- async function revokeSession(sessionId, row) {
- const originalRow = row.cloneNode(true);
- row.style.opacity = '0.5';
- row.querySelector('button').disabled = true;
-
- try {
- const res = await fetch(`/api/auth/sessions/${sessionId}`, {
- method: 'DELETE',
- credentials: 'include',
- });
-
- if (!res.ok) {
- throw new Error('Failed to revoke session');
- }
-
- row.style.animation = 'fade-out 0.3s';
- setTimeout(() => {
- row.remove();
- showToast('Session revoked');
- const remaining = document.querySelectorAll('#sessionsList tr').length;
- if (remaining === 1) {
- document.getElementById('signOutBtn').style.display = 'none';
- }
- }, 300);
- } catch (err) {
- console.error(err);
- row.replaceWith(originalRow);
- originalRow.querySelector('button').onclick = () =>
- revokeSession(sessionId, originalRow);
- showToast('Failed to revoke session', true);
- }
- }
-
- async function signOutEverywhere() {
- if (
- !confirm(
- 'Sign out of all other devices? You will stay signed in on this device.',
- )
- )
- return;
-
- const signOutBtn = document.getElementById('signOutBtn');
- const originalText = signOutBtn.textContent;
- signOutBtn.disabled = true;
- signOutBtn.textContent = 'Signing out...';
-
- try {
- const res = await fetch('/api/auth/sessions', {
- method: 'DELETE',
- credentials: 'include',
- });
-
- if (!res.ok) throw new Error('Failed to sign out');
-
- const { revoked } = await res.json();
- showToast(`Signed out of ${revoked} device${revoked === 1 ? '' : 's'}`);
- loadSessions();
- } catch (err) {
- console.error(err);
- signOutBtn.disabled = false;
- signOutBtn.textContent = originalText;
- showToast('Failed to sign out of other devices', true);
- }
- }
-
- document.getElementById('signOutBtn').onclick = signOutEverywhere;
-
- loadSessions();
-
- // Add CSS animation
- const style = document.createElement('style');
- style.textContent = `
- @keyframes fade-out {
- to {
- opacity: 0;
- transform: translateX(-20px);
- }
- }
- `;
- document.head.appendChild(style);
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/sns.html b/public/dashboard-classic/sns.html
deleted file mode 100644
index 8ebc411c6..000000000
--- a/public/dashboard-classic/sns.html
+++ /dev/null
@@ -1,442 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>SNS Domains · three.ws</title>
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- </head>
- <body>
- <div class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <h1 class="dash-title">SNS Domains</h1>
- <p class="dash-sub">
- Attach a Solana Name Service <code class="dash-mono">.sol</code> domain as your
- agent's readable id. Domains owned by either the agent's wallet or any wallet linked
- to your account are eligible.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </div>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const contentEl = document.getElementById('content');
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- }
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) =>
- ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[
- c
- ],
- );
- }
-
- async function getSns(agentId) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {
- credentials: 'include',
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- async function attach(agentId, domain) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ domain }),
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- async function detach(agentId) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {
- method: 'DELETE',
- credentials: 'include',
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- async function checkDomain(agentId, domain) {
- const url = `/api/agents/${encodeURIComponent(agentId)}/sns/check?domain=${encodeURIComponent(domain)}`;
- const r = await fetch(url, { credentials: 'include' });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- const { data } = await r.json();
- return data;
- }
-
- async function registerWithAgent(agentId, domain) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns/register`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ domain }),
- });
- const j = await r.json().catch(() => ({}));
- if (!r.ok) throw new Error(j.error_description || `HTTP ${r.status}`);
- return j.data;
- }
-
- function detectSolanaProvider() {
- if (typeof window === 'undefined') return null;
- return (
- window.phantom?.solana ||
- window.solana ||
- window.backpack ||
- window.solflare ||
- null
- );
- }
-
- async function registerWithBrowserWallet(agentId, domain) {
- const provider = detectSolanaProvider();
- if (!provider)
- throw new Error(
- 'No Solana wallet detected. Install Phantom, Backpack, or Solflare.',
- );
- if (!provider.isConnected) {
- try {
- await provider.connect();
- } catch (e) {
- throw new Error(e?.message || 'Wallet connection refused');
- }
- }
- const walletAddress = provider.publicKey?.toBase58?.();
- if (!walletAddress) throw new Error('Wallet did not return a public key');
-
- const prepRes = await fetch(
- `/api/agents/${encodeURIComponent(agentId)}/sns/register-prep`,
- {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ domain, wallet_address: walletAddress }),
- },
- );
- const prepJson = await prepRes.json().catch(() => ({}));
- if (!prepRes.ok) {
- if (
- prepRes.status === 403 &&
- /not linked/.test(prepJson.error_description || '')
- ) {
- throw new Error(
- `Link this Solana wallet first at /dashboard/wallets (${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}).`,
- );
- }
- throw new Error(
- prepJson.error_description || `register-prep failed (${prepRes.status})`,
- );
- }
-
- const { tx_base64 } = prepJson.data;
- const { VersionedTransaction } = await import(
- 'https://esm.sh/@solana/[email protected]'
- );
- const txBytes = Uint8Array.from(atob(tx_base64), (c) => c.charCodeAt(0));
- const tx = VersionedTransaction.deserialize(txBytes);
-
- const signed = await provider.signTransaction(tx);
- const signedBytes = signed.serialize();
- const submitRes = await fetch('/api/solana-rpc', {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({
- jsonrpc: '2.0',
- id: 1,
- method: 'sendTransaction',
- params: [
- btoa(String.fromCharCode(...signedBytes)),
- { encoding: 'base64', preflightCommitment: 'confirmed' },
- ],
- }),
- });
- const submitJson = await submitRes.json();
- if (submitJson.error)
- throw new Error(submitJson.error.message || 'tx submit failed');
- const signature = submitJson.result;
-
- // Poll for confirmation up to ~30s, then ask the API to mark it attached.
- for (let i = 0; i < 15; i++) {
- await new Promise((r) => setTimeout(r, 2000));
- const confirmRes = await fetch(
- `/api/agents/${encodeURIComponent(agentId)}/sns/register-confirm`,
- {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({
- signature,
- domain,
- wallet_address: walletAddress,
- }),
- },
- );
- const confirmJson = await confirmRes.json().catch(() => ({}));
- if (confirmRes.ok) return confirmJson.data;
- if (confirmJson.error !== 'not_confirmed') {
- throw new Error(confirmJson.error_description || 'register-confirm failed');
- }
- }
- throw new Error(
- 'Registered on-chain but confirmation timed out — retry attaching from the owned-domains list in a moment.',
- );
- }
-
- function render(agentId, data) {
- const current = data.sns_domain;
- const domains = data.domains || [];
- const favorite = data.favorite;
-
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>Current SNS id</h2>
- <div class="dash-row">
- ${
- current
- ? `<span class="dash-pill" style="font-size:13px">${escapeHtml(current)}.sol</span>
- ${data.sns_owner_wallet ? `<span class="dash-muted">owned by <span class="dash-mono">${escapeHtml(data.sns_owner_wallet)}</span></span>` : ''}
- <button class="dash-btn danger" id="detach-btn">Detach</button>`
- : '<span class="dash-muted">None attached.</span>'
- }
- </div>
- <div class="dash-muted" style="margin-top:10px">
- Agent wallet: <span class="dash-mono">${escapeHtml(data.address || '')}</span>
- </div>
- </div>
-
- <div class="dash-card">
- <h2>Owned domains</h2>
- ${!data.upstream_ok ? '<div class="dash-err">SNS API unreachable — retry in a moment.</div>' : ''}
- ${
- domains.length
- ? `<ul class="dash-list">
- ${domains
- .map(
- (
- d,
- ) => `<li class="dash-row" style="justify-content:space-between">
- <div>
- <span class="dash-mono" style="font-size:14px">${escapeHtml(d)}.sol</span>
- ${favorite === d ? ' <span class="dash-pill">favorite</span>' : ''}
- ${current === d ? ' <span class="dash-pill">attached</span>' : ''}
- </div>
- ${current === d ? '' : `<button class="dash-btn primary" data-attach="${escapeHtml(d)}">Use as agent id</button>`}
- </li>`,
- )
- .join('')}
- </ul>`
- : '<div class="dash-empty">No .sol domains found for this agent\'s wallet or your linked Solana wallets.</div>'
- }
- </div>
-
- <div class="dash-card">
- <h2>Register a new domain</h2>
- <p class="dash-muted">Buy a <code class="dash-mono">.sol</code> with USDC, paid by either this agent's wallet or your linked browser wallet.</p>
- <div class="dash-row" style="gap:8px;margin-top:8px;flex-wrap:wrap">
- <input id="register-input" type="text" placeholder="yourname" autocomplete="off" spellcheck="false"
- style="flex:1;min-width:220px;padding:8px 10px;border-radius:8px;border:1px solid var(--dash-line,#2a2a36);background:#0e0e16;color:inherit;font-family:ui-monospace,monospace" />
- <span class="dash-muted" style="font-family:ui-monospace,monospace">.sol</span>
- <button class="dash-btn" id="register-check">Check</button>
- </div>
- <div id="register-status" style="margin-top:10px"></div>
- <div id="register-actions" class="dash-row" style="gap:8px;margin-top:10px;flex-wrap:wrap;display:none"></div>
- <p class="dash-muted" style="font-size:11.5px;margin-top:10px">
- Or
- <a href="${escapeHtml(data.register_url || 'https://www.sns.id/?search=')}" target="_blank" rel="noopener">register on sns.id</a>
- and return to attach it.
- </p>
- </div>
- `;
-
- const detachBtn = document.getElementById('detach-btn');
- if (detachBtn) {
- detachBtn.addEventListener('click', async () => {
- if (!confirm(`Detach ${current}.sol?`)) return;
- detachBtn.disabled = true;
- try {
- await detach(agentId);
- showStatus('Detached.', 'ok');
- await refresh(agentId);
- } catch (e) {
- showStatus(e.message || 'Detach failed', 'err');
- detachBtn.disabled = false;
- }
- });
- }
- contentEl.querySelectorAll('[data-attach]').forEach((btn) => {
- btn.addEventListener('click', async () => {
- btn.disabled = true;
- try {
- await attach(agentId, btn.dataset.attach);
- showStatus(`Attached ${btn.dataset.attach}.sol`, 'ok');
- await refresh(agentId);
- } catch (e) {
- showStatus(e.message || 'Attach failed', 'err');
- btn.disabled = false;
- }
- });
- });
-
- bindRegisterCard(agentId);
- }
-
- function setRegisterStatus(text, kind = '') {
- const el = document.getElementById('register-status');
- if (!el) return;
- el.innerHTML = text
- ? `<div class="${kind === 'err' ? 'dash-err' : kind === 'ok' ? 'dash-ok' : 'dash-muted'}">${escapeHtml(text)}</div>`
- : '';
- }
-
- function bindRegisterCard(agentId) {
- const input = document.getElementById('register-input');
- const checkBtn = document.getElementById('register-check');
- const actionsEl = document.getElementById('register-actions');
- if (!input || !checkBtn || !actionsEl) return;
-
- input.addEventListener('input', () => {
- actionsEl.style.display = 'none';
- actionsEl.innerHTML = '';
- setRegisterStatus('');
- });
- input.addEventListener('keydown', (e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- checkBtn.click();
- }
- });
-
- checkBtn.addEventListener('click', async () => {
- const raw = (input.value || '')
- .trim()
- .toLowerCase()
- .replace(/\.sol$/, '');
- if (!/^[a-z0-9-]{1,63}$/.test(raw)) {
- setRegisterStatus('Use a–z, 0–9, hyphen (max 63 chars).', 'err');
- return;
- }
- checkBtn.disabled = true;
- setRegisterStatus('Checking availability…');
- try {
- const info = await checkDomain(agentId, raw);
- if (!info.available) {
- setRegisterStatus(
- `${raw}.sol is already registered (owner ${info.owner}).`,
- 'err',
- );
- actionsEl.style.display = 'none';
- return;
- }
- setRegisterStatus(
- `${raw}.sol is available — ${info.price_usdc} USDC.`,
- 'ok',
- );
- actionsEl.innerHTML = `
- <button class="dash-btn primary" id="register-agent-btn">
- Buy with agent wallet (${info.price_usdc} USDC)
- </button>
- <button class="dash-btn" id="register-browser-btn">
- Buy with my browser wallet
- </button>
- `;
- actionsEl.style.display = '';
-
- document
- .getElementById('register-agent-btn')
- .addEventListener('click', async () => {
- if (
- !confirm(
- `Register ${raw}.sol using the agent's wallet for ${info.price_usdc} USDC? The agent's USDC ATA must be funded.`,
- )
- )
- return;
- const btn = document.getElementById('register-agent-btn');
- btn.disabled = true;
- setRegisterStatus('Registering on-chain (this can take 10-30s)…');
- try {
- const out = await registerWithAgent(agentId, raw);
- setRegisterStatus(
- `Registered ${out.sns_domain}.sol — signature ${out.signature.slice(0, 8)}…`,
- 'ok',
- );
- input.value = '';
- actionsEl.style.display = 'none';
- await refresh(agentId);
- } catch (e) {
- setRegisterStatus(e.message || 'Register failed', 'err');
- btn.disabled = false;
- }
- });
-
- document
- .getElementById('register-browser-btn')
- .addEventListener('click', async () => {
- const btn = document.getElementById('register-browser-btn');
- btn.disabled = true;
- setRegisterStatus('Connecting wallet…');
- try {
- const out = await registerWithBrowserWallet(agentId, raw);
- setRegisterStatus(
- `Registered ${out.sns_domain}.sol — signature ${out.signature.slice(0, 8)}…`,
- 'ok',
- );
- input.value = '';
- actionsEl.style.display = 'none';
- await refresh(agentId);
- } catch (e) {
- setRegisterStatus(e.message || 'Register failed', 'err');
- btn.disabled = false;
- }
- });
- } catch (e) {
- setRegisterStatus(e.message || 'Check failed', 'err');
- } finally {
- checkBtn.disabled = false;
- }
- });
- }
-
- async function refresh(agentId) {
- contentEl.innerHTML = '<div class="dash-empty">Loading SNS data…</div>';
- try {
- const { data } = await getSns(agentId);
- render(agentId, data);
- } catch (e) {
- showStatus(e.message || 'Failed to load', 'err');
- contentEl.innerHTML = '';
- }
- }
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => refresh(agentId),
- });
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/storage.html b/public/dashboard-classic/storage.html
deleted file mode 100644
index 08c16ee70..000000000
--- a/public/dashboard-classic/storage.html
+++ /dev/null
@@ -1,504 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Storage · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #9a8cff;
- text-decoration: none;
- }
- header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: var(--bg);
- z-index: 5;
- }
- .brand {
- font-weight: 600;
- letter-spacing: -0.01em;
- }
- main {
- padding: 28px;
- max-width: 720px;
- margin: 0 auto;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: #888;
- margin: 0 0 22px;
- font-size: 14px;
- }
- .card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 14px;
- padding: 20px;
- margin-bottom: 20px;
- }
- fieldset {
- border: 0;
- padding: 0;
- margin: 0;
- }
- legend {
- font-size: 13px;
- font-weight: 600;
- color: #ccc;
- margin-bottom: 12px;
- letter-spacing: 0.02em;
- text-transform: uppercase;
- }
- label {
- display: block;
- margin: 14px 0 6px;
- font-size: 13px;
- color: #bbb;
- }
- input,
- select {
- background: #0f0f17;
- border: 1px solid var(--border);
- color: #eee;
- padding: 9px 11px;
- border-radius: 8px;
- font-size: 14px;
- font-family: inherit;
- width: 100%;
- }
- input:focus,
- select:focus {
- outline: none;
- border-color: var(--accent);
- }
- .kv {
- display: flex;
- align-items: center;
- gap: 10px;
- margin: 10px 0;
- }
- .kv-label {
- font-size: 13px;
- color: #888;
- min-width: 120px;
- }
- .kv-value {
- font-size: 13px;
- color: #ddd;
- word-break: break-all;
- }
- .badge {
- display: inline-block;
- font-size: 11px;
- font-weight: 700;
- padding: 2px 8px;
- border-radius: 99px;
- letter-spacing: 0.04em;
- }
- .badge.green {
- background: rgba(92, 255, 140, 0.1);
- color: #7ef0a3;
- border: 1px solid rgba(92, 255, 140, 0.25);
- }
- .badge.grey {
- background: rgba(180, 180, 200, 0.08);
- color: #aaa;
- border: 1px solid rgba(180, 180, 200, 0.15);
- }
- .badge.yellow {
- background: rgba(255, 220, 92, 0.1);
- color: #f0dc7e;
- border: 1px solid rgba(255, 220, 92, 0.25);
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- }
- .btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- .btn.sec {
- background: #15151d;
- color: #ddd;
- border-color: #222222;
- }
- .btn.sec:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .muted {
- color: #888;
- font-size: 13px;
- }
- .err {
- padding: 12px;
- background: rgba(255, 92, 92, 0.1);
- border: 1px solid rgba(255, 92, 92, 0.3);
- border-radius: 8px;
- color: #ffb3b3;
- margin-bottom: 14px;
- }
- .ok {
- padding: 12px;
- background: rgba(92, 255, 140, 0.07);
- border: 1px solid rgba(92, 255, 140, 0.2);
- border-radius: 8px;
- color: #b6f2c6;
- margin-bottom: 14px;
- }
- code {
- font-family:
- ui-monospace,
- SF Mono,
- Menlo,
- monospace;
- background: #0f0f17;
- border: 1px solid var(--border);
- border-radius: 4px;
- padding: 1px 6px;
- font-size: 12px;
- }
- .actions {
- display: flex;
- gap: 10px;
- margin-top: 16px;
- }
- hr {
- border: 0;
- border-top: 1px solid var(--border);
- margin: 22px 0;
- }
- .hidden {
- display: none !important;
- }
- body[data-auth-pending] {
- visibility: hidden;
- }
- </style>
- </head>
- <body data-auth-pending>
- <header>
- <div class="brand"><a href="/dashboard">← Dashboard</a></div>
- <div class="muted"><span id="avatar-name">Avatar</span></div>
- </header>
- <main>
- <h1>Storage</h1>
- <p class="sub">
- Manage where <code id="avatar-id-label">your avatar</code>'s bytes live and track content
- attestation.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
-
- <div id="storage-cards" class="hidden">
-
- <!-- R2 -->
- <div class="card">
- <fieldset>
- <legend>R2 (primary storage)</legend>
- <div class="kv">
- <span class="kv-label">Status</span>
- <span class="badge green" id="r2-present-badge">Present</span>
- </div>
- <div class="kv">
- <span class="kv-label">Storage key</span>
- <code id="r2-key" class="kv-value">—</code>
- </div>
- </fieldset>
- </div>
-
- <!-- IPFS -->
- <div class="card">
- <fieldset>
- <legend>IPFS</legend>
- <div class="kv">
- <span class="kv-label">Pinned</span>
- <span class="badge grey" id="ipfs-pinned-badge">Not pinned</span>
- </div>
- <div class="kv" id="ipfs-cid-row">
- <span class="kv-label">CID</span>
- <code id="ipfs-cid" class="kv-value">—</code>
- </div>
- <div class="kv" id="ipfs-pinned-at-row">
- <span class="kv-label">Pinned at</span>
- <span id="ipfs-pinned-at" class="kv-value muted">—</span>
- </div>
- <div class="actions">
- <button class="btn" id="pin-btn">Pin to IPFS</button>
- </div>
- <p class="muted" style="margin-top: 10px">
- Real pinning runs through Pinata when <code>PINATA_JWT</code> is configured
- on the server. Otherwise the endpoint records a content-hash stub CID so the
- rest of the flow still works in dev.
- </p>
- </fieldset>
- </div>
-
- <!-- Attestation -->
- <div class="card">
- <fieldset>
- <legend>On-chain attestation</legend>
- <div class="kv">
- <span class="kv-label">Content hash</span>
- <code id="attest-hash" class="kv-value">—</code>
- </div>
- <div class="kv">
- <span class="kv-label">Chain</span>
- <span id="attest-chain" class="kv-value muted">—</span>
- </div>
- <div class="kv">
- <span class="kv-label">Tx hash</span>
- <code id="attest-tx" class="kv-value">—</code>
- </div>
- <div class="kv">
- <span class="kv-label">Attested at</span>
- <span id="attest-at" class="kv-value muted">—</span>
- </div>
- <p class="muted" style="margin-top: 10px">
- On-chain attestation is read-only. Content hashing runs server-side
- post-upload. Transaction broadcasting is a future feature.
- </p>
- </fieldset>
- </div>
-
- <div class="actions">
- <button class="btn sec" id="reload">Reload</button>
- </div>
- <!-- /storage-cards -->
- </div>
- </main>
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const nameEl = document.getElementById('avatar-name');
- const labelEl = document.getElementById('avatar-id-label');
- const cardsEl = document.getElementById('storage-cards');
- const pickerEl = document.getElementById('picker');
-
- let avatarId = null;
-
- async function api(method, path, body) {
- const res = await fetch(path, {
- method,
- credentials: 'include',
- headers: body ? { 'content-type': 'application/json' } : {},
- body: body ? JSON.stringify(body) : undefined,
- });
- const ct = res.headers.get('content-type') || '';
- const data = ct.includes('application/json') ? await res.json() : null;
- if (!res.ok)
- throw Object.assign(
- new Error((data && data.error_description) || res.statusText),
- { status: res.status },
- );
- return data;
- }
-
- function setStatus(html) {
- statusEl.innerHTML = html;
- }
-
- function escapeHtml(s) {
- return String(s ?? '').replace(
- /[&<>"']/g,
- (c) =>
- ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[
- c
- ],
- );
- }
-
- function populateMode(mode) {
- if (!mode) return;
-
- // R2
- document.getElementById('r2-key').textContent = mode.r2?.key || '—';
- const r2Badge = document.getElementById('r2-present-badge');
- if (mode.r2?.present) {
- r2Badge.textContent = 'Present';
- r2Badge.className = 'badge green';
- } else {
- r2Badge.textContent = 'Missing';
- r2Badge.className = 'badge grey';
- }
-
- // IPFS
- const ipfsBadge = document.getElementById('ipfs-pinned-badge');
- if (mode.ipfs?.pinned) {
- ipfsBadge.textContent = 'Pinned';
- ipfsBadge.className = 'badge green';
- document.getElementById('pin-btn').disabled = true;
- document.getElementById('pin-btn').textContent = 'Already pinned';
- } else {
- ipfsBadge.textContent = 'Not pinned';
- ipfsBadge.className = 'badge grey';
- document.getElementById('pin-btn').disabled = false;
- document.getElementById('pin-btn').textContent = 'Pin to IPFS';
- }
- document.getElementById('ipfs-cid').textContent = mode.ipfs?.cid || '—';
- document.getElementById('ipfs-pinned-at').textContent = mode.ipfs?.pinned_at
- ? new Date(mode.ipfs.pinned_at).toLocaleString()
- : '—';
-
- // Attestation
- const hash = mode.attestation?.hash;
- document.getElementById('attest-hash').textContent = hash || 'Not yet computed';
- document.getElementById('attest-chain').textContent =
- mode.attestation?.chain_id != null ? String(mode.attestation.chain_id) : '—';
- document.getElementById('attest-tx').textContent = mode.attestation?.tx_hash || '—';
- document.getElementById('attest-at').textContent = mode.attestation?.attested_at
- ? new Date(mode.attestation.attested_at).toLocaleString()
- : '—';
- }
-
- async function loadMe() {
- let data;
- try {
- data = await api('GET', '/api/auth/me');
- } catch {
- data = null;
- }
- if (!data?.user) {
- location.href =
- '/login?next=' + encodeURIComponent(location.pathname + location.search);
- throw new Error('redirecting');
- }
- document.body.removeAttribute('data-auth-pending');
- }
-
- async function loadAvatar() {
- try {
- const data = await api('GET', `/api/avatars/${avatarId}`);
- const av = data.avatar || data;
- nameEl.textContent = av.name || avatarId;
- labelEl.textContent = av.name || avatarId;
- } catch (e) {
- setStatus(
- `<div class="err">Could not load avatar: ${escapeHtml(e.message)}</div>`,
- );
- }
- }
-
- async function loadMode() {
- try {
- const { storage_mode } = await api(
- 'GET',
- `/api/avatars/${avatarId}/storage-mode`,
- );
- populateMode(storage_mode);
- } catch (e) {
- setStatus(
- `<div class="err">Could not load storage mode: ${escapeHtml(e.message)}</div>`,
- );
- }
- }
-
- async function pinIpfs() {
- setStatus('');
- document.getElementById('pin-btn').disabled = true;
- try {
- const result = await api('POST', `/api/avatars/${avatarId}/pin-ipfs`);
- populateMode(result.storage_mode);
- setStatus(
- result.stub
- ? '<div class="ok">Pinned (stub CID). Set PINATA_JWT on the server for real IPFS pins.</div>'
- : '<div class="ok">Pinned to IPFS via Pinata.</div>',
- );
- } catch (e) {
- document.getElementById('pin-btn').disabled = false;
- setStatus(`<div class="err">${escapeHtml(e.message)}</div>`);
- }
- }
-
- async function loadForAvatar(id) {
- avatarId = id;
- setStatus('');
- cardsEl.classList.remove('hidden');
- labelEl.textContent = id;
- await loadAvatar();
- await loadMode();
- }
-
- async function loadForAgent(agent) {
- if (!agent?.avatar_id) {
- cardsEl.classList.add('hidden');
- setStatus(
- `<div class="err">${escapeHtml(agent?.name || 'This agent')} has no avatar attached. Attach one from the agent editor first.</div>`,
- );
- return;
- }
- nameEl.textContent = agent.name || 'Avatar';
- await loadForAvatar(agent.avatar_id);
- }
-
- document.getElementById('pin-btn').addEventListener('click', pinIpfs);
- document.getElementById('reload').addEventListener('click', loadMode);
-
- (async () => {
- await loadMe();
-
- const params = new URLSearchParams(location.search);
- const directAvatarId = params.get('id');
-
- if (directAvatarId) {
- await loadForAvatar(directAvatarId);
- return;
- }
-
- await mountAgentPicker({
- host: pickerEl,
- onPick: (_agentId, agent) => loadForAgent(agent),
- });
- })();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/strategy.html b/public/dashboard-classic/strategy.html
deleted file mode 100644
index 5d6fa839f..000000000
--- a/public/dashboard-classic/strategy.html
+++ /dev/null
@@ -1,137 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent Strategy · three.ws</title>
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- </head>
- <body>
- <div class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <h1 class="dash-title">Agent Strategy</h1>
- <p class="dash-sub">
- Freeform JSON your agent's skills can read at runtime. Stored on
- <code class="dash-mono">agent_identities.meta.strategy</code>. For typed DCA rules see
- <a href="/strategy-lab">Strategy lab</a>.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </div>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const contentEl = document.getElementById('content');
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- }
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[c],
- );
- }
-
- async function loadStrategy(agentId) {
- const r = await fetch(`/api/agent-strategy?id=${encodeURIComponent(agentId)}`, {
- credentials: 'include',
- });
- if (r.status === 404) return null;
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- const data = await r.json();
- return data?.data?.strategy ?? null;
- }
-
- async function saveStrategy(agentId, strategy) {
- const r = await fetch(`/api/agent-strategy?id=${encodeURIComponent(agentId)}`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ strategy }),
- });
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- function render(agentId, current) {
- const initial =
- current === null
- ? '{\n "objective": "trade memes profitably",\n "max_position_sol": 0.5,\n "stop_loss_pct": 20\n}'
- : JSON.stringify(current, null, 2);
-
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>Strategy JSON</h2>
- <textarea id="strategy-input" class="dash-textarea" style="min-height:340px" spellcheck="false">${escapeHtml(initial)}</textarea>
- <div class="dash-row" style="margin-top:12px">
- <button class="dash-btn primary" id="save-btn">Save strategy</button>
- <button class="dash-btn" id="format-btn">Reformat JSON</button>
- <span class="dash-muted" id="form-status"></span>
- </div>
- <p class="dash-muted" style="margin-top:10px">
- Skills receive this object from
- <code class="dash-mono">getStrategy()</code>. Empty <code class="dash-mono">{}</code> is valid.
- </p>
- </div>
- `;
-
- const input = document.getElementById('strategy-input');
- const formStatus = document.getElementById('form-status');
-
- document.getElementById('format-btn').addEventListener('click', () => {
- try {
- input.value = JSON.stringify(JSON.parse(input.value), null, 2);
- formStatus.textContent = '';
- } catch (e) {
- formStatus.textContent = 'Invalid JSON: ' + e.message;
- }
- });
-
- document.getElementById('save-btn').addEventListener('click', async () => {
- let parsed;
- try {
- parsed = JSON.parse(input.value);
- } catch (e) {
- formStatus.textContent = 'Invalid JSON: ' + e.message;
- return;
- }
- formStatus.textContent = 'Saving…';
- try {
- await saveStrategy(agentId, parsed);
- formStatus.textContent = 'Saved.';
- showStatus('Strategy saved.', 'ok');
- } catch (e) {
- formStatus.textContent = '';
- showStatus(e.message || 'Save failed', 'err');
- }
- });
- }
-
- async function refresh(agentId) {
- contentEl.innerHTML = '<div class="dash-empty">Loading strategy…</div>';
- try {
- const current = await loadStrategy(agentId);
- render(agentId, current);
- } catch (e) {
- showStatus(e.message || 'Failed to load', 'err');
- }
- }
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => refresh(agentId),
- });
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/tokens.html b/public/dashboard-classic/tokens.html
deleted file mode 100644
index 84eb441be..000000000
--- a/public/dashboard-classic/tokens.html
+++ /dev/null
@@ -1,162 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent Tokens · three.ws</title>
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- </head>
- <body>
- <div class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <h1 class="dash-title">Agent Tokens</h1>
- <p class="dash-sub">
- If your agent has launched a Pump.fun token, the live state lives here. Launch a new one via
- <a href="/dashboard/agent-pumpfun">Agent · Pump.fun</a> or from the agent's home page.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </div>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const contentEl = document.getElementById('content');
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- }
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[c],
- );
- }
-
- async function getAgent(agentId) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}`, {
- credentials: 'include',
- });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- return (await r.json()).agent;
- }
-
- // Pump.fun Frontend API for live state. Public, no auth.
- async function fetchPumpData(mint) {
- try {
- const r = await fetch(`https://frontend-api-v3.pump.fun/coins/${mint}`);
- if (!r.ok) return null;
- return r.json();
- } catch {
- return null;
- }
- }
-
- async function render(agentId) {
- contentEl.innerHTML = '<div class="dash-empty">Loading token data…</div>';
- let agent;
- try {
- agent = await getAgent(agentId);
- } catch (e) {
- showStatus(e.message || 'Failed to load agent', 'err');
- return;
- }
-
- const token = agent?.token || agent?.meta?.token || null;
- if (!token?.mint) {
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>No token launched</h2>
- <p class="dash-muted" style="margin-bottom:14px">
- This agent has no Pump.fun token yet. Launch one from the agent's home page or via the
- Pump.fun studio.
- </p>
- <div class="dash-row">
- <a class="dash-btn primary" href="/agent/${encodeURIComponent(agentId)}">Open agent</a>
- <a class="dash-btn" href="/dashboard/agent-pumpfun">Pump.fun studio</a>
- </div>
- </div>`;
- return;
- }
-
- const live = token.cluster === 'mainnet' ? await fetchPumpData(token.mint) : null;
- const usdMc = live?.usd_market_cap;
- const solBalance = (live?.virtual_sol_reserves || 0) / 1e9;
- const tokensLeft = (live?.virtual_token_reserves || 0) / 1e6;
- const complete = live?.complete;
-
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>${escapeHtml(token.name || 'Token')} · ${escapeHtml(token.symbol || '')}</h2>
- <div class="dash-row" style="gap:18px;flex-wrap:wrap;margin-bottom:14px">
- ${token.image ? `<img src="${escapeHtml(token.image)}" alt="" width="64" height="64" style="border-radius:10px;background:#1a1a24" />` : ''}
- <div style="flex:1;min-width:240px">
- <div class="dash-mono">${escapeHtml(token.mint)}</div>
- <div class="dash-muted" style="margin-top:4px">
- Launched ${token.launched_at ? new Date(token.launched_at).toLocaleString() : '—'}
- ${token.cluster ? ' · ' + escapeHtml(token.cluster) : ''}
- </div>
- ${token.description ? `<p style="margin:8px 0 0;color:#ccc">${escapeHtml(token.description)}</p>` : ''}
- </div>
- </div>
- <div class="dash-row">
- ${token.pumpfun_url ? `<a class="dash-btn primary" href="${escapeHtml(token.pumpfun_url)}" target="_blank" rel="noopener">Pump.fun ↗</a>` : ''}
- ${token.explorer_url ? `<a class="dash-btn" href="${escapeHtml(token.explorer_url)}" target="_blank" rel="noopener">Explorer ↗</a>` : ''}
- <a class="dash-btn" href="https://dexscreener.com/solana/${encodeURIComponent(token.mint)}" target="_blank" rel="noopener">DEX Screener ↗</a>
- <a class="dash-btn" href="https://birdeye.so/token/${encodeURIComponent(token.mint)}?chain=solana" target="_blank" rel="noopener">Birdeye ↗</a>
- </div>
- </div>
-
- ${
- live
- ? `<div class="dash-card">
- <h2>Live state</h2>
- <div class="dash-row" style="gap:24px">
- <div>
- <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Market cap</div>
- <div style="font-size:18px">${usdMc != null ? '$' + Number(usdMc).toLocaleString(undefined, { maximumFractionDigits: 0 }) : '—'}</div>
- </div>
- <div>
- <div class="dash-muted" style="font-size:11px;text-transform:uppercase">SOL in curve</div>
- <div style="font-size:18px">${solBalance.toFixed(2)}</div>
- </div>
- <div>
- <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Tokens left</div>
- <div style="font-size:18px">${tokensLeft.toLocaleString(undefined, { maximumFractionDigits: 0 })}</div>
- </div>
- <div>
- <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Status</div>
- <div style="font-size:18px">${complete ? '🎓 Graduated' : '📈 Bonding'}</div>
- </div>
- </div>
- </div>`
- : token.cluster === 'mainnet'
- ? '<div class="dash-empty">Pump.fun returned no data for this mint — token may be very new.</div>'
- : '<div class="dash-muted" style="text-align:center;padding:12px">Devnet token — live Pump.fun stats are mainnet-only.</div>'
- }
-
- <div class="dash-card">
- <h2>Launch tx</h2>
- ${
- token.tx_signature
- ? `<div class="dash-mono" style="word-break:break-all">${escapeHtml(token.tx_signature)}</div>
- <a class="dash-btn" style="margin-top:10px" target="_blank" rel="noopener" href="https://solscan.io/tx/${encodeURIComponent(token.tx_signature)}${token.cluster === 'devnet' ? '?cluster=devnet' : ''}">View on Solscan ↗</a>`
- : '<div class="dash-muted">No tx signature recorded.</div>'
- }
- </div>
- `;
- }
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => render(agentId),
- });
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/usage.html b/public/dashboard-classic/usage.html
deleted file mode 100644
index 37fb37079..000000000
--- a/public/dashboard-classic/usage.html
+++ /dev/null
@@ -1,212 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>LLM Usage — three.ws</title>
- <style>
- body {
- font-family:
- system-ui,
- -apple-system,
- sans-serif;
- max-width: 640px;
- margin: 2rem auto;
- padding: 0 1rem;
- color: #111;
- }
- h1 {
- font-size: 1.25rem;
- margin-bottom: 0.25rem;
- }
- .sub {
- color: #555;
- font-size: 0.875rem;
- margin-bottom: 1.5rem;
- }
- .quota-bar {
- background: #e5e7eb;
- border-radius: 999px;
- height: 12px;
- overflow: hidden;
- margin: 0.5rem 0 0.25rem;
- }
- .quota-fill {
- background: #3b82f6;
- height: 100%;
- border-radius: 999px;
- transition: width 0.4s;
- }
- .quota-fill.warn {
- background: #f59e0b;
- }
- .quota-fill.danger {
- background: #ef4444;
- }
- .quota-label {
- font-size: 0.8rem;
- color: #555;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- margin-top: 1.5rem;
- font-size: 0.875rem;
- }
- th {
- text-align: left;
- padding: 6px 8px;
- border-bottom: 2px solid #e5e7eb;
- color: #555;
- font-weight: 600;
- }
- td {
- padding: 5px 8px;
- border-bottom: 1px solid #f3f4f6;
- }
- .sparkline {
- display: flex;
- align-items: flex-end;
- gap: 2px;
- height: 40px;
- margin-top: 1.5rem;
- }
- .sparkline-bar {
- flex: 1;
- background: #3b82f6;
- border-radius: 2px 2px 0 0;
- min-height: 2px;
- }
- .sparkline-bar:hover {
- background: #2563eb;
- }
- .error {
- color: #dc2626;
- padding: 1rem 0;
- }
- .section {
- margin-top: 2rem;
- }
- h2 {
- font-size: 1rem;
- margin-bottom: 0.5rem;
- color: #374151;
- }
- </style>
- </head>
- <body>
- <h1>LLM Usage</h1>
- <div class="sub" id="agent-label">Loading…</div>
-
- <div class="section" id="quota-section" style="display: none">
- <h2>Current month</h2>
- <div class="quota-bar">
- <div class="quota-fill" id="quota-fill" style="width: 0%"></div>
- </div>
- <div class="quota-label" id="quota-label"></div>
- </div>
-
- <div class="section" id="spark-section" style="display: none">
- <h2>Last 30 days</h2>
- <div class="sparkline" id="sparkline"></div>
- </div>
-
- <div class="section" id="table-section" style="display: none">
- <table>
- <thead>
- <tr>
- <th>Day</th>
- <th>Calls</th>
- </tr>
- </thead>
- <tbody id="daily-tbody"></tbody>
- </table>
- </div>
-
- <div class="error" id="error-msg" style="display: none"></div>
-
- <script>
- (async () => {
- const params = new URLSearchParams(location.search);
- const id = params.get('id');
- if (!id) {
- show('error-msg', 'Missing ?id= parameter.');
- return;
- }
-
- document.getElementById('agent-label').textContent = `Agent ${id}`;
-
- let data;
- try {
- const r = await fetch(`/api/agents/${id}/usage`, { credentials: 'include' });
- if (r.status === 401) {
- show('error-msg', 'Not signed in. Visit /login first.');
- return;
- }
- if (r.status === 404) {
- show('error-msg', 'Agent not found or not yours.');
- return;
- }
- if (!r.ok) {
- show('error-msg', `Error ${r.status}`);
- return;
- }
- data = await r.json();
- } catch (e) {
- show('error-msg', `Fetch failed: ${e.message}`);
- return;
- }
-
- const { currentMonthCalls, monthlyQuota, dailyBreakdown, agentId } = data;
- document.getElementById('agent-label').textContent = `Agent ${agentId}`;
-
- // Quota bar
- if (typeof monthlyQuota === 'number') {
- const pct = Math.min(100, (currentMonthCalls / monthlyQuota) * 100);
- const fill = document.getElementById('quota-fill');
- fill.style.width = pct + '%';
- fill.className =
- 'quota-fill' + (pct >= 90 ? ' danger' : pct >= 70 ? ' warn' : '');
- document.getElementById('quota-label').textContent =
- `${currentMonthCalls.toLocaleString()} / ${monthlyQuota.toLocaleString()} calls this month (${Math.round(pct)}%)`;
- document.getElementById('quota-section').style.display = '';
- } else {
- document.getElementById('quota-section').style.display = '';
- document.getElementById('quota-label').textContent =
- `${currentMonthCalls.toLocaleString()} calls this month (no quota set)`;
- }
-
- // Sparkline + table
- if (dailyBreakdown && dailyBreakdown.length) {
- const max = Math.max(1, ...dailyBreakdown.map((r) => r.calls));
- const spark = document.getElementById('sparkline');
- const tbody = document.getElementById('daily-tbody');
- for (const row of dailyBreakdown) {
- const bar = document.createElement('div');
- bar.className = 'sparkline-bar';
- bar.style.height = Math.max(2, Math.round((row.calls / max) * 40)) + 'px';
- bar.title = `${row.day}: ${row.calls}`;
- spark.appendChild(bar);
-
- const tr = document.createElement('tr');
- tr.innerHTML = `<td>${row.day}</td><td>${row.calls.toLocaleString()}</td>`;
- tbody.appendChild(tr);
- }
- document.getElementById('spark-section').style.display = '';
- document.getElementById('table-section').style.display = '';
- } else {
- document.getElementById('spark-section').style.display = '';
- document.getElementById('spark-section').innerHTML +=
- '<p style="color:#555;font-size:0.875rem">No calls in the last 30 days.</p>';
- }
- })();
-
- function show(id, msg) {
- const el = document.getElementById(id);
- el.textContent = msg;
- el.style.display = '';
- }
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/voice.html b/public/dashboard-classic/voice.html
deleted file mode 100644
index 0d5dd5dd2..000000000
--- a/public/dashboard-classic/voice.html
+++ /dev/null
@@ -1,222 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Agent Voice · three.ws</title>
- <link rel="stylesheet" href="/dashboard/_dash-shell.css" />
- </head>
- <body>
- <div class="dash-shell">
- <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>
- <h1 class="dash-title">Agent Voice</h1>
- <p class="dash-sub">
- Clone a voice from a ≥30-second sample (ElevenLabs) or fall back to browser TTS. Used by chat,
- agent-3d, and the X-Spaces voice agent.
- </p>
-
- <div id="picker"></div>
- <div id="status"></div>
- <div id="content"></div>
- </div>
-
- <script type="module">
- import { mountAgentPicker } from '/src/dashboard/_agent-picker.js';
-
- const statusEl = document.getElementById('status');
- const contentEl = document.getElementById('content');
-
- function showStatus(msg, kind = '') {
- statusEl.innerHTML = msg
- ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`
- : '';
- }
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(
- /[&<>"']/g,
- (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;' })[c],
- );
- }
-
- async function getVoice(agentId) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/voice`, {
- credentials: 'include',
- });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- return r.json();
- }
-
- async function deleteVoice(agentId) {
- const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/voice`, {
- method: 'DELETE',
- credentials: 'include',
- });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- return r.json();
- }
-
- let recorder = null;
- let chunks = [];
- let startedAt = 0;
- let timerInt = null;
-
- function pickMime() {
- const cands = [
- 'audio/webm;codecs=opus',
- 'audio/webm',
- 'audio/mp4',
- 'audio/mpeg',
- ];
- for (const c of cands) {
- if (window.MediaRecorder && MediaRecorder.isTypeSupported(c)) return c;
- }
- return 'audio/webm';
- }
-
- async function startRecord() {
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
- const mime = pickMime();
- recorder = new MediaRecorder(stream, { mimeType: mime });
- chunks = [];
- recorder.ondataavailable = (e) => {
- if (e.data && e.data.size) chunks.push(e.data);
- };
- recorder.start();
- startedAt = Date.now();
- const timerEl = document.getElementById('rec-timer');
- timerInt = setInterval(() => {
- const sec = Math.floor((Date.now() - startedAt) / 1000);
- timerEl.textContent = sec + 's';
- }, 200);
- }
-
- async function stopRecord() {
- if (!recorder) return null;
- const r = recorder;
- const durationSec = Math.max(1, Math.floor((Date.now() - startedAt) / 1000));
- const blob = await new Promise((resolve) => {
- r.onstop = () => resolve(new Blob(chunks, { type: r.mimeType }));
- r.stop();
- });
- r.stream.getTracks().forEach((t) => t.stop());
- clearInterval(timerInt);
- recorder = null;
- return { blob, durationSec };
- }
-
- async function uploadClone(agentId, blob, durationSec) {
- const r = await fetch(
- `/api/agents/${encodeURIComponent(agentId)}/voice/clone?name=${encodeURIComponent(
- (document.getElementById('voice-name').value || 'Agent Voice').slice(0, 100),
- )}`,
- {
- method: 'POST',
- credentials: 'include',
- headers: {
- 'content-type': blob.type || 'audio/webm',
- 'x-recording-duration': String(durationSec),
- },
- body: blob,
- },
- );
- if (!r.ok) {
- const err = await r.json().catch(() => ({}));
- throw new Error(err.error_description || `HTTP ${r.status}`);
- }
- return r.json();
- }
-
- function render(agentId, voice) {
- const hasClone = !!voice.voice_id;
- contentEl.innerHTML = `
- <div class="dash-card">
- <h2>Current voice</h2>
- <div class="dash-row" style="gap:14px">
- <span class="dash-pill">${escapeHtml(voice.voice_provider || 'browser')}</span>
- ${hasClone ? `<span class="dash-mono">${escapeHtml(voice.voice_id)}</span>` : '<span class="dash-muted">No cloned voice — falls back to browser TTS.</span>'}
- ${hasClone ? `<button class="dash-btn danger" id="remove-voice">Remove clone</button>` : ''}
- </div>
- ${voice.voice_cloned_at ? `<div class="dash-muted" style="margin-top:8px">Cloned ${new Date(voice.voice_cloned_at).toLocaleString()}</div>` : ''}
- </div>
- <div class="dash-card">
- <h2>Clone a new voice</h2>
- <label style="display:block;margin-bottom:10px">
- <div class="dash-muted" style="margin-bottom:4px">Voice name</div>
- <input id="voice-name" class="dash-input" value="${escapeHtml(voice.voice_name || 'Agent Voice')}" maxlength="100" />
- </label>
- <div class="dash-row" style="gap:12px;align-items:center">
- <button class="dash-btn primary" id="rec-toggle">Start recording</button>
- <span class="dash-mono" id="rec-timer">0s</span>
- <span class="dash-muted">Min 30 seconds. Limit 10 MB.</span>
- </div>
- <div id="rec-out" style="margin-top:14px"></div>
- </div>
- `;
-
- const removeBtn = document.getElementById('remove-voice');
- if (removeBtn) {
- removeBtn.addEventListener('click', async () => {
- if (!confirm('Remove the cloned voice? The agent will fall back to browser TTS.')) return;
- removeBtn.disabled = true;
- try {
- await deleteVoice(agentId);
- showStatus('Removed.', 'ok');
- await refresh(agentId);
- } catch (e) {
- showStatus(e.message || 'Remove failed', 'err');
- removeBtn.disabled = false;
- }
- });
- }
-
- const toggleBtn = document.getElementById('rec-toggle');
- const outEl = document.getElementById('rec-out');
- toggleBtn.addEventListener('click', async () => {
- if (!recorder) {
- try {
- await startRecord();
- toggleBtn.textContent = 'Stop & upload';
- toggleBtn.classList.add('danger');
- toggleBtn.classList.remove('primary');
- } catch (e) {
- showStatus('Microphone access denied: ' + (e.message || e.name), 'err');
- }
- return;
- }
- toggleBtn.disabled = true;
- toggleBtn.textContent = 'Uploading…';
- try {
- const { blob, durationSec } = await stopRecord();
- outEl.innerHTML = `<audio controls src="${URL.createObjectURL(blob)}" style="width:100%;margin-bottom:10px"></audio>`;
- if (durationSec < 30) throw new Error(`Recording was ${durationSec}s — need ≥30s.`);
- const { voice_id } = await uploadClone(agentId, blob, durationSec);
- showStatus(`Voice cloned: ${voice_id}`, 'ok');
- await refresh(agentId);
- } catch (e) {
- showStatus(e.message || 'Upload failed', 'err');
- toggleBtn.disabled = false;
- toggleBtn.textContent = 'Start recording';
- toggleBtn.classList.add('primary');
- toggleBtn.classList.remove('danger');
- }
- });
- }
-
- async function refresh(agentId) {
- contentEl.innerHTML = '<div class="dash-empty">Loading voice status…</div>';
- try {
- const voice = await getVoice(agentId);
- render(agentId, voice);
- } catch (e) {
- showStatus(e.message || 'Failed to load voice', 'err');
- }
- }
-
- mountAgentPicker({
- host: document.getElementById('picker'),
- onPick: (agentId) => refresh(agentId),
- });
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/wallets.html b/public/dashboard-classic/wallets.html
deleted file mode 100644
index 43ce20836..000000000
--- a/public/dashboard-classic/wallets.html
+++ /dev/null
@@ -1,558 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Linked Wallets · Dashboard · three.ws</title>
- <link rel="icon" href="/favicon.ico" />
- <style>
- :root {
- color-scheme: dark;
- --accent: #ffffff;
- --accent2: #cccccc;
- --border: #222222;
- --bg: #000;
- --panel: #141414;
- }
- * {
- box-sizing: border-box;
- }
- body {
- font:
- 15px/1.55 -apple-system,
- system-ui,
- Segoe UI,
- Roboto,
- sans-serif;
- color: #eee;
- margin: 0;
- background: var(--bg);
- min-height: 100vh;
- }
- a {
- color: #9a8cff;
- text-decoration: none;
- }
- header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 16px 24px;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: var(--bg);
- z-index: 5;
- }
- .brand {
- font-weight: 600;
- letter-spacing: -0.01em;
- }
- .row {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- main {
- padding: 28px;
- max-width: 800px;
- margin: 0 auto;
- }
- h1 {
- font-size: 22px;
- margin: 0 0 6px;
- letter-spacing: -0.01em;
- }
- .sub {
- color: #888;
- margin: 0 0 22px;
- font-size: 14px;
- }
- .btn {
- padding: 8px 14px;
- border-radius: 6px;
- border: 1px solid #2a2a36;
- font-size: 13px;
- font-weight: 600;
- cursor: pointer;
- background: #000;
- color: #fff;
- transition: border-color 0.12s ease, background 0.12s ease;
- }
- .btn:hover:not(:disabled) {
- border-color: #3d3d52;
- background: #0a0a12;
- }
- .btn.sec {
- background: #15151d;
- color: #ddd;
- border-color: #222222;
- }
- .btn.sec:hover:not(:disabled) {
- background: #1c1c26;
- border-color: #2e2e3e;
- }
- .btn.danger {
- background: #15151d;
- border-color: rgba(204, 64, 64, 0.4);
- color: #ffb3b3;
- }
- .btn.danger:hover:not(:disabled) {
- background: rgba(204, 64, 64, 0.12);
- border-color: rgba(204, 64, 64, 0.6);
- }
- .btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
- .wallet-table {
- width: 100%;
- border-collapse: collapse;
- margin-bottom: 24px;
- }
- .wallet-table th {
- text-align: left;
- padding: 12px;
- border-bottom: 1px solid var(--border);
- font-size: 12px;
- font-weight: 600;
- color: #aaa;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- }
- .wallet-table td {
- padding: 12px;
- border-bottom: 1px solid var(--border);
- font-size: 14px;
- }
- .wallet-table tr:last-child td {
- border-bottom: none;
- }
- .address-cell {
- display: flex;
- align-items: center;
- gap: 8px;
- font-family:
- ui-monospace,
- SF Mono,
- Menlo,
- monospace;
- font-size: 13px;
- }
- .copy-btn {
- background: none;
- border: none;
- color: #666;
- cursor: pointer;
- padding: 2px 4px;
- font-size: 12px;
- }
- .copy-btn:hover {
- color: #aaa;
- }
- .pill {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- font-size: 11px;
- padding: 3px 8px;
- border-radius: 99px;
- background: #20202c;
- color: #ccc;
- white-space: nowrap;
- }
- .meta {
- color: #888;
- font-size: 13px;
- }
- .err {
- padding: 12px;
- background: rgba(255, 92, 92, 0.1);
- border: 1px solid rgba(255, 92, 92, 0.3);
- border-radius: 8px;
- color: #ffb3b3;
- margin-bottom: 14px;
- display: none;
- }
- .empty {
- text-align: center;
- padding: 40px 20px;
- border: 1px dashed var(--border);
- border-radius: 14px;
- color: #888;
- }
- .loading {
- opacity: 0.6;
- }
- .muted {
- color: #888;
- font-size: 13px;
- }
- body[data-auth-pending] {
- visibility: hidden;
- }
- .header-logo {
- width: 14px;
- height: 14px;
- vertical-align: -2px;
- margin-right: 6px;
- }
- </style>
- </head>
- <body data-auth-pending>
- <header>
- <div class="brand"><a href="/"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a></div>
- <div class="row">
- <a href="/dashboard" class="muted" style="font-size:13px">← Dashboard</a>
- <div id="header-user-slot"></div>
- </div>
- </header>
- <main>
- <h1>Linked Wallets</h1>
- <p class="sub">Manage Ethereum wallets connected to your account.</p>
-
- <div id="error" class="err"></div>
-
- <div id="wallets-container" class="loading">
- <p style="color: #666">Loading wallets…</p>
- </div>
-
- <div class="row" style="margin-top: 20px; gap: 10px; flex-wrap: wrap">
- <button id="link-evm-btn" class="btn">Link Ethereum Wallet</button>
- <button id="link-solana-btn" class="btn sec">Link Solana Wallet</button>
- </div>
- <p class="muted" id="link-hint" style="margin-top: 10px"></p>
- </main>
-
- <script type="module">
- import { renderHeaderUser } from '/src/header-user.js';
- let apiUrl = '/api';
-
- async function fetchUser() {
- const res = await fetch(`${apiUrl}/auth/me`, { credentials: 'include' });
- const data = res.ok ? await res.json() : null;
- if (!data?.user) {
- location.href = '/login?next=' + encodeURIComponent(location.pathname);
- return null;
- }
- document.body.removeAttribute('data-auth-pending');
- return data;
- }
-
- async function loadWallets() {
- try {
- const res = await fetch(`${apiUrl}/auth/wallets`, { credentials: 'include' });
- if (!res.ok) throw new Error('Failed to load wallets');
- const data = await res.json();
- renderWallets(data.wallets);
- } catch (err) {
- showError(err.message);
- }
- }
-
- function chainLabel(w) {
- if (w.chain_type === 'solana') {
- return w.chain_id && w.chain_id !== 'mainnet' ? `Solana (${w.chain_id})` : 'Solana';
- }
- if (w.chain_id) {
- const evmNames = { 1: 'Ethereum', 8453: 'Base', 10: 'Optimism', 137: 'Polygon', 42161: 'Arbitrum', 56: 'BNB Chain' };
- return evmNames[w.chain_id] || `Chain ${w.chain_id}`;
- }
- return w.chain_type === 'evm' ? 'Ethereum' : 'Unknown';
- }
-
- function renderWallets(wallets) {
- const container = document.getElementById('wallets-container');
- if (wallets.length === 0) {
- container.innerHTML = `
- <div class="empty">
- <p>No wallets linked yet.</p>
- <p class="muted">Click a link button below to add your first wallet.</p>
- </div>
- `;
- return;
- }
-
- const rows = wallets
- .map(
- (w) => `
- <tr>
- <td>
- <div class="address-cell">
- <span>${w.address.slice(0, 6)}…${w.address.slice(-4)}</span>
- <button
- class="copy-btn"
- onclick="copyToClipboard('${w.address}')"
- title="Copy full address"
- >
- 📋
- </button>
- </div>
- </td>
- <td class="meta">${chainLabel(w)}</td>
- <td class="meta">${new Date(w.created_at).toLocaleDateString()}</td>
- <td>
- ${w.is_primary ? '<span class="pill">Primary</span>' : ''}
- </td>
- <td style="text-align: right">
- <button
- class="btn sec btn-sm"
- onclick="unlinkWallet('${w.address}')"
- style="padding: 6px 10px; font-size: 12px"
- >
- Unlink
- </button>
- </td>
- </tr>
- `,
- )
- .join('');
-
- container.innerHTML = `
- <table class="wallet-table">
- <thead>
- <tr>
- <th>Address</th>
- <th>Chain</th>
- <th>Linked</th>
- <th></th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- ${rows}
- </tbody>
- </table>
- `;
- }
-
- function copyToClipboard(text) {
- navigator.clipboard.writeText(text).then(
- () => {
- // Show brief feedback
- const btn = event.target;
- const orig = btn.textContent;
- btn.textContent = '✓';
- setTimeout(() => {
- btn.textContent = orig;
- }, 1500);
- },
- () => alert('Copy failed'),
- );
- }
-
- async function unlinkWallet(address) {
- if (!confirm(`Unlink ${address.slice(0, 6)}…${address.slice(-4)}?`)) return;
-
- try {
- const res = await fetch(`${apiUrl}/auth/wallets/${address}`, {
- method: 'DELETE',
- credentials: 'include',
- });
- if (!res.ok) {
- const err = await res.json();
- throw new Error(err.error_description || 'Failed to unlink wallet');
- }
- loadWallets();
- } catch (err) {
- showError(err.message);
- }
- }
-
- function detectEvmProvider() {
- if (typeof window === 'undefined') return null;
- const eth = window.ethereum;
- if (!eth) return null;
- // Prefer a non-Solana EVM injection. Phantom's EVM provider works but
- // surfaces an address-match warning when used alongside a Solana session.
- if (Array.isArray(eth.providers)) {
- const real = eth.providers.find((p) => !p.isPhantom) || eth.providers[0];
- return real;
- }
- return eth;
- }
-
- function detectSolanaProvider() {
- if (typeof window === 'undefined') return null;
- return window.phantom?.solana || window.solana || window.backpack || window.solflare || null;
- }
-
- async function linkEvmWallet() {
- const provider = detectEvmProvider();
- if (!provider) {
- showError('No Ethereum wallet detected. Install MetaMask, Rabby, or Coinbase Wallet to link.');
- return;
- }
-
- const btn = document.getElementById('link-evm-btn');
- btn.disabled = true;
- try {
- const accounts = await provider.request({ method: 'eth_requestAccounts' });
- const address = accounts[0];
- const chainIdHex = await provider.request({ method: 'eth_chainId' });
- const chainId = parseInt(chainIdHex, 16);
-
- const nonceRes = await fetch(`${apiUrl}/auth/wallets/nonce`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ address, chainId }),
- });
- const nonceData = await nonceRes.json();
- if (!nonceRes.ok) {
- throw new Error(nonceData.error_description || 'Failed to get nonce');
- }
- const { message } = nonceData;
-
- let signature;
- try {
- signature = await provider.request({
- method: 'personal_sign',
- params: [message, address],
- });
- } catch (err) {
- if (err.code === 4001) {
- showError('Signature cancelled');
- } else {
- showError(err.message || 'Signature failed');
- }
- return;
- }
-
- const linkRes = await fetch(`${apiUrl}/auth/wallets`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ message, signature }),
- });
- const linkData = await linkRes.json();
- if (!linkRes.ok) {
- throw new Error(linkData.error_description || 'Failed to link wallet');
- }
-
- showError('', 'success');
- loadWallets();
- } catch (err) {
- showError(err.message);
- } finally {
- btn.disabled = false;
- }
- }
-
- async function linkSolanaWallet() {
- const provider = detectSolanaProvider();
- if (!provider) {
- showError('No Solana wallet detected. Install Phantom, Backpack, or Solflare to link.');
- return;
- }
-
- const btn = document.getElementById('link-solana-btn');
- btn.disabled = true;
- try {
- if (!provider.isConnected) {
- await provider.connect();
- }
- const address = provider.publicKey?.toBase58?.() || provider.publicKey?.toString?.();
- if (!address) throw new Error('Could not read wallet public key.');
-
- const nonceRes = await fetch(`${apiUrl}/auth/wallets/nonce-solana`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ address, chainId: 'mainnet' }),
- });
- const nonceData = await nonceRes.json();
- if (!nonceRes.ok) {
- throw new Error(nonceData.error_description || 'Failed to get nonce');
- }
-
- let sigBase64;
- try {
- const msgBytes = new TextEncoder().encode(nonceData.message);
- const { signature } = await provider.signMessage(msgBytes, 'utf8');
- sigBase64 = btoa(String.fromCharCode(...signature));
- } catch (err) {
- if (err?.code === 4001 || /reject/i.test(err?.message || '')) {
- showError('Signature cancelled');
- } else {
- showError(err.message || 'Signature failed');
- }
- return;
- }
-
- const linkRes = await fetch(`${apiUrl}/auth/wallets/link-solana`, {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ message: nonceData.message, signature: sigBase64 }),
- });
- const linkData = await linkRes.json();
- if (!linkRes.ok) {
- throw new Error(linkData.error_description || 'Failed to link wallet');
- }
-
- showError('', 'success');
- loadWallets();
- } catch (err) {
- showError(err.message);
- } finally {
- btn.disabled = false;
- }
- }
-
- function refreshLinkButtons() {
- const evmBtn = document.getElementById('link-evm-btn');
- const solBtn = document.getElementById('link-solana-btn');
- const hint = document.getElementById('link-hint');
- const hasEvm = !!detectEvmProvider();
- const hasSol = !!detectSolanaProvider();
- evmBtn.disabled = !hasEvm;
- solBtn.disabled = !hasSol;
- evmBtn.title = hasEvm ? '' : 'Install MetaMask, Rabby, or Coinbase Wallet';
- solBtn.title = hasSol ? '' : 'Install Phantom, Backpack, or Solflare';
- if (!hasEvm && !hasSol) {
- hint.textContent = 'Install a browser wallet extension to link.';
- } else {
- hint.textContent = '';
- }
- }
-
- function showError(msg, type = 'error') {
- const el = document.getElementById('error');
- if (!msg) {
- el.style.display = 'none';
- return;
- }
- if (type === 'success') {
- el.textContent = '✓ Wallet linked successfully!';
- el.style.background = 'rgba(92, 255, 92, 0.1)';
- el.style.borderColor = 'rgba(92, 255, 92, 0.3)';
- el.style.color = '#b3ffb3';
- } else {
- el.textContent = msg;
- el.style.background = 'rgba(255, 92, 92, 0.1)';
- el.style.borderColor = 'rgba(255, 92, 92, 0.3)';
- el.style.color = '#ffb3b3';
- }
- el.style.display = 'block';
- }
-
- window.copyToClipboard = copyToClipboard;
- window.unlinkWallet = unlinkWallet;
-
- // Initialize
- (async () => {
- const me = await fetchUser();
- if (me) {
- renderHeaderUser(document.getElementById('header-user-slot'), me.user, { activePath: '/dashboard/wallets' });
- loadWallets();
- }
- })();
-
- document.getElementById('link-evm-btn').addEventListener('click', linkEvmWallet);
- document.getElementById('link-solana-btn').addEventListener('click', linkSolanaWallet);
- refreshLinkButtons();
- </script>
- <script src="/brand.js" defer></script>
-</body>
-</html>
diff --git a/public/dashboard-classic/x402.html b/public/dashboard-classic/x402.html
deleted file mode 100644
index b7825ad0a..000000000
--- a/public/dashboard-classic/x402.html
+++ /dev/null
@@ -1,629 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
-<meta charset="utf-8" />
-<meta name="viewport" content="width=device-width,initial-scale=1" />
-<title>x402 Checkout · Dashboard</title>
-<link rel="icon" href="/favicon.ico" />
-<style>
- :root {
- color-scheme: dark;
- --bg: #0a0b10;
- --bg-2: #0f1119;
- --panel: #14161f;
- --panel-2: #1a1d29;
- --border: #232636;
- --border-strong: #2e3447;
- --text: #f0f2f8;
- --muted: #8a90a8;
- --muted-2: #6b7088;
- --accent: #0a84ff;
- --accent-2: #60a5fa;
- --green: #4ade80;
- --red: #ef4444;
- --mono: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
- }
- * { box-sizing: border-box; }
- html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
- body {
- font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
- -webkit-font-smoothing: antialiased;
- line-height: 1.5;
- min-height: 100dvh;
- }
- a { color: var(--accent-2); text-decoration: none; }
- a:hover { color: #93c5fd; }
-
- header {
- display: flex; align-items: center; gap: 16px;
- padding: 16px 28px;
- border-bottom: 1px solid var(--border);
- background: rgba(10, 11, 16, 0.92);
- backdrop-filter: blur(12px);
- position: sticky; top: 0; z-index: 10;
- }
- header .brand {
- display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px;
- letter-spacing: -0.01em;
- }
- header .brand .dot {
- width: 22px; height: 22px;
- background: conic-gradient(from 200deg, #ffffff, #60a5fa);
- border-radius: 6px;
- }
- header .crumb { color: var(--muted); margin-left: 4px; }
- header .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
- .btn {
- padding: 9px 16px;
- background: #ffffff; color: #0a0b10;
- border: none; border-radius: 9px;
- font-size: 13px; font-weight: 600; font-family: inherit;
- cursor: pointer;
- transition: background 0.12s, transform 0.05s;
- }
- .btn:hover:not(:disabled) { background: #e7e9ee; }
- .btn:active:not(:disabled) { transform: translateY(1px); }
- .btn:disabled { opacity: 0.5; cursor: not-allowed; }
- .btn.ghost {
- background: var(--panel); color: var(--text);
- border: 1px solid var(--border);
- }
- .btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: var(--border-strong); }
- .btn.danger { background: #1f1416; color: #fca5a5; border: 1px solid #7f1d1d; }
- .btn.danger:hover:not(:disabled) { background: #2a1d20; }
-
- .wrap { max-width: 1080px; margin: 0 auto; padding: 32px 28px 60px; }
- @media (max-width: 640px) { .wrap { padding: 24px 18px 60px; } header { padding: 14px 18px; } }
-
- h1 {
- font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
- margin: 0 0 4px;
- }
- .sub { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
-
- .stats {
- display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
- gap: 12px; margin-bottom: 28px;
- }
- .stat-card {
- background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
- padding: 18px;
- }
- .stat-card .k {
- font-size: 11px; color: var(--muted); font-weight: 600;
- text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px;
- }
- .stat-card .v {
- font-size: 24px; font-weight: 700; letter-spacing: -0.01em;
- font-variant-numeric: tabular-nums;
- }
- .stat-card .v .unit { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
-
- .skus-head {
- display: flex; align-items: center; justify-content: space-between;
- margin-bottom: 14px;
- }
- .skus-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
-
- .sku-table {
- background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
- overflow: hidden;
- }
- .sku-row {
- display: grid; grid-template-columns: 1fr auto auto auto;
- gap: 14px; padding: 14px 18px;
- align-items: center;
- border-bottom: 1px solid var(--border);
- transition: background 0.1s;
- }
- .sku-row:hover { background: var(--panel-2); }
- .sku-row:last-child { border-bottom: none; }
- .sku-row .name { font-weight: 600; font-size: 14px; letter-spacing: -0.005em; }
- .sku-row .slug { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
- .sku-row .calls { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
- .sku-row .calls strong { color: var(--text); font-size: 13px; font-weight: 700; }
- .sku-row .revenue { font-family: var(--mono); font-size: 13px; color: var(--green); font-weight: 700; font-variant-numeric: tabular-nums; }
- .sku-row .actions { display: flex; gap: 6px; }
- .sku-row .actions .btn { padding: 6px 12px; font-size: 12px; }
- @media (max-width: 640px) {
- .sku-row { grid-template-columns: 1fr; gap: 8px; }
- .sku-row .actions { justify-content: flex-start; }
- }
-
- .empty {
- text-align: center; padding: 60px 24px;
- color: var(--muted); font-size: 14px;
- }
- .empty h3 { color: var(--text); font-size: 17px; margin: 0 0 6px; }
-
- .modal-overlay {
- position: fixed; inset: 0;
- background: rgba(8, 10, 18, 0.7);
- backdrop-filter: blur(10px);
- display: none; align-items: center; justify-content: center;
- z-index: 100; padding: 18px;
- }
- .modal-overlay.show { display: flex; }
- .modal {
- background: var(--panel); border: 1px solid var(--border-strong);
- border-radius: 16px; width: 100%; max-width: 520px;
- max-height: calc(100dvh - 36px); overflow: auto;
- box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
- }
- .modal-head {
- padding: 18px 22px; border-bottom: 1px solid var(--border);
- display: flex; align-items: center; justify-content: space-between;
- }
- .modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
- .modal-close {
- background: none; border: none; color: var(--muted); cursor: pointer;
- font-size: 18px; width: 30px; height: 30px; border-radius: 7px;
- }
- .modal-close:hover { background: var(--panel-2); color: var(--text); }
- .modal-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
-
- label {
- display: flex; flex-direction: column; gap: 5px;
- font-size: 12px; font-weight: 600; color: var(--muted);
- text-transform: uppercase; letter-spacing: 0.03em;
- }
- label input, label select, label textarea {
- background: var(--bg-2); border: 1px solid var(--border);
- color: var(--text);
- padding: 11px 13px; border-radius: 9px;
- font-size: 14px; font-family: inherit;
- text-transform: none; letter-spacing: 0; font-weight: 400;
- outline: none;
- transition: border-color 0.12s;
- }
- label input:focus, label select:focus, label textarea:focus { border-color: var(--accent); }
- label textarea { min-height: 70px; resize: vertical; font-family: var(--mono); font-size: 12px; }
- label .hint { font-size: 11px; color: var(--muted-2); font-weight: 500; text-transform: none; letter-spacing: 0; margin-top: -2px; }
- .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
- @media (max-width: 540px) { .row-2 { grid-template-columns: 1fr; } }
-
- .form-error {
- padding: 10px 12px; border-radius: 8px;
- background: #1f1416; border: 1px solid #7f1d1d; color: #fca5a5;
- font-size: 12px; font-family: var(--mono);
- }
- .form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
-
- /* Drawer for SKU detail */
- .drawer {
- position: fixed; top: 0; right: 0; bottom: 0;
- width: 100%; max-width: 540px;
- background: var(--panel); border-left: 1px solid var(--border);
- transform: translateX(100%); transition: transform 0.22s ease-out;
- z-index: 90; overflow: auto;
- box-shadow: -24px 0 60px rgba(0, 0, 0, 0.4);
- }
- .drawer.show { transform: translateX(0); }
- .drawer-head {
- padding: 22px 24px 14px;
- border-bottom: 1px solid var(--border);
- }
- .drawer-head .merchant { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
- .drawer-head .action-name { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
- .drawer-head .url {
- margin-top: 12px; font-family: var(--mono); font-size: 12px;
- color: var(--muted);
- background: var(--bg-2); padding: 8px 12px; border-radius: 8px;
- display: flex; align-items: center; gap: 8px; word-break: break-all;
- }
- .drawer-head .url-copy {
- background: var(--panel); border: 1px solid var(--border); color: var(--muted);
- font-size: 11px; padding: 4px 8px; border-radius: 5px; cursor: pointer; font-family: inherit;
- flex: 0 0 auto;
- }
- .drawer-head .url-copy:hover { color: var(--text); border-color: var(--border-strong); }
- .drawer-head .url-copy.copied { color: var(--green); border-color: var(--green); }
- .drawer-body { padding: 18px 24px 24px; }
- .drawer-body section { margin-bottom: 26px; }
- .drawer-body section h4 {
- margin: 0 0 10px; font-size: 11px; color: var(--muted);
- text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
- }
-
- .call-list { font-family: var(--mono); font-size: 12px; }
- .call-row {
- display: grid; grid-template-columns: 110px 1fr 100px 80px;
- gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border);
- align-items: center;
- }
- .call-row:last-child { border-bottom: none; }
- .call-row .ago { color: var(--muted); }
- .call-row .who { color: var(--text); word-break: break-all; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
- .call-row .amount { color: var(--green); text-align: right; font-weight: 600; }
- .call-row .net { color: var(--muted-2); text-align: right; }
-
- .drawer-actions {
- display: flex; gap: 8px; padding: 14px 24px;
- border-top: 1px solid var(--border);
- position: sticky; bottom: 0; background: var(--panel);
- }
-</style>
-</head>
-<body>
-
-<header>
- <a class="brand" href="/x402">
- <div class="dot"></div>
- <span>x402</span>
- </a>
- <span class="crumb">/ Dashboard</span>
- <div class="right">
- <a href="/x402" class="btn ghost">View landing</a>
- <button class="btn" id="newBtn">+ New SKU</button>
- </div>
-</header>
-
-<div class="wrap">
- <h1>Checkout SKUs</h1>
- <p class="sub">Hosted checkout links for your paid endpoints. Each SKU gets a shareable URL — buyers pay with one click.</p>
-
- <div class="stats" id="stats" style="display:none">
- <div class="stat-card">
- <div class="k">Active SKUs</div>
- <div class="v" id="s-skus">—</div>
- </div>
- <div class="stat-card">
- <div class="k">Paid calls</div>
- <div class="v" id="s-calls">—</div>
- </div>
- <div class="stat-card">
- <div class="k">Gross revenue</div>
- <div class="v" id="s-revenue">—<span class="unit"> USDC</span></div>
- </div>
- </div>
-
- <div class="skus-head">
- <h2>Your SKUs</h2>
- </div>
-
- <div id="content"></div>
-</div>
-
-<!-- Create / edit modal -->
-<div class="modal-overlay" id="modal">
- <div class="modal">
- <div class="modal-head">
- <h3 id="modalTitle">New SKU</h3>
- <button class="modal-close" id="modalClose">✕</button>
- </div>
- <form class="modal-body" id="skuForm">
- <label>
- URL slug
- <input name="slug" required pattern="^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$" placeholder="pro-summary" />
- <span class="hint">Used in the public URL: /pay/c/&lt;slug&gt;. 3–64 chars, lowercase + hyphens.</span>
- </label>
- <div class="row-2">
- <label>
- Merchant
- <input name="merchant_name" required maxlength="80" placeholder="Acme" />
- </label>
- <label>
- Action
- <input name="action_name" required maxlength="80" placeholder="Summarize text" />
- </label>
- </div>
- <label>
- Description
- <textarea name="description" maxlength="2000" placeholder="What does this charge for?"></textarea>
- <span class="hint">Optional. Shown on the hosted checkout page.</span>
- </label>
- <label>
- Target endpoint
- <input name="target_endpoint" type="url" required placeholder="https://api.acme.com/summarize" />
- <span class="hint">A 402-enabled URL. Returns the price + a settlement receipt.</span>
- </label>
- <div class="row-2">
- <label>
- Method
- <select name="target_method">
- <option value="GET">GET</option>
- <option value="POST">POST</option>
- </select>
- </label>
- <label>
- Accent color
- <input name="accent_color" type="color" value="#0a84ff" />
- </label>
- </div>
- <label id="bodyLabel" style="display:none">
- Request body (JSON)
- <textarea name="target_body" placeholder='{"text":"hello"}'></textarea>
- </label>
- <label>
- Logo URL
- <input name="logo_url" type="url" placeholder="https://acme.com/logo.png" />
- <span class="hint">Optional.</span>
- </label>
- <label>
- Success redirect
- <input name="success_url" type="url" placeholder="https://acme.com/thanks" />
- <span class="hint">Optional. Where to send the buyer after a successful payment.</span>
- </label>
- <div id="formError" class="form-error" style="display:none"></div>
- <div class="form-actions">
- <button type="button" class="btn ghost" id="cancelBtn">Cancel</button>
- <button type="submit" class="btn" id="saveBtn">Create</button>
- </div>
- </form>
- </div>
-</div>
-
-<!-- Detail drawer -->
-<aside class="drawer" id="drawer">
- <div class="drawer-head">
- <div class="merchant" id="d-merchant">—</div>
- <div class="action-name" id="d-action">—</div>
- <div class="url" id="d-url">
- <span id="d-url-text">—</span>
- <button class="url-copy" id="d-url-copy">copy</button>
- </div>
- </div>
- <div class="drawer-body">
- <section>
- <h4>Performance</h4>
- <div class="stats" style="display:grid;margin-bottom:0">
- <div class="stat-card"><div class="k">Calls</div><div class="v" id="d-s-calls">—</div></div>
- <div class="stat-card"><div class="k">Revenue</div><div class="v" id="d-s-revenue">—<span class="unit"> USDC</span></div></div>
- <div class="stat-card"><div class="k">Unique payers</div><div class="v" id="d-s-payers">—</div></div>
- </div>
- </section>
- <section>
- <h4>Recent calls</h4>
- <div class="call-list" id="d-calls"><div style="color:var(--muted);font-family:inherit;font-size:13px">No calls yet.</div></div>
- </section>
- <section>
- <h4>Endpoint</h4>
- <div class="url" id="d-endpoint">—</div>
- </section>
- </div>
- <div class="drawer-actions">
- <button class="btn ghost" id="d-edit">Edit</button>
- <button class="btn ghost" id="d-open">Open page ↗</button>
- <button class="btn danger" id="d-archive" style="margin-left:auto">Archive</button>
- </div>
-</aside>
-
-<script type="module">
- const $ = (id) => document.getElementById(id);
- const content = $('content');
- let cachedSkus = [];
- let editingId = null;
-
- function escapeHtml(s) {
- return String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
- }
- function fmtUsdc(atomics) {
- const n = Number(atomics || 0) / 1_000_000;
- if (n === 0) return '0.00';
- if (n < 0.01) return n.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
- if (n < 1) return n.toFixed(4).replace(/0+$/, '').replace(/\.$/, '');
- return n.toFixed(2);
- }
- function fmtAgo(ts) {
- if (!ts) return '—';
- const d = Math.max(0, Date.now() - new Date(ts).getTime());
- if (d < 60_000) return `${Math.floor(d / 1000)}s ago`;
- if (d < 3600_000) return `${Math.floor(d / 60_000)}m ago`;
- if (d < 86400_000) return `${Math.floor(d / 3600_000)}h ago`;
- return `${Math.floor(d / 86400_000)}d ago`;
- }
-
- async function loadList() {
- try {
- const r = await fetch('/api/x402-skus', { credentials: 'include' });
- if (r.status === 401) {
- renderUnauth();
- return;
- }
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- const { skus } = await r.json();
- cachedSkus = skus || [];
- renderList();
- } catch (err) {
- content.innerHTML = `<div class="empty"><h3>Couldn't load SKUs</h3><p>${escapeHtml(err.message)}</p></div>`;
- }
- }
-
- function renderUnauth() {
- content.innerHTML = `
- <div class="empty">
- <h3>Sign in to manage your checkout SKUs</h3>
- <p>Each SKU becomes a hosted /pay/c/&lt;slug&gt; URL that accepts x402 payments.</p>
- <p style="margin-top:18px"><a class="btn ghost" href="/login?redirect=/dashboard/x402">Sign in</a></p>
- </div>`;
- $('stats').style.display = 'none';
- }
-
- function renderList() {
- if (!cachedSkus.length) {
- content.innerHTML = `
- <div class="empty">
- <h3>No SKUs yet</h3>
- <p>Create your first checkout link — point it at any 402-enabled endpoint.</p>
- <p style="margin-top:18px"><button class="btn" onclick="document.getElementById('newBtn').click()">+ Create SKU</button></p>
- </div>`;
- $('stats').style.display = 'none';
- return;
- }
- // roll-up stats
- const totalCalls = cachedSkus.reduce((s, x) => s + (x.paid_calls || 0), 0);
- const totalAtomics = cachedSkus.reduce((s, x) => s + Number(x.gross_atomics || 0), 0);
- $('s-skus').textContent = cachedSkus.length;
- $('s-calls').textContent = totalCalls;
- $('s-revenue').innerHTML = `${fmtUsdc(totalAtomics)}<span class="unit"> USDC</span>`;
- $('stats').style.display = 'grid';
-
- content.innerHTML = `<div class="sku-table">${cachedSkus.map((s) => `
- <div class="sku-row" data-id="${s.id}">
- <div>
- <div class="name">${escapeHtml(s.merchant_name)} · ${escapeHtml(s.action_name)}</div>
- <div class="slug">/pay/c/${escapeHtml(s.slug)}</div>
- </div>
- <div class="calls"><strong>${s.paid_calls || 0}</strong> calls</div>
- <div class="revenue">${fmtUsdc(s.gross_atomics)}</div>
- <div class="actions">
- <button class="btn ghost" data-act="open">Details</button>
- </div>
- </div>
- `).join('')}</div>`;
- content.querySelectorAll('.sku-row').forEach((row) => {
- const id = row.dataset.id;
- row.querySelector('[data-act="open"]').addEventListener('click', () => openDrawer(id));
- });
- }
-
- // ─── Modal (create / edit) ───
- const modal = $('modal');
- const modalTitle = $('modalTitle');
- const skuForm = $('skuForm');
- const saveBtn = $('saveBtn');
- const formError = $('formError');
- const bodyLabel = $('bodyLabel');
-
- function openModal(sku) {
- editingId = sku?.id || null;
- modalTitle.textContent = sku ? 'Edit SKU' : 'New SKU';
- saveBtn.textContent = sku ? 'Save' : 'Create';
- formError.style.display = 'none';
- skuForm.reset();
- if (sku) {
- for (const [k, v] of Object.entries(sku)) {
- if (k === 'target_body' && v) skuForm.target_body.value = JSON.stringify(v, null, 2);
- else if (skuForm[k] != null && v != null) skuForm[k].value = v;
- }
- }
- toggleBody();
- modal.classList.add('show');
- }
- function closeModal() {
- modal.classList.remove('show');
- editingId = null;
- }
- function toggleBody() {
- bodyLabel.style.display = skuForm.target_method.value === 'POST' ? '' : 'none';
- }
- skuForm.target_method.addEventListener('change', toggleBody);
-
- $('newBtn').addEventListener('click', () => openModal(null));
- $('modalClose').addEventListener('click', closeModal);
- $('cancelBtn').addEventListener('click', closeModal);
- modal.addEventListener('click', (e) => { if (e.target === modal) closeModal(); });
-
- skuForm.addEventListener('submit', async (e) => {
- e.preventDefault();
- formError.style.display = 'none';
- saveBtn.disabled = true;
- try {
- const fd = new FormData(skuForm);
- const payload = Object.fromEntries(fd.entries());
- // Drop empties so PATCH doesn't clobber existing values.
- for (const k of Object.keys(payload)) if (payload[k] === '') delete payload[k];
- if (payload.target_body) {
- try { payload.target_body = JSON.parse(payload.target_body); }
- catch { throw new Error('Request body must be valid JSON.'); }
- } else delete payload.target_body;
-
- const url = editingId ? `/api/x402-skus?id=${editingId}` : '/api/x402-skus';
- const method = editingId ? 'PATCH' : 'POST';
- const r = await fetch(url, {
- method, credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify(payload),
- });
- const data = await r.json();
- if (!r.ok) throw new Error(data.error_description || data.error || `HTTP ${r.status}`);
- closeModal();
- await loadList();
- } catch (err) {
- formError.textContent = err.message;
- formError.style.display = '';
- } finally {
- saveBtn.disabled = false;
- }
- });
-
- // ─── Drawer (detail) ───
- const drawer = $('drawer');
- let openSkuId = null;
- async function openDrawer(id) {
- openSkuId = id;
- drawer.classList.add('show');
- try {
- const r = await fetch(`/api/x402-skus?id=${id}&stats=1`, { credentials: 'include' });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- const { sku, stats, recent } = await r.json();
- renderDrawer(sku, stats, recent);
- } catch (err) {
- $('d-calls').innerHTML = `<div class="form-error">${escapeHtml(err.message)}</div>`;
- }
- }
- function closeDrawer() {
- drawer.classList.remove('show');
- openSkuId = null;
- }
- function renderDrawer(sku, stats, recent) {
- $('d-merchant').textContent = sku.merchant_name;
- $('d-action').textContent = sku.action_name;
- const publicUrl = `${location.origin}/pay/c/${sku.slug}`;
- $('d-url-text').textContent = publicUrl;
- $('d-url-copy').onclick = async () => {
- await navigator.clipboard.writeText(publicUrl);
- $('d-url-copy').textContent = '✓';
- $('d-url-copy').classList.add('copied');
- setTimeout(() => { $('d-url-copy').textContent = 'copy'; $('d-url-copy').classList.remove('copied'); }, 1600);
- };
- $('d-s-calls').textContent = stats.paid_calls || 0;
- $('d-s-revenue').innerHTML = `${fmtUsdc(stats.gross_atomics)}<span class="unit"> USDC</span>`;
- $('d-s-payers').textContent = stats.unique_payers || 0;
- $('d-endpoint').innerHTML = `<span style="word-break:break-all">${escapeHtml(sku.target_method)} ${escapeHtml(sku.target_endpoint)}</span>`;
- if (recent?.length) {
- $('d-calls').innerHTML = recent.map((c) => {
- const netLabel = c.network?.startsWith('solana') ? 'sol' : c.network === 'eip155:8453' ? 'base' : c.network?.slice(0, 8);
- const explorer = c.tx_signature
- ? (c.network?.startsWith('solana') ? `https://solscan.io/tx/${c.tx_signature}` : `https://basescan.org/tx/${c.tx_signature}`)
- : null;
- const who = c.payer_address ? `${c.payer_address.slice(0, 6)}…${c.payer_address.slice(-4)}` : '—';
- return `<div class="call-row">
- <span class="ago">${fmtAgo(c.paid_at)}</span>
- <span class="who">${escapeHtml(who)}</span>
- <span class="amount">${fmtUsdc(c.amount_atomics)}</span>
- <span class="net">${explorer ? `<a href="${explorer}" target="_blank">${netLabel} ↗</a>` : escapeHtml(netLabel || '—')}</span>
- </div>`;
- }).join('');
- } else {
- $('d-calls').innerHTML = `<div style="color:var(--muted);font-family:inherit;font-size:13px">No calls yet. Share your link to start collecting.</div>`;
- }
- $('d-edit').onclick = () => { closeDrawer(); openModal(sku); };
- $('d-open').onclick = () => window.open(publicUrl, '_blank');
- $('d-archive').onclick = async () => {
- if (!confirm(`Archive "${sku.merchant_name} · ${sku.action_name}"? The link will stop working.`)) return;
- const r = await fetch(`/api/x402-skus?id=${sku.id}`, { method: 'DELETE', credentials: 'include' });
- if (r.ok) { closeDrawer(); await loadList(); }
- else alert('Archive failed: ' + (await r.text()));
- };
- }
-
- // Click outside drawer to close
- document.addEventListener('click', (e) => {
- if (!drawer.classList.contains('show')) return;
- if (drawer.contains(e.target)) return;
- if (e.target.closest('.sku-row')) return;
- closeDrawer();
- });
- document.addEventListener('keydown', (e) => {
- if (e.key !== 'Escape') return;
- if (drawer.classList.contains('show')) closeDrawer();
- if (modal.classList.contains('show')) closeModal();
- });
-
- loadList();
-</script>
-
- <script src="/brand.js" defer></script>
-</body>
-</html>