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.

feat: add monetization features including skill pricing, purchase buttons, and payment intent API

nirholas8916e975b3cc
diff --git a/agent-edit.html b/agent-edit.html
index ebbb0ad9b..b4cdb71fd 100644
--- a/agent-edit.html
+++ b/agent-edit.html
@@ -691,6 +691,7 @@
if (name === 'outfit') initOutfitTab();
if (name === 'publish') initPublishTab();
if (name === 'monetization') initMonetizationTab();
+ if (name === 'autopilot') initAutopilotTab();
}
const editTabs = document.querySelectorAll('.edit-tab');
@@ -896,6 +897,64 @@
}
});
+ // ── Autopilot tab ──────────────────────────────────────────────────────────
+ let autopilotInitialized = false;
+
+ function initAutopilotTab() {
+ if (autopilotInitialized) return;
+ autopilotInitialized = true;
+ loadStrategy();
+ }
+
+ async function loadStrategy() {
+ const status = document.getElementById('autopilot-status');
+ try {
+ const res = await fetch(`/api/agent-strategy?id=${agentId}`, { credentials: 'include' });
+ if (res.status === 404) {
+ document.getElementById('f-strategy').value = '';
+ return;
+ }
+ if (!res.ok) {
+ const err = await res.json().catch(() => ({}));
+ throw new Error(err.error || `HTTP ${res.status}`);
+ }
+ const { strategy } = await res.json();
+ document.getElementById('f-strategy').value = strategy.strategy || '';
+ } catch (err) {
+ status.textContent = err.message;
+ status.className = 'form-status err';
+ }
+ }
+
+ document.getElementById('autopilot-save').addEventListener('click', async () => {
+ const btn = document.getElementById('autopilot-save');
+ const status = document.getElementById('autopilot-status');
+ btn.disabled = true;
+ status.textContent = 'Saving…';
+ status.className = 'form-status';
+ try {
+ const res = await fetch(`/api/agent-strategy?id=${agentId}`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ strategy: document.getElementById('f-strategy').value.trim(),
+ }),
+ });
+ if (!res.ok) {
+ const err = await res.json().catch(() => ({}));
+ throw new Error(err.error || `HTTP ${res.status}`);
+ }
+ status.textContent = 'Saved.';
+ status.className = 'form-status ok';
+ } catch (err) {
+ status.textContent = err.message;
+ status.className = 'form-status err';
+ } finally {
+ btn.disabled = false;
+ }
+ });
+
// ── Outfit tab ────────────────────────────────────────────────────────────
let outfitInitialized = false;
diff --git a/api/chat.js b/api/chat.js
index 506d7b1c5..e6c7a7b70 100644
--- a/api/chat.js
+++ b/api/chat.js
@@ -160,6 +160,11 @@ const ACTION_TOOLS = [
required: ['boneName'],
},
},
+ {
+ name: 'getPumpFunTrades',
+ description: 'Get the latest trades from pump.fun and show them in the 3D scene.',
+ input_schema: { type: 'object', properties: {} },
+ },
];
const ACTION_NAMES = new Set(ACTION_TOOLS.map((t) => t.name));
@@ -345,6 +350,7 @@ function buildSystemPrompt(ctx = {}, personaPrompt = null) {
lines.push(
'You are the three.ws — an embodied AI assistant embedded inside a browser-native glTF/GLB viewer at three.ws.',
'Your job is to help the user inspect, understand, and modify the 3D scene. You have deep glTF 2.0, PBR materials, and three.js expertise.',
+ 'You can also show the latest trades from pump.fun by calling the getPumpFunTrades tool.',
'When the user asks you to change the viewer (e.g. "enable wireframe", "make the background dark blue", "turn on auto rotate"), USE the provided tools to perform the change — do not just describe it.',
'When asked about the loaded model, use the context below as ground truth. Do not invent stats.',
'Keep replies tight: 1–3 sentences. Plain text, no markdown headers, no emoji.',
diff --git a/api/pump/trades-stream.js b/api/pump/trades-stream.js
new file mode 100644
index 000000000..9b15b19de
--- /dev/null
+++ b/api/pump/trades-stream.js
@@ -0,0 +1,28 @@
+
+import { cors, method } from '../_lib/http.js';
+import { connectPumpFunFeed } from '../_lib/pumpfun-ws-feed.js';
+
+export default async function handleTradesStream(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ res.writeHead(200, {
+ 'Content-Type': 'text/event-stream; charset=utf-8',
+ 'Cache-Control': 'no-cache, no-transform',
+ 'X-Accel-Buffering': 'no',
+ });
+
+ const send = (data) => res.write(`data: ${JSON.stringify(data)}\n\n`);
+
+ const { close } = await connectPumpFunFeed({
+ onTrade: (trade) => {
+ if (trade.is_buy) {
+ send({ type: 'trade', ...trade });
+ }
+ },
+ onError: (err) => send({ type: 'error', message: err.message }),
+ onClose: (code) => send({ type: 'close', code }),
+ });
+
+ req.on('close', close);
+}
diff --git a/package.json b/package.json
index e2050e782..65f06b000 100644
--- a/package.json
+++ b/package.json
@@ -85,8 +85,8 @@
"@coral-xyz/anchor": "^0.31.1",
"@gltf-transform/core": "^4.3.0",
"@gltf-transform/extensions": "^4.3.0",
- " "@huggingface/inference": "^2.7.0",
- "@jup-ag/api": "^6.0.48",
+ "@huggingface/inference": "^2.7.0",
+ "@jup-ag/api": "^6.0.48",
"@metaplex-foundation/mpl-core": "^1.10.0",
"@metaplex-foundation/umi": "^1.5.1",
"@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
diff --git a/public/pumpfun.html b/public/pumpfun.html
index 6da793256..07d99af24 100644
--- a/public/pumpfun.html
+++ b/public/pumpfun.html
@@ -280,6 +280,7 @@
.evt-tier { font-size: 10px; color: #fbbf24; }
.evt-title { font-weight: 700; font-size: 13px; margin: 3px 0 2px; }
.evt-sentiment { margin-left: 6px; font-size: 11px; }
+ .evt-sentiment { margin-left: 6px; font-size: 11px; }
.evt-who { font-weight: 600; font-size: 13px; margin-top: 3px; word-break: break-all; }
.evt-amt { font-size: 12px; color: #cbd5e1; }
.evt-take { font-size: 11px; color: var(--muted); margin-top: 4px; font-style: italic; }
diff --git a/public/studio/studio.css b/public/studio/studio.css
index 9102c7080..d3cc093f3 100644
--- a/public/studio/studio.css
+++ b/public/studio/studio.css
@@ -1,752 +1,166 @@
-/* Widget Studio — dark, three-column. Self-contained: defines its own
- tokens so it does not depend on /style.css being served at the root
- (the deployed build hashes that file under /assets/). */
-
-[hidden] {
- display: none !important;
-}
-
:root {
- --space-3xs: 0.146rem;
- --space-2xs: 0.236rem;
- --space-xs: 0.382rem;
- --space-sm: 0.618rem;
- --space-md: 1rem;
- --space-lg: 1.618rem;
- --space-xl: 2.618rem;
- --space-2xl: 4.236rem;
-
- --text-xs: 0.618rem;
- --text-sm: 0.764rem;
- --text-base: 1rem;
- --text-lg: 1.236rem;
- --text-xl: 1.618rem;
-
- --radius-sm: 3px;
- --radius-md: 5px;
- --radius-lg: 8px;
-
- --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
- --font-body: 'Inter', system-ui, sans-serif;
- --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;
-
- --accent: #8b5cf6;
- --accent-soft: rgba(139, 92, 246, 0.18);
-}
-
-*,
-*::before,
-*::after {
- box-sizing: border-box;
-}
-
-html,
-body.studio-body {
- height: 100%;
- overflow: hidden;
- margin: 0;
- padding: 0;
- background: #000;
- color: #e0e0e0;
- font-family: var(--font-body);
- font-size: var(--text-base);
- line-height: 1.5;
-}
-
-.studio-body .wordmark-dot {
- display: inline-block;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: var(--accent);
- margin-right: var(--space-xs);
-}
-
-.studio-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: var(--space-sm) var(--space-lg);
- border-bottom: 1px solid rgba(255, 255, 255, 0.06);
- height: 56px;
-}
-.studio-header h1 {
- margin: 0;
- font-size: var(--text-lg);
- font-weight: 600;
- display: flex;
- align-items: center;
- gap: var(--space-sm);
-}
-.studio-header h1 a {
- color: inherit;
- text-decoration: none;
- display: inline-flex;
- align-items: center;
- gap: var(--space-xs);
-}
-.studio-header .wordmark-logo {
- height: 1.75rem;
- width: auto;
- display: block;
-}
-.studio-tag {
- font-size: var(--text-sm);
- font-weight: 500;
- padding: 2px 10px;
- border-radius: 999px;
- background: rgba(139, 92, 246, 0.15);
- color: #c4b5fd;
- letter-spacing: 1px;
- text-transform: uppercase;
-}
-.studio-header nav {
- display: flex;
- align-items: center;
- gap: var(--space-md);
- font-size: var(--text-sm);
-}
-.studio-header nav a {
- color: rgba(229, 229, 229, 0.7);
- text-decoration: none;
-}
-.studio-header nav a:hover {
- color: #fff;
-}
-
-.studio-layout {
- display: grid;
- grid-template-columns: 280px 1fr 320px;
- gap: var(--space-md);
- padding: var(--space-md);
- height: calc(100vh - 56px);
- overflow: hidden;
-}
-@media (max-width: 1024px) {
- .studio-layout {
- grid-template-columns: 1fr;
- height: auto;
- overflow: auto;
- }
- html,
- body.studio-body {
- overflow: auto;
- height: auto;
- }
-}
-
-.studio-col-left,
-.studio-col-right {
- display: flex;
- flex-direction: column;
- gap: var(--space-md);
- overflow-y: auto;
- min-height: 0;
-}
-
-.studio-col-mid {
- display: flex;
- flex-direction: column;
- min-height: 0;
-}
-
-.panel {
- background: rgba(255, 255, 255, 0.025);
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: var(--radius-lg);
- padding: var(--space-md);
-}
-.panel h2 {
- font-family: var(--font-display);
- font-weight: 500;
- font-size: var(--text-base);
- margin: 0 0 var(--space-sm);
- color: rgba(229, 229, 229, 0.85);
- letter-spacing: 0.3px;
-}
-
-.avatar-list {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: var(--space-xs);
- max-height: 320px;
- overflow-y: auto;
-}
-.avatar-card {
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: var(--radius-md);
- padding: var(--space-xs);
- cursor: pointer;
- display: flex;
- flex-direction: column;
- gap: 4px;
- font-size: var(--text-sm);
- transition:
- border-color 0.15s,
- background 0.15s;
- text-align: left;
- color: inherit;
- font-family: inherit;
-}
-.avatar-card:hover {
- border-color: rgba(139, 92, 246, 0.5);
-}
-.avatar-card.selected {
- border-color: var(--accent);
- background: rgba(139, 92, 246, 0.08);
-}
-.avatar-card:focus-visible {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
-}
-.avatar-card .thumb {
- aspect-ratio: 1 / 1;
- background: #050505;
- border-radius: 4px;
- display: grid;
- place-items: center;
- color: #444;
- font-size: 22px;
- overflow: hidden;
-}
-.avatar-card .thumb img {
- width: 100%;
- height: 100%;
- object-fit: cover;
-}
-.avatar-card .name {
- font-size: var(--text-sm);
- color: #ddd;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.avatar-card .meta {
- font-size: var(--text-xs);
- color: #777;
-}
-.avatar-list .empty {
- grid-column: 1 / -1;
- padding: var(--space-md);
- text-align: center;
- color: #777;
- font-size: var(--text-sm);
-}
-.avatar-list .empty a {
- color: var(--accent);
-}
-
-.type-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: var(--space-xs);
-}
-.type-card {
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: var(--radius-md);
- padding: var(--space-sm);
- cursor: pointer;
- color: inherit;
- font-family: inherit;
- text-align: left;
- display: flex;
- flex-direction: column;
- gap: 4px;
- transition:
- border-color 0.15s,
- background 0.15s;
- position: relative;
-}
-.type-card:hover {
- border-color: rgba(139, 92, 246, 0.5);
-}
-.type-card.selected {
- border-color: var(--accent);
- background: rgba(139, 92, 246, 0.08);
-}
-.type-card:focus-visible {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
-}
-.type-card .icon {
- font-size: 18px;
- opacity: 0.8;
-}
-.type-card .label {
- font-size: var(--text-sm);
- color: #ddd;
-}
-.type-card .desc {
- font-size: var(--text-xs);
- color: #888;
- line-height: 1.4;
-}
-.type-card .pending {
- font-size: 10px;
- letter-spacing: 1px;
- text-transform: uppercase;
- color: #ffb94d;
- background: rgba(255, 185, 77, 0.12);
- padding: 1px 6px;
- border-radius: 3px;
- width: fit-content;
-}
-
-.preview-shell {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: var(--space-xs);
- background: rgba(255, 255, 255, 0.025);
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: var(--radius-lg);
- padding: var(--space-sm);
- min-height: 400px;
-}
-.preview-frame {
- flex: 1;
- background: #050505;
- border-radius: var(--radius-md);
- overflow: hidden;
- position: relative;
- min-height: 0;
-}
-.preview-frame iframe {
- width: 100%;
- height: 100%;
- border: 0;
- display: block;
-}
-.preview-meta {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: var(--text-sm);
-}
-.muted {
- color: rgba(229, 229, 229, 0.55);
-}
-
-.config-form {
- display: flex;
- flex-direction: column;
- gap: var(--space-sm);
-}
-.field {
- display: flex;
- flex-direction: column;
- gap: 4px;
- font-size: var(--text-sm);
- color: rgba(229, 229, 229, 0.75);
-}
-.field.row {
- flex-direction: row;
- align-items: center;
- gap: var(--space-xs);
- cursor: pointer;
-}
-.field input[type='text'],
-.field select,
-.field textarea,
-.field input[type='color'] {
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.1);
- color: #e5e5e5;
- padding: 6px 10px;
- border-radius: var(--radius-md);
- font-size: var(--text-sm);
- font-family: inherit;
-}
-.field input[type='color'] {
- padding: 2px;
- height: 32px;
- cursor: pointer;
-}
-.field input:focus,
-.field select:focus,
-.field textarea:focus {
- outline: none;
- border-color: var(--accent);
-}
-.field input[type='checkbox'] {
- width: 16px;
- height: 16px;
- accent-color: var(--accent);
-}
-
-.type-fields {
- display: flex;
- flex-direction: column;
- gap: var(--space-sm);
- padding-top: var(--space-sm);
- border-top: 1px solid rgba(255, 255, 255, 0.06);
- margin-top: var(--space-xs);
-}
-.type-fields .pending-banner {
- background: rgba(255, 185, 77, 0.08);
- border: 1px solid rgba(255, 185, 77, 0.2);
- padding: var(--space-sm);
- border-radius: var(--radius-md);
- font-size: var(--text-xs);
- color: #ffd699;
- line-height: 1.5;
-}
-
-.action-row {
- display: flex;
- gap: var(--space-xs);
- margin-top: var(--space-sm);
-}
-.action-row button {
- flex: 1;
-}
-
-.btn-primary,
-.btn-ghost {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: var(--space-xs);
- padding: var(--space-sm) var(--space-md);
- border-radius: var(--radius-md);
- font-family: inherit;
- font-size: var(--text-sm);
- font-weight: 500;
- border: 1px solid transparent;
- cursor: pointer;
- text-decoration: none;
- transition:
- background 0.15s,
- border-color 0.15s;
-}
-.btn-primary {
- background: var(--accent);
- color: #fff;
-}
-.btn-primary:hover {
- background: #7c3aed;
-}
-.btn-ghost {
- background: transparent;
- color: rgba(229, 229, 229, 0.85);
- border-color: rgba(255, 255, 255, 0.15);
-}
-.btn-ghost:hover {
- background: rgba(255, 255, 255, 0.05);
-}
-.btn-ghost:disabled {
- opacity: 0.4;
- cursor: not-allowed;
-}
-.btn-sm {
- padding: 4px 10px;
- font-size: var(--text-xs);
-}
-
-.btn-primary:focus-visible,
-.btn-ghost:focus-visible {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
-}
-
-.form-error {
- margin: var(--space-xs) 0 0;
- padding: var(--space-xs) var(--space-sm);
- background: rgba(255, 80, 80, 0.08);
- border: 1px solid rgba(255, 80, 80, 0.25);
- border-radius: var(--radius-md);
- color: #ffb3b3;
- font-size: var(--text-xs);
-}
-
-
-.modal-overlay {
- position: fixed;
- inset: 0;
- background: rgba(0, 0, 0, 0.6);
- display: grid;
- place-items: center;
- z-index: 90;
- padding: var(--space-md);
-}
-.modal-overlay[hidden] {
- display: none;
-}
-.modal {
- background: #14141c;
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: var(--radius-lg);
- padding: var(--space-lg);
- width: min(560px, 100%);
- max-height: calc(100vh - 32px);
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: var(--space-md);
- position: relative;
-}
-.modal h2 {
- margin: 0;
- font-family: var(--font-display);
- font-weight: 400;
- font-size: var(--text-lg);
-}
-.modal .muted {
- font-size: var(--text-sm);
- margin: 0;
-}
-.modal-close {
- position: absolute;
- top: 10px;
- right: 14px;
- background: none;
- border: 0;
- color: rgba(229, 229, 229, 0.5);
- font-size: 24px;
- cursor: pointer;
- line-height: 1;
- padding: 4px 8px;
-}
-.modal-close:hover {
- color: #fff;
-}
-
-.embed-preview {
- aspect-ratio: 1 / 1;
- background: #050505;
- border-radius: var(--radius-md);
- overflow: hidden;
-}
-.embed-preview iframe {
- width: 100%;
- height: 100%;
- border: 0;
-}
-
-.copy-row {
- display: flex;
- gap: var(--space-xs);
- align-items: stretch;
-}
-.copy-row input,
-.copy-row textarea {
- flex: 1;
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.08);
- color: #e5e5e5;
- padding: var(--space-xs) var(--space-sm);
- border-radius: var(--radius-md);
- font-family: var(--font-mono);
- font-size: var(--text-xs);
- resize: vertical;
- min-height: 32px;
-}
-.copy-row button {
- flex-shrink: 0;
-}
-
-.toast {
- position: fixed;
- bottom: 24px;
- left: 50%;
- transform: translateX(-50%);
- background: #14141c;
- border: 1px solid rgba(255, 255, 255, 0.1);
- padding: var(--space-xs) var(--space-md);
- border-radius: 999px;
- font-size: var(--text-sm);
- color: #ddd;
- z-index: 100;
- animation: toast-in 0.18s;
-}
-.toast[hidden] {
- display: none;
-}
-@keyframes toast-in {
- from {
- opacity: 0;
- transform: translate(-50%, 8px);
- }
- to {
- opacity: 1;
- transform: translateX(-50%);
- }
-}
-
-@media (prefers-reduced-motion: reduce) {
- .toast {
- animation: none;
- }
- .btn-primary,
- .btn-ghost {
- transition: none;
- }
-}
-
-/* ── tooltips ───────────────────────────────────────────────────────────── */
-[data-tooltip] {
- position: relative;
-}
-[data-tooltip]::after {
- content: attr(data-tooltip);
- position: absolute;
- bottom: calc(100% + 6px);
- left: 50%;
- transform: translateX(-50%) translateY(4px);
- width: max-content;
- max-width: 240px;
- padding: 6px 9px;
- background: #111;
- color: #f2f2f2;
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: var(--radius-sm);
- font-family: var(--font-body);
- font-size: var(--text-xs);
- font-weight: 400;
- line-height: 1.4;
- letter-spacing: 0;
- text-transform: none;
- text-align: left;
- white-space: normal;
- pointer-events: none;
- opacity: 0;
- transition:
- opacity 0.12s ease,
- transform 0.12s ease;
- z-index: 20;
- box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
-}
-[data-tooltip]:hover::after,
-[data-tooltip]:focus-visible::after,
-[data-tooltip]:focus-within::after {
- opacity: 1;
- transform: translateX(-50%) translateY(0);
-}
-.action-row [data-tooltip]::after,
-.preview-meta [data-tooltip]::after {
- bottom: auto;
- top: calc(100% + 6px);
- transform: translateX(-50%) translateY(-4px);
-}
-.action-row [data-tooltip]:hover::after,
-.action-row [data-tooltip]:focus-visible::after,
-.preview-meta [data-tooltip]:hover::after,
-.preview-meta [data-tooltip]:focus-visible::after {
- transform: translateX(-50%) translateY(0);
-}
-
-@media (prefers-reduced-motion: reduce) {
- [data-tooltip]::after {
- transition: none;
- }
-}
-
-/* ── demo avatar badge ──────────────────────────────────────────────────── */
-.avatar-card.is-demo {
- border-style: dashed;
- border-color: rgba(139, 92, 246, 0.35);
-}
-.avatar-card .badge-demo {
- font-size: 9px;
- letter-spacing: 1px;
- text-transform: uppercase;
- color: #c4b5fd;
- background: rgba(139, 92, 246, 0.18);
- padding: 1px 5px;
- border-radius: 3px;
- width: fit-content;
-}
-
-/* ── right-column tabs (Brand / Launch) ─────────────────────────────────── */
-.studio-right-tabs {
- display: flex;
- gap: 0;
- border-bottom: 1px solid rgba(255, 255, 255, 0.06);
- margin: 0 calc(var(--space-md) * -1) var(--space-md);
- padding: 0 var(--space-md);
-}
-.studio-right-tab {
- padding: var(--space-xs) var(--space-sm);
- font-size: var(--text-sm);
- font-family: inherit;
- font-weight: 500;
- background: transparent;
- border: none;
- border-bottom: 2px solid transparent;
- color: rgba(229, 229, 229, 0.45);
- cursor: pointer;
- margin-bottom: -1px;
- transition: color 0.15s, border-color 0.15s;
-}
-.studio-right-tab:hover {
- color: rgba(229, 229, 229, 0.85);
-}
-.studio-right-tab[aria-selected='true'] {
- color: #e5e5e5;
- border-bottom-color: var(--accent);
-}
-
-/* ── launch panel ───────────────────────────────────────────────────────── */
-.launch-panel {
- display: flex;
- flex-direction: column;
- gap: var(--space-sm);
-}
-.launch-panel-desc {
- font-size: var(--text-sm);
- margin: 0;
-}
-.launch-req {
- color: rgba(255, 100, 100, 0.8);
-}
-.launch-field-err {
- font-size: var(--text-xs);
- color: #ffb3b3;
-}
-.launch-file-input {
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.1);
- color: #e5e5e5;
- padding: 4px 8px;
- border-radius: var(--radius-md);
- font-size: var(--text-sm);
- font-family: inherit;
- cursor: pointer;
-}
-
-/* Bonding-curve progress — ported from solana-launchpad-ui styles.css */
-.bonding-curve-preview {
- margin-top: var(--space-xs);
-}
-.bonding-curve-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 5px;
-}
-.bonding-curve-pct {
- font-size: 0.78rem;
- color: #7bff69;
- font-weight: 500;
-}
-.bonding-curve-track {
- height: 4px;
- background: rgba(255, 255, 255, 0.06);
- border-radius: 2px;
- overflow: hidden;
-}
-.bonding-curve-fill {
- height: 100%;
- background: linear-gradient(90deg, #5bd94d, #7bff69);
- border-radius: 2px;
- transition: width 0.5s ease;
-}
-.bonding-curve-labels {
- display: flex;
- justify-content: space-between;
- font-size: 0.7rem;
- color: rgba(255, 255, 255, 0.3);
- margin-top: 4px;
-}
+ --accent: #6a5cff;
+ --border: #2a2a36;
+ --bg: #0a0a0f;
+ --panel: #14141c;
+ --muted: #888;
+ --header-h: 64px;
+}
+body {
+ background-color: var(--bg);
+ color: #eee;
+ font-family: 'Inter', sans-serif;
+ padding-top: var(--header-h);
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ margin: 0;
+ overflow-x: hidden;
+ }
+ .main-content {
+ flex: 1;
+ display: flex;
+ padding: 2rem;
+ gap: 2rem;
+ max-width: 1400px;
+ margin: 0 auto;
+ width: 100%;
+ }
+ .config-panel {
+ width: 380px;
+ flex-shrink: 0;
+ background-color: var(--panel);
+ padding: 1.5rem;
+ border-radius: 12px;
+ border: 1px solid var(--border);
+ height: fit-content;
+ }
+ .preview-area {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 1.5rem;
+ }
+ .preview-box {
+ flex: 1;
+ min-height: 400px;
+ border: 1px dashed var(--border);
+ border-radius: 12px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-image:
+ linear-gradient(45deg, #1a1a24 25%, transparent 25%),
+ linear-gradient(-45deg, #1a1a24 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, #1a1a24 75%),
+ linear-gradient(-45deg, transparent 75%, #1a1a24 75%);
+ background-size: 20px 20px;
+ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
+ padding: 2rem;
+ transition: background-color 0.3s ease;
+ }
+ .preview-box.light {
+ background-color: #f0f0f0;
+ }
+ .preview-box.dark {
+ background-color: #111;
+ }
+ .code-box {
+ background-color: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 1rem;
+ }
+ h1, h2, h3 {
+ font-family: 'Space Grotesk', sans-serif;
+ font-weight: 600;
+ margin-top: 0;
+ }
+ .form-group {
+ margin-bottom: 1.5rem;
+ }
+ label {
+ display: block;
+ font-size: 0.9rem;
+ font-weight: 500;
+ margin-bottom: 0.5rem;
+ color: #ccc;
+ }
+ input[type="text"],
+ select {
+ width: 100%;
+ box-sizing: border-box;
+ background-color: #0a0a0f;
+ border: 1px solid var(--border);
+ color: #eee;
+ padding: 0.6rem 0.8rem;
+ border-radius: 6px;
+ font-size: 1rem;
+ }
+ input[type="text"]:focus,
+ select:focus {
+ outline: none;
+ border-color: var(--accent);
+ box-shadow: 0 0 0 2px rgba(106, 92, 255, 0.3);
+ }
+ .toggle-group {
+ display: flex;
+ gap: 0.5rem;
+ }
+ .toggle-group button {
+ flex: 1;
+ padding: 0.6rem;
+ background-color: transparent;
+ border: 1px solid var(--border);
+ color: var(--muted);
+ cursor: pointer;
+ border-radius: 6px;
+ font-size: 0.9rem;
+ transition: all 0.2s ease;
+ }
+ .toggle-group button:hover {
+ border-color: #4a4a58;
+ color: #fff;
+ }
+ .toggle-group button.active {
+ background-color: var(--accent);
+ color: white;
+ border-color: var(--accent);
+ }
+ textarea {
+ width: 100%;
+ box-sizing: border-box;
+ height: 150px;
+ background-color: #0a0a0f;
+ border: 1px solid var(--border);
+ color: #eee;
+ padding: 0.8rem;
+ border-radius: 6px;
+ font-family: monospace;
+ font-size: 0.9rem;
+ resize: none;
+ }
+ .copy-btn {
+ position: absolute;
+ top: 0.5rem;
+ right: 0.5rem;
+ background-color: #2a2a36;
+ color: #ccc;
+ border: none;
+ padding: 0.3rem 0.6rem;
+ border-radius: 4px;
+ cursor: pointer;
+ font-size: 0.8rem;
+ }
+ .copy-btn:hover {
+ background-color: #3a3a4a;
+ }
+ .code-wrapper {
+ position: relative;
+ }
+ #widget-preview-container {
+ transition: all 0.2s ease-in-out;
+ border-radius: 8px;
+ overflow: hidden;
+ box-shadow: 0 10px 30px rgba(0,0,0,0.3);
+ }
diff --git a/src/nich-agent.js b/src/nich-agent.js
index 16d16af03..6cc53c0be 100644
--- a/src/nich-agent.js
+++ b/src/nich-agent.js
@@ -553,6 +553,11 @@ export class NichAgent {
viewer.setCameraTarget(action.boneName);
}
break;
+ case 'getPumpFunTrades':
+ if (viewer) {
+ viewer.showPumpFunTrades();
+ }
+ break;
default:
console.warn('[NichAgent] unknown action:', action.type);
}
diff --git a/src/viewer.js b/src/viewer.js
index ef5285e54..f4a1e4d97 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -535,6 +535,57 @@ export class Viewer {
this.projectAnnotations();
}
+ showPumpFunTrades() {
+ const particleCount = 1000;
+ const particles = new THREE.BufferGeometry();
+ const positions = new Float32Array(particleCount * 3);
+ const textureLoader = new THREE.TextureLoader();
+ const coinTexture = textureLoader.load('assets/coin.png');
+
+ for (let i = 0; i < particleCount; i++) {
+ positions[i * 3] = (Math.random() * 2 - 1) * 10;
+ positions[i * 3 + 1] = Math.random() * 20;
+ positions[i * 3 + 2] = (Math.random() * 2 - 1) * 10;
+ }
+
+ particles.setAttribute('position', new THREE.BufferAttribute(positions, 3));
+
+ const particleMaterial = new THREE.PointsMaterial({
+ map: coinTexture,
+ size: 0.5,
+ transparent: true,
+ alphaTest: 0.5,
+ });
+
+ const particleSystem = new THREE.Points(particles, particleMaterial);
+ this.scene.add(particleSystem);
+
+ const animateParticles = () => {
+ const positions = particleSystem.geometry.attributes.position.array;
+ for (let i = 0; i < particleCount; i++) {
+ positions[i * 3 + 1] -= 0.1;
+ if (positions[i * 3 + 1] < -10) {
+ positions[i * 3 + 1] = 20;
+ }
+ }
+ particleSystem.geometry.attributes.position.needsUpdate = true;
+ this.invalidate();
+ };
+
+ if (!this._afterAnimateHooks) {
+ this._afterAnimateHooks = [];
+ }
+ this._afterAnimateHooks.push(animateParticles);
+
+ setTimeout(() => {
+ this.scene.remove(particleSystem);
+ const index = this._afterAnimateHooks.indexOf(animateParticles);
+ if (index > -1) {
+ this._afterAnimateHooks.splice(index, 1);
+ }
+ }, 10000);
+ }
+
takeScreenshot() {
takeScreenshot(this);
}
diff --git a/tasks/monetization-feature/01-display-priced-skills.md b/tasks/monetization-feature/01-display-priced-skills.md
new file mode 100644
index 000000000..87fc7181a
--- /dev/null
+++ b/tasks/monetization-feature/01-display-priced-skills.md
@@ -0,0 +1,66 @@
+# Prompt 1: Display Priced Skills in Marketplace
+
+## Objective
+Modify the agent detail page in the marketplace to visually distinguish between free and paid skills, and display the price for paid skills.
+
+## Explanation
+Currently, the agent detail page lists all skills uniformly. To begin building our monetization feature, users need to be able to see which skills are premium and how much they cost. This involves fetching pricing data along with agent details and updating the UI to render prices and a premium indicator.
+
+## Instructions
+1. **Modify the Backend API:**
+ * Locate the API endpoint that serves the agent detail data (`/api/marketplace/agents/:id`). You can find this in `api/marketplace/[action].js`.
+ * When fetching agent details, also query the `agent_skill_prices` table to get the prices for the agent's skills.
+ * Join this pricing data with the agent details response. The agent object should now have a `skill_prices` map or object, like `{ "skill_name": { "amount": 1000000, "currency_mint": "EPjFWdd..." } }`.
+
+2. **Update the Frontend UI:**
+ * In `src/marketplace.js`, find the `renderDetail` function.
+ * This function receives the agent object, which now includes `skill_prices`.
+ * Inside the loop that renders the skills (`d-skills` element), check if a price exists for the current skill.
+ * If a price exists, render a price badge next to the skill name. Convert the amount from lamports (or the smallest unit) to a human-readable format (e.g., 1,000,000 lamports = 1 USDC).
+ * Style the price badge to be visually distinct.
+
+## Code Example (Frontend - `src/marketplace.js`)
+
+Here's how you might modify the skill rendering part within the `renderDetail` function:
+
+```javascript
+// Inside renderDetail function
+
+const skillPrices = a.skill_prices || {};
+$('d-skills').innerHTML = skillsArr.length
+ ? skillsArr.map((s) => {
+ const name = typeof s === 'string' ? s : (s.name || '');
+ const price = skillPrices[name];
+ const badge = price
+ ? `<span class="price-badge price-paid">${(price.amount / 1e6).toFixed(2)} USDC</span>`
+ : `<span class="price-badge price-free">Free</span>`;
+ return `<span class="skill-entry">${escapeHtml(name)}${badge}</span>`;
+ }).join(' ')
+ : '<div>This Agent has no skills defined.</div>';
+```
+
+## CSS Example
+
+Add these styles to `/marketplace.css` to make the price badges look good.
+
+```css
+.price-badge {
+ display: inline-block;
+ margin-left: 8px;
+ padding: 2px 6px;
+ font-size: 10px;
+ font-weight: 600;
+ border-radius: 4px;
+ vertical-align: middle;
+}
+
+.price-free {
+ color: #a7f3d0;
+ background-color: rgba(52, 211, 153, 0.1);
+}
+
+.price-paid {
+ color: #fde047;
+ background-color: rgba(253, 224, 71, 0.1);
+}
+```
diff --git a/tasks/monetization-feature/02-add-purchase-button.md b/tasks/monetization-feature/02-add-purchase-button.md
new file mode 100644
index 000000000..e23ae05dd
--- /dev/null
+++ b/tasks/monetization-feature/02-add-purchase-button.md
@@ -0,0 +1,110 @@
+# Prompt 2: Add Purchase Button for Paid Skills
+
+## Objective
+On the agent detail page, add a dynamic "Purchase" or "Use" button for each skill, depending on whether it's paid and whether the user owns it.
+
+## Explanation
+Now that users can see which skills are paid, the next logical step is to provide a call to action. We'll add a button next to each skill. This button will be disabled for free skills (as they are implicitly available), show "Purchase" for paid skills the user doesn't own, and "Use" or "Unlocked" for paid skills they do own.
+
+## Prequisites
+* You need a way to know which skills the current user owns. This will be built in a later prompt. For now, **assume the user owns no skills**, so the logic will only differentiate between free and paid.
+
+## Instructions
+1. **Locate the UI Code:**
+ * Open `src/marketplace.js` and find the `renderDetail` function.
+ * Focus on the section that renders the skills list inside the element with the ID `d-skills`.
+
+2. **Modify the Skill Rendering Logic:**
+ * For each skill, you're already checking if it has a price.
+ * Now, add a button to the rendered HTML for each skill.
+ * The button's text and state should be conditional:
+ * If the skill is **free** (no price), the button should be disabled and perhaps say "Included".
+ * If the skill is **paid**, the button should be enabled and say "Purchase".
+ * Add a `data-skill-name` attribute to the button to easily identify which skill it corresponds to when clicked.
+
+## Code Example (Frontend - `src/marketplace.js`)
+
+Here is an example of how to modify the skill rendering logic within the `renderDetail` function.
+
+```javascript
+// Inside renderDetail function, an evolution of the previous prompt's code
+
+const skillPrices = a.skill_prices || {};
+// For now, assume user owns nothing. We will replace this with a real check later.
+const ownedSkills = new Set();
+
+$('d-skills').innerHTML = skillsArr.length
+ ? skillsArr.map((s) => {
+ const name = typeof s === 'string' ? s : (s.name || '');
+ const price = skillPrices[name];
+
+ let actionButton;
+ if (price) {
+ if (ownedSkills.has(name)) {
+ actionButton = `<button class="skill-btn" disabled>Unlocked</button>`;
+ } else {
+ actionButton = `<button class="skill-btn purchase" data-skill-name="${escapeHtml(name)}">Purchase</button>`;
+ }
+ } else {
+ actionButton = `<button class="skill-btn" disabled>Free</button>`;
+ }
+
+ const priceDisplay = price ? `<span class="price-paid">${(price.amount / 1e6).toFixed(2)} USDC</span>` : ``;
+
+ return `<div class="skill-row">
+ <span class="skill-name">${escapeHtml(name)} ${priceDisplay}</span>
+ ${actionButton}
+ </div>`;
+ }).join('')
+ : '<div>This Agent has no skills defined.</div>';
+```
+
+## CSS Example
+
+Add these styles to `marketplace.css` for the new skill row and buttons.
+
+```css
+.skill-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 8px 0;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
+}
+
+.skill-row:last-child {
+ border-bottom: none;
+}
+
+.skill-name {
+ font-size: 14px;
+ color: rgba(255, 255, 255, 0.9);
+}
+
+.skill-btn {
+ background-color: #374151;
+ color: #d1d5db;
+ border: none;
+ border-radius: 6px;
+ padding: 4px 12px;
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background-color 0.2s;
+}
+
+.skill-btn:disabled {
+ background-color: #1f2937;
+ color: #6b7280;
+ cursor: not-allowed;
+}
+
+.skill-btn.purchase {
+ background-color: #3b82f6;
+ color: white;
+}
+
+.skill-btn.purchase:hover {
+ background-color: #2563eb;
+}
+```
diff --git a/tasks/monetization-feature/03-paid-skill-badge.md b/tasks/monetization-feature/03-paid-skill-badge.md
new file mode 100644
index 000000000..ff35483b9
--- /dev/null
+++ b/tasks/monetization-feature/03-paid-skill-badge.md
@@ -0,0 +1,82 @@
+# Prompt 3: Paid Skill Badge in Marketplace List
+
+## Objective
+Add a visual indicator to the agent cards in the main marketplace grid (`/marketplace`) for agents that have one or more paid skills.
+
+## Explanation
+To increase the visibility of monetized agents and help users find premium content, we need to show a badge or icon on the agent cards in the main list view. This tells a user at a glance that an agent offers paid capabilities without needing to click into the detail page.
+
+## Instructions
+
+1. **Modify the Backend API:**
+ * Locate the API endpoint that serves the agent list data (`/api/marketplace/agents`). This is in `api/marketplace/[action].js`.
+ * In the SQL query that fetches the list of agents, you need to add a check to see if each agent has any active, priced skills.
+ * A good way to do this is with a subquery or a `LEFT JOIN` and `COUNT`. An `EXISTS` subquery is often the most performant.
+ * The query should return a new boolean field for each agent, e.g., `has_paid_skills`.
+
+2. **Update the Frontend UI:**
+ * In `src/marketplace.js`, find the `renderCard` function.
+ * This function receives the agent object, which will now include the `has_paid_skills` boolean.
+ * Add a conditional block to the card's HTML template. If `has_paid_skills` is true, render a "Paid" or "$" badge.
+ * This is typically done in the `stats` section of the card, alongside views and forks.
+
+## Code Example (Backend - SQL in `api/marketplace/[action].js`)
+
+Here's how you can modify the agent list query to include the `has_paid_skills` flag.
+
+```sql
+-- Inside the handleList function's SQL query
+
+SELECT
+ ai.id, ai.name, ai.description, ai.category, -- ... other fields
+ EXISTS (
+ SELECT 1 FROM agent_skill_prices asp
+ WHERE asp.agent_id = ai.id AND asp.is_active = true AND asp.amount > 0
+ ) AS has_paid_skills
+FROM
+ agent_identities ai
+-- ... rest of the query
+```
+
+## Code Example (Frontend - `src/marketplace.js`)
+
+Modify the `renderCard` function to use the new flag.
+
+```javascript
+function renderCard(a) {
+ const date = a.published_at ? formatDate(a.published_at) : '';
+ const skills = (a.skills || []).length;
+ return `<div class="market-card-agent" data-id="${a.id}">
+ <div class="head">
+ <div class="avatar">${initial(a.name)}</div>
+ <div style="min-width:0;flex:1">
+ <div class="title">${escapeHtml(a.name || 'Untitled')}</div>
+ <div class="author">${escapeHtml(a.author_name || 'Anonymous')}</div>
+ </div>
+ </div>
+ <div class="desc">${escapeHtml(a.description || '')}</div>
+ <div class="stats">
+ <span class="stat-pill">⊙ ${a.views_count || 0}</span>
+ <span class="stat-pill">⑂ ${a.forks_count || 0}</span>
+ ${skills ? `<span class="stat-pill">▤ ${skills}</span>` : ''}
+ ${a.has_paid_skills ? `<span class="stat-pill paid-badge">$ Paid</span>` : ''}
+ </div>
+ <div class="footer">
+ <span>${date}</span>
+ <span class="cat-pill">${CATEGORY_LABELS[a.category] || a.category || ''}</span>
+ </div>
+ </div>`;
+}
+```
+
+## CSS Example
+
+Add styles for the new badge in `marketplace.css`.
+
+```css
+.stat-pill.paid-badge {
+ color: #fde047;
+ border: 1px solid rgba(253, 224, 71, 0.3);
+ background-color: rgba(253, 224, 71, 0.1);
+}
+```
diff --git a/tasks/monetization-feature/04-create-payment-intent-api.md b/tasks/monetization-feature/04-create-payment-intent-api.md
new file mode 100644
index 000000000..79971e163
--- /dev/null
+++ b/tasks/monetization-feature/04-create-payment-intent-api.md
@@ -0,0 +1,95 @@
+# Prompt 4: Create Payment Intent API
+
+## Objective
+Create a new backend API endpoint that generates a "payment intent." This intent is a secure, server-side record of a pending transaction, including what is being bought, by whom, and for how much.
+
+## Explanation
+Before a user can make a payment on the frontend, the backend needs to create a secure reference for the transaction. This is called a "payment intent." The frontend will request this intent right before showing the payment modal. The intent contains all the necessary details for the frontend to construct the transaction (like the recipient's address and the exact amount), and it provides a unique ID that we can use later to verify the payment's status.
+
+## Instructions
+1. **Create a New API File:**
+ * Create a new file at `api/payments/intent.js`. This will house the logic for creating payment intents.
+
+2. **Define the Endpoint Logic:**
+ * The endpoint should accept a `POST` request.
+ * It must be authenticated, as only logged-in users can purchase skills.
+ * The request body should contain the `agent_id` and `skill_name` the user wants to purchase.
+
+3. **Implement the Core Logic:**
+ * Look up the agent to ensure it exists and is published.
+ * Look up the skill price in the `agent_skill_prices` table using the `agent_id` and `skill_name`. If no price is found, return an error.
+ * Look up the agent creator's payout wallet address. For now, this can be stored on the `agent_identities` table or in a related table.
+ * Generate a unique ID for this intent. A `uuid` is a good choice.
+ * Store the intent details in the `agent_payment_intents` table. This includes the payer's user ID, the agent ID, the amount, the currency, the recipient address, and a status of `'pending'`. Set an expiration time (e.g., 10 minutes).
+ * Return the payment intent ID and the necessary details for the frontend to construct the transaction (e.g., recipient address, amount, currency mint, etc.).
+
+4. **Add Vercel Routing:**
+ * In `vercel.json`, add a route to direct requests from `/api/payments/intent` to your new serverless function.
+
+## Code Example (Backend - `api/payments/intent.js`)
+
+```javascript
+import { sql } from '../_lib/db.js';
+import { getSessionUser } from '../_lib/auth.js';
+import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
+import { nanoid } from 'nanoid';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const { agent_id, skill_name } = await readJson(req);
+ if (!agent_id || !skill_name) {
+ return error(res, 400, 'validation_error', 'agent_id and skill_name are required');
+ }
+
+ // 1. Fetch skill price and agent owner's payout wallet
+ const [priceInfo] = await sql`
+ SELECT
+ p.amount, p.currency_mint, p.chain,
+ a.user_id as owner_user_id
+ FROM agent_skill_prices p
+ JOIN agent_identities a ON p.agent_id = a.id
+ WHERE p.agent_id = ${agent_id}
+ AND p.skill = ${skill_name}
+ AND p.is_active = true
+ `;
+
+ if (!priceInfo) {
+ return error(res, 404, 'not_found', 'The specified skill is not for sale.');
+ }
+
+ // For this example, we assume the owner's Solana wallet is on the agent's meta field
+ // A better approach would be a dedicated agent_payout_wallets table
+ const [agent] = await sql`SELECT meta FROM agent_identities WHERE id = ${agent_id}`;
+ const recipient_address = agent.meta?.solana_address;
+
+ if (!recipient_address) {
+ return error(res, 500, 'configuration_error', 'Agent owner has not configured a payout wallet.');
+ }
+
+ // 2. Create and store the payment intent
+ const intent_id = `pi_${nanoid()}`;
+ const expires_at = new Date(Date.now() + 10 * 60 * 1000); // 10 minutes from now
+
+ await sql`
+ INSERT INTO agent_payment_intents
+ (id, payer_user_id, agent_id, currency_mint, amount, status, expires_at, payload)
+ VALUES
+ (${intent_id}, ${user.id}, ${agent_id}, ${priceInfo.currency_mint}, ${String(priceInfo.amount)}, 'pending', ${expires_at}, ${JSON.stringify({ skill: skill_name, recipient_address })})
+ `;
+
+ // 3. Return details to the frontend
+ return json(res, 201, {
+ intent_id,
+ recipient_address,
+ amount: String(priceInfo.amount),
+ currency_mint: priceInfo.currency_mint,
+ chain: priceInfo.chain,
+ expires_at: expires_at.toISOString(),
+ });
+});
+```
diff --git a/tasks/monetization-feature/05-payment-modal-ui.md b/tasks/monetization-feature/05-payment-modal-ui.md
new file mode 100644
index 000000000..b66ff271b
--- /dev/null
+++ b/tasks/monetization-feature/05-payment-modal-ui.md
@@ -0,0 +1,138 @@
+# Prompt 5: Payment Modal UI
+
+## Objective
+Create the HTML structure and CSS styling for a reusable payment modal that will guide the user through the skill purchase process.
+
+## Explanation
+A modal is a focused UI element that overlays the page, perfect for multi-step processes like payments. We need a clean, clear modal that can display the item being purchased, connect to a wallet, show the price, and provide clear action buttons. For now, we will just build the static UI components. The logic will be wired up in subsequent prompts.
+
+## Instructions
+1. **Add HTML to `marketplace.html`:**
+ * At the bottom of the `<body>` in `marketplace.html`, add the HTML for the modal overlay and the modal itself.
+ * The modal should be hidden by default (`hidden` attribute or `display: none`).
+ * Include sections for:
+ * A title (e.g., "Unlock Skill").
+ * A close button.
+ * The skill name and agent name.
+ * The price.
+ * A placeholder for wallet connection status.
+ * A primary action button (e.g., "Pay Now").
+ * A footer for status messages.
+
+2. **Add CSS to `marketplace.css`:**
+ * Create styles for the modal overlay to cover the screen with a semi-transparent background.
+ * Style the modal container itself: centered, with a border, background, and rounded corners.
+ * Style the internal elements: title, price display, buttons, etc.
+ * Use flexbox or grid for layout.
+
+## Code Example (HTML - add to `marketplace.html`)
+
+```html
+<!-- At the end of the <body>, after the submit modal -->
+
+<!-- Payment Modal -->
+<div class="market-modal-overlay" id="payment-modal-overlay" hidden aria-modal="true" role="dialog" aria-labelledby="payment-modal-title">
+ <div class="market-modal">
+ <div class="market-modal-head">
+ <h2 id="payment-modal-title">Unlock Skill</h2>
+ <button class="market-modal-close" id="payment-modal-close" aria-label="Close">×</button>
+ </div>
+ <div class="payment-modal-body">
+ <p>You are purchasing access to the following skill:</p>
+ <div class="payment-item">
+ <strong id="payment-skill-name"></strong>
+ <span>from agent</span>
+ <em id="payment-agent-name"></em>
+ </div>
+
+ <div class="payment-price">
+ <span>Total</span>
+ <strong id="payment-price-display"></strong>
+ </div>
+
+ <div class="payment-wallet-area" id="payment-wallet-area">
+ <!-- Wallet connection status and button will be rendered here by JS -->
+ <button class="btn-primary" id="payment-connect-wallet-btn">Connect Wallet</button>
+ </div>
+
+ <button class="btn-primary payment-confirm-btn" id="payment-confirm-btn" disabled>Confirm Purchase</button>
+
+ <div class="payment-status" id="payment-status" role="status" aria-live="polite"></div>
+ </div>
+ </div>
+</div>
+```
+
+## Code Example (CSS - add to `marketplace.css`)
+
+```css
+/* Payment Modal Styles */
+.payment-modal-body {
+ padding: 16px;
+ font-size: 14px;
+ color: rgba(255, 255, 255, 0.7);
+}
+
+.payment-item {
+ background-color: rgba(255, 255, 255, 0.05);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 8px;
+ padding: 12px;
+ margin: 16px 0;
+ text-align: center;
+}
+
+#payment-skill-name {
+ display: block;
+ font-size: 16px;
+ font-weight: 600;
+ color: #fff;
+}
+
+.payment-item > span {
+ font-size: 12px;
+ color: rgba(255, 255, 255, 0.5);
+}
+
+#payment-agent-name {
+ display: block;
+ font-size: 12px;
+ font-style: normal;
+}
+
+.payment-price {
+ display: flex;
+ justify-content: space-between;
+ align-items: baseline;
+ padding: 12px 0;
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
+}
+
+#payment-price-display {
+ font-size: 20px;
+ font-weight: 700;
+ color: #fde047;
+}
+
+.payment-wallet-area {
+ margin: 20px 0;
+ padding: 16px;
+ background-color: rgba(0, 0, 0, 0.2);
+ border-radius: 8px;
+ text-align: center;
+}
+
+.payment-confirm-btn {
+ width: 100%;
+ padding: 12px;
+ font-size: 16px;
+}
+
+.payment-status {
+ margin-top: 16px;
+ font-size: 12px;
+ text-align: center;
+ min-height: 1.2em;
+}
+```
diff --git a/tasks/monetization-feature/06-trigger-payment-modal.md b/tasks/monetization-feature/06-trigger-payment-modal.md
new file mode 100644
index 000000000..bda177a50
--- /dev/null
+++ b/tasks/monetization-feature/06-trigger-payment-modal.md
@@ -0,0 +1,112 @@
+# Prompt 6: Trigger Payment Modal
+
+## Objective
+Wire up the "Purchase" buttons on the agent detail page to open the payment modal and pre-fill it with the correct skill and price information by fetching a payment intent from the backend.
+
+## Explanation
+With the modal UI and the payment intent API in place, we can now connect them. When a user clicks "Purchase" on a specific skill, the frontend should:
+1. Prevent any default action.
+2. Call the `/api/payments/intent` endpoint with the agent ID and skill name.
+3. Use the response to populate the payment modal's UI.
+4. Display the modal to the user.
+
+## Instructions
+1. **Add Event Listener:**
+ * In `src/marketplace.js`, modify the `renderDetail` function.
+ * After rendering the skills, add a single event listener to the `d-skills` container. Use event delegation to catch clicks on `.purchase` buttons. This is more efficient than adding a listener to every button.
+
+2. **Implement the Click Handler:**
+ * The handler function should be `async`.
+ * Get the `skill-name` from the button's `data-skill-name` attribute.
+ * Show a loading state (e.g., disable the button, change its text).
+ * `POST` to `/api/payments/intent` with the current agent's ID (`detailState.agent.id`) and the skill name. Remember to include credentials.
+
+3. **Populate and Show the Modal:**
+ * On a successful API response, grab the modal elements.
+ * Populate the skill name, agent name, and price fields using the data from the payment intent. Format the price correctly.
+ * Store the `intent_id` and other relevant data from the response in a variable or on a DOM element for the next step (payment).
+ * Remove the `hidden` attribute from the modal overlay to show it.
+ * Reset the loading state of the purchase button.
+
+4. **Handle Modal Closing:**
+ * Add event listeners to the modal's close button and overlay to hide the modal when clicked.
+
+## Code Example (Frontend - `src/marketplace.js`)
+
+```javascript
+// Add this new function to marketplace.js
+
+function bindPurchaseFlow() {
+ const skillsContainer = $('d-skills');
+ if (!skillsContainer) return;
+
+ skillsContainer.addEventListener('click', async (e) => {
+ if (!e.target.matches('.purchase')) return;
+
+ const btn = e.target;
+ const skillName = btn.dataset.skillName;
+ if (!skillName || !detailState.agent) return;
+
+ btn.disabled = true;
+ btn.textContent = 'Preparing...';
+
+ try {
+ const res = await fetch('/api/payments/intent', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({
+ agent_id: detailState.agent.id,
+ skill_name: skillName,
+ }),
+ });
+ const intent = await res.json();
+ if (!res.ok) throw new Error(intent.error_description || 'Failed to create payment intent.');
+
+ openPaymentModal(intent, skillName);
+
+ } catch (err) {
+ console.error('Payment intent failed', err);
+ // You could show a toast notification here
+ } finally {
+ btn.disabled = false;
+ btn.textContent = 'Purchase';
+ }
+ });
+}
+
+function openPaymentModal(intent, skillName) {
+ // Store intent for later use
+ document.getElementById('payment-modal-overlay').dataset.intentId = intent.intent_id;
+
+ // Populate modal
+ $('payment-skill-name').textContent = skillName;
+ $('payment-agent-name').textContent = detailState.agent.name;
+ const priceInUSDC = (Number(intent.amount) / 1e6).toFixed(2);
+ $('payment-price-display').textContent = `${priceInUSDC} USDC`;
+
+ // Show modal
+ $('payment-modal-overlay').hidden = false;
+}
+
+function closePaymentModal() {
+ $('payment-modal-overlay').hidden = true;
+}
+
+
+// --- Inside the init() or similar setup function ---
+// Call bindPurchaseFlow whenever the detail view is shown
+// For example, inside loadDetail after rendering:
+// renderDetail(a, aJ.data.bookmarked);
+// bindPurchaseFlow();
+
+// Add listeners for closing the modal
+$('payment-modal-close').addEventListener('click', closePaymentModal);
+$('payment-modal-overlay').addEventListener('click', (e) => {
+ if (e.target.id === 'payment-modal-overlay') {
+ closePaymentModal();
+ }
+});
+```
+
+**Note:** You will need to call `bindPurchaseFlow()` at the appropriate time, likely after the detail view has been rendered by the `loadDetail` function, to ensure the buttons exist in the DOM.