Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: wire remix, DM, and coin-launch-graduation events into the notification bell
fudjia5476460c0124
diff --git a/api/_lib/feed.js b/api/_lib/feed.jsindex 64e6250a3..7045d7c05 100644--- a/api/_lib/feed.js+++ b/api/_lib/feed.js@@ -79,6 +79,8 @@ export const USER_EVENT_TYPES = new Set(['reply', // new reply to an agent interaction'follow', // someone followed you; { actor, follower_username, link }'agent_review', // someone reviewed your agent; { actor, agent_id, agent_name, rating, link }+ 'dm_received', // a friend sent you a DM while you were away; { actor, link }+ 'pump_launch_filled',// a launch you own graduated its bonding curve; { name, mint, link }// types already produced by purchase-confirm / buy-asset confirm flows'skill_purchased','skill_purchase_confirmed',diff --git a/api/_lib/friends-store.js b/api/_lib/friends-store.jsindex 759ddb949..d19914d36 100644--- a/api/_lib/friends-store.js+++ b/api/_lib/friends-store.js@@ -25,6 +25,19 @@ function toProfile(row) {};}+// Public display profile for a single account — used where a caller (e.g. the+// DM notification write path) needs a display name/link but isn't already+// walking the friend graph. Returns null for a missing/deleted account.+export async function getPublicProfile(userId) {+ if (!userId) return null;+ const [row] = await sql`+ select id, display_name, username, avatar_url from users+ where id = ${userId} and deleted_at is null+ limit 1+ `;+ return toProfile(row);+}+// ── search ───────────────────────────────────────────────────────────────────// Find accounts by display name or username, excluding the caller and anyone// they've already muted. The caller's existing relationship to each hit isdiff --git a/api/_lib/notify-prefs.js b/api/_lib/notify-prefs.jsindex 0a9d128f7..f0c333ba9 100644--- a/api/_lib/notify-prefs.js+++ b/api/_lib/notify-prefs.js@@ -75,6 +75,9 @@ const TYPE_CATEGORY = {embed: 'social',mention: 'social',fork: 'social',+ follow: 'social',+ dm_received: 'social',+ agent_review: 'social',irl_interaction: 'irl',irl_reply: 'irl',@@ -197,10 +200,13 @@ const PUSH_COPY = {sale: () => ['You made a sale 🛒', 'Your agent made a sale'],pump_launch_filled: (p) => ['Your launch filled 🚀', p.name ? `${p.name} hit its target` : 'Your launch reached its target'],embed: () => ['New embed 🔗', 'Your creation was embedded somewhere new'],- remix: () => ['Remixed 🔄', 'Someone remixed your creation'],+ remix: (p) => ['Remixed 🔄', p.royaltyPaid && p.royaltyUsd ? `Someone remixed your creation — you earned $${Number(p.royaltyUsd).toFixed(3)}` : 'Someone remixed your creation'],fork: () => ['Forked 🍴', 'Someone forked your agent'],reply: () => ['New reply 💬', 'New reply on your agent'],mention: () => ['You were mentioned 📣', 'Your agent was mentioned'],+ follow: (p) => ['New follower 👤', p.actor ? `${p.actor} started following you` : 'Someone started following you'],+ dm_received: (p) => ['New message 💬', p.actor ? `${p.actor} sent you a message` : 'You have a new message'],+ agent_review: (p) => ['New review ⭐', p.actor ? `${p.actor} reviewed your agent` : 'Your agent received a review'],irl_interaction: (p) => ['Met in person 📍', p.message ? `“${p.message}”` : 'Someone interacted with your agent in person'],irl_reply: (p) => ['Agent replied 💬', p.message ? `“${p.message}”` : 'An agent replied to your message'],pump_alert: (p) => ['Market alert 📈', p.summary || 'A token alert you configured just fired'],diff --git a/api/cron/[name].js b/api/cron/[name].jsindex a90acd28f..7db6d8241 100644--- a/api/cron/[name].js+++ b/api/cron/[name].js@@ -66,6 +66,7 @@ import { sendEmail } from '../_lib/email.js';import { fetchSafePublicUrl } from '../_lib/ssrf-guard.js';import { runPumpAlertRules } from '../_lib/pump-alert-runner.js';import { constantTimeEquals } from '../_lib/crypto.js';+import { publishUserEvent } from '../_lib/feed.js';// ─── Cron auth ───────────────────────────────────────────────────────────────//@@ -965,7 +966,7 @@ async function handlePumpAgentStats(req, res) {if (!requireCron(req, res)) return;const mints = await sql`- select id, mint, network from pump_agent_mints+ select id, mint, network, user_id, name from pump_agent_mintsorder by id limit ${PUMP_STATS_MAX_PER_RUN}`;@@ -1064,6 +1065,18 @@ async function handlePumpAgentStats(req, res) {} catch {// pumpfun_signals table optional}++ // Tell the launch owner their coin filled its bonding curve and+ // migrated — the platform already knew this the instant the flip+ // happened but had no way to surface it until now.+ if (m.user_id) {+ publishUserEvent(m.user_id, {+ type: 'pump_launch_filled',+ name: m.name || null,+ mint: m.mint,+ link: `/launches/${encodeURIComponent(m.mint)}`,+ });+ }}report.updated++;diff --git a/api/friends/messages.js b/api/friends/messages.jsindex dac44d684..3dd25c1fa 100644--- a/api/friends/messages.js+++ b/api/friends/messages.js@@ -13,7 +13,8 @@ import { requireCsrf } from '../_lib/csrf.js';import { clientIp, limits } from '../_lib/rate-limit.js';import { resolveAccount } from '../_lib/account-auth.js';import { notifyMultiplayer } from '../_lib/presence-store.js';-import { areFriends, getThread, markThreadRead, sendDM } from '../_lib/friends-store.js';+import { areFriends, getThread, markThreadRead, sendDM, getPublicProfile } from '../_lib/friends-store.js';+import { publishUserEvent } from '../_lib/feed.js';const MAX_BODY_LEN = 2000;@@ -80,5 +81,20 @@ export default wrap(async (req, res) => {}notifyMultiplayer('dm', to, { message });++ // Durable bell notification alongside the live socket push, so a recipient+ // who is offline (or on a different page than /walk) still learns about the+ // message on their next visit — the socket-only path left them with no+ // record at all. Fire-and-forget; never blocks the send.+ getPublicProfile(me)+ .then((sender) => {+ publishUserEvent(to, {+ type: 'dm_received',+ actor: sender?.name || 'Someone',+ link: `/walk?dm=${encodeURIComponent(me)}`,+ });+ })+ .catch(() => {});+return json(res, 200, { data: { message } });});diff --git a/api/x402/remix-asset.js b/api/x402/remix-asset.jsindex 7828a627d..a057c9386 100644--- a/api/x402/remix-asset.js+++ b/api/x402/remix-asset.js@@ -28,6 +28,7 @@ import { atomicsToUsd } from '../_lib/remix-royalty.js';import { composeRefinement } from '../../mcp-server/src/tools/_lineage.js';import { generate, originFromReq, viewerUrl } from '../_mcp-studio/forge-client.js';import remixAssetListing from '../_lib/service-catalog/services/remix-asset.js';+import { publishUserEvent } from '../_lib/feed.js';// $0.25 — the cost of a generation. The creator royalty comes OUT of this fee// (the platform's share), never as an extra charge to the remixer.@@ -146,6 +147,22 @@ async function handleRemix({ req, requirement }) {royalty = { paid: false, reason: 'royalty_transfer_failed', error: err.message };}+ // Notify the source creator (real signed-in creators only — anonymous+ // forge_creations rows have no user_id to notify). Fire-and-forget, never+ // blocks the response; folds the royalty outcome into the same notice so a+ // creator learns "you were remixed" and "you got paid" in one line.+ if (source.userId) {+ publishUserEvent(source.userId, {+ type: 'remix',+ actor: 'Someone',+ link: remixCreationId ? viewerUrl(base, job.glb_url) : '/profile',+ sourcePrompt: source.prompt,+ creationId: remixCreationId,+ royaltyPaid: royalty.paid,+ royaltyUsd: royalty.creatorUsd ?? 0,+ });+ }+return {ok: true,remix: {diff --git a/public/nav.css b/public/nav.cssindex 3fd927052..e91e6da73 100644--- a/public/nav.css+++ b/public/nav.css@@ -238,6 +238,15 @@.notif-mark-all:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.06); }.notif-mark-all:focus-visible { outline: 2px solid rgba(255,255,255,0.3); outline-offset: 1px; }.notif-mark-all:disabled { opacity: 0.45; cursor: default; }+.notif-prefs-link {+ display: flex; align-items: center; justify-content: center;+ width: 24px; height: 24px; border-radius: 6px;+ font-size: var(--text-sm); color: rgba(255,255,255,0.4);+ text-decoration: none; line-height: 1;+ transition: color 0.12s, background 0.12s;+}+.notif-prefs-link:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.06); }+.notif-prefs-link:focus-visible { outline: 2px solid rgba(255,255,255,0.3); outline-offset: 1px; }.notif-panel-body { overflow-y: auto; flex: 1; }.notif-panel-body::-webkit-scrollbar { width: 4px; }.notif-panel-body::-webkit-scrollbar-track { background: transparent; }diff --git a/src/dashboard-next/pages/settings.js b/src/dashboard-next/pages/settings.jsindex 8dd4aa5c9..b5daa4562 100644--- a/src/dashboard-next/pages/settings.js+++ b/src/dashboard-next/pages/settings.js@@ -19,7 +19,7 @@// PATCH /api/dashboard/prefs body prefs patchimport { mountShell } from '../shell.js';-import { requireUser, get, post, del, patch, esc, relTime, ApiError } from '../api.js';+import { requireUser, get, post, put, del, patch, esc, relTime, ApiError } from '../api.js';import { emptyStateHTML, errorStateHTML, ensureStateKitStyles, attachRetry } from '../../shared/state-kit.js';const MONO = `'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace`;@@ -114,9 +114,10 @@ async function loadContent(host) {const retry = () => loadContent(host);- const [sessionsResp, notifResp, summaryResp, usageResp, prefsResp] = await Promise.all([+ const [sessionsResp, notifResp, notifPrefsResp, summaryResp, usageResp, prefsResp] = await Promise.all([safeGet('/api/auth/sessions'),safeGet('/api/notifications?limit=20'),+ safeGet('/api/notifications/preferences'),safeGet('/api/billing/summary'),safeGet('/api/usage/summary'),safeGet('/api/dashboard/prefs'),@@ -128,6 +129,7 @@ async function loadContent(host) {host.appendChild(renderTheme());host.appendChild(renderSessions(sessionsResp, retry));host.appendChild(renderNotifications(notifResp, retry));+ host.appendChild(renderNotificationPrefs(notifPrefsResp, retry));host.appendChild(renderDefaultNetwork(prefs));host.appendChild(renderStorage(summaryResp, retry));host.appendChild(renderLlmUsage(usageResp, retry));@@ -328,6 +330,129 @@ function renderNotifications(resp, onRetry) {return panel;}+// ── Notification preferences ────────────────────────────────────────────────+// Per-type mute control: which channel(s) deliver each category of notification+// (sales, purchases, social, irl, alerts, account). Backed by the real+// notification_preferences table (api/_lib/notify-prefs.js is the single+// source of truth for categories/channels/defaults) — every write path in+// api/_lib/notify.js checks this before sending push/email, so a toggle here+// takes effect on the very next event, not just in the UI.++const CHANNEL_LABEL = { in_app: 'In-app', push: 'Push', email: 'Email', telegram: 'Telegram' };++function renderNotificationPrefs(resp, onRetry) {+ const panel = document.createElement('div');+ panel.className = 'dn-panel';+ panel.setAttribute('aria-label', 'Notification preferences');++ if (!resp.ok) {+ panel.innerHTML = `+ <div style="margin-bottom:14px">+ <div class="dn-panel-title">Notification preferences</div>+ <div class="dn-panel-sub" style="margin:2px 0 0">Choose which channels deliver each kind of notification.</div>+ </div>+ <div data-slot="notif-prefs-err"></div>`;+ const errHost = panel.querySelector('[data-slot="notif-prefs-err"]');+ errHost.innerHTML = errorStateHTML({+ title: "Couldn't load notification preferences",+ body: 'We couldn’t reach the preference center. Try again in a moment.',+ });+ attachRetry(errHost, onRetry);+ return panel;+ }++ const body = resp.data || {};+ const categories = Array.isArray(body.categories) ? body.categories : [];+ const channels = Array.isArray(body.channels) ? body.channels : ['in_app', 'push', 'email', 'telegram'];+ const matrix = body.prefs?.categories || {};+ const subscribedDevices = body.push?.subscribed_devices ?? 0;++ panel.innerHTML = `+ <div style="margin-bottom:14px">+ <div class="dn-panel-title">Notification preferences</div>+ <div class="dn-panel-sub" style="margin:2px 0 0">Mute noisy categories per channel — the bell (in-app) always stays available so nothing is ever silently lost.</div>+ </div>+ ${!categories.length ? emptyStateHTML({+ icon: '',+ title: 'No preference categories yet',+ body: 'The preference center will appear here once it has categories to show.',+ compact: true,+ }) : `+ <div style="overflow-x:auto">+ <table style="width:100%;border-collapse:collapse;font-size:13px">+ <thead>+ <tr style="text-align:left;color:var(--nxt-ink-fade);border-bottom:1px solid var(--nxt-stroke)">+ <th style="padding:8px 10px;font-weight:500;min-width:180px">Category</th>+ ${channels.map((ch) => `<th style="padding:8px 10px;font-weight:500;text-align:center">${esc(CHANNEL_LABEL[ch] || ch)}</th>`).join('')}+ </tr>+ </thead>+ <tbody>+ ${categories.map((cat) => `+ <tr style="border-bottom:1px solid var(--nxt-stroke)" data-cat-row="${esc(cat.key)}">+ <td style="padding:10px">+ <div style="font-weight:500">${esc(cat.label || cat.key)}</div>+ ${cat.description ? `<div style="font-size:12px;color:var(--nxt-ink-dim);margin-top:2px">${esc(cat.description)}</div>` : ''}+ </td>+ ${channels.map((ch) => {+ const on = matrix?.[cat.key]?.[ch] ?? false;+ const disabled = ch === 'telegram' && !body.prefs?.telegram_chat_id;+ return `+ <td style="padding:10px;text-align:center">+ <button type="button" role="switch" class="set-switch" data-notif-cat="${esc(cat.key)}" data-notif-ch="${esc(ch)}"+ aria-checked="${on ? 'true' : 'false'}"+ ${disabled ? 'disabled title="Link a Telegram chat id to enable"' : ''}+ aria-label="${esc(cat.label || cat.key)} via ${esc(CHANNEL_LABEL[ch] || ch)}"+ style="${disabled ? 'opacity:.35;cursor:not-allowed' : ''}"></button>+ </td>+ `;+ }).join('')}+ </tr>+ `).join('')}+ </tbody>+ </table>+ </div>+ <div style="margin-top:12px;font-size:12px;color:var(--nxt-ink-fade)">+ ${subscribedDevices > 0+ ? `Push is enabled on ${subscribedDevices} device${subscribedDevices === 1 ? '' : 's'}.`+ : 'No devices are subscribed to push yet — enable it from the notification bell.'}+ </div>+ <div style="margin-top:16px;padding-top:14px;border-top:1px solid var(--nxt-stroke);display:flex;justify-content:flex-end">+ <button class="dn-btn primary" data-action="save-notif-prefs">Save notification preferences</button>+ </div>+ `}+ `;++ panel.querySelectorAll('[data-notif-cat]').forEach((sw) => {+ sw.addEventListener('click', () => {+ if (sw.disabled) return;+ sw.setAttribute('aria-checked', sw.getAttribute('aria-checked') === 'true' ? 'false' : 'true');+ });+ });++ panel.querySelector('[data-action="save-notif-prefs"]')?.addEventListener('click', async (e) => {+ const btn = e.currentTarget;+ const next = {};+ panel.querySelectorAll('[data-notif-cat]').forEach((sw) => {+ const cat = sw.dataset.notifCat;+ const ch = sw.dataset.notifCh;+ (next[cat] ??= {})[ch] = sw.getAttribute('aria-checked') === 'true';+ });+ btn.disabled = true;+ btn.textContent = 'Saving…';+ try {+ await put('/api/notifications/preferences', { categories: next });+ toast('Notification preferences saved');+ } catch (err) {+ toast(err?.message || 'Save failed');+ } finally {+ btn.disabled = false;+ btn.textContent = 'Save notification preferences';+ }+ });++ return panel;+}+// ── Storage ────────────────────────────────────────────────────────────────function renderStorage(resp, onRetry) {diff --git a/src/notifications.js b/src/notifications.jsindex 64f316a6c..bea570943 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -81,6 +81,10 @@ const TYPE_ICON = {reply: '💬',irl_interaction: '📍',irl_reply: '💬',+ follow: '👤',+ dm_received: '💬',+ pump_launch_filled: '🚀',+ agent_review: '⭐',};function notifLabel(n) {@@ -114,7 +118,17 @@ function notifLabel(n) {case 'embed':return `Your creation was embedded`;case 'remix':- return `Someone remixed your creation`;+ return p.royaltyPaid && p.royaltyUsd+ ? `Someone remixed your creation — you earned $${Number(p.royaltyUsd).toFixed(3)} in royalties`+ : `Someone remixed your creation`;+ case 'follow':+ return p.actor ? `${p.actor} started following you` : `Someone started following you`;+ case 'dm_received':+ return p.actor ? `New message from ${p.actor}` : `You have a new message`;+ case 'pump_launch_filled':+ return p.name ? `${p.name} hit its funding target and graduated` : `Your launch hit its funding target and graduated`;+ case 'agent_review':+ return p.actor ? `${p.actor} reviewed your agent${p.rating ? ` (${p.rating}★)` : ''}` : `Your agent received a new review`;case 'reply':return `New reply on your agent`;case 'irl_interaction':@@ -375,7 +389,10 @@ class NotificationInbox {el.innerHTML = `<div class="notif-panel-head"><span class="notif-panel-title">Notifications</span>- <button type="button" class="notif-mark-all btn-ghost" aria-label="Mark all as read">Mark all read</button>+ <div style="display:flex;align-items:center;gap:4px">+ <a href="/dashboard/settings" class="notif-prefs-link btn-ghost" aria-label="Notification preferences" title="Notification preferences">⚙</a>+ <button type="button" class="notif-mark-all btn-ghost" aria-label="Mark all as read">Mark all read</button>+ </div></div><div class="notif-panel-body" aria-live="polite" aria-atomic="false"></div>`;diff --git a/src/walk.js b/src/walk.jsindex 1ebcaa50c..a2a7b1742 100644--- a/src/walk.js+++ b/src/walk.js@@ -382,6 +382,14 @@ function toggleFriendsPanel() {if (friendsHudBtn) friendsHudBtn.addEventListener('click', toggleFriendsPanel);if (friendsCloseBtn) friendsCloseBtn.addEventListener('click', closeFriendsPanel);+// Deep link from a DM notification: /walk?dm=<friendId> opens the panel+// straight into that thread instead of the friend list.+const _dmDeepLink = new URLSearchParams(location.search).get('dm');+if (_dmDeepLink) {+ openFriendsPanel();+ _friendsPanel?.client?.openThread?.(_dmDeepLink);+}+// Close on backdrop click.if (friendsOverlay) {friendsOverlay.addEventListener('pointerdown', (e) => {