Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

chore: remove monetization-feature task docs

nirholas43fcdd98ef92
diff --git a/docs/monetization-feature/02-backend-create-skill-pricing-table.md b/docs/monetization-feature/02-backend-create-skill-pricing-table.md
deleted file mode 100644
index 6a6768360..000000000
--- a/docs/monetization-feature/02-backend-create-skill-pricing-table.md
+++ /dev/null
@@ -1,55 +0,0 @@
----
-status: not-started
----
-
-# Prompt 2: Create Skill Pricing Table
-
-**Status:** Not Started
-
-## Objective
-Create a database table to store pricing information for agent skills. This is a foundational step for monetizing skills.
-
-## Explanation
-To allow agent creators to set prices for their skills, we need a dedicated table in our database. This table, `agent_skill_prices`, will link a skill to an agent and define its price and currency. We'll use a SQL migration script to create this table.
-
-## Instructions
-1. **Create a new migration file:**
- - In your database migration tool (e.g., `node-pg-migrate`, `flyway`), create a new migration file. Name it something like `1683158400_create_agent_skill_prices.js`.
-
-2. **Define the table schema:**
- - The table should include the following columns:
- - `id`: Primary key (e.g., UUID or auto-incrementing integer).
- - `agent_id`: Foreign key referencing the `agents` table.
- - `skill_name`: The name of the skill (e.g., `text-to-speech`). This should match the skill identifier in the agent's definition.
- - `amount`: The price of the skill in the smallest currency unit (e.g., lamports for SOL, or cents for USD). Use a `BIGINT` to support large numbers.
- - `currency_mint`: The mint address of the currency token (e.g., the USDC mint address on Solana).
- - `created_at`: Timestamp of creation.
- - `updated_at`: Timestamp of last update.
-
-3. **Add constraints:**
- - Create a unique constraint on `(agent_id, skill_name)` to ensure a skill can only have one price per agent.
- - Add an index on `agent_id` for faster lookups.
-
-4. **Run the migration:**
- - Execute the migration to create the table in your database.
-
-## Code Example (SQL)
-
-```sql
-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,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- UNIQUE(agent_id, skill_name)
-);
-
-CREATE INDEX idx_agent_skill_prices_agent_id ON agent_skill_prices(agent_id);
-```
-
-## Verification
-- After running the migration, connect to your database and verify that the `agent_skill_prices` table exists with the correct schema.
-- You can try inserting a sample record to ensure it works as expected.
diff --git a/docs/monetization-feature/03-backend-create-user-purchases-table.md b/docs/monetization-feature/03-backend-create-user-purchases-table.md
deleted file mode 100644
index 767762101..000000000
--- a/docs/monetization-feature/03-backend-create-user-purchases-table.md
+++ /dev/null
@@ -1,55 +0,0 @@
----
-status: not-started
----
-
-# Prompt 3: Create User Purchases Table
-
-**Status:** Not Started
-
-## Objective
-Create a database table to track which users have purchased which skills.
-
-## Explanation
-To manage access to paid skills, we need to record every successful purchase. A `user_skill_purchases` table will store the relationship between a user, an agent, and a specific skill they've bought. This table will be the source of truth for skill ownership.
-
-## Instructions
-1. **Create a new migration file:**
- - Create a migration file (e.g., `1683159000_create_user_skill_purchases.js`).
-
-2. **Define the table schema:**
- - The table should include:
- - `id`: Primary key.
- - `user_id`: Foreign key referencing the `users` table.
- - `agent_id`: Foreign key referencing the `agents` table.
- - `skill_name`: The name of the purchased skill.
- - `purchase_price`: The amount paid for the skill at the time of purchase.
- - `purchase_currency`: The currency mint used for the purchase.
- - `transaction_signature`: The signature of the on-chain transaction.
- - `purchased_at`: Timestamp of the purchase.
-
-3. **Add constraints:**
- - Create a unique constraint on `(user_id, agent_id, skill_name)`.
- - Add indexes on `user_id` and `agent_id` for performance.
-
-## Code Example (SQL)
-
-```sql
-CREATE TABLE user_skill_purchases (
- 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_price BIGINT NOT NULL,
- purchase_currency VARCHAR(255) NOT NULL,
- transaction_signature VARCHAR(255) UNIQUE NOT NULL,
- purchased_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- UNIQUE(user_id, agent_id, skill_name)
-);
-
-CREATE INDEX idx_user_skill_purchases_user_id ON user_skill_purchases(user_id);
-CREATE INDEX idx_user_skill_purchases_agent_id ON user_skill_purchases(agent_id);
-```
-
-## Verification
-- Run the migration and check the database for the new `user_skill_purchases` table.
-- Ensure all columns, constraints, and indexes are correctly defined.
diff --git a/docs/monetization-feature/04-backend-purchase-skill-endpoint.md b/docs/monetization-feature/04-backend-purchase-skill-endpoint.md
deleted file mode 100644
index 166e42dc6..000000000
--- a/docs/monetization-feature/04-backend-purchase-skill-endpoint.md
+++ /dev/null
@@ -1,84 +0,0 @@
----
-status: not-started
----
-
-# Prompt 4: Create Purchase Skill API Endpoint
-
-**Status:** Not Started
-
-## Objective
-Create a backend API endpoint to handle the initiation of a skill purchase.
-
-## Explanation
-When a user decides to buy a skill, the frontend needs to communicate with the backend to start the transaction. This endpoint (`/api/skills/purchase`) will be responsible for validating the request, checking that the skill is for sale, and returning the necessary information for the frontend to proceed with the payment flow (e.g., a Solana Pay transaction request URL).
-
-## Instructions
-1. **Create the API route:**
- - Create a new file for the purchase logic, e.g., `api/skills/purchase.js`.
- - This endpoint should handle `POST` requests.
-
-2. **Implement request handling:**
- - The request body should contain the `agent_id` and `skill_name` to be purchased.
- - The endpoint must be authenticated, so ensure you have the user's ID from their session.
- - **Validation:**
- - Check if the user has already purchased the skill by querying the `user_skill_purchases` table.
- - Fetch the skill's price from the `agent_skill_prices` table. If no price is found, return an error.
-
-3. **Generate transaction details:**
- - If the request is valid, generate the parameters needed for a Solana Pay transaction. This includes:
- - The recipient's public key (the agent creator's wallet).
- - The amount to be transferred.
- - The SPL token mint address (e.g., USDC).
- - A unique reference key for the transaction.
-
-4. **Return the response:**
- - The API should return a JSON object containing the Solana Pay URL or the transaction parameters that the frontend can use to initiate the payment.
-
-## Code Example (Node.js/Express-like)
-
-```javascript
-// api/skills/purchase.js
-
-export default async function handler(req, res) {
- if (req.method !== 'POST') {
- return res.status(405).json({ error: 'Method Not Allowed' });
- }
-
- const { agentId, skillName } = req.body;
- const userId = await getUserIdFromSession(req); // Assume you have this function
-
- if (!userId) {
- return res.status(401).json({ error: 'Unauthorized' });
- }
-
- // 1. Check if already purchased
- const existingPurchase = await db.query(
- 'SELECT id FROM user_skill_purchases WHERE user_id = $1 AND agent_id = $2 AND skill_name = $3',
- [userId, agentId, skillName]
- );
- if (existingPurchase.rows.length > 0) {
- return res.status(409).json({ error: 'Skill already purchased' });
- }
-
- // 2. Get skill price
- const priceResult = await db.query(
- 'SELECT amount, currency_mint FROM agent_skill_prices WHERE agent_id = $1 AND skill_name = $2',
- [agentId, skillName]
- );
- if (priceResult.rows.length === 0) {
- return res.status(404).json({ error: 'Skill not for sale' });
- }
- const price = priceResult.rows[0];
-
- // 3. (To be implemented in next step) Generate Solana Pay URL
- const { solanaPayUrl } = await generateSolanaPayUrl(price);
-
- // 4. Return response
- res.status(200).json({ solanaPayUrl });
-}
-```
-
-## Verification
-- Test the endpoint using a tool like Postman or `curl`.
-- Verify that it correctly handles cases like unauthenticated requests, already purchased skills, and skills that are not for sale.
-- Check that it returns the expected transaction details for a valid request.
diff --git a/docs/monetization-feature/05-ui-add-buy-skill-button.md b/docs/monetization-feature/05-ui-add-buy-skill-button.md
deleted file mode 100644
index 02dda82e3..000000000
--- a/docs/monetization-feature/05-ui-add-buy-skill-button.md
+++ /dev/null
@@ -1,87 +0,0 @@
----
-status: not-started
----
-
-# Prompt 5: UI - Add "Buy Skill" Button
-
-**Status:** Not Started
-
-## Objective
-Add a "Buy Skill" button to the agent detail page for paid skills that the user has not yet purchased.
-
-## Explanation
-To allow users to purchase skills, we need to provide a clear call-to-action. This task involves updating the marketplace UI to display a "Buy" button next to each paid skill. The button should only be visible to logged-in users and for skills they don't already own. We'll also need to know which skills the user has purchased.
-
-## Instructions
-1. **Backend - Pass Purchase Data to Frontend:**
- - In the `/api/marketplace/agents/:id` endpoint (`api/marketplace/[action].js`), after fetching the agent details and skill prices, you need to check which of those skills the current user has purchased.
- - If a user is logged in, query the `user_skill_purchases` table for the current `user_id` and `agent_id`.
- - Add a `purchased_skills` array or set to the agent object in the API response, listing the names of the skills the user owns.
-
-2. **Frontend - Conditionally Render the "Buy" Button:**
- - In `src/marketplace.js`, within the `renderDetail` function, you now have access to the `purchased_skills` list.
- - In the loop that renders the skills, add a condition:
- - If a skill has a price and is *not* in the `purchased_skills` list, render a "Buy" button next to the price.
- - If the skill is free, show the "Free" badge.
- - If the skill is paid and already owned, you can show an "Owned" badge (this will be covered in a future prompt). For now, you can just omit the "Buy" button.
- - The "Buy" button should have `data-agent-id` and `data-skill-name` attributes to identify the skill when clicked.
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// Inside renderDetail function
-
-const skillPrices = a.skill_prices || {};
-const purchasedSkills = new Set(a.purchased_skills || []);
-
-$('d-skills').innerHTML = skillsArr.length
- ? skillsArr.map((s) => {
- const name = typeof s === 'string' ? s : (s.name || '');
- const price = skillPrices[name];
- let badge = `<span class="price-badge price-free">Free</span>`;
- if (price) {
- if (purchasedSkills.has(name)) {
- badge = `<span class="price-badge price-owned">Owned</span>`;
- } else {
- const priceInUSDC = (price.amount / 1e6).toFixed(2);
- badge = `
- <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">${escapeHtml(name)}${badge}</span>`;
- }).join(' ')
- : '<div>This Agent has no skills defined.</div>';
-```
-
-## CSS Example
-
-Add these styles for the "Buy" button in `/marketplace.css`:
-
-```css
-.buy-skill-btn {
- margin-left: 8px;
- padding: 3px 8px;
- font-size: 10px;
- font-weight: 600;
- border-radius: 4px;
- border: 1px solid #fde047;
- color: #fde047;
- background-color: transparent;
- cursor: pointer;
- transition: background-color 0.2s, color 0.2s;
-}
-
-.buy-skill-btn:hover {
- background-color: rgba(253, 224, 71, 0.1);
- color: #fef08a;
-}
-```
-
-## Verification
-- Load an agent detail page for a logged-in user.
-- Verify that paid skills you haven't purchased show a "Buy" button.
-- Verify that free skills show the "Free" badge.
-- Verify that (for now) purchased skills do not show a "Buy" button.
-- Log out and verify that no "Buy" buttons are visible.
diff --git a/docs/monetization-feature/06-frontend-handle-buy-skill-click.md b/docs/monetization-feature/06-frontend-handle-buy-skill-click.md
deleted file mode 100644
index fe4ffad47..000000000
--- a/docs/monetization-feature/06-frontend-handle-buy-skill-click.md
+++ /dev/null
@@ -1,88 +0,0 @@
----
-status: not-started
----
-
-# Prompt 6: Frontend - Handle "Buy Skill" Click
-
-**Status:** Not Started
-
-## Objective
-Implement the frontend logic to handle clicks on the "Buy Skill" button.
-
-## Explanation
-When a user clicks the "Buy Skill" button, the frontend needs to initiate the purchase process. This involves making a `POST` request to our new `/api/skills/purchase` endpoint. The frontend will then receive a Solana Pay URL, which it will use to open a payment modal or QR code for the user to complete the transaction.
-
-## Instructions
-1. **Add a click listener:**
- - In `src/marketplace.js`, add a global click listener or a delegated listener to the `d-skills` container.
- - Check if the clicked element has the `buy-skill-btn` class.
-
-2. **Make the API request:**
- - If the "Buy" button is clicked, get the `agentId` and `skillName` from the `data-` attributes.
- - Send a `POST` request to `/api/skills/purchase` with these details in the request body.
- - Handle the API response:
- - On success, you'll receive a `solanaPayUrl`.
- - On failure (e.g., already purchased), display an appropriate message to the user.
-
-3. **Integrate Solana Pay:**
- - Once you have the `solanaPayUrl`, use the Solana Pay QR code generator to display a QR code to the user.
- - You can use a library like `@solana/pay-qr-code` for this.
- - Display the QR code in a modal window. This will allow users to scan it with their mobile wallet to approve the transaction.
-
-## Code Example (`src/marketplace.js`)
-
-```javascript
-// Add this logic to your main marketplace script
-
-function handleBuySkillClick(event) {
- if (!event.target.matches('.buy-skill-btn')) {
- return;
- }
-
- const button = event.target;
- const { agentId, skillName } = button.dataset;
-
- button.disabled = true;
- button.textContent = 'Preparing...';
-
- fetch('/api/skills/purchase', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ agentId, skillName }),
- })
- .then(response => {
- if (!response.ok) {
- return response.json().then(err => Promise.reject(err));
- }
- return response.json();
- })
- .then(data => {
- // Assume you have a function to show a Solana Pay modal
- showSolanaPayModal(data.solanaPayUrl);
- button.textContent = 'Pay...';
- })
- .catch(err => {
- console.error('Purchase failed:', err);
- alert(err.error || 'Could not initiate purchase.');
- button.disabled = false;
- button.textContent = 'Buy';
- });
-}
-
-// Attach the listener
-document.addEventListener('click', handleBuySkillClick);
-
-// You will need to implement this modal function
-function showSolanaPayModal(url) {
- // 1. Create a modal element
- // 2. Use a QR code library to generate a QR code from the URL
- // 3. Append the QR code to the modal and display it
-}
-```
-
-## Verification
-- Click a "Buy" button on the agent detail page.
-- Verify in your browser's developer tools that the `POST` request is sent to the backend.
-- Check that the backend responds with a Solana Pay URL.
-- Ensure that a modal with a QR code appears.
-- Try clicking "Buy" for a skill you've already purchased (if you have seeded data) and verify the error handling.
diff --git a/docs/monetization-feature/07-backend-verify-and-record-purchase.md b/docs/monetization-feature/07-backend-verify-and-record-purchase.md
deleted file mode 100644
index 80da0cd63..000000000
--- a/docs/monetization-feature/07-backend-verify-and-record-purchase.md
+++ /dev/null
@@ -1,76 +0,0 @@
----
-status: not-started
----
-
-# Prompt 7: Backend - Verify and Record Purchase
-
-**Status:** Not Started
-
-## Objective
-Create a backend endpoint to verify a completed Solana transaction and record the skill purchase in the database.
-
-## Explanation
-After a user approves a transaction through the Solana Pay QR code, we need a way to confirm that the payment was successful. Solana Pay includes a mechanism for this. The transaction can be found on-chain and, once verified, the purchase can be recorded in our `user_skill_purchases` table. This endpoint will be responsible for this verification and recording process.
-
-## Instructions
-1. **Create a verification endpoint:**
- - Create a new API route, e.g., `/api/skills/verify-purchase`.
- - It should accept a `POST` request with the `transaction_signature`.
-
-2. **Verify the transaction:**
- - In the endpoint, use the Solana Web3 library (`@solana/web3.js`) to fetch the transaction details using the provided signature.
- - **Crucially, verify all aspects of the transaction:**
- - That the transaction was successful.
- - That the correct amount of the correct SPL token was transferred.
- - That the token was transferred to the correct recipient (the agent creator).
- - That the `reference` public key in the transaction matches the one you generated in the purchase initiation step.
-
-3. **Record the purchase:**
- - If the transaction is valid, insert a new record into the `user_skill_purchases` table.
- - The record should include the `user_id`, `agent_id`, `skill_name`, price, currency, and the transaction signature.
-
-4. **Polling from the frontend:**
- - The frontend, after displaying the Solana Pay QR code, will need to poll this verification endpoint to know when the purchase is complete.
- - The frontend will send the transaction signature (which it can get from the Solana Pay `findTransactionSignature` method) to the backend.
- - When the backend confirms the purchase, the frontend can close the modal and update the UI to show the skill as "Owned."
-
-## Code Example (`api/skills/verify-purchase.js`)
-
-```javascript
-// api/skills/verify-purchase.js
-import { Connection, PublicKey } from '@solana/web3.js';
-
-export default async function handler(req, res) {
- // ... authentication and request validation ...
-
- const { transactionSignature, agentId, skillName } = req.body;
- const userId = await getUserIdFromSession(req);
-
- // 1. Fetch transaction from Solana blockchain
- const connection = new Connection(process.env.SOLANA_RPC_URL);
- const transaction = await connection.getTransaction(transactionSignature);
-
- // 2. Verify transaction details (this is a simplified example)
- // In a real app, you would need to parse the transaction instructions
- // to confirm the amount, mint, and recipient are correct.
- if (transaction && !transaction.meta.err) {
- // 3. Record the purchase
- const price = await getSkillPrice(agentId, skillName); // You need this function
- await db.query(
- `INSERT INTO user_skill_purchases (user_id, agent_id, skill_name, purchase_price, purchase_currency, transaction_signature)
- VALUES ($1, $2, $3, $4, $5, $6)`,
- [userId, agentId, skillName, price.amount, price.currency_mint, transactionSignature]
- );
-
- return res.status(200).json({ success: true, message: 'Purchase successful' });
- } else {
- return res.status(400).json({ error: 'Transaction verification failed' });
- }
-}
-```
-
-## Verification
-- Use a test wallet to complete a purchase generated by your "Buy" button.
-- After the transaction is confirmed, manually call the `/api/skills/verify-purchase` endpoint with the transaction signature.
-- Check your `user_skill_purchases` table to ensure the purchase was recorded correctly.
-- Test with an invalid or failed transaction signature to ensure the endpoint handles errors properly.
diff --git a/docs/monetization-feature/08-ui-polling-for-purchase-completion.md b/docs/monetization-feature/08-ui-polling-for-purchase-completion.md
deleted file mode 100644
index 86f200ec1..000000000
--- a/docs/monetization-feature/08-ui-polling-for-purchase-completion.md
+++ /dev/null
@@ -1,82 +0,0 @@
----
-status: not-started
----
-
-# Prompt 8: UI - Polling for Purchase Completion
-
-**Status:** Not Started
-
-## Objective
-Implement frontend logic to poll the backend for purchase verification and update the UI upon successful purchase.
-
-## Explanation
-After the user is shown the Solana Pay QR code, the frontend needs to know when the transaction is complete. The standard way to do this with Solana Pay is to poll an endpoint on our backend. This task involves writing the JavaScript to repeatedly check for purchase completion and then update the UI in real-time without requiring the user to refresh the page.
-
-## Instructions
-1. **Start polling after QR code is shown:**
- - In `src/marketplace.js`, in the function that shows the Solana Pay modal (`showSolanaPayModal`), you will need the `reference` public key that you generated on the backend. This should be returned from the `/api/skills/purchase` endpoint.
- - Use the Solana Pay `findTransactionSignature` method to listen for the transaction on-chain. This will give you the transaction signature once it's found.
-
-2. **Poll the verification endpoint:**
- - Once `findTransactionSignature` returns a signature, start polling your `/api/skills/verify-purchase` endpoint.
- - Use a `setInterval` or a recursive `setTimeout` function to make a `POST` request every few seconds (e.g., every 2-3 seconds).
- - Send the transaction signature to the endpoint.
-
-3. **Handle the polling response:**
- - If the backend responds with success:
- - Stop the polling.
- - Close the payment modal.
- - Update the UI to reflect that the skill is now owned. You can do this by re-rendering the skills section or by directly manipulating the DOM to change the "Buy" button to an "Owned" badge.
- - If the backend responds with an error (e.g., transaction not found yet), continue polling.
- - Implement a timeout for the polling (e.g., 5 minutes) to avoid indefinite requests. If it times out, inform the user that the transaction is taking longer than expected.
-
-## Code Example (`src/marketplace.js`)
-
-```javascript
-// In your showSolanaPayModal function or similar
-
-async function pollForPurchaseCompletion(reference, agentId, skillName) {
- const connection = new Connection(SOLANA_RPC_URL);
- let signature;
-
- try {
- signature = await findTransactionSignature(connection, reference, { finality: 'confirmed' });
- } catch (error) {
- // Handle timeout or other errors from findTransactionSignature
- console.error(error);
- alert('Transaction not found. Please check your wallet.');
- return;
- }
-
- const pollInterval = setInterval(async () => {
- try {
- const response = await fetch('/api/skills/verify-purchase', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ transactionSignature: signature, agentId, skillName }),
- });
-
- if (response.ok) {
- clearInterval(pollInterval);
- closeSolanaPayModal(); // Assume this function exists
- // Re-render agent details or update the specific skill entry
- updateSkillAsOwned(skillName);
- }
- } catch (error) {
- console.error('Polling error:', error);
- }
- }, 3000);
-
- // Add a timeout to stop polling after, e.g., 5 minutes
- setTimeout(() => {
- clearInterval(pollInterval);
- }, 300000);
-}
-```
-
-## Verification
-- Go through the full purchase flow in your browser.
-- After scanning the QR code and approving the transaction, watch the browser's network tab to see the polling requests.
-- Verify that once the transaction is confirmed on-chain, the polling stops.
-- Confirm that the UI updates automatically to show the skill as "Owned," and the "Buy" button is removed.
-- Test the timeout logic by generating a QR code but not completing the transaction.
diff --git a/docs/monetization-feature/09-ui-creator-set-prices-interface.md b/docs/monetization-feature/09-ui-creator-set-prices-interface.md
deleted file mode 100644
index 85b9d6a9d..000000000
--- a/docs/monetization-feature/09-ui-creator-set-prices-interface.md
+++ /dev/null
@@ -1,78 +0,0 @@
----
-status: not-started
----
-
-# Prompt 9: UI - Creator-Facing "Set Prices" Interface
-
-**Status:** Not Started
-
-## Objective
-Create a user interface for agent creators to set and manage prices for their skills.
-
-## Explanation
-To enable skill monetization, creators need a way to specify which of their skills are for sale and at what price. This task involves creating a new section in the agent editing interface where a creator can view their agent's skills and set a price for each one. This will be a new page or a new tab in the existing `agent-edit.html`.
-
-## Instructions
-1. **Create the UI component:**
- - In `agent-edit.html`, add a new tab for "Monetization" or "Skill Pricing."
- - This panel should fetch and display a list of the agent's skills (from the `capabilities.skills` object in the agent's data).
- - For each skill, display its name and an input field for the price.
-
-2. **Design the pricing input:**
- - The price input should be a number field.
- - Add a currency selector (for now, you can default to USDC, but a dropdown would be better for the future).
- - Include a "Save Prices" button.
-
-3. **Handle data fetching:**
- - When the panel loads, it should fetch the current skill prices for the agent from a new backend endpoint (which you'll create in the next step). This ensures that existing prices are displayed for editing.
-
-4. **Handle saving:**
- - When the "Save Prices" button is clicked, collect the pricing data from all the input fields.
- - Send this data to a new backend endpoint (`/api/agents/:id/skill-prices`) that will save the prices to the `agent_skill_prices` table.
-
-## Code Example (HTML in `agent-edit.html`)
-
-```html
-<!-- Inside the new "Monetization" tab panel -->
-<div class="edit-panel" id="monetization-panel">
- <h3>Skill Pricing</h3>
- <p>Set prices for your skills in USDC. Leave the price as 0 for free skills.</p>
- <div id="skill-pricing-list">
- <!-- Skills will be dynamically rendered here -->
- </div>
- <button id="save-prices-btn">Save Prices</button>
-</div>
-```
-
-## Code Example (JavaScript to render the pricing list)
-
-```javascript
-// In your agent editing script
-
-async function renderSkillPricing(agentId) {
- const agent = await fetchAgentData(agentId); // Assumes you have this
- const skills = agent.capabilities.skills || [];
- const prices = await fetchSkillPrices(agentId); // You'll build this endpoint
-
- const listEl = document.getElementById('skill-pricing-list');
- listEl.innerHTML = skills.map(skill => {
- const price = prices[skill.name] || { amount: 0, currency_mint: 'USDC' };
- const priceInUSDC = price.amount / 1e6;
-
- return `
- <div class="skill-price-entry">
- <span class="skill-name">${skill.name}</span>
- <input type="number" class="price-input" data-skill-name="${skill.name}" value="${priceInUSDC}" min="0" step="0.01">
- <span class="currency-label">USDC</span>
- </div>
- `;
- }).join('');
-}
-```
-
-## Verification
-- Navigate to the agent edit page.
-- Verify that the new "Monetization" tab is present.
-- Check that it correctly lists the agent's skills.
-- Ensure that price input fields and a "Save" button are visible.
-- The save functionality will be verified after the next prompt's task (creating the backend endpoint) is complete.
diff --git a/docs/monetization-feature/10-backend-save-skill-prices.md b/docs/monetization-feature/10-backend-save-skill-prices.md
deleted file mode 100644
index 15e11cffb..000000000
--- a/docs/monetization-feature/10-backend-save-skill-prices.md
+++ /dev/null
@@ -1,97 +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.
diff --git a/docs/monetization-feature/11-backend-access-control-logic.md b/docs/monetization-feature/11-backend-access-control-logic.md
deleted file mode 100644
index 63def179e..000000000
--- a/docs/monetization-feature/11-backend-access-control-logic.md
+++ /dev/null
@@ -1,84 +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.
diff --git a/docs/monetization-feature/12-ui-display-owned-locked-states.md b/docs/monetization-feature/12-ui-display-owned-locked-states.md
deleted file mode 100644
index ba936b316..000000000
--- a/docs/monetization-feature/12-ui-display-owned-locked-states.md
+++ /dev/null
@@ -1,81 +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.
diff --git a/docs/monetization-feature/13-creator-earnings-dashboard.md b/docs/monetization-feature/13-creator-earnings-dashboard.md
deleted file mode 100644
index 614246559..000000000
--- a/docs/monetization-feature/13-creator-earnings-dashboard.md
+++ /dev/null
@@ -1,99 +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.