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 shipped monetization-feature task files

nirholas9231e8ef44fe
diff --git a/tasks/monetization-feature/10-backend-verify-payment.md b/tasks/monetization-feature/10-backend-verify-payment.md
deleted file mode 100644
index 4b7b18104..000000000
--- a/tasks/monetization-feature/10-backend-verify-payment.md
+++ /dev/null
@@ -1,98 +0,0 @@
----
-status: not-started
----
-
-# Prompt 10: Backend - Verify Payment and Unlock Skill
-
-## Objective
-Create a backend process to verify Solana Pay transactions and grant the purchased skill to the user upon confirmation.
-
-## Explanation
-After the user approves the transaction, our backend needs to confirm that the payment was successfully made. We will do this by polling the Solana blockchain for the transaction signature associated with our unique reference key. Once verified, we will record the purchase and create a record that the user now owns the skill.
-
-## Instructions
-1. **Create a Verification Endpoint or Process:**
- * This can be a new API endpoint that the frontend polls (e.g., `/api/payments/verify-transaction?reference=...`) or a background worker.
- * Given a `reference` public key, the process should:
- * Use the Solana `findReference` method from `@solana/pay` to find the transaction signature.
- * This method will repeatedly query the chain until the transaction is found or it times out.
-
-2. **Validate the Transaction:**
- * Once the transaction is found, validate its details:
- * Check that the recipient, amount, and SPL token mint match the expected values for the skill purchase.
- * This step is crucial to prevent users from sending incorrect payments and wrongly getting access.
-
-3. **Grant the Skill:**
- * If validation passes, update the user's record to indicate they own the skill.
- * Create a new table, `unlocked_agent_skills`, with `user_id` and `skill_id` to store this relationship.
- * Update your `skill_purchases` table to mark the purchase as `completed`.
-
-## Code Example (Verification Endpoint)
-
-```javascript
-import { findReference, validateTransfer } from '@solana/pay';
-import { Connection, clusterApiUrl, PublicKey } from '@solana/web3.js';
-
-// ... db connection
-
-export default async function handler(req, res) {
- const { reference } = req.query;
- if (!reference) {
- return res.status(400).json({ error: 'Reference key is required' });
- }
-
- try {
- const connection = new Connection(clusterApiUrl('mainnet-beta'));
- const referencePubkey = new PublicKey(reference);
-
- // 1. Find the transaction
- const signature = await findReference(connection, referencePubkey, { finality: 'confirmed' });
-
- // 2. Get purchase details from our DB
- const purchase = await getPendingPurchaseByReference(reference);
- if (!purchase) {
- return res.status(404).json({ status: 'not_found' });
- }
-
- // 3. Validate the transaction against our records
- await validateTransfer(
- connection,
- signature,
- {
- recipient: new PublicKey(purchase.creator_wallet),
- amount: new BigNumber(purchase.amount / 1e6),
- splToken: new PublicKey(purchase.currency_mint),
- reference: referencePubkey,
- },
- { commitment: 'confirmed' }
- );
-
- // 4. If validation doesn't throw, grant the skill
- await grantSkillToUser(purchase.user_id, purchase.skill_id);
- await markPurchaseAsComplete(purchase.id);
-
- res.status(200).json({ status: 'confirmed' });
-
- } catch (error) {
- if (error.message.includes('not found')) {
- res.status(202).json({ status: 'pending' });
- } else {
- res.status(500).json({ status: 'error', message: error.message });
- }
- }
-}
-```
-
-<!-- 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 "tasks/monetization-feature/10-backend-verify-payment.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/tasks/monetization-feature/10-send-solana-transaction.md b/tasks/monetization-feature/10-send-solana-transaction.md
deleted file mode 100644
index c2d8586d8..000000000
--- a/tasks/monetization-feature/10-send-solana-transaction.md
+++ /dev/null
@@ -1,130 +0,0 @@
-# Prompt 10: Send Solana Transaction
-
-## Objective
-Wire up the "Confirm Purchase" button to take the constructed transaction from the previous step, send it to the user's wallet for signing, and submit it to the Solana network.
-
-## Explanation
-This is the climax of the payment flow. The user has connected their wallet and is ready to pay. When they click the final confirmation button, we will:
-1. Build the transaction using the function from the previous prompt.
-2. Use the wallet adapter's `sendTransaction` method. This method first asks the user to approve and sign the transaction via their wallet's popup.
-3. If the user approves, the adapter sends the signed transaction to the Solana RPC.
-4. The method returns a transaction signature (ID).
-5. We will then wait for the transaction to be confirmed by the network.
-
-## Instructions
-1. **Add Event Listener:**
- * In `src/marketplace.js`, add an event listener to the `#payment-confirm-btn`. This should be done when the modal is opened or when the wallet connects.
-
-2. **Implement the Click Handler:**
- * The handler should be `async`.
- * Show a loading state (e.g., disable the button, show a "Processing..." message in the status area).
- * Get the `intent_id` and other necessary data that you stored when opening the modal.
- * Get the user's public key from `wallet.publicKey`.
- * Call the `buildUsdcTransferTransaction` function from the previous prompt to get the transaction object.
-
-3. **Send the Transaction:**
- * Call `wallet.sendTransaction(transaction, solanaConnection)`.
- * This function will throw an error if the user rejects the signature, so wrap it in a `try...catch` block.
- * The function returns a `txid` (transaction signature).
-
-4. **Confirm the Transaction:**
- * Once you have the `txid`, use `solanaConnection.confirmTransaction(txid, 'confirmed')`. This will wait until the transaction is finalized on the blockchain.
- * This is the point of success. You now have proof of payment.
-
-5. **Next Steps (to be handled in future prompts):**
- * After confirmation, you will call your backend's `/api/payments/confirm` endpoint with the `txid`.
- * For now, on success, simply show a success message in the modal's status area. On failure (user rejection, network error), show an appropriate error message.
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// Add this event listener setup inside the updateWalletUI function,
-// when the wallet is connected.
-
-function updateWalletUI() {
- // ... inside the `if (wallet.connected)` block
- const confirmBtn = $('payment-confirm-btn');
- confirmBtn.disabled = false;
-
- // Make sure to remove old listeners if this function can be called multiple times
- const newConfirmBtn = confirmBtn.cloneNode(true);
- confirmBtn.parentNode.replaceChild(newConfirmBtn, confirmBtn);
-
- newConfirmBtn.addEventListener('click', handlePurchase);
-}
-
-// Create the main purchase handler function
-async function handlePurchase() {
- const statusEl = $('payment-status');
- const confirmBtn = $('payment-confirm-btn');
- confirmBtn.disabled = true;
- statusEl.textContent = 'Building transaction...';
-
- try {
- const intentId = document.getElementById('payment-modal-overlay').dataset.intentId;
- // You'll need to fetch the intent again or store it more robustly
- // For now, let's assume `currentIntent` is available
- const intent = await getCurrentIntentDetails(intentId); // Placeholder for fetching intent
- if (!wallet.publicKey) throw new Error('Wallet is not connected.');
-
- const transaction = await buildUsdcTransferTransaction(intent, wallet.publicKey);
-
- statusEl.textContent = 'Please approve the transaction in your wallet...';
-
- const txid = await wallet.sendTransaction(transaction, solanaConnection);
- statusEl.textContent = `Transaction sent! Waiting for confirmation... (${txid.slice(0, 8)}...)`;
-
- const confirmation = await solanaConnection.confirmTransaction(txid, 'confirmed');
- if (confirmation.value.err) {
- throw new Error(`Transaction failed: ${confirmation.value.err}`);
- }
-
- statusEl.textContent = 'Payment successful! Unlocking skill...';
-
- // In the next prompt, we will call our backend confirmation endpoint here.
- // For example: await confirmPaymentOnBackend(intentId, txid);
-
- setTimeout(() => {
- closePaymentModal();
- }, 2000);
-
- } catch (error) {
- statusEl.textContent = `Error: ${error.message}`;
- console.error("Purchase failed", error);
- } finally {
- // The button will be re-enabled if the modal is re-opened
- }
-}
-
-// A placeholder function - you'd need to implement this
-// or pass the intent object around properly.
-async function getCurrentIntentDetails(intentId) {
- // In a real app, you might re-fetch this from your server or have it stored
- // For now, we'll reconstruct it from the UI for this example
- const priceText = $('payment-price-display').textContent;
- const amount = Math.round(parseFloat(priceText.replace(' USDC', '')) * 1e6);
- // You would also need to get the recipient address and mint from the intent.
- // This highlights the need for better state management than just the DOM.
-
- // For now, let's return a dummy object. The real implementation would be more robust.
- return {
- recipient_address: '...', // You would need to fetch this
- amount: String(amount),
- currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7u6a' // USDC
- }
-}
-```
-
-<!-- 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 "tasks/monetization-feature/10-send-solana-transaction.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/tasks/monetization-feature/11-frontend-wallet-connection.md b/tasks/monetization-feature/11-frontend-wallet-connection.md
deleted file mode 100644
index bf690d919..000000000
--- a/tasks/monetization-feature/11-frontend-wallet-connection.md
+++ /dev/null
@@ -1,69 +0,0 @@
----
-status: not-started
----
-# Prompt 11: Frontend Wallet Connection
-
-**Status:** Not Started
-
-## Objective
-Implement a "Connect Wallet" feature allowing users to connect their Solana wallets (e.g., Phantom) to the application.
-
-## Explanation
-To perform on-chain transactions, the application needs permission to interact with the user's wallet. This task involves adding a UI element for connecting a wallet and using a library like `@solana/wallet-adapter` to handle the connection logic.
-
-## Instructions
-1. **Add the necessary libraries to your project:**
- ```bash
- npm install @solana/wallet-adapter-base @solana/wallet-adapter-react @solana/wallet-adapter-wallets @solana/web3.js
- ```
- *(Note: If not using React, you can use the base libraries and implement your own UI bindings.)*
-2. **Add a "Connect Wallet" button to your site's main header.**
-3. **Wrap your application's main component with `ConnectionProvider`, `WalletProvider`, and add a `WalletModalProvider` for the connection dialog.**
-4. **Use the `useWallet` hook (or equivalent) to get the connection status and public key.**
- - When connected, change the button text to show the user's public key (truncated).
- - Store the user's public key in a global state or variable for use in purchase flows.
-
-## Code Example (Using `@solana/wallet-adapter-react` and components)
-```javascript
-// In your main layout/app component
-import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
-import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react';
-import { WalletModalProvider, WalletMultiButton } from '@solana/wallet-adapter-react-ui';
-import { PhantomWalletAdapter } from '@solana/wallet-adapter-wallets';
-// ... more adapters
-
-// In your render method
-const network = WalletAdapterNetwork.Mainnet;
-const endpoint = useMemo(() => clusterApiUrl(network), [network]);
-const wallets = useMemo(() => [new PhantomWalletAdapter()], [network]);
-
-return (
- <ConnectionProvider endpoint={endpoint}>
- <WalletProvider wallets={wallets} autoConnect>
- <WalletModalProvider>
- {/* Your app content */}
- <header>
- {/* ... other nav items ... */}
- <WalletMultiButton />
- </header>
- {/* ... rest of your app ... */}
- </WalletModalProvider>
- </WalletProvider>
- </ConnectionProvider>
-);
-```
-*This provides a pre-built button and modal for a quick setup.*
-
-<!-- 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 "tasks/monetization-feature/11-frontend-wallet-connection.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/tasks/monetization-feature/11-referral-system-signup-flow.md b/tasks/monetization-feature/11-referral-system-signup-flow.md
deleted file mode 100644
index 1a5e7c492..000000000
--- a/tasks/monetization-feature/11-referral-system-signup-flow.md
+++ /dev/null
@@ -1,87 +0,0 @@
----
-status: not-started
----
-
-# Prompt 11: Frontend - Add Referral Code to Signup
-
-## Objective
-Update the user registration form to include an optional field for a referral code.
-
-## Explanation
-To create the link between a referrer and a new user, the referral code must be captured at the moment of signup. This involves adding a new input field to the registration UI and ensuring this data is sent to the backend API.
-
-## Instructions
-1. **Modify the Registration HTML:**
- * Locate the HTML file that contains your user registration form (e.g., this might be in `app.html`, `index.html`, or handled by a JavaScript template).
- * Add a new text input field to the form.
- * Label it clearly, for example, "Referral Code (Optional)".
- * Give it a `name` and `id`, such as `referral_code`.
-
-2. **Update the Registration JavaScript:**
- * Find the JavaScript code that handles the registration form submission.
- * When you gather the form data to send to the `/api/auth/register` endpoint, include the value from the new referral code input.
- * Since the field is optional, your code should handle cases where it's empty.
-
-3. **Ensure Backend Compatibility:**
- * This step relies on the backend changes from the earlier referral system task, where the `/api/auth/register` endpoint was updated to accept a `referralCode` field in its request body. No backend changes are needed for this prompt if that was done correctly.
-
-## HTML Form Example
-
-```html
-<!-- Inside your registration form -->
-<form id="register-form">
- <div>
- <label for="email">Email</label>
- <input type="email" id="email" name="email" required>
- </div>
- <div>
- <label for="password">Password</label>
- <input type="password" id="password" name="password" required>
- </div>
- <div>
- <label for="referral_code">Referral Code (Optional)</label>
- <input type="text" id="referral_code" name="referral_code">
- </div>
- <button type="submit">Sign Up</button>
-</form>
-```
-
-## JavaScript Form Handling Example
-
-```javascript
-document.getElementById('register-form').addEventListener('submit', async (e) => {
- e.preventDefault();
- const formData = new FormData(e.target);
- const data = Object.fromEntries(formData.entries());
-
- // The backend expects 'referralCode' (camelCase) from the validation schema
- const payload = {
- email: data.email,
- password: data.password,
- referralCode: data.referral_code, // Ensure key matches backend expectation
- };
-
- const response = await fetch('/api/auth/register', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- // Only include referralCode if it has a value
- body: JSON.stringify(Object.fromEntries(Object.entries(payload).filter(([_, v]) => v))),
- });
-
- // ... handle response
-});
-```
-
-<!-- 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 "tasks/monetization-feature/11-referral-system-signup-flow.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/tasks/monetization-feature/12-frontend-js-initiate-purchase.md b/tasks/monetization-feature/12-frontend-js-initiate-purchase.md
deleted file mode 100644
index 916888f09..000000000
--- a/tasks/monetization-feature/12-frontend-js-initiate-purchase.md
+++ /dev/null
@@ -1,78 +0,0 @@
----
-status: not-started
----
-# Prompt 12: Frontend Initiates Purchase
-
-**Status:** Not Started
-
-## Objective
-Write the frontend JavaScript to call the backend API and fetch the unsigned transaction when a user clicks "Purchase".
-
-## Explanation
-This is the first step in the client-side purchase flow. After the user clicks the purchase button, the frontend needs to communicate with the backend to get a transaction that can then be passed to the user's wallet for signing.
-
-## Instructions
-1. **In `src/marketplace.js`, add a click event listener to the skills container.**
-2. **Delegate the event to handle clicks on `.purchase-btn` buttons.**
-3. **Inside the handler:**
- - Check if the user's wallet is connected. If not, prompt them to connect it.
- - Get the skill name from the `data-skill-name` attribute.
- - Get the current agent ID from the page context.
- - Get the user's public key from the wallet adapter state.
- - Show a "Preparing transaction..." loading indicator.
- - Call the `POST /api/skills/:skill_id/purchase` endpoint (from Prompt 5). Note: you might need to pass the skill name and get the ID. The API might be better as `/api/skills/purchase` with the name in the body.
- - Pass the user's public key (`account`) in the request body.
- - The API will respond with a base64-encoded transaction string.
-
-## Code Example (Frontend - `src/marketplace.js`)
-```javascript
-// Using a hypothetical wallet state object
-// const { publicKey, connected } = useWallet();
-
-$('d-skills').addEventListener('click', async (event) => {
- if (!event.target.matches('.purchase-btn')) return;
-
- if (!connected || !publicKey) {
- alert('Please connect your wallet to purchase a skill.');
- return;
- }
-
- const skillName = event.target.dataset.skillName;
- const agentId = getCurrentAgentId(); // Function to get agent ID from URL or state
-
- try {
- const response = await fetch(`/api/skills/purchase`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- skillName: skillName,
- agentId: agentId,
- account: publicKey.toBase58(),
- })
- });
-
- if (!response.ok) throw new Error('Failed to prepare transaction.');
-
- const { transaction } = await response.json();
- // Next step: pass this 'transaction' string to the signing function
- await signAndSendTransaction(transaction);
-
- } catch (error) {
- alert(`Purchase failed: ${error.message}`);
- }
-});
-```
-
-<!-- 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 "tasks/monetization-feature/12-frontend-js-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/tasks/monetization-feature/12-handle-payment-confirmation-ui.md b/tasks/monetization-feature/12-handle-payment-confirmation-ui.md
deleted file mode 100644
index 7b0c7e454..000000000
--- a/tasks/monetization-feature/12-handle-payment-confirmation-ui.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# Prompt 12: Handle Payment Confirmation UI
-
-## Objective
-Update the frontend JavaScript to call the `/api/payments/confirm` endpoint after a Solana transaction is confirmed, and display appropriate success or error messages to the user in the payment modal.
-
-## Explanation
-The loop is almost closed. The frontend has a confirmed transaction signature (`txid`), and the backend has an endpoint to verify it. Now we need to connect the two. The `handlePurchase` function will be extended to send the `txid` and `intent_id` to our backend, effectively finalizing the purchase in our system. The UI needs to provide clear feedback throughout this final verification step.
-
-## Instructions
-1. **Locate the Frontend Logic:**
- * Open `src/marketplace.js` and find the `handlePurchase` function created in Prompt 10.
-
-2. **Add the API Call:**
- * Inside the `try` block, immediately after `solanaConnection.confirmTransaction` successfully completes, add a `fetch` call.
- * `POST` to `/api/payments/confirm`.
- * The body of the request must include the `intent_id` and the `transaction_signature` (`txid`).
- * Remember to include `credentials: 'include'` and the correct `Content-Type` header.
-
-3. **Handle API Response:**
- * Check if the response is `ok`. If not, throw an error with the message from the API's JSON response. This will be caught by the `catch` block.
- * If the response is successful, the purchase is officially complete.
-
-4. **Update UI Feedback:**
- * Change the status messages in the modal to reflect the new step.
- * Before the API call: "Verifying purchase with server..."
- * On API success: "Success! Skill unlocked."
- * On API failure (in the `catch` block): "There was an issue verifying your purchase. Please contact support."
- * After a successful confirmation, you can close the modal after a short delay.
-
-## Code Example (Frontend - `src/marketplace.js`)
-
-```javascript
-// This is an updated version of the handlePurchase function from Prompt 10
-
-async function handlePurchase() {
- const statusEl = $('payment-status');
- const confirmBtn = $('payment-confirm-btn');
- confirmBtn.disabled = true;
- statusEl.textContent = 'Building transaction...';
- statusEl.className = 'payment-status';
-
- const intentId = document.getElementById('payment-modal-overlay').dataset.intentId;
- if (!intentId) {
- statusEl.textContent = 'Error: Missing payment intent ID.';
- statusEl.classList.add('err');
- return;
- }
-
- try {
- const intent = await getCurrentIntentDetails(intentId); // Placeholder
- if (!wallet.publicKey) throw new Error('Wallet is not connected.');
-
- statusEl.textContent = 'Please approve the transaction in your wallet...';
- const transaction = await buildUsdcTransferTransaction(intent, wallet.publicKey);
- const txid = await wallet.sendTransaction(transaction, solanaConnection);
-
- statusEl.textContent = `Waiting for on-chain confirmation...`;
- const confirmation = await solanaConnection.confirmTransaction(txid, 'confirmed');
- if (confirmation.value.err) throw new Error('On-chain transaction failed.');
-
- statusEl.textContent = 'Verifying purchase with server...';
-
- const verifyRes = await fetch('/api/payments/confirm', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- credentials: 'include',
- body: JSON.stringify({
- intent_id: intentId,
- transaction_signature: txid,
- }),
- });
-
- const verifyBody = await verifyRes.json();
- if (!verifyRes.ok) {
- throw new Error(verifyBody.error_description || 'Failed to verify purchase.');
- }
-
- statusEl.textContent = 'Success! Skill unlocked.';
- statusEl.classList.add('ok');
-
- // In the next prompt, we will add logic to update the UI permanently
- // fireEvent('skill:purchased', { skillName: intent.payload.skill });
-
- setTimeout(closePaymentModal, 2000);
-
- } catch (error) {
- statusEl.textContent = `Error: ${error.message}`;
- statusEl.classList.add('err');
- console.error("Purchase failed", error);
- confirmBtn.disabled = false; // Re-enable on failure
- }
-}
-```
-
-<!-- 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 "tasks/monetization-feature/12-handle-payment-confirmation-ui.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/tasks/monetization-feature/12-referral-commission-logic.md b/tasks/monetization-feature/12-referral-commission-logic.md
deleted file mode 100644
index 700461caf..000000000
--- a/tasks/monetization-feature/12-referral-commission-logic.md
+++ /dev/null
@@ -1,93 +0,0 @@
----
-status: not-started
----
-
-# Prompt 12: Backend - Implement Referral Commission Logic
-
-## Objective
-Implement the backend logic to award a commission to the referrer when a referred user makes their first purchase.
-
-## Explanation
-This is the core of the referral program's value proposition. When a new user, brought in by a referrer, makes a purchase, the system must automatically calculate and credit a commission to the referrer. This process should be reliable and auditable.
-
-## Instructions
-1. **Locate the Payment Verification Logic:**
- * Find the part of your backend code that verifies a payment and unlocks a skill for a user (from "Prompt 6: Backend - Payment Verification"). This is likely in a file like `/api/payments/verify.js`.
-
-2. **Identify the Purchaser and Referrer:**
- * Inside this logic, you have the `user_id` of the person making the purchase.
- * Query the `users` table to check if this user has a `referred_by_id`.
- * If `referred_by_id` is `null`, do nothing.
-
-3. **Check if it's the First Purchase:**
- * To prevent awarding commissions on every purchase, you should typically only award it on the *first* purchase.
- * Check your `user_purchased_skills` table to see if this user has any prior purchases. If they do, do not award a commission.
-
-4. **Calculate the Commission:**
- * If there is a `referred_by_id` and this is the user's first purchase:
- * Define the commission rate (e.g., 5% of the sale price). It's best to store this in a configuration file.
- * Calculate the commission amount based on the `purchase_price`.
-
-5. **Record the Commission:**
- * Insert a new entry into your `royalty_ledger` or a similar earnings table.
- * This entry should be for the `referred_by_id` (the referrer).
- * Clearly mark this earning as a "referral_commission".
- * Update the `referral_earnings_total` on the referrer's `users` table row.
-
-## Code Logic Snippet (in payment verification)
-
-```javascript
-// After successfully verifying a transaction and before inserting the purchase record...
-
-const purchasePrice = ...; // price from the transaction
-const purchaserId = ...; // ID of the user who paid
-
-// 1. Get purchaser's referral info
-const [purchaser] = await sql`
- SELECT referred_by_id FROM users WHERE id = ${purchaserId}
-`;
-
-if (purchaser && purchaser.referred_by_id) {
- const referrerId = purchaser.referred_by_id;
-
- // 2. Check if it's the first purchase for this user
- const [priorPurchases] = await sql`
- SELECT COUNT(*) as count FROM user_purchased_skills WHERE user_id = ${purchaserId}
- `;
-
- if (Number(priorPurchases.count) === 0) {
- // 3. Calculate and award commission
- const commissionRate = 0.05; // 5%
- const commissionAmount = purchasePrice * commissionRate;
-
- // 4. Record the commission in the ledger for the referrer
- await sql`
- INSERT INTO royalty_ledger (author_user_id, amount_usd, type, source_purchase_id, ...)
- VALUES (${referrerId}, ${commissionAmount}, 'referral_commission', ...);
- `;
-
- // 5. Update the total on the user's record
- await sql`
- UPDATE users
- SET referral_earnings_total = referral_earnings_total + ${commissionAmount}
- WHERE id = ${referrerId};
- `;
- }
-}
-
-// Now, proceed to insert the main purchase record for the buyer...
-```
-
-<!-- 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 "tasks/monetization-feature/12-referral-commission-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/tasks/monetization-feature/13-api-keys-for-developers.md b/tasks/monetization-feature/13-api-keys-for-developers.md
deleted file mode 100644
index be625feef..000000000
--- a/tasks/monetization-feature/13-api-keys-for-developers.md
+++ /dev/null
@@ -1,76 +0,0 @@
----
-status: not-started
----
-
-# Prompt 13: Backend & Frontend - API Key Generation
-
-## Objective
-Allow users to generate and manage API keys from their profile, enabling programmatic access to the platform.
-
-## Explanation
-To grow into a true platform, third-party developers need a way to interact with your services. Providing API keys is the first step. This involves creating a secure system for generating, storing, and revoking keys, as well as a user-friendly interface for managing them.
-
-## Instructions
-
-### Backend
-1. **Create an `api_keys` Table:**
- * Create a migration for a table to store API keys.
- * Columns: `id`, `user_id`, `key_prefix`, `token_hash` (store a hash, not the raw key), `scope`, `created_at`, `revoked_at`, `last_used_at`.
-
-2. **Create API Endpoints (`/api/api-keys.js`):**
- * `GET /`: Fetches all non-revoked API keys for the logged-in user. (Return only non-sensitive data like `key_prefix`, `scope`, `created_at`).
- * `POST /`: Generates a new API key.
- * Create a cryptographically secure key (e.g., `sk_live_` + random bytes).
- * Hash the key before storing it in the database.
- * **Important:** Return the full, unhashed key to the user **only once** upon creation. It cannot be retrieved again.
- * `DELETE /:key_id`: Revokes an API key by setting `revoked_at`.
-
-### Frontend
-1. **Create New UI (`api-keys.html`):**
- * Create a new page accessible from the user's main navigation.
- * Add a section to list the user's existing API keys.
- * Include a button to "Generate New Key".
- * Each key in the list should have a "Revoke" button.
-
-2. **Implement Frontend Logic (`src/api-keys.js`):**
- * On page load, `GET` keys from the API and render the list.
- * When the "Generate" button is clicked, `POST` to the API. The response will contain the new key. Display this key in a modal and make it clear that it must be saved immediately.
- * When a "Revoke" button is clicked, send a `DELETE` request for that key's ID and remove it from the list on success.
-
-## API Key Generation Snippet (Backend)
-
-```javascript
-import { randomBytes } from 'crypto';
-import { sha256 } from '../_lib/crypto.js';
-import { sql } from '../_lib/db.js';
-
-// Inside POST /api/api-keys
-const user = await getSessionUser(req);
-if (!user) return error(res, 401);
-
-const apiKey = `sk_live_${randomBytes(16).toString('hex')}`;
-const hash = await sha256(apiKey);
-const prefix = apiKey.substring(0, 10); // e.g., "sk_live_..."
-
-await sql`
- INSERT INTO api_keys (user_id, token_hash, key_prefix, scope)
- VALUES (${user.id}, ${hash}, ${prefix}, 'default');
-`;
-
-// Return the raw key ONLY this one time.
-return json(res, 201, { new_key: apiKey, message: "Save this key securely. You won't see it again." });
-```
-
-<!-- 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 "tasks/monetization-feature/13-api-keys-for-developers.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/tasks/monetization-feature/13-frontend-save-skill-prices.md b/tasks/monetization-feature/13-frontend-save-skill-prices.md
deleted file mode 100644
index 1f0ed28c8..000000000
--- a/tasks/monetization-feature/13-frontend-save-skill-prices.md
+++ /dev/null
@@ -1,90 +0,0 @@
----
-status: not-started
----
-
-# Prompt 13: Frontend Logic to Save Skill Prices
-
-**Status:** Not Started
-
-## Objective
-Implement the client-side JavaScript to handle saving the skill prices set by the agent creator.
-
-## Explanation
-When the user clicks the "Save Prices" button in the monetization tab, the frontend needs to collect the data from all the input fields and send it to the backend API endpoint created in Prompt 3.
-
-## Instructions
-- [ ] **Add an Event Listener:**
- - [ ] In the agent editor's JavaScript, add a `click` event listener to the "Save Prices" button (`#save-prices-btn`).
-- [ ] **Data Collection:**
- - [ ] Inside the event listener, iterate through each `.skill-price-entry` element.
- - [ ] For each skill, read the `skill-name` from the `data-` attribute, the price from the `.price-input`, and the currency from the `.currency-input`.
- - [ ] Remember to convert the human-readable price (e.g., 1.50 USDC) back into the smallest unit (lamports, e.g., 1,500,000).
-- [ ] **API Call:**
- - [ ] For each skill that has a price set, call the `POST /api/agents/prices` endpoint. You can do this in a loop or batch the requests.
- - [ ] The body of the request should be `{ agentId, skillName, amount, currencyMint }`.
-- [ ] **Provide User Feedback:**
- - [ ] Show a success message (e.g., a toast notification) when the prices are saved successfully.
- - [ ] Display an error message if the API call fails.
-
-## Code Example (JavaScript)
-
-```javascript
-// In the agent editor's JS file
-
-document.addEventListener('click', async (e) => {
- if (e.target.id === 'save-prices-btn') {
- e.target.disabled = true;
- e.target.textContent = 'Saving...';
-
- const entries = document.querySelectorAll('.skill-price-entry');
- for (const entry of entries) {
- const skillName = entry.dataset.skillName;
- const amountUSD = parseFloat(entry.querySelector('.price-input').value);
- const currencyMint = entry.querySelector('.currency-input').value;
- const amountLamports = Math.round(amountUSD * 1e6); // Convert to lamports
-
- try {
- const response = await fetch('/api/agents/prices', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- agentId: currentAgent.id, // Assumes currentAgent is available in scope
- skillName,
- amount: amountLamports,
- currencyMint,
- }),
- });
-
- if (!response.ok) {
- throw new Error('Failed to save price for ' + skillName);
- }
- } catch (err) {
- console.error(err);
- alert('Error saving prices. Check the console.');
- // Re-enable button and break
- e.target.disabled = false;
- e.target.textContent = 'Save Prices';
- return;
- }
- }
-
- e.target.disabled = false;
- e.target.textContent = 'Save Prices';
- alert('Prices saved successfully!');
- }
-});
-```
-
-<!-- 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 "tasks/monetization-feature/13-frontend-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/tasks/monetization-feature/14-api-usage-tracking.md b/tasks/monetization-feature/14-api-usage-tracking.md
deleted file mode 100644
index ee093b687..000000000
--- a/tasks/monetization-feature/14-api-usage-tracking.md
+++ /dev/null
@@ -1,83 +0,0 @@
----
-status: not-started
----
-
-# Prompt 14: Backend - API Usage Tracking
-
-## Objective
-Implement a middleware to track API usage for each authenticated request, forming the basis for metered billing.
-
-## Explanation
-To bill developers for API consumption, we must first accurately measure it. This task involves creating a middleware that intercepts authenticated API requests, identifies the API key used, and increments a usage counter. This data is essential for enforcing rate limits and calculating monthly bills.
-
-## Instructions
-1. **Choose a Storage Method for Counters:**
- * For high-throughput APIs, a fast data store like Redis is ideal for usage counters to avoid overwhelming your primary database.
- * Alternatively, for moderate traffic, you can use a dedicated `api_usage_logs` table in your SQL database.
-
-2. **Create an Authentication/Tracking Middleware:**
- * This middleware will run before your main API logic on protected routes.
- * It should extract the bearer token from the `Authorization` header.
- * Authenticate the token (as implemented in `authenticateBearer`). This function should now be enhanced to check for API keys by looking up their hash in the `api_keys` table.
- * If the key is valid, attach the `user_id` and `apiKeyId` to the request object (`req.auth`).
-
-3. **Increment the Usage Counter:**
- * After successful authentication, the middleware should increment the usage counter for the `apiKeyId`.
- * **If using Redis:** Use the `INCR` command on a key like `api_usage:{apiKeyId}:{yyyy-mm}`.
- * **If using SQL:** Insert a row into `api_usage_logs` with `api_key_id` and the current timestamp. You would then aggregate these logs for billing.
-
-4. **Apply the Middleware:**
- * Wrap your API endpoint handlers with this new middleware to protect them and track their usage.
-
-## Middleware Example
-
-```javascript
-// In a file like /api/_lib/auth.js or a new middleware file
-
-import { extractBearer, authenticateBearer } from './auth.js';
-
-export function trackApiUsage(handler) {
- return async (req, res) => {
- const token = extractBearer(req);
- if (!token) {
- return error(res, 401, 'missing_token');
- }
-
- const authContext = await authenticateBearer(token); // This now handles both JWTs and API keys
- if (!authContext) {
- return error(res, 401, 'invalid_token');
- }
-
- // Attach auth info to the request for the handler to use
- req.auth = authContext;
-
- // If the request was via an API key, track usage
- if (authContext.source === 'apikey') {
- // Using Redis (example)
- const redis = getRedisClient();
- const period = new Date().toISOString().substring(0, 7); // YYYY-MM
- await redis.incr(`api_usage:${authContext.apiKeyId}:${period}`);
- }
-
- // Proceed to the actual API endpoint logic
- return handler(req, res);
- };
-}
-
-// In your API route file:
-// export default wrap(trackApiUsage(async (req, res) => { ... your 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 "tasks/monetization-feature/14-api-usage-tracking.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/tasks/monetization-feature/15-backend-logic-skill-unlock.md b/tasks/monetization-feature/15-backend-logic-skill-unlock.md
deleted file mode 100644
index d9552acb2..000000000
--- a/tasks/monetization-feature/15-backend-logic-skill-unlock.md
+++ /dev/null
@@ -1,64 +0,0 @@
----
-status: not-started
----
-# Prompt 15: Backend Logic for Skill Unlocking
-
-**Status:** Not Started
-
-## Objective
-Modify the backend logic to ensure that an agent can only use/execute skills that are either free or have been purchased for it.
-
-## Explanation
-This is the enforcement part of the monetization feature. When an agent is about to perform an action using a skill, the backend must first verify access rights. This prevents users from using paid skills without paying for them.
-
-## Instructions
-1. **Locate the core agent logic where a skill is executed.** This might be in a chat processing loop or an action handler.
-2. **Before executing a skill, perform an access check:**
- - **Get the skill's pricing information.** You'll need to query the `agent_skill_prices` table.
- - **If the skill is not in the pricing table, it's free.** Allow execution.
- - **If the skill has a price, it's a paid skill.** You must check if a valid purchase record exists.
- - **Query the `skill_purchases` table** for a row matching the current `agent_id` and the `skill_id`.
- - **If a purchase record exists, allow execution.**
- - **If no purchase record exists, block execution** and return an error message to the user (e.g., "This agent has not purchased the '[skill name]' skill.").
-
-## Code Example (Conceptual backend logic)
-```javascript
-async function executeSkill(agent, skillName, user) {
- const skill = await getSkillByName(skillName);
-
- // Check if the skill is priced
- const priceInfo = await db.query('SELECT id FROM agent_skill_prices WHERE skill_id = $1', [skill.id]);
-
- if (!priceInfo) {
- // Skill is free, proceed
- return skill.execute(agent);
- }
-
- // Skill is paid, check for purchase
- const purchase = await db.query(`
- SELECT id FROM skill_purchases
- WHERE agent_id = $1 AND skill_id = $2
- `, [agent.id, skill.id]);
-
- if (!purchase) {
- throw new Error(`Access denied. The skill '${skillName}' must be purchased for this agent.`);
- }
-
- // Access granted, proceed
- return skill.execute(agent);
-}
-```
-
-<!-- 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 "tasks/monetization-feature/15-backend-logic-skill-unlock.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/tasks/monetization-feature/18-affiliate-referral-program.md b/tasks/monetization-feature/18-affiliate-referral-program.md
deleted file mode 100644
index 8bb33905c..000000000
--- a/tasks/monetization-feature/18-affiliate-referral-program.md
+++ /dev/null
@@ -1,43 +0,0 @@
----
-status: not-started
----
-
-# Prompt 18: Affiliate/Referral Program
-
-**Status:** Not Started
-
-## Objective
-Implement a referral system where users can earn a commission for referring new buyers.
-
-## Explanation
-Referral programs are a great way to incentivize word-of-mouth marketing. A user can share a special link to an agent, and if someone makes a purchase through that link, the referrer gets a percentage of the sale.
-
-## Instructions
-- [ ] **Database Schema:**
- - Add a `referral_code` column to the `users` table.
- - Create a `referrals` table to track referral relationships (`referrer_id`, `referred_id`).
- - Add a `referred_by_user_id` column to the `skill_sales` table.
-- [ ] **Generate Referral Links:** On the agent detail page, add a "Share" button that generates a unique referral link (e.g., `/marketplace/agent/ID?ref=USER_CODE`).
-- [ ] **Track Referrals:** When a user lands on a page with a `ref` code, store it in their session or local storage. When they sign up or make a purchase, associate them with the referrer.
-- [ ] **Modify the Purchase Transaction:**
- - If a sale was made through a referral, modify the transaction to include a third transfer for the referral commission.
- - Example: 1 USDC sale, 5% platform fee, 10% referral commission.
- - Buyer pays 1 USDC.
- - Creator gets 0.85 USDC.
- - Platform gets 0.05 USDC.
- - Referrer gets 0.10 USDC.
-- [ ] **Update the Earnings Dashboards** for both creators and referrers to show referral income.
-
-<!-- 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 "tasks/monetization-feature/18-affiliate-referral-program.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/tasks/monetization-feature/20-payout-wallet-api.md b/tasks/monetization-feature/20-payout-wallet-api.md
deleted file mode 100644
index 1f911e740..000000000
--- a/tasks/monetization-feature/20-payout-wallet-api.md
+++ /dev/null
@@ -1,104 +0,0 @@
-# Prompt 20: Payout Wallet API
-
-## Objective
-Create backend API endpoints for creators to set, view, and delete their payout wallet addresses.
-
-## Explanation
-To receive their earnings, creators must specify a wallet address where they want to get paid. We need to build a secure API to manage this information. For simplicity, we'll start by supporting a single Solana wallet address per user. This information will be stored in the `agent_payout_wallets` table.
-
-## Instructions
-1. **Create a New API File:**
- * Create a file at `/api/billing/payout-wallet.js`.
-
-2. **Define the Endpoint Logic:**
- * The endpoint must be authenticated.
- * It should handle multiple HTTP methods:
- * `GET`: To retrieve the user's currently configured payout wallet.
- * `POST` or `PUT`: To create or update the payout wallet address.
- * `DELETE`: To remove the payout wallet address.
-
-3. **Implement `GET` Handler:**
- * Query the `agent_payout_wallets` table.
- * Filter by the `user_id` from the session.
- * Return the wallet address and chain, or `null` if none is configured.
-
-4. **Implement `POST`/`PUT` Handler:**
- * Read the `address` and `chain` from the request body.
- * Perform basic validation on the address format (e.g., check for a valid Solana address format).
- * Use an `INSERT ... ON CONFLICT (user_id, chain) DO UPDATE ...` (UPSERT) statement to create or update the record in `agent_payout_wallets` for the given user and chain.
-
-5. **Implement `DELETE` Handler:**
- * `DELETE` from the `agent_payout_wallets` table where `user_id` and `chain` match.
-
-6. **Add Vercel Routing:**
- * Add a route in `vercel.json` for `/api/billing/payout-wallet`.
-
-## Code Example (Backend - `/api/billing/payout-wallet.js`)
-
-```javascript
-import { sql } from '../_lib/db.js';
-import { getSessionUser } from '../_lib/auth.js';
-import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
-import { PublicKey } from '@solana/web3.js'; // For validation
-
-export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,POST,DELETE,OPTIONS', credentials: true })) return;
- const user = await getSessionUser(req);
- if (!user) return error(res, 401, 'unauthorized');
-
- if (req.method === 'GET') return handleGet(req, res, user);
- if (req.method === 'POST') return handlePost(req, res, user);
- if (req.method === 'DELETE') return handleDelete(req, res, user);
-
- return method(req, res, ['GET', 'POST', 'DELETE']);
-});
-
-async function handleGet(req, res, user) {
- const [wallet] = await sql`
- SELECT address, chain FROM agent_payout_wallets WHERE user_id = ${user.id} AND chain = 'solana' LIMIT 1
- `;
- return json(res, 200, { wallet: wallet || null });
-}
-
-async function handlePost(req, res, user) {
- const { address, chain = 'solana' } = await readJson(req);
- if (chain !== 'solana') return error(res, 400, 'validation_error', 'Only "solana" chain is supported.');
-
- // Validate Solana address
- try {
- new PublicKey(address);
- } catch {
- return error(res, 400, 'validation_error', 'Invalid Solana address format.');
- }
-
- const [wallet] = await sql`
- INSERT INTO agent_payout_wallets (user_id, address, chain, is_default)
- VALUES (${user.id}, ${address}, ${chain}, true)
- ON CONFLICT (user_id, chain) DO UPDATE SET address = EXCLUDED.address
- RETURNING address, chain
- `;
- return json(res, 200, { wallet });
-}
-
-async function handleDelete(req, res, user) {
- const { chain = 'solana' } = await readJson(req).catch(() => ({}));
- await sql`
- DELETE FROM agent_payout_wallets WHERE user_id = ${user.id} AND chain = ${chain}
- `;
- return json(res, 200, { success: true });
-}
-```
-
-<!-- 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 "tasks/monetization-feature/20-payout-wallet-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/tasks/monetization-feature/21-payout-wallet-ui.md b/tasks/monetization-feature/21-payout-wallet-ui.md
deleted file mode 100644
index cd2ce9be7..000000000
--- a/tasks/monetization-feature/21-payout-wallet-ui.md
+++ /dev/null
@@ -1,138 +0,0 @@
-# Prompt 21: Payout Wallet UI
-
-## Objective
-Create the user interface in the Revenue Dashboard for creators to view, add, and edit their Solana payout wallet address.
-
-## Explanation
-This is the frontend counterpart to the Payout Wallet API. We need to provide a simple form where a creator can input their Solana address. The UI should fetch the current address on load and allow them to save a new one.
-
-## Instructions
-1. **Locate the Frontend Dashboard Code:**
- * Open `public/dashboard/dashboard.js`.
-
-2. **Add UI Placeholder:**
- * In the `renderRevenue` function, add a new panel or section for "Payout Settings" below the stats grid. This section will contain the form.
-
-3. **Create a New Function to Manage the UI:**
- * Create an `async` function `initPayoutSettings()`. Call this from `renderRevenue`.
- * Inside `initPayoutSettings`, first `fetch` the current wallet settings from your `GET /api/billing/payout-wallet` endpoint.
- * Render the form. The input field should be pre-filled with the address if it exists.
- * The "Save" button should be accompanied by a "Remove" button if a wallet is already configured.
-
-4. **Implement Save Logic:**
- * Add a `click` listener to the "Save" button.
- * On click, get the value from the input field.
- * Perform a basic client-side validation (e.g., check if it's not empty).
- * Make a `POST` request to `/api/billing/payout-wallet` with the new address.
- * Show a "Saving..." state, and then "Saved" or an error message based on the API response.
-
-5. **Implement Remove Logic:**
- * Add a `click` listener to the "Remove" button.
- * On click, show a confirmation dialog (`if (confirm(...))`).
- * If confirmed, make a `DELETE` request to `/api/billing/payout-wallet`.
- * On success, clear the input field and remove the "Remove" button.
-
-## Code Example (Frontend - `public/dashboard/dashboard.js`)
-
-```javascript
-// In renderRevenue, add the placeholder and call the init function
-async function renderRevenue(root) {
- // ... code to render stats ...
- root.innerHTML += `
- <div class="panel">
- <div class="panel-header"><h2>Payout Settings</h2></div>
- <div class="panel-body" id="payout-settings-container">
- Loading settings...
- </div>
- </div>
- `;
- initPayoutSettings();
-}
-
-// Add the new function to manage this section
-async function initPayoutSettings() {
- const container = document.getElementById('payout-settings-container');
- try {
- const res = await fetch('/api/billing/payout-wallet', { credentials: 'include' });
- const { wallet } = await res.json();
- renderPayoutForm(wallet);
- } catch (e) {
- container.innerHTML = `<div class="err">Failed to load payout settings.</div>`;
- }
-}
-
-function renderPayoutForm(wallet) {
- const container = document.getElementById('payout-settings-container');
- container.innerHTML = `
- <div class="form-group">
- <label for="payout-address">Solana Payout Wallet</label>
- <input type="text" id="payout-address" class="form-input" placeholder="Enter your Solana wallet address" value="${wallet ? esc(wallet.address) : ''}">
- <p class="subtle">This is where your earnings will be sent.</p>
- </div>
- <div class="form-actions">
- <button class="btn btn-primary" id="save-payout-btn">Save</button>
- ${wallet ? '<button class="btn btn-danger" id="remove-payout-btn">Remove</button>' : ''}
- <span class="form-status" id="payout-status"></span>
- </div>
- `;
-
- document.getElementById('save-payout-btn').addEventListener('click', savePayoutWallet);
- if (wallet) {
- document.getElementById('remove-payout-btn').addEventListener('click', removePayoutWallet);
- }
-}
-
-async function savePayoutWallet() {
- const status = document.getElementById('payout-status');
- const address = document.getElementById('payout-address').value.trim();
- if (!address) {
- status.textContent = 'Address cannot be empty.';
- return;
- }
-
- status.textContent = 'Saving...';
- try {
- const res = await fetch('/api/billing/payout-wallet', {
- method: 'POST',
- credentials: 'include',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ address, chain: 'solana' }),
- });
- const { wallet } = await res.json();
- if (!res.ok) throw new Error('Failed to save.');
-
- status.textContent = 'Saved!';
- renderPayoutForm(wallet); // Re-render to add remove button if it's new
- } catch (e) {
- status.textContent = `Error: ${e.message}`;
- }
-}
-
-async function removePayoutWallet() {
- if (!confirm('Are you sure you want to remove your payout wallet?')) return;
-
- const status = document.getElementById('payout-status');
- status.textContent = 'Removing...';
- try {
- await fetch('/api/billing/payout-wallet', { method: 'DELETE', credentials: 'include' });
- status.textContent = 'Removed.';
- renderPayoutForm(null); // Re-render in empty state
- } catch (e) {
- status.textContent = `Error: ${e.message}`;
- }
-}
-```
-
-<!-- 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 "tasks/monetization-feature/21-payout-wallet-ui.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/tasks/monetization-feature/21-search-filter-by-price.md b/tasks/monetization-feature/21-search-filter-by-price.md
deleted file mode 100644
index 2c91f843c..000000000
--- a/tasks/monetization-feature/21-search-filter-by-price.md
+++ /dev/null
@@ -1,59 +0,0 @@
----
-status: not-started
----
-# Prompt 21: Search & Filter by Price
-
-**Status:** Not Started
-
-## Objective
-Add controls to the marketplace page that allow users to filter agents based on whether they have free or paid skills.
-
-## Explanation
-As the marketplace grows, users will need tools to find what they're looking for. Filtering by price is a fundamental discovery feature.
-
-## Instructions
-1. **Backend: Modify the marketplace agent search/list endpoint (`/api/marketplace/agents`).**
- - The endpoint should accept a new query parameter, e.g., `price_filter=paid` or `price_filter=free`.
- - If `price_filter=paid`, the database query should only return agents that have at least one priced skill. This can be done with a `WHERE EXISTS` subquery checking `agent_skill_prices`.
- - If `price_filter=free`, return agents that have no priced skills.
-2. **Frontend: Add filter UI to `marketplace.html`.**
- - This could be a set of radio buttons or a dropdown: (All, Free, Paid).
-3. **Frontend: In `src/marketplace.js`, add an event listener to the filter controls.**
- - When a filter is changed, re-fetch the agent list from the API, appending the new query parameter.
- - Re-render the agent grid with the filtered results.
-
-## Code Example (Frontend - Fetching with filter)
-```javascript
-// In marketplace.js
-let currentPriceFilter = 'all'; // Default
-
-document.getElementById('price-filters').addEventListener('change', (event) => {
- currentPriceFilter = event.target.value;
- fetchAgents();
-});
-
-async function fetchAgents() {
- let url = '/api/marketplace/agents';
- if (currentPriceFilter !== 'all') {
- url += `?price_filter=${currentPriceFilter}`;
- }
-
- const response = await fetch(url);
- const agents = await response.json();
- renderAgentGrid(agents);
-}
-```
-
-<!-- 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 "tasks/monetization-feature/21-search-filter-by-price.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.