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.

Remove remaining shipped monetization prompt backlogs

nirholas491c28e757a6
diff --git a/prompts/monetization-feature/10-backend-save-skill-prices.md b/prompts/monetization-feature/10-backend-save-skill-prices.md
deleted file mode 100644
index d1df39420..000000000
--- a/prompts/monetization-feature/10-backend-save-skill-prices.md
+++ /dev/null
@@ -1,111 +0,0 @@
----
-status: not-started
----
-
-# Prompt 10: Backend - Save Skill Prices Endpoint
-
-**Status:** Not Started
-
-## Objective
-Create a backend endpoint for saving or updating skill prices for an agent.
-
-## Explanation
-The creator-facing UI for setting prices needs a backend endpoint to persist the data. This endpoint will receive a list of skills and their prices and will perform an "upsert" operation (insert or update) into the `agent_skill_prices` table. This is a critical step in allowing creators to manage their skill offerings.
-
-## Instructions
-1. **Create the API route:**
- - Create a new API route to handle this, e.g., `/api/agents/:id/skill-prices`.
- - It should accept `POST` or `PUT` requests.
- - This endpoint must be authenticated, and you must verify that the logged-in user is the owner of the agent they are trying to price skills for.
-
-2. **Handle the request:**
- - The request body should contain an object or array of skill prices, e.g., `[{ skill_name: 'text-to-speech', price: 1.50, currency: 'USDC' }, ...]`.
- - Loop through the submitted prices.
- - For each skill price, perform an `UPSERT` operation on the `agent_skill_prices` table.
- - If a price for that `agent_id` and `skill_name` already exists, `UPDATE` it.
- - If it doesn't exist, `INSERT` a new row.
- - Remember to convert the price from the human-readable format (e.g., 1.50 USDC) to the smallest unit (e.g., 1,500,000 lamports) before saving.
-
-3. **Handle price removal:**
- - If a creator sets a price to 0 or removes it, you can either delete the corresponding row from `agent_skill_prices` or mark it as inactive (e.g., with an `is_active` flag). Deleting is simpler for now.
-
-## Code Example (SQL for `UPSERT`)
-
-This example uses PostgreSQL syntax for an `UPSERT` operation.
-
-```sql
--- For each skill price provided in the API request body...
-INSERT INTO agent_skill_prices (agent_id, skill_name, amount, currency_mint)
-VALUES ($1, $2, $3, $4)
-ON CONFLICT (agent_id, skill_name)
-DO UPDATE SET
- amount = EXCLUDED.amount,
- currency_mint = EXCLUDED.currency_mint,
- updated_at = NOW();
-```
-
-## Code Example (Node.js/Express-like handler)
-
-```javascript
-// api/agents/[id]/skill-prices.js
-
-export default async function handler(req, res) {
- // ... authentication and ownership verification ...
- const agentId = req.query.id;
- const pricesToSet = req.body.prices; // e.g., [{ skill_name, price, currency }]
-
- // Use a transaction to update all prices atomically
- const client = await db.getClient();
- try {
- await client.query('BEGIN');
-
- for (const p of pricesToSet) {
- const amountInSmallestUnit = p.price * 1e6; // Convert to lamports
- if (amountInSmallestUnit > 0) {
- await client.query(
- `INSERT INTO agent_skill_prices (agent_id, skill_name, amount, currency_mint)
- VALUES ($1, $2, $3, $4)
- ON CONFLICT (agent_id, skill_name) DO UPDATE SET amount = $3, updated_at = NOW()`,
- [agentId, p.skill_name, amountInSmallestUnit, 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7Gz3'] // USDC mint
- );
- } else {
- // If price is 0, delete the record
- await client.query(
- 'DELETE FROM agent_skill_prices WHERE agent_id = $1 AND skill_name = $2',
- [agentId, p.skill_name]
- );
- }
- }
-
- await client.query('COMMIT');
- res.status(200).json({ success: true, message: 'Prices updated' });
- } catch (error) {
- await client.query('ROLLBACK');
- res.status(500).json({ error: 'Failed to update prices' });
- } finally {
- client.release();
- }
-}
-```
-
-## Verification
-- On the "Monetization" tab of the agent edit page, set some prices for skills.
-- Click "Save Prices."
-- Check the network tab in your browser's developer tools to ensure the request is sent correctly.
-- Verify that the data in your `agent_skill_prices` table is updated as expected.
-- Reload the page and confirm that the prices you set are correctly displayed in the input fields.
-- Try setting a price to 0 and verify that the corresponding row is deleted from the database.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-feature/10-backend-save-skill-prices.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-feature/11-backend-access-control-logic.md b/prompts/monetization-feature/11-backend-access-control-logic.md
deleted file mode 100644
index 84e90bbea..000000000
--- a/prompts/monetization-feature/11-backend-access-control-logic.md
+++ /dev/null
@@ -1,98 +0,0 @@
----
-status: not-started
----
-
-# Prompt 11: Backend - Logic for Access Control
-
-**Status:** Not Started
-
-## Objective
-Implement backend logic to restrict access to paid skills to only those users who have purchased them.
-
-## Explanation
-Currently, the API that executes a skill doesn't check for ownership. This means anyone could use a paid skill without paying for it. We need to add an access control layer to the skill execution endpoint. This is a critical security and functionality step for our monetization feature.
-
-## Instructions
-1. **Identify the skill execution endpoint:**
- - Find the API endpoint responsible for running an agent's skills. This might be a general-purpose chat or agent interaction endpoint (e.g., `/api/chat`).
-
-2. **Add an ownership check:**
- - Inside this endpoint, before executing a skill, determine if the skill is a paid one.
- - To do this, check the `agent_skill_prices` table for the `agent_id` and `skill_name`.
- - If the skill has a price, you must then check if the user has purchased it.
- - Query the `user_skill_purchases` table for a record matching the `user_id`, `agent_id`, and `skill_name`.
-
-3. **Enforce access control:**
- - If the skill is paid and no purchase record is found for the user, return a `403 Forbidden` or `402 Payment Required` error.
- - The error message should inform the user that they need to purchase the skill to use it.
- - If the skill is free or if the user has purchased it, proceed with executing the skill as normal.
-
-## Code Example (in the skill execution endpoint)
-
-```javascript
-// In your skill execution endpoint (e.g., /api/chat)
-
-export default async function handler(req, res) {
- // ... existing code to get agent, user, and the skill to be executed ...
-
- const { agentId, skillName, userId } = /* ... from your request context ... */;
-
- // 1. Check if the skill is priced
- const priceResult = await db.query(
- 'SELECT id FROM agent_skill_prices WHERE agent_id = $1 AND skill_name = $2',
- [agentId, skillName]
- );
-
- const isPaidSkill = priceResult.rows.length > 0;
-
- if (isPaidSkill) {
- // 2. If it's a paid skill, check for a purchase record
- if (!userId) {
- return res.status(401).json({ error: 'Authentication required for this skill' });
- }
-
- const purchaseResult = await db.query(
- 'SELECT id FROM user_skill_purchases WHERE user_id = $1 AND agent_id = $2 AND skill_name = $3',
- [userId, agentId, skillName]
- );
-
- const hasPurchased = purchaseResult.rows.length > 0;
-
- // 3. Enforce access control
- if (!hasPurchased) {
- return res.status(402).json({
- error: 'Payment Required',
- message: `You must purchase the skill "${skillName}" to use it.`,
- });
- }
- }
-
- // If we reach here, the user has access. Proceed with skill execution.
- const skillResult = await executeSkill(agentId, skillName, /* ... other params ... */);
-
- res.status(200).json({ result: skillResult });
-}
-```
-
-## Verification
-- Seed your database with a paid skill for an agent, but do *not* create a purchase record for your test user.
-- Try to use that paid skill via the API or your application's UI.
-- Verify that you receive a `402` or `403` error and a message informing you that the skill must be purchased.
-- Now, manually insert a purchase record for your user in the `user_skill_purchases` table.
-- Try to use the skill again.
-- Verify that the skill now executes successfully.
-- Also, test a free skill to ensure that the access control logic doesn't block it.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-feature/11-backend-access-control-logic.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-feature/12-ui-display-owned-locked-states.md b/prompts/monetization-feature/12-ui-display-owned-locked-states.md
deleted file mode 100644
index e284cc604..000000000
--- a/prompts/monetization-feature/12-ui-display-owned-locked-states.md
+++ /dev/null
@@ -1,95 +0,0 @@
----
-status: not-started
----
-
-# Prompt 12: UI - Display "Owned" and "Locked" States
-
-**Status:** Not Started
-
-## Objective
-Enhance the UI to clearly show which skills a user owns and which paid skills are "locked" (not yet purchased).
-
-## Explanation
-To provide a clear and intuitive user experience, the marketplace needs to visually communicate the status of each skill relative to the current user. We've already added a "Buy" button, but we can make the distinction clearer with "Owned" badges for purchased skills and perhaps a "lock" icon for paid skills the user doesn't own.
-
-## Instructions
-1. **Style the "Owned" badge:**
- - In `marketplace.css`, add a style for the `price-owned` class that you might have added in a previous step. This should be visually distinct from the "Free" and "Paid" badges (e.g., using a different color).
-
-2. **Add a "Locked" icon:**
- - For paid skills that the user has *not* purchased, add a lock icon next to the skill name or "Buy" button.
- - You can use an SVG icon for this.
- - The logic for this is already in place from when you added the "Buy" button: if a skill has a price and is not in the `purchased_skills` list, it is "locked."
-
-3. **Update the rendering logic:**
- - In `src/marketplace.js` within the `renderDetail` function, update the skill rendering map to include these new visual elements.
-
-## Code Example (CSS in `/marketplace.css`)
-
-```css
-/* Add this to your existing badge styles */
-.price-owned {
- color: #818cf8; /* Indigo */
- background-color: rgba(129, 140, 248, 0.1);
-}
-
-.skill-entry .lock-icon {
- display: inline-block;
- width: 12px;
- height: 12px;
- margin-right: 4px;
- vertical-align: middle;
- opacity: 0.6;
-}
-```
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// Inside renderDetail function, updated map logic
-
-$('d-skills').innerHTML = skillsArr.length
- ? skillsArr.map((s) => {
- const name = typeof s === 'string' ? s : (s.name || '');
- const price = skillPrices[name];
- let badgeHTML = `<span class="price-badge price-free">Free</span>`;
- let iconHTML = '';
-
- if (price) {
- if (purchasedSkills.has(name)) {
- badgeHTML = `<span class="price-badge price-owned">Owned</span>`;
- } else {
- const priceInUSDC = (price.amount / 1e6).toFixed(2);
- iconHTML = `<svg class="lock-icon" ... SvgForLock ...></svg>`;
- badgeHTML = `
- <span class="price-badge price-paid">${priceInUSDC} USDC</span>
- <button class="buy-skill-btn" data-agent-id="${a.id}" data-skill-name="${name}">Buy</button>
- `;
- }
- }
- return `<span class="skill-entry">${iconHTML}${escapeHtml(name)}${badgeHTML}</span>`;
- }).join(' ')
- : '<div>This Agent has no skills defined.</div>';
-```
-
-## Verification
-- Log in and navigate to an agent detail page with a mix of free, paid, and owned skills.
-- Verify that free skills have the "Free" badge.
-- Verify that paid skills you haven't bought have a lock icon and a "Buy" button.
-- Verify that skills you own have the new "Owned" badge and no "Buy" button.
-- The visual appearance should be clear and easy to understand at a glance.
-- Log out and ensure no "Owned" badges or lock icons are displayed.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-feature/12-ui-display-owned-locked-states.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-feature/13-creator-earnings-dashboard.md b/prompts/monetization-feature/13-creator-earnings-dashboard.md
deleted file mode 100644
index 0c691e995..000000000
--- a/prompts/monetization-feature/13-creator-earnings-dashboard.md
+++ /dev/null
@@ -1,113 +0,0 @@
----
-status: not-started
----
-
-# Prompt 13: Creator Earnings/Dashboard Page
-
-**Status:** Not Started
-
-## Objective
-Create a basic dashboard page for creators to see their total earnings and a list of their sales.
-
-## Explanation
-To complete the monetization loop, creators need to be able to see how their paid skills are performing. This requires a new page or a section in their existing dashboard that provides sales data. This first version will be a simple summary of earnings and a log of recent sales.
-
-## Instructions
-1. **Create a new backend endpoint:**
- - Develop an endpoint like `/api/creators/dashboard` that is authenticated and returns the creator's sales data.
- - This endpoint should query the `user_skill_purchases` table for all purchases of skills belonging to agents owned by the logged-in user.
- - It should calculate total earnings (summing up `purchase_price`).
- - It should also return a list of recent transactions.
-
-2. **Create a new frontend page:**
- - Create a new HTML file, e.g., `dashboard.html`.
- - This page will fetch data from your new `/api/creators/dashboard` endpoint.
- - **UI elements:**
- - A summary section to display "Total Earnings."
- - A table or list to display "Recent Sales." The table should show the skill name, the agent name, the price it was sold for, and the date of the sale.
-
-3. **Data aggregation:**
- - In the backend endpoint, you'll need to join a few tables:
- - `user_skill_purchases` (the source of sales data).
- - `agent_identities` (to get the agent name and verify the owner).
- - `users` (to get the buyer's name, if you want to display it).
-
-## Code Example (Backend Endpoint - `/api/creators/dashboard`)
-
-```javascript
-export default async function handler(req, res) {
- // ... authentication ...
- const userId = await getUserIdFromSession(req);
-
- // Get all agents owned by the user
- const agentsResult = await db.query('SELECT id FROM agent_identities WHERE user_id = $1', [userId]);
- const agentIds = agentsResult.rows.map(r => r.id);
-
- if (agentIds.length === 0) {
- return res.status(200).json({ total_earnings: 0, sales: [] });
- }
-
- // Get sales for those agents
- const salesResult = await db.query(
- `SELECT p.skill_name, p.purchase_price, p.purchased_at, a.name as agent_name
- FROM user_skill_purchases p
- JOIN agent_identities a ON p.agent_id = a.id
- WHERE p.agent_id = ANY($1)
- ORDER BY p.purchased_at DESC
- LIMIT 100`,
- [agentIds]
- );
-
- const totalEarnings = salesResult.rows.reduce((sum, row) => sum + Number(row.purchase_price), 0);
-
- res.status(200).json({
- total_earnings: totalEarnings / 1e6, // Convert to USDC
- sales: salesResult.rows,
- });
-}
-```
-
-## Code Example (Frontend JavaScript for `dashboard.html`)
-
-```javascript
-async function loadDashboard() {
- const response = await fetch('/api/creators/dashboard');
- const data = await response.json();
-
- document.getElementById('total-earnings').textContent = `${data.total_earnings.toFixed(2)} USDC`;
-
- const salesList = document.getElementById('sales-list');
- salesList.innerHTML = data.sales.map(sale => `
- <tr>
- <td>${sale.agent_name}</td>
- <td>${sale.skill_name}</td>
- <td>${(sale.purchase_price / 1e6).toFixed(2)} USDC</td>
- <td>${new Date(sale.purchased_at).toLocaleDateString()}</td>
- </tr>
- `).join('');
-}
-
-loadDashboard();
-```
-
-## Verification
-- Seed your database with some sample sales for agents owned by your test user.
-- Navigate to the new `/dashboard` page.
-- Verify that the total earnings are calculated and displayed correctly.
-- Check that the list of recent sales is populated with the correct data.
-- Ensure the page handles the case where a creator has no sales yet.
-- Make sure only the creator's own sales are visible, not sales from other creators.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-feature/13-creator-earnings-dashboard.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/01-display-priced-skills.md b/prompts/monetization-prompts/01-display-priced-skills.md
deleted file mode 100644
index 9533e6fe5..000000000
--- a/prompts/monetization-prompts/01-display-priced-skills.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Prompt 1: Display Priced Skills in Marketplace
-
-**Status:** - [ ] Not Started
-
-## 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);
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/01-display-priced-skills.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/02-add-purchase-button.md b/prompts/monetization-prompts/02-add-purchase-button.md
deleted file mode 100644
index baf7ef19f..000000000
--- a/prompts/monetization-prompts/02-add-purchase-button.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# Prompt 2: Add Purchase Button for Priced Skills
-
-**Status:** - [ ] Not Started
-
-## Objective
-On the agent detail page, display a "Purchase" button next to paid skills and an "Owned" or "Equipped" label for skills the user has already purchased.
-
-## Explanation
-Building on the previous step, now that prices are displayed, the next logical step is to provide a call to action for users to buy the skill. This prompt focuses on updating the UI to include this button and reflect the user's ownership status of a skill.
-
-## Instructions
-1. **Fetch User's Purchased Skills:**
- * You'll need an API endpoint to get the skills a user has purchased for a specific agent. Let's assume a new endpoint `/api/users/me/agent-skills/:agentId`.
- * This endpoint should return a list of skill names the user owns for that agent.
-
-2. **Update Frontend Data Fetching:**
- * In `src/marketplace.js`, within `renderDetail`, after fetching the agent details, make another API call to fetch the user's purchased skills for the current agent.
-
-3. **Modify UI Rendering Logic:**
- * In the `renderDetail` function, when looping through the agent's skills, you now have access to `skillPrices` and the `purchasedSkills`.
- * The logic for rendering each skill entry should be updated:
- * If the skill is free (no price in `skillPrices`), show the "Free" badge.
- * If the skill is paid and the user has purchased it (skill name is in `purchasedSkills`), show an "Owned" badge/label.
- * If the skill is paid and the user has *not* purchased it, show the price and a "Purchase" button.
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// Inside renderDetail function, after fetching agent and purchased skills
-
-const skillPrices = a.skill_prices || {};
-const purchasedSkills = userSkills || []; // from new API call
-
-$('d-skills').innerHTML = skillsArr.length
- ? skillsArr.map((s) => {
- const name = typeof s === 'string' ? s : (s.name || '');
- const price = skillPrices[name];
- const isOwned = purchasedSkills.includes(name);
-
- let badgeOrButton = '';
- if (isOwned) {
- badgeOrButton = `<span class="skill-status-badge skill-owned">Owned</span>`;
- } else if (price) {
- const priceInUSDC = (price.amount / 1e6).toFixed(2);
- badgeOrButton = `<button class="purchase-btn" data-skill-name="${escapeHtml(name)}">Purchase for ${priceInUSDC} USDC</button>`;
- } else {
- badgeOrButton = `<span class="price-badge price-free">Free</span>`;
- }
-
- return `<div class="skill-entry">
- <span class="skill-name">${escapeHtml(name)}</span>
- ${badgeOrButton}
- </div>`;
- }).join('')
- : '<div>This Agent has no skills defined.</div>';
-
-```
-
-## CSS Example
-
-Add these styles to `/marketplace.css` for the new elements.
-
-```css
-.skill-entry {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 8px 0;
- border-bottom: 1px solid var(--border);
-}
-
-.purchase-btn {
- background-color: var(--accent);
- color: white;
- border: none;
- padding: 6px 12px;
- font-size: 12px;
- font-weight: 600;
- border-radius: 6px;
- cursor: pointer;
- transition: background-color 0.2s;
-}
-
-.purchase-btn:hover {
- background-color: #5a4ccc; /* A slightly darker shade of accent */
-}
-
-.skill-status-badge {
- display: inline-block;
- padding: 2px 6px;
- font-size: 10px;
- font-weight: 600;
- border-radius: 4px;
- vertical-align: middle;
-}
-
-.skill-owned {
- color: #a7f3d0;
- background-color: rgba(52, 211, 153, 0.1);
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/02-add-purchase-button.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/02-database-schema-skill-prices.md b/prompts/monetization-prompts/02-database-schema-skill-prices.md
deleted file mode 100644
index d5412fb1e..000000000
--- a/prompts/monetization-prompts/02-database-schema-skill-prices.md
+++ /dev/null
@@ -1,63 +0,0 @@
-# Prompt 02: Database Schema for Skill Prices
-
-## Objective
-Create the necessary database table to store pricing information for agent skills.
-
-## Explanation
-To make skills sellable, we need a way to persist their price, currency, and associated creator. This prompt establishes the foundational database schema for skill monetization. The `agent_skill_prices` table will be the single source of truth for skill pricing.
-
-## Instructions
-1. **Locate the Schema File:**
- * Find the main database schema definition file at `api/_lib/schema.sql`.
-
-2. **Define the `agent_skill_prices` Table:**
- * Add a new `CREATE TABLE` statement to `schema.sql`.
- * The table should include the following columns:
- * `id`: A UUID primary key.
- * `agent_id`: A UUID foreign key referencing `agent_identities(id)`.
- * `skill_id`: A text field representing the unique identifier of the skill (e.g., its URI or name).
- * `creator_id`: A UUID foreign key referencing `users(id)`, to know who gets paid.
- * `amount`: A `BIGINT` to store the price in the smallest unit of the currency (e.g., lamports for SOL, or 10^-6 for USDC).
- * `currency_mint`: A text field for the mint address of the currency (e.g., the USDC mint address on Solana).
- * `created_at`, `updated_at`, `deleted_at`: Standard timestamp columns.
-
-3. **Add an Index:**
- * Create a unique index on `(agent_id, skill_id)` to ensure a skill on a specific agent can only have one price.
-
-## SQL Example
-
-```sql
--- In api/_lib/schema.sql
-
-CREATE TABLE agent_skill_prices (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
- skill_id TEXT NOT NULL,
- creator_id UUID NOT NULL REFERENCES users(id),
- amount BIGINT NOT NULL CHECK (amount > 0),
- currency_mint TEXT NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- deleted_at TIMESTAMPTZ
-);
-
-CREATE UNIQUE INDEX idx_agent_skill_prices_one_price_per_skill
-ON agent_skill_prices (agent_id, skill_id)
-WHERE deleted_at IS NULL;
-
-CREATE INDEX idx_agent_skill_prices_creator_id ON agent_skill_prices(creator_id);
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/02-database-schema-skill-prices.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/02-purchase-skill-button.md b/prompts/monetization-prompts/02-purchase-skill-button.md
deleted file mode 100644
index 4e12906a0..000000000
--- a/prompts/monetization-prompts/02-purchase-skill-button.md
+++ /dev/null
@@ -1,85 +0,0 @@
----
-status: not-started
----
-
-# Prompt 02: Add Purchase Button for Priced Skills
-
-## Objective
-Add a "Purchase" button next to paid skills on the agent detail page, creating a clear call-to-action for users.
-
-## Explanation
-With prices now visible, the next step is to provide a way for users to initiate a purchase. This prompt focuses on adding the button to the UI. The button's functionality will be implemented in subsequent steps.
-
-## Instructions
-- [ ] **Update the Frontend UI (`src/marketplace.js`):**
- - [ ] Modify the `renderDetail` function.
- - [ ] In the skill rendering loop, if a skill is paid, render a "Purchase" button next to the price badge.
- - [ ] For now, we will assume the user does not own any skills. In a later prompt, we will fetch user ownership data and update the button state (e.g., to a disabled "Unlocked" button).
- - [ ] Add a `data-skill-name` attribute to the button to easily identify which skill is being purchased when the button is clicked.
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// Inside renderDetail's map function for skills
-const name = typeof s === 'string' ? s : (s.name || '');
-const price = skillPrices[name];
-
-if (price) {
- // In a future step, isOwned will be dynamically determined.
- const isOwned = false;
- const priceText = `${(price.amount / 1e6).toFixed(2)} USDC`;
- const badge = `<span class="price-badge price-paid">${priceText}</span>`;
- const button = isOwned
- ? `<button class="purchase-btn" disabled>Unlocked</button>`
- : `<button class="purchase-btn" data-skill-name="${escapeHtml(name)}">Purchase</button>`;
- return `<span class="skill-entry">${escapeHtml(name)}${badge}${button}</span>`;
-} else {
- const badge = `<span class="price-badge price-free">Free</span>`;
- return `<span class="skill-entry">${escapeHtml(name)}${badge}</span>`;
-}
-```
-
-## CSS Example
-
-Add these styles to a relevant CSS file.
-
-```css
-.purchase-btn {
- margin-left: 8px;
- padding: 4px 10px;
- font-size: 12px;
- font-weight: 600;
- border-radius: 6px;
- border: 1px solid #fde047;
- background-color: transparent;
- color: #fde047;
- cursor: pointer;
- transition: background-color 0.2s, color 0.2s;
-}
-
-.purchase-btn:hover {
- background-color: #fde047;
- color: #111;
-}
-
-.purchase-btn:disabled {
- border-color: #444;
- color: #444;
- cursor: not-allowed;
- background-color: transparent;
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/02-purchase-skill-button.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/03-create-purchase-modal.md b/prompts/monetization-prompts/03-create-purchase-modal.md
deleted file mode 100644
index e2eae4e3e..000000000
--- a/prompts/monetization-prompts/03-create-purchase-modal.md
+++ /dev/null
@@ -1,142 +0,0 @@
-# Prompt 3: Create Purchase Confirmation Modal
-
-**Status:** - [ ] Not Started
-
-## Objective
-Implement a modal dialog that appears when a user clicks the "Purchase" button for a skill, asking for confirmation before proceeding with the transaction.
-
-## Explanation
-A confirmation step is crucial for any purchasing flow to prevent accidental purchases. This modal will summarize the transaction (skill name, price) and require an explicit user action to continue. It will serve as the container for wallet interactions in subsequent steps.
-
-## Instructions
-1. **Create Modal HTML Structure:**
- * Add the HTML for a modal to `marketplace.html`. It should be hidden by default.
- * The modal should contain elements for the skill name, price, a "Confirm Purchase" button, and a close button.
-
-2. **Add JavaScript Logic to Control the Modal:**
- * In `src/marketplace.js`, add event listeners for the "Purchase" buttons. Since these buttons are dynamically generated, use event delegation on a parent element (e.g., `$('d-skills')`).
- * When a purchase button is clicked, populate the modal with the correct skill name and price.
- * Show the modal.
- * Implement the logic for the close button and for closing the modal by clicking the backdrop.
-
-3. **Style the Modal:**
- * Add CSS to `/marketplace.css` to style the modal, its backdrop, and its contents for a clean, user-friendly appearance.
-
-## Code Example (HTML in `marketplace.html`)
-
-```html
-<!-- Add this somewhere in the body of marketplace.html -->
-<div id="purchase-modal-backdrop" class="modal-backdrop" style="display: none;">
- <div id="purchase-modal" class="modal">
- <div class="modal-header">
- <h2>Confirm Purchase</h2>
- <button id="modal-close-btn" class="modal-close-btn">&times;</button>
- </div>
- <div class="modal-body">
- <p>You are about to purchase the skill:</p>
- <h3 id="modal-skill-name"></h3>
- <p>Price:</p>
- <h3 id="modal-skill-price"></h3>
- </div>
- <div class="modal-footer">
- <button id="modal-confirm-purchase-btn" class="purchase-btn">Confirm Purchase</button>
- </div>
- </div>
-</div>
-```
-
-## Code Example (JavaScript in `src/marketplace.js`)
-
-```javascript
-// At the top of the script
-const purchaseModal = $('purchase-modal-backdrop');
-const modalSkillName = $('modal-skill-name');
-const modalSkillPrice = $('modal-skill-price');
-
-// Event listener using delegation
-$('d-skills').addEventListener('click', (e) => {
- if (e.target.classList.contains('purchase-btn')) {
- const skillName = e.target.dataset.skillName;
- const agent = window.currentAgent; // Assuming current agent data is available
- const priceInfo = agent.skill_prices[skillName];
-
- if (priceInfo) {
- modalSkillName.textContent = skillName;
- modalSkillPrice.textContent = `${(priceInfo.amount / 1e6).toFixed(2)} USDC`;
- purchaseModal.style.display = 'flex';
- }
- }
-});
-
-// Close modal logic
-$('modal-close-btn').addEventListener('click', () => {
- purchaseModal.style.display = 'none';
-});
-purchaseModal.addEventListener('click', (e) => {
- if (e.target === purchaseModal) {
- purchaseModal.style.display = 'none';
- }
-});
-```
-
-## CSS Example (`/marketplace.css`)
-
-```css
-.modal-backdrop {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.6);
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 1000;
-}
-
-.modal {
- background-color: var(--panel);
- padding: 24px;
- border-radius: 12px;
- border: 1px solid var(--border);
- width: 90%;
- max-width: 400px;
-}
-
-.modal-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid var(--border);
- padding-bottom: 16px;
- margin-bottom: 16px;
-}
-
-.modal-header h2 {
- margin: 0;
- font-size: 18px;
-}
-
-.modal-close-btn {
- background: none;
- border: none;
- font-size: 24px;
- color: var(--muted);
- cursor: pointer;
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/03-create-purchase-modal.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/03-creator-api-set-skill-prices.md b/prompts/monetization-prompts/03-creator-api-set-skill-prices.md
deleted file mode 100644
index ed7c5c36c..000000000
--- a/prompts/monetization-prompts/03-creator-api-set-skill-prices.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Prompt 03: Creator API to Set Skill Prices
-
-## Objective
-Create a secure API endpoint for agent creators to set, update, and remove prices for their skills.
-
-## Explanation
-With the database schema in place, creators need a way to manage their skill prices. This requires a new API endpoint that authenticates the user, verifies they own the agent, and allows them to perform CRUD operations on the `agent_skill_prices` table for that agent.
-
-## Instructions
-1. **Create a New API Endpoint File:**
- * Create a new file, for example, `api/agents/[id]/skill-prices.js`. Vercel's file-based routing will handle the `[id]` parameter.
-
-2. **Implement the Endpoint Logic:**
- * The endpoint should handle `POST`, `PUT`, and `DELETE` requests.
- * **Authentication:** Use the existing `getSessionUser` or `authenticateBearer` helpers to get the current user.
- * **Authorization:** Verify that the authenticated user is the owner of the agent specified in the URL (`agent_id`). Query `agent_identities` to check ownership.
- * **`POST` (Create):**
- * Accept a payload with `skill_id`, `amount`, and `currency_mint`.
- * Insert a new record into `agent_skill_prices`.
- * **`PUT` (Update):**
- * Accept `skill_id` and the new `amount`.
- * Update the existing record in `agent_skill_prices`.
- * **`DELETE` (Remove):**
- * Accept `skill_id`.
- * Soft-delete the record by setting `deleted_at`.
- * **Validation:** Use `zod` to validate the incoming request bodies.
-
-## Code Example (`api/agents/[id]/skill-prices.js`)
-
-```javascript
-import { sql } from '../_lib/db.js';
-import { getSessionUser } from '../_lib/auth.js';
-import { error, json, wrap } from '../_lib/http.js';
-import { z } from 'zod';
-
-const priceSchema = z.object({
- skill_id: z.string().min(1),
- amount: z.number().int().positive(),
- currency_mint: z.string().min(32), // Solana mint address length
-});
-
-export default wrap(async (req, res) => {
- const user = await getSessionUser(req);
- if (!user) return error(res, 401, 'unauthorized');
-
- const agentId = req.query.id;
- const [agent] = await sql`
- SELECT user_id FROM agent_identities WHERE id = ${agentId} AND deleted_at IS NULL
- `;
-
- if (!agent || agent.user_id !== user.id) {
- return error(res, 403, 'forbidden', 'You do not own this agent.');
- }
-
- if (req.method === 'POST') {
- const body = priceSchema.parse(await req.json());
- await sql`
- INSERT INTO agent_skill_prices (agent_id, skill_id, creator_id, amount, currency_mint)
- VALUES (${agentId}, ${body.skill_id}, ${user.id}, ${body.amount}, ${body.currency_mint})
- `;
- return json(res, { success: true });
- }
-
- // ... implement PUT and DELETE handlers similarly ...
-
- return error(res, 405, 'method_not_allowed');
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/03-creator-api-set-skill-prices.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/03-skill-purchase-modal.md b/prompts/monetization-prompts/03-skill-purchase-modal.md
deleted file mode 100644
index e6a01b94a..000000000
--- a/prompts/monetization-prompts/03-skill-purchase-modal.md
+++ /dev/null
@@ -1,78 +0,0 @@
----
-status: not-started
----
-
-# Prompt 03: Create Skill Purchase Modal
-
-## Objective
-Create a modal that appears when a user clicks the "Purchase" button, confirming the skill details and price before the transaction.
-
-## Explanation
-A confirmation modal prevents accidental purchases and provides a clear, focused step in the user journey. This modal will be the central point for initiating the wallet transaction.
-
-## Instructions
-- [ ] **Create the Modal HTML:**
- - [ ] Add the HTML structure for a hidden modal to `marketplace.html`. It should include placeholders for the skill name, price, and agent name, along with "Confirm Purchase" and "Cancel" buttons.
-
-- [ ] **Add JavaScript Logic (`src/marketplace.js`):**
- - [ ] Create a new function, `openPurchaseModal(skillName, price, agentName)`. This function will populate the modal with the correct data and make it visible.
- - [ ] Attach an event listener to the `d-skills` container that listens for clicks on `.purchase-btn`.
- - [ ] When a purchase button is clicked, get the skill name from the `data-skill-name` attribute, find its price from the agent data, and call `openPurchaseModal`.
- - [ ] Add event listeners for the "Confirm" and "Cancel" buttons within the modal. For now, they can just log to the console.
-
-## HTML Example (in `marketplace.html`)
-
-```html
-<div id="purchase-modal" class="modal-hidden">
- <div class="modal-content">
- <h2>Confirm Purchase</h2>
- <p>Unlock the skill <strong id="modal-skill-name"></strong> for agent <strong id="modal-agent-name"></strong>?</p>
- <div class="modal-price">Price: <span id="modal-skill-price"></span></div>
- <div class="modal-actions">
- <button id="modal-cancel-btn">Cancel</button>
- <button id="modal-confirm-btn">Confirm Purchase</button>
- </div>
- </div>
-</div>
-```
-
-## JavaScript Example (`src/marketplace.js`)
-
-```javascript
-// At the end of init function
-const skillsContainer = document.getElementById('d-skills');
-skillsContainer.addEventListener('click', (event) => {
- if (event.target.classList.contains('purchase-btn')) {
- const skillName = event.target.dataset.skillName;
- // Assume 'currentAgent' is available in a higher scope
- const price = currentAgent.skill_prices[skillName];
- if (price) {
- openPurchaseModal(skillName, price, currentAgent.name);
- }
- }
-});
-
-function openPurchaseModal(skillName, price, agentName) {
- document.getElementById('modal-skill-name').textContent = skillName;
- document.getElementById('modal-agent-name').textContent = agentName;
- const priceText = `${(price.amount / 1e6).toFixed(2)} USDC`;
- document.getElementById('modal-skill-price').textContent = priceText;
- document.getElementById('purchase-modal').classList.remove('modal-hidden');
-}
-
-// Add listeners for modal buttons to close it, etc.
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/03-skill-purchase-modal.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/04-connect-wallet-integration.md b/prompts/monetization-prompts/04-connect-wallet-integration.md
deleted file mode 100644
index 0c1e725b7..000000000
--- a/prompts/monetization-prompts/04-connect-wallet-integration.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# Prompt 4: Connect Wallet Integration
-
-**Status:** - [ ] Not Started
-
-## Objective
-Integrate a "Connect Wallet" feature into the purchase modal, allowing users to connect their Solana wallet before making a purchase.
-
-## Explanation
-To purchase skills, users must have a connected Solana wallet. This prompt focuses on adding the necessary UI and logic to handle wallet connection directly within the purchase flow, ensuring a seamless user experience. We will use `@solana/wallet-adapter-react` and related libraries, which might already be in the project.
-
-## Instructions
-1. **Add a Wallet Connection Button:**
- * In the purchase modal's HTML, add a "Connect Wallet" button. This button should be shown if the user's wallet is not connected, and the "Confirm Purchase" button should be hidden.
-
-2. **Implement Wallet Connection Logic:**
- * Use a wallet adapter library (like `@solana/wallet-adapter-react` or equivalent for vanilla JS) to handle the wallet connection logic.
- * When the "Connect Wallet" button is clicked, trigger the wallet adapter's connection modal.
- * Once the wallet is connected, update the UI of the purchase modal to hide the "Connect Wallet" button and show the "Confirm Purchase" button.
-
-3. **Manage Wallet State:**
- * Maintain a global state that tracks the user's wallet connection status and public key.
- * The `renderDetail` function and the purchase modal logic should react to changes in this wallet state.
-
-## Code Example (JavaScript in `src/marketplace.js`)
-
-```javascript
-// This example assumes a wallet adapter setup that exposes a `wallet` object
-// and `connectWallet` function.
-
-// In the event listener for the purchase button
-$('d-skills').addEventListener('click', (e) => {
- if (e.target.classList.contains('purchase-btn')) {
- // ... (previous modal logic)
-
- // New logic to handle wallet connection
- if (wallet.connected) {
- $('modal-connect-wallet-btn').style.display = 'none';
- $('modal-confirm-purchase-btn').style.display = 'block';
- } else {
- $('modal-connect-wallet-btn').style.display = 'block';
- $('modal-confirm-purchase-btn').style.display = 'none';
- }
-
- purchaseModal.style.display = 'flex';
- }
-});
-
-// Event listener for the new connect wallet button
-$('modal-connect-wallet-btn').addEventListener('click', async () => {
- try {
- await connectWallet();
- // After successful connection, update the modal UI
- $('modal-connect-wallet-btn').style.display = 'none';
- $('modal-confirm-purchase-btn').style.display = 'block';
- } catch (error) {
- console.error('Failed to connect wallet:', error);
- // Handle connection error (e.g., show a toast message)
- }
-});
-```
-
-## Code Example (HTML in `marketplace.html`)
-
-```html
-<!-- Update the modal footer -->
-<div class="modal-footer">
- <button id="modal-connect-wallet-btn" class="purchase-btn" style="display: none;">Connect Wallet</button>
- <button id="modal-confirm-purchase-btn" class="purchase-btn" style="display: none;">Confirm Purchase</button>
-</div>
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/04-connect-wallet-integration.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/04-database-schema-user-purchases.md b/prompts/monetization-prompts/04-database-schema-user-purchases.md
deleted file mode 100644
index 2e42f7333..000000000
--- a/prompts/monetization-prompts/04-database-schema-user-purchases.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# Prompt 04: Database Schema for User Skill Purchases
-
-## Objective
-Create a database table to track which users have purchased which skills, effectively acting as a license or entitlement ledger.
-
-## Explanation
-When a user buys a skill, we need to record that transaction to grant them access. The `user_skill_purchases` table will store this information, linking a user, a skill, and the transaction details of their purchase. This table is critical for gating access to paid skills.
-
-## Instructions
-1. **Locate the Schema File:**
- * Open the main database schema definition file at `api/_lib/schema.sql`.
-
-2. **Define the `user_skill_purchases` Table:**
- * Add a `CREATE TABLE` statement for `user_skill_purchases`.
- * The table should include:
- * `id`: UUID primary key.
- * `user_id`: Foreign key to `users(id)`.
- * `agent_id`: Foreign key to `agent_identities(id)`.
- * `skill_id`: The identifier of the purchased skill.
- * `price_id`: Foreign key to `agent_skill_prices(id)` to link to the exact price at time of purchase.
- * `transaction_id`: A text field to store the on-chain transaction signature.
- * `status`: An enum or text field for the purchase status (e.g., 'pending', 'confirmed', 'failed').
- * `created_at`: Standard timestamp.
-
-3. **Add Indexes:**
- * Create a unique index on `(user_id, agent_id, skill_id)` to prevent duplicate purchase records.
- * Create an index on `transaction_id` for quick lookups.
-
-## SQL Example
-
-```sql
--- In api/_lib/schema.sql
-
-CREATE TYPE purchase_status AS ENUM ('pending', 'confirmed', 'failed');
-
-CREATE TABLE user_skill_purchases (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- user_id UUID NOT NULL REFERENCES users(id),
- agent_id UUID NOT NULL REFERENCES agent_identities(id),
- skill_id TEXT NOT NULL,
- price_id UUID NOT NULL REFERENCES agent_skill_prices(id),
- transaction_id TEXT, -- e.g., Solana transaction signature
- status purchase_status NOT NULL DEFAULT 'pending',
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
-);
-
-CREATE UNIQUE INDEX idx_user_skill_purchases_one_per_user
-ON user_skill_purchases (user_id, agent_id, skill_id);
-
-CREATE INDEX idx_user_skill_purchases_tx_id ON user_skill_purchases(transaction_id);
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/04-database-schema-user-purchases.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/04-wallet-integration-setup.md b/prompts/monetization-prompts/04-wallet-integration-setup.md
deleted file mode 100644
index 3ae2d006f..000000000
--- a/prompts/monetization-prompts/04-wallet-integration-setup.md
+++ /dev/null
@@ -1,90 +0,0 @@
----
-status: not-started
----
-
-# Prompt 04: Frontend Wallet Integration Setup
-
-## Objective
-Integrate a Solana wallet adapter to allow users to connect their wallets (e.g., Phantom) to the application.
-
-## Explanation
-To perform any on-chain transactions, the user must first connect their cryptocurrency wallet. This step involves adding the necessary libraries and UI elements for wallet connection. We will use the official Solana wallet-adapter libraries.
-
-## Instructions
-- [ ] **Add Wallet-Adapter Libraries:**
- - [ ] Include the Solana wallet-adapter scripts in `marketplace.html`. You can use a CDN like unpkg for this proof-of-concept. You'll need `@solana/wallet-adapter-base` and `@solana/wallet-adapter-wallets`, plus the DOM integration package.
-
-- [ ] **Add "Connect Wallet" Button:**
- - [ ] Add a "Connect Wallet" button to the header of the application. The button text should dynamically update to show the user's wallet address when connected.
-
-- [ ] **Initialize the Wallet Adapter:**
- - [ ] In your main JavaScript file (`src/marketplace.js`), initialize the wallet adapter.
- - [ ] Configure the wallets you want to support (e.g., Phantom, Solflare).
- - [ ] Add logic to the "Connect Wallet" button to trigger the connection prompt.
- - [ ] Listen for connection status changes to update the UI accordingly.
-
-## HTML Example (in `marketplace.html` header)
-
-```html
-<div class="wallet-controls">
- <button id="connect-wallet-btn">Connect Wallet</button>
-</div>
-```
-
-## JavaScript Example (`src/marketplace.js`)
-
-```javascript
-// This is a simplified example. Refer to Solana wallet-adapter docs for the full setup.
-
-// Use imports if you have a build system, or window vars from CDN
-const { WalletAdapterNetwork } = solanaWalletAdapter;
-const {
- ConnectionProvider,
- WalletProvider,
-} = solanaWalletAdapterReact;
-const {
- WalletModalProvider,
- WalletMultiButton,
-} = solanaWalletAdapterReactUi;
-
-// In your main app logic
-const network = WalletAdapterNetwork.Devnet;
-const endpoint = web3.clusterApiUrl(network);
-const wallets = [new PhantomWalletAdapter()];
-
-// You would typically wrap your app in providers.
-// For vanilla JS, you'll need to instantiate and manage the adapter manually.
-
-const wallet = ... // initialization logic
-
-const connectBtn = document.getElementById('connect-wallet-btn');
-connectBtn.addEventListener('click', async () => {
- try {
- await wallet.connect();
- } catch (error) {
- console.error('Failed to connect wallet', error);
- }
-});
-
-wallet.on('connect', (publicKey) => {
- connectBtn.textContent = `${publicKey.toBase58().slice(0, 4)}...${publicKey.toBase58().slice(-4)}`;
-});
-
-wallet.on('disconnect', () => {
- connectBtn.textContent = 'Connect Wallet';
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/04-wallet-integration-setup.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/05-api-initiate-purchase.md b/prompts/monetization-prompts/05-api-initiate-purchase.md
deleted file mode 100644
index 942b0c6a5..000000000
--- a/prompts/monetization-prompts/05-api-initiate-purchase.md
+++ /dev/null
@@ -1,88 +0,0 @@
-# Prompt 05: API Endpoint to Initiate a Purchase
-
-## Objective
-Create a backend endpoint that initiates the skill purchase process by creating a pending purchase record and returning transaction details to the client.
-
-## Explanation
-The purchase flow begins when a user clicks "buy". This endpoint will be responsible for creating a record in the `user_skill_purchases` table with a 'pending' status. For a Solana-based payment, it will then generate the necessary parameters for the frontend to construct a Solana Pay transaction request.
-
-## Instructions
-1. **Create the API Endpoint File:**
- * Create a new file, e.g., `api/marketplace/purchase.js`.
-
-2. **Implement the `POST` Handler:**
- * **Authentication:** Get the logged-in user.
- * **Input Validation:** Expect an `agent_id` and `skill_id` in the request body. Use `zod` for validation.
- * **Check for Existing Purchase:** Verify the user hasn't already bought this skill.
- * **Fetch Skill Price:** Get the current price from `agent_skill_prices`.
- * **Create Pending Record:** Insert a new row into `user_skill_purchases` with `status = 'pending'`.
- * **Generate Solana Pay Parameters:**
- * Create a unique reference key for the transaction (e.g., the new purchase ID).
- * Return the recipient address (the creator's wallet), the SPL token mint (e.g., USDC), the amount, and the reference key.
- * **Return Response:** Send back the Solana Pay parameters and the `purchaseId` to the client.
-
-## Code Example (`api/marketplace/purchase.js`)
-
-```javascript
-import { sql } from '../_lib/db.js';
-import { getSessionUser } from '../_lib/auth.js';
-import { error, json, wrap } from '../_lib/http.js';
-import { z } from 'zod';
-import { Keypair } from '@solana/web3.js'; // Assuming solana-sdk is available
-
-const purchaseSchema = z.object({
- agent_id: z.string().uuid(),
- skill_id: z.string().min(1),
-});
-
-export default wrap(async (req, res) => {
- if (req.method !== 'POST') return error(res, 405, 'method_not_allowed');
-
- const user = await getSessionUser(req);
- if (!user) return error(res, 401, 'unauthorized');
-
- const body = purchaseSchema.parse(await req.json());
-
- // Fetch price and creator info
- const [priceInfo] = await sql`
- SELECT id, creator_id, amount, currency_mint
- FROM agent_skill_prices
- WHERE agent_id = ${body.agent_id} AND skill_id = ${body.skill_id} AND deleted_at IS NULL
- `;
- if (!priceInfo) return error(res, 404, 'price_not_found');
-
- // TODO: Fetch creator's wallet address from users table
- const creatorWallet = '...'; // Placeholder
-
- // Create pending purchase record
- const [purchase] = await sql`
- INSERT INTO user_skill_purchases (user_id, agent_id, skill_id, price_id, status)
- VALUES (${user.id}, ${body.agent_id}, ${body.skill_id}, ${priceInfo.id}, 'pending')
- RETURNING id
- `;
-
- // Return details for Solana Pay transaction
- return json(res, {
- purchaseId: purchase.id,
- recipient: creatorWallet,
- amount: (priceInfo.amount / 1_000_000).toString(), // Assuming 6 decimals for USDC
- splToken: priceInfo.currency_mint,
- reference: purchase.id,
- label: `3D-Agent Skill: ${body.skill_id}`,
- });
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/05-api-initiate-purchase.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/05-solana-pay-integration.md b/prompts/monetization-prompts/05-solana-pay-integration.md
deleted file mode 100644
index ee6993c9c..000000000
--- a/prompts/monetization-prompts/05-solana-pay-integration.md
+++ /dev/null
@@ -1,84 +0,0 @@
----
-status: not-started
----
-
-# Prompt 05: Solana Pay Transaction Integration
-
-## Objective
-Integrate Solana Pay into the purchase modal to generate a transaction for the user to sign.
-
-## Explanation
-When the user clicks "Confirm Purchase", we need to construct and present a Solana transaction. We'll use the Solana Pay standard, which allows for reliable transaction requests. The backend will create the transaction, and the frontend will use it.
-
-## Instructions
-- [ ] **Create a Backend Endpoint for Transaction Creation:**
- - [ ] Create a new API endpoint, e.g., `POST /api/transactions/create-skill-purchase`.
- - [ ] This endpoint will take `agentId`, `skillName`, and the `buyerPublicKey` as input.
- - [ ] It should look up the skill price, the creator's destination wallet, and the platform fee wallet.
- - [ ] Using the Solana SDK (`@solana/web3.js`), it will construct a transaction that transfers the correct amount of USDC from the buyer to the creator (and platform).
- - [ ] The endpoint should return the serialized transaction.
-
-- [ ] **Update Frontend Modal Logic:**
- - [ ] In `src/marketplace.js`, modify the event listener for the "Confirm Purchase" button (`#modal-confirm-btn`).
- - [ ] When clicked, it should first check if the user's wallet is connected.
- - [ ] Then, it should make a `POST` request to your new backend endpoint.
- - [ ] The frontend receives the serialized transaction from the backend.
-
-- [ ] **Sign and Send the Transaction:**
- - [ ] Use the wallet-adapter's `sendTransaction` method to ask the user to sign and send the transaction received from the backend.
- - [ ] Handle potential errors during this process (e.g., user rejection).
-
-## JavaScript Example (`src/marketplace.js` - Confirm Button Listener)
-
-```javascript
-const confirmBtn = document.getElementById('modal-confirm-btn');
-confirmBtn.addEventListener('click', async () => {
- if (!wallet.connected) {
- alert('Please connect your wallet first.');
- return;
- }
-
- // Get details from modal/app state
- const skillName = document.getElementById('modal-skill-name').textContent;
- const buyerPublicKey = wallet.publicKey.toBase58();
-
- try {
- // 1. Fetch transaction from backend
- const response = await fetch('/api/transactions/create-skill-purchase', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ skillName, agentId: currentAgent.id, buyerPublicKey }),
- });
- const { transaction } = await response.json();
-
- // 2. Deserialize and send
- const connection = new solanaWeb3.Connection(solanaWeb3.clusterApiUrl('devnet'));
- const tx = solanaWeb3.Transaction.from(Buffer.from(transaction, 'base64'));
-
- const signature = await wallet.sendTransaction(tx, connection);
-
- // 3. Start polling for confirmation (covered in next prompt)
- console.log('Transaction sent with signature:', signature);
- await connection.confirmTransaction(signature, 'processed');
- alert('Purchase successful!');
-
- } catch (error) {
- console.error('Purchase failed', error);
- alert('Purchase failed. See console for details.');
- }
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/05-solana-pay-integration.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/05-spl-token-transfer.md b/prompts/monetization-prompts/05-spl-token-transfer.md
deleted file mode 100644
index 5198a60cc..000000000
--- a/prompts/monetization-prompts/05-spl-token-transfer.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# Prompt 5: Execute SPL Token Transfer for Purchase
-
-**Status:** - [ ] Not Started
-
-## Objective
-Implement the client-side logic to construct and send a Solana transaction to transfer SPL tokens (e.g., USDC) from the user's wallet to the creator's wallet when the "Confirm Purchase" button is clicked.
-
-## Explanation
-This is the core of the purchase transaction. When a user confirms they want to buy a skill, the frontend needs to create a transaction, have the user sign it with their wallet, and send it to the Solana network.
-
-## Instructions
-1. **Gather Transaction Details:**
- * When the "Confirm Purchase" button is clicked, you need the following information:
- * User's public key (from the connected wallet).
- * Creator's public key (this should be part of the agent's data).
- * The price (amount).
- * The currency mint address (e.g., USDC mint address).
-
-2. **Construct the Transaction:**
- * Use `@solana/web3.js` to create a new `Transaction`.
- * Add an instruction to the transaction to transfer the SPL token. You will need functions from `@solana/spl-token` to create the transfer instruction.
- * The instruction will need the source token account, destination token account, amount, and the user's public key as the owner.
- * **Important:** You'll need to find the user's and the creator's associated token accounts for the given mint.
-
-3. **Sign and Send the Transaction:**
- * Use the `sendTransaction` method provided by the wallet adapter, passing it the transaction you constructed.
- * The wallet adapter will prompt the user to approve and sign the transaction.
- * Await the confirmation of the transaction.
-
-## Code Example (JavaScript in `src/marketplace.js`)
-
-```javascript
-// This assumes a wallet adapter that provides a `publicKey` and `sendTransaction` function.
-import { Connection, PublicKey, Transaction } from '@solana/web3.js';
-import { getAssociatedTokenAddress, createTransferInstruction } from '@solana/spl-token';
-
-const connection = new Connection('your_rpc_url');
-
-$('modal-confirm-purchase-btn').addEventListener('click', async () => {
- const agent = window.currentAgent;
- const skillName = $('modal-skill-name').textContent;
- const priceInfo = agent.skill_prices[skillName];
- const creatorPublicKey = new PublicKey(agent.creator_address);
- const userPublicKey = wallet.publicKey;
-
- if (!priceInfo || !creatorPublicKey || !userPublicKey) {
- console.error('Missing required info for transaction');
- return;
- }
-
- try {
- const currencyMint = new PublicKey(priceInfo.currency_mint);
-
- // Get the associated token accounts
- const userTokenAccount = await getAssociatedTokenAddress(currencyMint, userPublicKey);
- const creatorTokenAccount = await getAssociatedTokenAddress(currencyMint, creatorPublicKey);
-
- const transaction = new Transaction().add(
- createTransferInstruction(
- userTokenAccount,
- creatorTokenAccount,
- userPublicKey,
- priceInfo.amount,
- [],
- )
- );
-
- const signature = await wallet.sendTransaction(transaction, connection);
- await connection.confirmTransaction(signature, 'processed');
-
- console.log('Transaction successful with signature:', signature);
- // Next step: Call backend to record the purchase
-
- } catch (error) {
- console.error('Transaction failed:', error);
- // Show error message to user
- }
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/05-spl-token-transfer.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/06-backend-purchase-endpoint.md b/prompts/monetization-prompts/06-backend-purchase-endpoint.md
deleted file mode 100644
index a82eed315..000000000
--- a/prompts/monetization-prompts/06-backend-purchase-endpoint.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# Prompt 6: Create Backend Endpoint to Verify and Record Purchase
-
-**Status:** - [ ] Not Started
-
-## Objective
-Create a backend API endpoint that the frontend can call after a Solana transaction is successfully confirmed. This endpoint will verify the transaction on-chain and record the skill ownership in the database.
-
-## Explanation
-Client-side confirmation of a transaction is not enough. For security and reliability, the backend must independently verify that the correct payment was made before granting the user access to the skill.
-
-## Instructions
-1. **Create a New API Endpoint:**
- * Create a new file for the endpoint, e.g., `api/marketplace/purchase-skill.js`.
- * This endpoint should accept the `agentId`, `skillName`, and the `transactionSignature` as input.
- * It must be an authenticated endpoint, ensuring a user is logged in.
-
-2. **Implement Transaction Verification:**
- * In the endpoint's handler, use `@solana/web3.js` to connect to a Solana RPC node.
- * Fetch the confirmed transaction using the provided signature.
- * Parse the transaction details to verify:
- * The transaction was successful.
- * The source address matches the logged-in user's wallet address.
- * The destination address matches the agent creator's wallet address.
- * The transferred amount is correct for the skill being purchased.
- * The mint of the transferred token is correct.
-
-3. **Record Ownership in the Database:**
- * If verification is successful, insert a new record into a table that tracks skill ownership. Let's call this table `user_agent_skills`.
- * The table should store at least the `user_id`, `agent_id`, and `skill_name`.
-
-## Code Example (Backend - `api/marketplace/purchase-skill.js`)
-
-```javascript
-import { Connection, PublicKey } from '@solana/web3.js';
-import { getDB } from './_lib/db'; // Your database utility
-
-export default async function handler(req, res) {
- // Assume user is authenticated and user ID is available
- const userId = req.user.id;
- const { agentId, skillName, transactionSignature } = req.body;
-
- // Fetch agent and skill price details from your DB
- const db = getDB();
- const agent = await db.getAgent(agentId);
- const skillPrice = await db.getSkillPrice(agentId, skillName);
-
- if (!agent || !skillPrice) {
- return res.status(404).json({ error: 'Agent or skill not found.' });
- }
-
- try {
- const connection = new Connection('your_rpc_url');
- const tx = await connection.getParsedTransaction(transactionSignature, 'confirmed');
-
- if (!tx) throw new Error('Transaction not found.');
-
- // Very simplified verification logic. In reality, this needs to be very robust.
- const instruction = tx.transaction.message.instructions.find(
- (ix) => ix.parsed?.type === 'transfer'
- );
-
- const transferInfo = instruction.parsed.info;
- const isCorrectAmount = BigInt(transferInfo.amount) === BigInt(skillPrice.amount);
- const isCorrectDestination = new PublicKey(transferInfo.destination).equals(new PublicKey(agent.creator_address));
-
- if (isCorrectAmount && isCorrectDestination) {
- // Record the purchase in the database
- await db.recordSkillPurchase(userId, agentId, skillName);
- return res.status(200).json({ success: true, message: 'Purchase successful!' });
- } else {
- throw new Error('Transaction verification failed.');
- }
-
- } catch (error) {
- console.error('Purchase verification failed:', error);
- return res.status(500).json({ error: 'Purchase verification failed.' });
- }
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/06-backend-purchase-endpoint.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/06-frontend-solana-pay-qr-code.md b/prompts/monetization-prompts/06-frontend-solana-pay-qr-code.md
deleted file mode 100644
index 7e530d0a2..000000000
--- a/prompts/monetization-prompts/06-frontend-solana-pay-qr-code.md
+++ /dev/null
@@ -1,77 +0,0 @@
-# Prompt 06: Solana Pay Integration for QR Code
-
-## Objective
-Integrate Solana Pay on the frontend to generate a payment QR code when a user decides to buy a skill.
-
-## Explanation
-Solana Pay provides a seamless mobile payment experience. After the backend creates a pending purchase and returns the transaction details, the frontend needs to use those details to construct a Solana Pay URL and display it as a QR code. This allows the user to approve the transaction from their mobile wallet.
-
-## Instructions
-1. **Add a QR Code Library:**
- * Install a client-side QR code generation library. `qrcode` is a popular choice.
- * `npm install qrcode`
-
-2. **Create a Purchase Modal:**
- * In `marketplace.html`, create a hidden modal element that will display the QR code.
- * This modal should have a canvas element for the QR code and show the price and skill name.
-
-3. **Implement QR Code Generation:**
- * In `src/marketplace.js`, create a function, e.g., `showPurchaseModal(txDetails)`.
- * This function will be called with the response from the `/api/marketplace/purchase` endpoint.
- * **Construct Solana Pay URL:** Create a URL according to the Solana Pay spec. The URL will be `solana:<recipient>?amount=<amount>&spl-token=<splToken>&reference=<reference>&label=<label>`.
- * **Render QR Code:** Use the `qrcode` library to render the Solana Pay URL into the modal's canvas.
- * **Show the Modal:** Make the purchase modal visible to the user.
-
-## Code Example (`src/marketplace.js`)
-
-```javascript
-import QRCode from 'qrcode';
-
-// ... inside the event listener for a "Buy Skill" button
-
-async function onBuySkill(agentId, skillId) {
- // 1. Call the initiate purchase API
- const res = await fetch('/api/marketplace/purchase', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ agent_id: agentId, skill_id: skillId }),
- });
- const txDetails = await res.json();
-
- // 2. Show the purchase modal
- showPurchaseModal(txDetails);
-}
-
-function showPurchaseModal(txDetails) {
- const modal = $('purchase-modal');
- const canvas = $('qr-canvas');
-
- const url = new URL(`solana:${txDetails.recipient}`);
- url.searchParams.set('amount', txDetails.amount);
- url.searchParams.set('spl-token', txDetails.splToken);
- url.searchParams.set('reference', txDetails.reference);
- url.searchParams.set('label', txDetails.label);
-
- QRCode.toCanvas(canvas, url.toString(), (error) => {
- if (error) console.error(error);
- console.log('QR code generated!');
- });
-
- modal.hidden = false;
- // Start polling for transaction confirmation... (covered in next prompt)
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/06-frontend-solana-pay-qr-code.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/06-transaction-status-polling.md b/prompts/monetization-prompts/06-transaction-status-polling.md
deleted file mode 100644
index 0c7201618..000000000
--- a/prompts/monetization-prompts/06-transaction-status-polling.md
+++ /dev/null
@@ -1,76 +0,0 @@
----
-status: not-started
----
-
-# Prompt 06: Transaction Status Polling and Verification
-
-## Objective
-After a transaction is sent, reliably confirm its success by polling a Solana RPC endpoint and then verifying it on the backend.
-
-## Explanation
-Sending a transaction to the network doesn't guarantee its success. We must confirm it has been processed and finalized. The frontend will poll for initial confirmation to give the user quick feedback, and the backend will do a final verification before unlocking the skill.
-
-## Instructions
-- [ ] **Frontend: Poll for Confirmation:**
- - [ ] After sending the transaction with `sendTransaction`, the wallet adapter returns a transaction signature (txid).
- - [ ] Use the `Connection` object's `confirmTransaction` method. This will poll the RPC until the transaction reaches a certain commitment level (e.g., 'processed' or 'confirmed').
- - [ ] While polling, update the UI to show a "Processing..." state in the purchase modal.
-
-- [ ] **Backend: Create a Verification Endpoint:**
- - [ ] Create a new backend endpoint, e.g., `POST /api/skills/purchase/verify`.
- - [ ] This endpoint will receive the `transactionSignature`.
- - [ ] On the backend, use the Solana SDK to fetch the transaction details using the signature.
-
-- [ ] **Backend: Verify Transaction Details:**
- - [ ] In the verification endpoint, inspect the fetched transaction.
- - [ ] Confirm that the transaction involves the correct sender (buyer), receiver (creator), and amount (price). This is a critical security step to prevent users from submitting fake or incorrect transaction signatures.
- - [ ] If the transaction is valid, proceed to record the skill ownership (covered in the next prompt).
-
-## JavaScript Example (`src/marketplace.js` - inside confirm button handler)
-
-```javascript
-// ... after const signature = await wallet.sendTransaction(tx, connection);
-
-// Show processing state in UI
-setModalState('processing');
-
-const { value: status } = await connection.confirmTransaction(signature, 'confirmed');
-
-if (status.err) {
- console.error('Transaction failed to confirm', status.err);
- setModalState('error', 'Transaction Failed');
- return;
-}
-
-// Now that frontend has confirmation, send signature to backend for final verification
-try {
- const verifyResponse = await fetch('/api/skills/purchase/verify', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ transactionSignature: signature, agentId: currentAgent.id, skillName }),
- });
-
- if (!verifyResponse.ok) throw new Error('Backend verification failed');
-
- setModalState('success', 'Purchase Complete!');
- // Update UI to show skill as unlocked (covered in next prompt)
-
-} catch (error) {
- console.error('Backend verification failed', error);
- setModalState('error', 'Verification Failed');
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/06-transaction-status-polling.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/07-api-webhook-confirm-purchase.md b/prompts/monetization-prompts/07-api-webhook-confirm-purchase.md
deleted file mode 100644
index 84ef72fc5..000000000
--- a/prompts/monetization-prompts/07-api-webhook-confirm-purchase.md
+++ /dev/null
@@ -1,86 +0,0 @@
-# Prompt 07: API Webhook to Confirm Solana Pay Transactions
-
-## Objective
-Create a webhook to receive confirmation of successful Solana Pay transactions, find the corresponding purchase record, and update its status.
-
-## Explanation
-The Solana Pay workflow includes a server-to-server confirmation. After a user approves a transaction, the Solana Pay service (or a custom RPC listener) will post the transaction signature to a webhook we provide. This webhook is the definitive confirmation of payment. It needs to verify the transaction on-chain and update our database accordingly.
-
-## Instructions
-1. **Create the Webhook API File:**
- * Create a new file: `api/webhooks/solana-pay.js`.
-
-2. **Implement the Webhook Handler:**
- * **`find` Method:** Solana Pay first sends a `GET` request to verify the endpoint exists. The handler should return a label and icon for the payment sheet.
- * **`transaction` Method (`POST`):**
- * The `POST` request contains the `transaction` (signature) and `reference` (our `purchaseId`).
- * **Verify Transaction:** Use a Solana RPC connection (`@solana/web3.js`) to fetch the transaction details using the signature.
- * **Validate Details:**
- * Check that the transaction was successful.
- * Confirm that the destination address, mint address, and amount match the details stored in our `user_skill_purchases` and `agent_skill_prices` tables. This is crucial to prevent spoofed transactions.
- * **Update Purchase Status:** If validation passes, update the `user_skill_purchases` record's `status` to `'confirmed'` and store the `transaction_id`.
- * Return a success message to the Solana Pay service.
-
-## Code Example (`api/webhooks/solana-pay.js`)
-
-```javascript
-import { Connection, PublicKey } from '@solana/web3.js';
-import { sql } from '../_lib/db.js';
-import { error, json, wrap } from '../_lib/http.js';
-
-const SOLANA_RPC_URL = process.env.RPC_URL_1399901; // Example for Solana Mainnet
-const connection = new Connection(SOLANA_RPC_URL, 'confirmed');
-
-export default wrap(async (req, res) => {
- if (req.method === 'GET') {
- // Solana Pay endpoint validation
- return json(res, {
- label: '3D-Agent Skill Marketplace',
- icon: 'https://three.ws/assets/logo.png',
- });
- }
-
- if (req.method === 'POST') {
- const { transaction, reference } = await req.json();
-
- // 1. Find the purchase record using the reference
- const [purchase] = await sql`SELECT ... FROM user_skill_purchases WHERE id = ${reference}`;
- // ... join with prices to get expected amount, mint, recipient ...
- if (!purchase || purchase.status !== 'pending') {
- return error(res, 404, 'purchase_not_found_or_completed');
- }
-
- // 2. Verify the transaction on-chain
- const tx = await connection.getParsedTransaction(transaction, 'confirmed');
- // ... logic to parse tx and confirm amount, mint, and recipient ...
-
- const isValid = /* ... validation logic ... */ ;
-
- if (isValid) {
- await sql`
- UPDATE user_skill_purchases
- SET status = 'confirmed', transaction_id = ${transaction}, updated_at = NOW()
- WHERE id = ${reference}
- `;
- return json(res, { message: 'Transaction confirmed' });
- } else {
- await sql`UPDATE ... SET status = 'failed' ...`;
- return error(res, 400, 'transaction_invalid');
- }
- }
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/07-api-webhook-confirm-purchase.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/07-ui-feedback-on-purchase.md b/prompts/monetization-prompts/07-ui-feedback-on-purchase.md
deleted file mode 100644
index dba88577e..000000000
--- a/prompts/monetization-prompts/07-ui-feedback-on-purchase.md
+++ /dev/null
@@ -1,42 +0,0 @@
----
-status: not-started
----
-
-# Prompt 07: UI Feedback for Purchase Flow
-
-## Objective
-Provide clear, real-time UI feedback to the user during the entire purchase process (e.g., processing, success, failure).
-
-## Explanation
-A good user experience requires keeping the user informed. We will enhance the purchase modal to reflect the current state of the transaction, from initiation to completion.
-
-## Instructions
-- [ ] **Enhance the Modal HTML:**
- - [ ] Add elements to the purchase modal to display different states: a loading spinner for processing, a success message/icon, and an error message/icon.
-
-- [ ] **Create a UI State Management Function:**
- - [ ] In `src/marketplace.js`, create a function like `setModalState(state, message)`.
- - [ ] This function will accept states like 'confirm', 'processing', 'success', and 'error'.
- - [ ] Based on the state, it will show/hide the appropriate elements in the modal (e.g., hide confirm/cancel buttons, show spinner).
-
-- [ ] **Integrate State Changes into Purchase Logic:**
- - [ ] Call `setModalState` at key points in the purchase flow:
- - [ ] When the confirm button is first clicked, before sending the transaction: `setModalState('processing')`.
- - [ ] If the transaction is successfully confirmed on the frontend and verified on the backend: `setModalState('success', 'Purchase Complete!')`.
- - [ ] If any step fails (user rejects, transaction fails, backend verification fails): `setModalState('error', 'Something went wrong.')`.
-
-## HTML Example (Enhanced Modal)
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/07-ui-feedback-on-purchase.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/08-creator-ui-set-prices.md b/prompts/monetization-prompts/08-creator-ui-set-prices.md
deleted file mode 100644
index f1870aa79..000000000
--- a/prompts/monetization-prompts/08-creator-ui-set-prices.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# Prompt 08: Creator UI to Set Skill Prices
-
-## Objective
-Implement a user interface in the agent editor or creator dashboard that allows creators to add, edit, and remove prices for their agent's skills.
-
-## Explanation
-Now that the backend API for price management exists, we need to provide a user-friendly frontend for creators to use it. This will involve adding a new section to the agent editing page (`agent-edit.html`) where a list of the agent's skills is displayed, each with an input field to set its price.
-
-## Instructions
-1. **Locate the Agent Editor Page:**
- * Open `agent-edit.html` and its corresponding JavaScript file, likely `src/agent-edit.js`.
-
-2. **Add a "Skill Monetization" Section:**
- * In `agent-edit.html`, add a new section or card titled "Skill Prices".
- * This section should fetch and display the list of skills from the agent's manifest.
-
-3. **Implement the UI for Each Skill:**
- * For each skill listed, display:
- * The skill name.
- * An input field for the price (e.g., in USDC).
- * A "Set Price" or "Save" button.
- * A "Remove Price" button if a price is already set.
-
-4. **Wire Up the API Calls:**
- * In `src/agent-edit.js`, add event listeners to the "Save" and "Remove" buttons.
- * **On Save:**
- * Read the price from the input.
- * Convert it to the smallest unit (e.g., multiply by 1,000,000 for USDC).
- * Call the `POST` or `PUT` endpoint from Prompt 03 (`/api/agents/[id]/skill-prices`) with the `skill_id`, `amount`, and `currency_mint`.
- * **On Remove:**
- * Call the `DELETE` endpoint from Prompt 03.
- * Provide user feedback (e.g., a success message or an error toast).
-
-## HTML Example (`agent-edit.html`)
-
-```html
-<!-- Inside the agent editor form -->
-<div class="card">
- <h3>Skill Prices</h3>
- <div id="skill-prices-list">
- <!-- Skills will be rendered here by JavaScript -->
- <!-- Example of a single skill item -->
- <div class="skill-price-item">
- <span>weather-forecast</span>
- <input type="number" step="0.01" placeholder="USDC Price">
- <button class="btn-primary">Set Price</button>
- </div>
- </div>
-</div>
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/08-creator-ui-set-prices.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/08-database-schema-for-pricing.md b/prompts/monetization-prompts/08-database-schema-for-pricing.md
deleted file mode 100644
index 7ebf37565..000000000
--- a/prompts/monetization-prompts/08-database-schema-for-pricing.md
+++ /dev/null
@@ -1,83 +0,0 @@
-# Prompt 8: Database Schema for Skill Pricing and Ownership
-
-**Status:** - [ ] Not Started
-
-## Objective
-Design and create the necessary SQL table schemas to store skill prices and user skill ownership.
-
-## Explanation
-A robust backend requires a well-defined database structure. This prompt outlines the schemas for two key tables: one to define the prices of skills set by creators, and another to track which users have purchased which skills.
-
-## Instructions
-1. **Design `agent_skill_prices` Table:**
- * This table will store the price for each monetized skill of an agent.
- * **Columns:**
- * `id`: Primary key (e.g., UUID or auto-incrementing integer).
- * `agent_id`: Foreign key to the `agents` table.
- * `skill_name`: The name of the skill (e.g., 'sentiment-analysis').
- * `amount`: The price in the smallest denomination of the currency (e.g., lamports for SOL, or 10^-6 for USDC). Use a `bigint` for this.
- * `currency_mint`: The public key of the SPL token mint used for the currency (e.g., USDC mint address).
- * `creator_address`: The Solana address where funds should be sent.
- * `created_at`, `updated_at`: Timestamps.
- * Create a unique constraint on (`agent_id`, `skill_name`).
-
-2. **Design `user_agent_skills` Table:**
- * This table will link users to the skills they've purchased.
- * **Columns:**
- * `id`: Primary key.
- * `user_id`: Foreign key to the `users` table.
- * `agent_id`: Foreign key to the `agents` table.
- * `skill_name`: The name of the purchased skill.
- * `purchase_tx_signature`: The Solana transaction signature of the purchase.
- * `created_at`: Timestamp.
- * Create a unique constraint on (`user_id`, `agent_id`, `skill_name`).
-
-3. **Create Migration File:**
- * Write the SQL `CREATE TABLE` statements for both tables in a new migration file. The project seems to have a migration system in `scripts/apply-migrations.mjs`, so follow that pattern.
-
-## SQL Example (for a PostgreSQL database)
-
-```sql
--- In a new migration file in your migrations directory
-
-CREATE TABLE agent_skill_prices (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- agent_id UUID NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
- skill_name VARCHAR(255) NOT NULL,
- amount BIGINT NOT NULL,
- currency_mint VARCHAR(255) NOT NULL,
- creator_address VARCHAR(255) NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- UNIQUE (agent_id, skill_name)
-);
-
-CREATE TABLE user_agent_skills (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
- agent_id UUID NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
- skill_name VARCHAR(255) NOT NULL,
- purchase_tx_signature VARCHAR(255) NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- UNIQUE (user_id, agent_id, skill_name)
-);
-
--- It's good practice to create indexes for foreign keys
-CREATE INDEX idx_agent_skill_prices_agent_id ON agent_skill_prices(agent_id);
-CREATE INDEX idx_user_agent_skills_user_id ON user_agent_skills(user_id);
-CREATE INDEX idx_user_agent_skills_agent_id ON user_agent_skills(agent_id);
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/08-database-schema-for-pricing.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/08-purchase-skill-api-endpoint.md b/prompts/monetization-prompts/08-purchase-skill-api-endpoint.md
deleted file mode 100644
index 8854003d5..000000000
--- a/prompts/monetization-prompts/08-purchase-skill-api-endpoint.md
+++ /dev/null
@@ -1,93 +0,0 @@
----
-status: not-started
----
-
-# Prompt 08: Backend Purchase API Endpoint
-
-## Objective
-Create the initial backend API endpoint that constructs and returns a Solana transaction for a skill purchase.
-
-## Explanation
-The frontend needs a secure way to get a valid transaction object. The backend is responsible for creating this transaction because it has secure access to critical information like the creator's payout wallet and the correct skill price, preventing tampering.
-
-## Instructions
-- [ ] **Create the API File and Route:**
- - [ ] Create a new API file, e.g., `api/transactions/create-skill-purchase.js`.
- - [ ] This file will handle `POST` requests. It should expect `agentId`, `skillName`, and `buyerPublicKey` in the request body.
-
-- [ ] **Fetch Necessary Data:**
- - [ ] Inside the endpoint logic, perform database lookups to get:
- - [ ] The skill's price from the `agent_skill_prices` table.
- - [ ] The agent creator's payout wallet address from the `users` or `agents` table.
- - [ ] The platform's fee wallet address (can be a constant or from a config file).
-
-- [ ] **Construct the Solana Transaction:**
- - [ ] Use the `@solana/web3.js` SDK.
- - [ ] You will be creating a SPL Token Transfer instruction. The currency is likely USDC, so you'll need its mint address.
- - [ ] The transaction will transfer `X` amount of USDC from the `buyerPublicKey` to the creator's wallet. (Platform fees will be added in a later prompt).
- - [ ] Set the `feePayer` to be the `buyerPublicKey`.
- - [ ] Fetch a recent blockhash.
-
-- [ ] **Serialize and Return the Transaction:**
- - [ ] Serialize the transaction but **do not sign it**. The user's wallet must sign it.
- - [ ] Return the serialized transaction as a base64-encoded string in the JSON response.
-
-## Code Example (Node.js with Express-like framework)
-
-```javascript
-import { Connection, PublicKey, SystemProgram, Transaction } from '@solana/web3.js';
-import { getOrCreateAssociatedTokenAccount, createTransferInstruction } from '@solana/spl-token';
-
-export default async function handler(req, res) {
- if (req.method !== 'POST') return res.status(405).end();
-
- const { agentId, skillName, buyerPublicKey } = req.body;
-
- // 1. Fetch data from DB (pseudo-code)
- const priceInfo = await db.getSkillPrice(agentId, skillName); // { amount: 1000000, currency_mint: '...' }
- const creator = await db.getAgentCreator(agentId); // { payout_wallet: '...' }
-
- const connection = new Connection(clusterApiUrl('devnet'));
- const buyer = new PublicKey(buyerPublicKey);
- const creatorWallet = new PublicKey(creator.payout_wallet);
- const usdcMint = new PublicKey(priceInfo.currency_mint);
-
- // 2. Get the buyer's and creator's token accounts
- const buyerUsdcAccount = await getOrCreateAssociatedTokenAccount(connection, buyer, usdcMint, buyer);
- const creatorUsdcAccount = await getOrCreateAssociatedTokenAccount(connection, buyer, usdcMint, creatorWallet);
-
- // 3. Create the transaction
- const transaction = new Transaction().add(
- createTransferInstruction(
- buyerUsdcAccount.address,
- creatorUsdcAccount.address,
- buyer,
- priceInfo.amount // Amount in smallest unit (lamports for SOL, etc.)
- )
- );
-
- transaction.feePayer = buyer;
- transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
-
- // 4. Serialize and return
- const serializedTx = transaction.serialize({ requireAllSignatures: false });
-
- res.status(200).json({
- transaction: serializedTx.toString('base64'),
- });
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/08-purchase-skill-api-endpoint.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/09-admin-interface-for-prices.md b/prompts/monetization-prompts/09-admin-interface-for-prices.md
deleted file mode 100644
index 561cffb33..000000000
--- a/prompts/monetization-prompts/09-admin-interface-for-prices.md
+++ /dev/null
@@ -1,106 +0,0 @@
-# Prompt 9: Create an Admin Interface for Setting Skill Prices
-
-**Status:** - [ ] Not Started
-
-## Objective
-Develop a UI for agent creators to set and manage prices for their agent's skills.
-
-## Explanation
-For creators to monetize their skills, they need an interface to specify which skills are for sale and at what price. This will likely be part of the agent editing page (`agent-edit.html`).
-
-## Instructions
-1. **Create UI for Price Management:**
- * In `agent-edit.html`, add a new section for "Skill Monetization".
- * This section should list all the skills available for the agent.
- * For each skill, provide input fields for:
- * Price (e.g., in USDC).
- * Currency (a dropdown, initially just supporting USDC).
- * A "Set Price" or "Save" button.
- * Also display the current price if one is set.
-
-2. **Develop Backend Endpoint for Setting Prices:**
- * Create a new API endpoint, e.g., `api/agents/set-skill-price.js`.
- * This must be an authenticated endpoint. Before processing, it must verify that the logged-in user is the creator of the agent.
- * It should accept `agentId`, `skillName`, `amount`, and `currencyMint`.
- * The handler will perform an `INSERT ... ON CONFLICT ... UPDATE` (or an "upsert") operation on the `agent_skill_prices` table for the given agent and skill.
-
-3. **Connect Frontend to Backend:**
- * In the JavaScript for the agent edit page, add an event listener to the "Set Price" button.
- * When clicked, it should gather the data from the input fields and make a `POST` request to the new API endpoint.
- * Provide feedback to the user on success or failure.
-
-## Code Example (HTML for `agent-edit.html`)
-
-```html
-<!-- In agent-edit.html, inside the agent form -->
-<div class="form-section">
- <h3>Skill Monetization</h3>
- <div id="skill-pricing-list">
- <!-- Skills will be dynamically rendered here by JavaScript -->
- </div>
-</div>
-```
-
-## Code Example (JavaScript for the agent edit page)
-
-```javascript
-// Function to render the skill pricing interface
-function renderSkillPricing(agent) {
- const container = $('skill-pricing-list');
- container.innerHTML = agent.skills.map(skill => `
- <div class="skill-price-entry">
- <label>${escapeHtml(skill.name)}</label>
- <input type="number" placeholder="Price (USDC)" data-skill-name="${escapeHtml(skill.name)}" value="${(agent.skill_prices?.[skill.name]?.amount / 1e6) || ''}">
- <button class="set-price-btn" data-skill-name="${escapeHtml(skill.name)}">Save</button>
- </div>
- `).join('');
-}
-
-// Event listener for the save buttons
-$('skill-pricing-list').addEventListener('click', async (e) => {
- if (e.target.classList.contains('set-price-btn')) {
- const skillName = e.target.dataset.skillName;
- const priceInput = document.querySelector(`input[data-skill-name="${skillName}"]`);
- const priceInUSDC = parseFloat(priceInput.value);
-
- if (isNaN(priceInUSDC) || priceInUSDC <= 0) {
- alert('Please enter a valid price.');
- return;
- }
-
- const amountInLamports = priceInUSDC * 1e6;
-
- // Call the backend
- const response = await fetch('/api/agents/set-skill-price', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- agentId: currentAgentId,
- skillName,
- amount: amountInLamports,
- currencyMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7u1b', // USDC mint
- }),
- });
-
- if (response.ok) {
- showToast('Price updated!', 'success');
- } else {
- showToast('Failed to update price.', 'error');
- }
- }
-});
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/09-admin-interface-for-prices.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/09-frontend-polling-confirmation.md b/prompts/monetization-prompts/09-frontend-polling-confirmation.md
deleted file mode 100644
index a59270db0..000000000
--- a/prompts/monetization-prompts/09-frontend-polling-confirmation.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# Prompt 09: Frontend Polling for Purchase Confirmation
-
-## Objective
-After displaying the Solana Pay QR code, implement a client-side polling mechanism to check the status of the purchase and update the UI upon confirmation.
-
-## Explanation
-While the webhook provides server-to-server confirmation, the user on the frontend is waiting for feedback. We need to poll a backend endpoint to check the status of the `user_skill_purchases` record. Once the status changes from 'pending' to 'confirmed', we can close the purchase modal and show a success message.
-
-## Instructions
-1. **Create a Status Check API Endpoint:**
- * Create a new API endpoint, e.g., `api/marketplace/purchase-status.js`.
- * It should accept a `purchaseId` as a query parameter.
- * The endpoint will query the `user_skill_purchases` table for the given ID.
- * It should return the current `status` of the purchase record.
- * **Security:** Ensure the user making the request is the same user who initiated the purchase.
-
-2. **Implement Frontend Polling:**
- * In `src/marketplace.js`, within the `showPurchaseModal` function (from Prompt 06), start a polling loop after displaying the QR code.
- * Use `setInterval` to call the `/api/marketplace/purchase-status?purchaseId=...` endpoint every few seconds (e.g., 2-3 seconds).
- * **On Confirmation:** If the endpoint returns `{ status: 'confirmed' }`, clear the interval, hide the modal, and display a success message to the user.
- * **On Failure:** If it returns `{ status: 'failed' }`, inform the user the payment failed.
- * **Timeout:** Implement a timeout (e.g., 5 minutes) to stop polling if no confirmation is received.
-
-## Code Example (`src/marketplace.js`)
-
-```javascript
-// In showPurchaseModal function, after showing the modal...
-
-const purchaseId = txDetails.purchaseId;
-const pollingId = setInterval(async () => {
- try {
- const res = await fetch(`/api/marketplace/purchase-status?purchaseId=${purchaseId}`);
- if (!res.ok) return; // Continue polling on server error
-
- const { status } = await res.json();
-
- if (status === 'confirmed') {
- clearInterval(pollingId);
- $('purchase-modal').hidden = true;
- // TODO: Show success message
- // TODO: Update UI to show the skill as 'Owned'
- } else if (status === 'failed') {
- clearInterval(pollingId);
- // TODO: Show failure message
- }
- } catch (e) {
- console.error('Polling failed', e);
- }
-}, 2500);
-
-// Set a timeout to stop polling after 5 minutes
-setTimeout(() => {
- clearInterval(pollingId);
-}, 300000);
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/09-frontend-polling-confirmation.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/09-verify-solana-transaction-api.md b/prompts/monetization-prompts/09-verify-solana-transaction-api.md
deleted file mode 100644
index fa0eeba90..000000000
--- a/prompts/monetization-prompts/09-verify-solana-transaction-api.md
+++ /dev/null
@@ -1,92 +0,0 @@
----
-status: not-started
----
-
-# Prompt 09: Backend Transaction Verification API
-
-## Objective
-Create the backend API endpoint that securely verifies a Solana transaction signature after it has been confirmed on the blockchain.
-
-## Explanation
-This is a critical security step. The frontend informs the backend that a transaction is complete by sending its signature. The backend must then independently fetch the transaction from the blockchain and verify that its contents (amount, sender, receiver) are correct before granting the user access to the skill. This prevents users from sending fake signatures or signatures for unrelated transactions.
-
-## Instructions
-- [ ] **Create the API File and Route:**
- - [ ] Create a new API file, e.g., `api/skills/purchase/verify.js`.
- - [ ] It will handle `POST` requests with `transactionSignature`, `agentId`, and `skillName` in the body.
-
-- [ ] **Fetch the Transaction from the Blockchain:**
- - [ ] Use the `@solana/web3.js` SDK's `connection.getParsedTransaction()` method with the provided signature. This method is useful as it parses the instruction data.
-
-- [ ] **Perform Verification Checks:**
- - [ ] Check if the transaction was successful (`err` field is null).
- - [ ] Look up the expected price and creator wallet from your database for the given `agentId` and `skillName`.
- - [ ] Parse the transaction's instructions to find the token transfer.
- - [ ] **Crucially, verify:**
- - [ ] The transfer `source` matches the buyer's public key (you might need to get this from the user's session or the transaction itself).
- - [ ] The transfer `destination` matches the creator's expected payout wallet.
- - [ ] The transfer `amount` matches the expected price from your database.
- - [ ] The token `mint` matches the expected currency (e.g., USDC).
-
-- [ ] **Handle Verification Outcome:**
- - [ ] If all checks pass, proceed to the next step: recording the ownership in the database.
- - [ ] If any check fails, return a `400 Bad Request` or `403 Forbidden` error with a message like "Transaction verification failed."
-
-## Code Example (Node.js with Express-like framework)
-
-```javascript
-import { Connection, PublicKey } from '@solana/web3.js';
-
-export default async function handler(req, res) {
- const { transactionSignature, agentId, skillName } = req.body;
-
- // 1. Get expected data from DB (pseudo-code)
- const expectedPrice = await db.getSkillPrice(agentId, skillName);
- const creator = await db.getAgentCreator(agentId);
- // Assume we get buyer public key from authenticated session
- const expectedBuyer = new PublicKey(req.session.user.publicKey);
-
- const connection = new Connection(clusterApiUrl('devnet'));
-
- // 2. Fetch transaction
- const tx = await connection.getParsedTransaction(transactionSignature, 'confirmed');
- if (!tx || tx.meta.err) {
- return res.status(400).json({ message: "Transaction not found or failed." });
- }
-
- // 3. Find the transfer instruction and verify details
- const transferInstruction = tx.transaction.message.instructions.find(ix => ix.parsed?.type === 'transferChecked');
-
- if (!transferInstruction) {
- return res.status(400).json({ message: "No valid transfer instruction found." });
- }
-
- const { source, destination, tokenAmount } = transferInstruction.parsed.info;
- const isVerified = source === expectedBuyer.toBase58() &&
- destination === creator.payout_wallet &&
- parseInt(tokenAmount.amount) === expectedPrice.amount;
-
- // 4. Handle outcome
- if (isVerified) {
- // Ownership recording logic comes next
- await recordSkillOwnership(req.session.user.id, agentId, skillName);
- res.status(200).json({ message: "Verification successful." });
- } else {
- res.status(403).json({ message: "Transaction details do not match expected values." });
- }
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/09-verify-solana-transaction-api.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/10-record-skill-ownership.md b/prompts/monetization-prompts/10-record-skill-ownership.md
deleted file mode 100644
index 1df065803..000000000
--- a/prompts/monetization-prompts/10-record-skill-ownership.md
+++ /dev/null
@@ -1,80 +0,0 @@
----
-status: not-started
----
-
-# Prompt 10: Record Skill Ownership in Database
-
-## Objective
-Create the database schema and logic to record that a user has successfully purchased and unlocked a skill.
-
-## Explanation
-After a transaction is successfully verified, the final step on the backend is to persist the user's ownership of the skill. This record will be the source of truth for all future checks, such as gating skill usage and updating the marketplace UI.
-
-## Instructions
-- [ ] **Design and Create a New Database Table:**
- - [ ] Create a new table named `unlocked_skills` (or similar).
- - [ ] It should contain, at a minimum, the following columns:
- - [ ] `id` (Primary Key)
- - [ ] `user_id` (Foreign Key to your `users` table)
- - [ ] `agent_id` (Foreign Key to your `agents` table)
- - [ ] `skill_name` (String)
- - [ ] `purchase_transaction_signature` (String, for auditing)
- - [ ] `created_at` (Timestamp)
- - [ ] Consider adding a unique constraint on `(user_id, agent_id, skill_name)` to prevent duplicate entries.
-
-- [ ] **Implement the Database Insertion Logic:**
- - [ ] In your backend verification endpoint (`/api/skills/purchase/verify`), after all the checks have passed, add the code to insert a new row into the `unlocked_skills` table.
- - [ ] Pass the authenticated user's ID, the agent ID, the skill name, and the transaction signature to the database query.
-
-- [ ] **Update Agent Details API to Include Ownership:**
- - [ ] Modify the main API that fetches agent details for the marketplace (`/api/marketplace/agents/:id`).
- - [ ] When a user requests this endpoint, it should now also query the `unlocked_skills` table to see which skills that specific user owns for that agent.
- - [ ] Include this ownership information in the API response, perhaps as an array of skill names: `unlocked_skills: ["skill1", "skill2"]`.
-
-- [ ] **Update Frontend to Use Ownership Data:**
- - [ ] In `src/marketplace.js`, when you receive the agent details, use the new `unlocked_skills` array.
- - [ ] In your skill rendering loop, set the `isOwned` variable based on whether the current skill's name is in this array. This will now correctly show the "Purchase" or "Unlocked" button.
-
-## SQL Schema Example
-
-```sql
-CREATE TABLE unlocked_skills (
- id SERIAL PRIMARY KEY,
- user_id INTEGER NOT NULL REFERENCES users(id),
- agent_id INTEGER NOT NULL REFERENCES agents(id),
- skill_name VARCHAR(255) NOT NULL,
- purchase_transaction_signature VARCHAR(128) NOT NULL UNIQUE,
- created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
- UNIQUE (user_id, agent_id, skill_name)
-);
-```
-
-## Frontend Code Example (`src/marketplace.js`)
-
-```javascript
-// Inside renderDetail function, after fetching agent 'a'
-const unlockedSkills = a.unlocked_skills || [];
-
-// Inside the skillsArr.map loop
-const name = s.name || '';
-const price = a.skill_prices[name];
-
-if (price) {
- const isOwned = unlockedSkills.includes(name); // <-- This is the new logic
- // ... rest of the button rendering logic
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/10-record-skill-ownership.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/11-api-security-for-purchase.md b/prompts/monetization-prompts/11-api-security-for-purchase.md
deleted file mode 100644
index 44d54835d..000000000
--- a/prompts/monetization-prompts/11-api-security-for-purchase.md
+++ /dev/null
@@ -1,88 +0,0 @@
----
-status: not-started
----
-
-# Prompt 11: API Security for Purchase Flow
-
-## Objective
-Implement essential security measures, including user authentication and input validation, for all monetization-related API endpoints.
-
-## Explanation
-Monetization APIs handle real money and user entitlements, making them a prime target for abuse. It's critical to ensure that only authenticated users can make purchases for themselves and that all incoming data is sanitized and validated to prevent exploits.
-
-## Instructions
-- [ ] **Implement User Authentication Middleware:**
- - [ ] Ensure all monetization endpoints (`/api/transactions/*`, `/api/skills/purchase/*`) are protected by an authentication middleware.
- - [ ] This middleware should verify the user's session (e.g., via a JWT token, session cookie, or API key).
- - [ ] If the user is not authenticated, the request should be rejected with a `401 Unauthorized` error.
- - [ ] The authenticated user's data (especially `user_id` and `publicKey`) should be attached to the request object for later use.
-
-- [ ] **Enforce Authorization:**
- - [ ] A user should only be able to purchase skills for their own account. The `user_id` used when recording skill ownership should come from the secure session, *not* from the request body.
-
-- [ ] **Implement Input Validation:**
- - [ ] For every monetization endpoint, validate the request body.
- - [ ] Use a library like `zod`, `joi`, or a simple custom validation function.
- - [ ] **Checks for `/api/transactions/create-skill-purchase`:**
- - [ ] `agentId`: should be a valid ID format.
- - [ ] `skillName`: should be a non-empty string.
- - [ ] `buyerPublicKey`: should be a valid Solana public key format.
- - [ ] **Checks for `/api/skills/purchase/verify`:**
- - [ ] `transactionSignature`: should be a valid Solana transaction signature format.
- - [ ] `agentId` and `skillName`: same as above.
- - [ ] If validation fails, return a `400 Bad Request` error with a clear message indicating the invalid field.
-
-## Code Example (Express.js-style Middleware)
-
-```javascript
-// middleware/auth.js
-export function requireAuth(req, res, next) {
- // Logic to verify session token (e.g., from Authorization header)
- const user = verifyToken(req.headers.authorization);
-
- if (!user) {
- return res.status(401).json({ message: "Authentication required." });
- }
- req.user = user; // Attach user to the request
- next();
-}
-
-// api/skills/purchase/verify.js
-import { requireAuth } from 'middleware/auth';
-import { z } from 'zod';
-
-const purchaseSchema = z.object({
- transactionSignature: z.string().min(80).max(100), // Basic validation
- agentId: z.number().int(),
- skillName: z.string().min(1),
-});
-
-// Apply middleware and validation
-export default async function handler(req, res) {
- requireAuth(req, res, () => {
- const validation = purchaseSchema.safeParse(req.body);
- if (!validation.success) {
- return res.status(400).json({ message: "Invalid input", errors: validation.error.issues });
- }
-
- // --- Main endpoint logic ---
- // Use req.user.id instead of any user ID from the body
- const userId = req.user.id;
- // ...
- });
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/11-api-security-for-purchase.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/11-user-purchased-skills.md b/prompts/monetization-prompts/11-user-purchased-skills.md
deleted file mode 100644
index c8a24fdc4..000000000
--- a/prompts/monetization-prompts/11-user-purchased-skills.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# Prompt 11: Display User's Purchased Skills in Profile
-
-**Status:** - [ ] Not Started
-
-## Objective
-Create a section in the user's profile or dashboard page (`profile.html` or a new dashboard page) where they can see all the agent skills they have purchased.
-
-## Explanation
-Users need a centralized place to view their digital assets. This enhances the sense of ownership and provides a useful overview of their collection of skills.
-
-## Instructions
-1. **Create a Backend Endpoint:**
- * Develop an API endpoint, e.g., `/api/users/me/purchased-skills`.
- * This endpoint should be authenticated.
- * It should query the `user_agent_skills` table for all records matching the logged-in user's ID.
- * To make the output more useful, it should join with the `agents` table to include details about the agent for each skill (e.g., agent name and image).
- * The endpoint should return an array of objects, each containing skill name, agent details, and purchase date.
-
-2. **Develop the Frontend UI:**
- * On the user's profile page (`profile.html`), add a new tab or section for "My Purchased Skills".
- * When the page loads (or this section is viewed), make a request to the new API endpoint.
- * Render the list of purchased skills. Each item in the list should display:
- * The skill name.
- * The name of the agent it belongs to (and maybe a thumbnail).
- * The date of purchase.
- * A link to the agent's detail page in the marketplace.
-
-## Code Example (Backend - `/api/users/me/purchased-skills.js`)
-
-```javascript
-import { getDB } from './_lib/db';
-
-export default async function handler(req, res) {
- // Assume user is authenticated
- const userId = req.user.id;
-
- const db = getDB();
- try {
- // This query would join user_agent_skills with agents table
- const skills = await db.query(
- `SELECT uas.skill_name, uas.created_at, a.name as agent_name, a.slug as agent_slug, a.thumbnail_url as agent_thumbnail
- FROM user_agent_skills uas
- JOIN agents a ON uas.agent_id = a.id
- WHERE uas.user_id = $1
- ORDER BY uas.created_at DESC`,
- [userId]
- );
-
- res.status(200).json({ skills });
- } catch (error) {
- console.error('Failed to fetch purchased skills:', error);
- res.status(500).json({ error: 'Failed to fetch skills.' });
- }
-}
-```
-
-## Code Example (JavaScript for `profile.html`)
-
-```javascript
-async function loadPurchasedSkills() {
- const container = $('purchased-skills-list');
- container.innerHTML = 'Loading...';
-
- try {
- const response = await fetch('/api/users/me/purchased-skills');
- if (!response.ok) throw new Error('Failed to load skills');
-
- const { skills } = await response.json();
-
- if (!skills.length) {
- container.innerHTML = 'You have not purchased any skills yet.';
- return;
- }
-
- container.innerHTML = skills.map(skill => `
- <div class="skill-item">
- <img src="${skill.agent_thumbnail || '/placeholder.png'}" alt="${skill.agent_name}" class="agent-thumb">
- <div>
- <div class="skill-name">${skill.skill_name}</div>
- <div class="agent-name">for <a href="/marketplace/${skill.agent_slug}">${skill.agent_name}</a></div>
- <div class="purchase-date">Purchased on ${new Date(skill.created_at).toLocaleDateString()}</div>
- </div>
- </div>
- `).join('');
-
- } catch (error) {
- container.innerHTML = 'Error loading your skills.';
- }
-}
-
-// Call this function when the page loads
-loadPurchasedSkills();
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/11-user-purchased-skills.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/12-backend-gate-skill-usage.md b/prompts/monetization-prompts/12-backend-gate-skill-usage.md
deleted file mode 100644
index 4f255cd40..000000000
--- a/prompts/monetization-prompts/12-backend-gate-skill-usage.md
+++ /dev/null
@@ -1,72 +0,0 @@
-# Prompt 12: Backend Logic to Gate Skill Usage
-
-## Objective
-Modify the agent's skill execution logic to check if a user is licensed to use a paid skill before running it.
-
-## Explanation
-Selling skills is only effective if their usage can be restricted to paying users. This requires adding a check in the agent's core runtime. Before executing any skill, the runtime must determine if the skill is priced and, if so, whether the current user has purchased it.
-
-## Instructions
-1. **Locate the Skill Execution Logic:**
- * Find the part of the agent runtime where skills are called. This is likely in `src/runtime/index.js` or a related file that handles the LLM tool-loop.
-
-2. **Add a Pre-Execution Check:**
- * Before a skill's handler is invoked, insert a new check.
- * **Is the skill priced?** Query the `agent_skill_prices` table for the current agent and the skill being called.
- * **If it is priced, does the user have a license?**
- * Get the current user's ID. Note: You'll need to pass user context into the runtime.
- * Query the `user_skill_purchases` table to see if a `'confirmed'` purchase record exists for this `user_id`, `agent_id`, and `skill_id`.
- * **Enforce the Gate:**
- * If the skill is priced and the user has *not* purchased it, do not execute the skill.
- * Instead, return a specific error message to the LLM (e.g., `tool_error: "User has not purchased this skill."`).
-
-3. **Instruct the LLM on How to Respond:**
- * Update the system prompt (e.g., in `api/chat.js`) to instruct the agent on what to do when it receives this specific error.
- * It should inform the user that the skill is a premium feature and they need to purchase it to use it.
-
-## Code Example (Conceptual - in agent runtime)
-
-```javascript
-// Before calling a skill's handler function...
-
-async function canUseSkill(userId, agentId, skillId) {
- // This check would be done via an API call from the client, or directly if on the server.
- const isPriced = await db.checkIfSkillIsPriced(agentId, skillId);
- if (!isPriced) {
- return true; // Free skill, allow usage.
- }
-
- if (!userId) {
- return false; // Priced skill, but user is not logged in.
- }
-
- const hasPurchased = await db.checkIfUserHasPurchased(userId, agentId, skillId);
- return hasPurchased;
-}
-
-// In the tool-loop
-const allowed = await canUseSkill(currentUser.id, agent.id, toolCall.name);
-if (allowed) {
- // Execute tool
-} else {
- // Return error to LLM
- return {
- tool_use_id: toolCall.id,
- content: JSON.stringify({ error: "User has not purchased this skill." }),
- };
-}
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/12-backend-gate-skill-usage.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/prompts/monetization-prompts/12-creator-payout-setup.md b/prompts/monetization-prompts/12-creator-payout-setup.md
deleted file mode 100644
index 25a64eb16..000000000
--- a/prompts/monetization-prompts/12-creator-payout-setup.md
+++ /dev/null
@@ -1,73 +0,0 @@
----
-status: not-started
----
-
-# Prompt 12: Creator Payout Wallet Setup
-
-## Objective
-Allow agent creators to specify and save a Solana wallet address for receiving payments.
-
-## Explanation
-To pay creators, we need to know where to send the funds. This involves adding a field to the database for their payout address and creating a UI and API for them to manage this setting.
-
-## Instructions
-- [ ] **Update Database Schema:**
- - [ ] Add a new column to your `users` table (or whichever table represents your creators).
- - [ ] The column should be named `payout_wallet_address` or similar.
- - [ ] It should be a `VARCHAR` or `TEXT` field, capable of storing a Solana public key (e.g., up to 44 characters). It can be nullable, as a user might not be a creator.
-
-- [ ] **Create API Endpoint for Saving Wallet Address:**
- - [ ] Create a new API endpoint, e.g., `PUT /api/users/payout-settings`.
- - [ ] This endpoint should be protected by authentication middleware.
- - [ ] It will accept a new `payout_wallet_address` in the request body.
- - [ ] Validate that the provided string is a valid Solana public key.
- - [ ] Update the `payout_wallet_address` for the authenticated user in the database.
-
-- [ ] **Update "Create Transaction" Endpoint:**
- - [ ] Modify the `POST /api/transactions/create-skill-purchase` endpoint.
- - [ ] When fetching creator details, retrieve the new `payout_wallet_address`.
- - [ ] Use this address as the destination for the payment transfer in the Solana transaction. If the address is not set, the transaction should fail with an error indicating the creator has not configured their payouts.
-
-## SQL Schema Example (Alter Table)
-
-```sql
-ALTER TABLE users
-ADD COLUMN payout_wallet_address VARCHAR(44) NULL;
-```
-
-## API Validation Example (Node.js)
-
-```javascript
-import { PublicKey } from '@solana/web3.js';
-
-function isValidSolanaAddress(address) {
- try {
- new PublicKey(address);
- return true;
- } catch (e) {
- return false;
- }
-}
-
-// In your PUT /api/users/payout-settings endpoint
-const { payout_wallet_address } = req.body;
-if (!isValidSolanaAddress(payout_wallet_address)) {
- return res.status(400).json({ message: "Invalid Solana wallet address." });
-}
-
-// ... proceed to update database for req.user.id
-```
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "prompts/monetization-prompts/12-creator-payout-setup.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.