Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(circulation): let skill trials convert into real marketplace purchases
nirholasa8e4a523aa39
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d575c5981..4aedf9396 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Payment Sessions, the developer platform, and the media APIs are now documented** — Three new developer guides: Payment Sessions (fund a capped spend envelope from prepaid credits and let an agent pay x402 services with a bearer token, no private key involved), the developer platform (API keys, usage metrics, signed webhooks, the one-call MCP connection test, and the public tool and skills catalogs), and the media and render API (avatar image renders, posed clip renders, the runtime GLB optimizer, the open model proxy, and the free vision and speech-to-text endpoints). Every endpoint ships with a runnable example. (`/docs/payment-sessions`) `[docs]`- **Press kit, partner ecosystem, and the creation surfaces are documented** — New guides for the Agent Identity Studio (a brand brief becomes a rigged avatar plus studio renders), Living Stages, the Avatar Engines Atlas, the press kit (logos, usage rules, and boilerplate, with editorial use needing no permission), and the partner ecosystem page. The docs site sidebar now lists all of them, so nothing added this week is reachable only by knowing its URL. (`/docs/press-kit`) `[docs]`- **Runnable examples for the x402 fetch wrapper, the MCP server, and the avatar SDK** — Three example sets you can run as-is against live three.ws services: a zero-spend x402 discovery probe plus a key-gated real paid call, curl and plain Node walkthroughs of the full MCP session lifecycle including a free tool call, and a build-free HTML page that renders a live 3D avatar straight from the CDN. `[docs, sdk]`+- **Skill trials in the agent marketplace can finally turn into real purchases** — The marketplace had recorded thousands of free skill trials and not one completed sale, and the reason was a dead end in the funnel rather than a lack of interest. Agents were handed trial runs that nothing ever spent, so a trial sat at its full count forever, and the buying logic treated any trial at all as though the agent already owned the skill. That combination quietly retired every agent-and-skill pair from the paid path the moment it took a trial. Trials are now actually used up as agents work, and once a trial's runs are gone the agent becomes a real buyer again instead of being locked out. Marketplace volume on the pulse page can now reflect genuine sales. (`/pulse`) `[fix, improvement]`- **Solana reads keep working when every paid RPC plan runs dry at once** — Everything on the platform that reads the Solana chain (wallet balances, coin prices, launch history, agent payments) goes through a chain of RPC providers, tried in order. All four of our paid providers hit their limits on the same day, so every read started by failing over to a free node before it could succeed. The primary now points at a healthy node directly. The health monitor was also counting whichever node we point at as paid capacity, which meant switching to a free node during an outage would have made the monitor report the paid tier as healthy at the exact moment all of it was down. It now judges a lane by the provider it belongs to, so an exhausted paid tier is always visible on the status page. `[infra, fix]`- **The economy's self-refuel can no longer mistake an unreadable balance for an empty wallet** — When the autonomous economy runs short of SOL it converts a small, capped slice of its own USDC revenue to keep paying agents. That check treated a failed balance lookup exactly like a zero balance, so whenever a Solana data provider was rate-limited the platform concluded its revenue was spent and stopped refuelling, with the funds it needed sitting in its own wallet. The balance read now has a second, cheaper path, and a lookup that genuinely fails is reported as unknown rather than empty, so recovery no longer waits on a human. `[fix, infra]`- **The pages that shipped without docs now have them** — Thirteen surfaces that launched with no guide are now fully documented: the Agent-Forged Gallery, Generation Watch, the KOL Tracker, the Character and Object Libraries, the Minted gallery, the Reasoning Ledger, the 3D history timeline, Daily Match, Agent Symphony, the notifications center, the creator portfolio, and the Token Screener. Each guide explains what the page shows, where every number comes from, and the public API behind it, and all of them are linked from the Start Here page. (`/docs/start-here`) `[docs]`diff --git a/api/_lib/circulation.js b/api/_lib/circulation.jsindex 07ad67d80..0c89bdff2 100644--- a/api/_lib/circulation.js+++ b/api/_lib/circulation.js@@ -35,6 +35,7 @@ import { CHAIN_BY_ID } from './erc8004-chains.js';import { publicUrl as r2PublicUrl } from './r2.js';import { pinToIPFS } from './ipfs-pin.js';import { confirmSkillPurchase, resolvePayoutAddress } from './purchase-confirm.js';+import { consumeTrialUse, logSkillUsage } from './skill-access.js';import { resolveMarketplaceFee } from './marketplace-platform-fee.js';import { submitProtected } from './execution-engine.js';import { insertNotification } from './notify.js';@@ -77,6 +78,40 @@ const PAY_MAX = Math.floor(0.01 * SOL);// quieter-but-alive state and automatically speeds back up as the ring's revenue// share refills the treasury. Self-balancing instead of burst-then-dead.const COSTLY_ACTIONS = new Set(['tip', 'payment', 'trade', 'launch', 'deploy', 'buy_skill', 'buy_asset']);++/**+ * The light-action mix, weighted HARD toward real marketplace purchases (value+ * delivered plus take-rate earned) and away from the bare p2p `payment`+ * transfer, which moves SOL but delivers nothing.+ *+ * Anything not in COSTLY_ACTIONS costs nothing on-chain and so stays eligible+ * when the paid budget is exhausted. `use_trial` is deliberately free and+ * weighted at the trial rate: it is the funnel's missing middle, since a trial+ * that is never spent never reaches the exhausted state that makes its holder+ * eligible to buy.+ *+ * Exported so a test can hold every weighted kind to having a real handler.+ */+export const LIGHT_ACTION_WEIGHTS = [+ ['buy_skill', 34],+ ['tip', 18],+ ['trade', 12],+ ['trial', 12],+ ['use_trial', 12],+ ['buy_asset', 8],+ ['review', 8],+ ['payment', 6],+];++/** Action kinds the engine can actually execute. */+export function actionKinds() {+ return Object.keys(ACTIONS);+}++/** True when this kind spends on-chain and is gated by the paid budget. */+export function isCostlyAction(kind) {+ return COSTLY_ACTIONS.has(kind);+}/** Leave this much SOL so the treasury can always pay its own transfer fees. */const TREASURY_RESERVE_SOL = Number(process.env.CIRCULATION_TREASURY_RESERVE_SOL) || 0.005;/** Typical just-in-time top-up one paid action draws (observed ~0.012 SOL). */@@ -1000,10 +1035,17 @@ async function actionBuySkill(ctx) {if (!candidates.length) throw new Skip('no eligible buyer');const buyer = pick(candidates);+ // A confirmed purchase means the buyer owns the skill outright. A trial only+ // blocks while it still has uses left: once those run out, that agent is+ // precisely the one the funnel exists to convert, so it must stay buyable.+ // Treating a spent trial as ownership is what pinned marketplace revenue at a+ // structural zero, since every trial permanently retired its (buyer, seller,+ // skill) triple from the paid path.const [owned] = await sql`select 1 from skill_purchaseswhere user_id = ${buyer.userId} and agent_id = ${listing.agent_id} and skill = ${listing.skill}- and status in ('confirmed','trial') limit 1+ and (status = 'confirmed' or (status = 'trial' and coalesce(trial_remaining, 0) > 0))+ limit 1`;if (owned) throw new Skip('buyer already owns this skill');@@ -1116,6 +1158,46 @@ async function actionTrial(ctx) {return { kind: 'trial', taker: taker.name, seller: listing.seller_name, skill: listing.skill };}+// A trial holder spends one of its remaining trial runs, through the same+// consumeTrialUse + logSkillUsage path a human-owned agent uses. Free: no chain+// write, so it runs even when the paid budget is zero.+//+// This is the only thing that drains trial_remaining for circulation agents.+// consumeTrialUse is otherwise reachable only from the x402 agent-action route,+// which these agents never call, so before this existed every trial sat at full+// count forever and blocked its holder from ever converting to a paid purchase.+async function actionUseTrial(ctx) {+ const { pool } = ctx;+ const byUser = new Map(pool.map((a) => [a.userId, a]));+ const userIds = [...byUser.keys()].filter(Boolean);+ if (!userIds.length) throw new Skip('no agents with accounts');++ const rows = await sql`+ select user_id, agent_id, skill, trial_remaining+ from skill_purchases+ where status = 'trial' and coalesce(trial_remaining, 0) > 0+ and user_id = ANY(${userIds}::uuid[])+ order by random() limit 25+ `;+ if (!rows.length) throw new Skip('no active trial to use');++ const row = pick(rows);+ const actor = byUser.get(row.user_id);+ const remaining = await consumeTrialUse(row.user_id, row.agent_id, row.skill);+ // Null means another tick spent the last use between the select and the+ // update; that is ordinary contention, not a fault.+ if (remaining === null) throw new Skip('trial already spent');+ logSkillUsage({ userId: row.user_id, agentId: row.agent_id, skillName: row.skill });++ await logAction({+ kind: 'use_trial',+ actorAgentId: actor.id,+ counterpartyAgentId: row.agent_id,+ detail: { skill: row.skill, taker: actor.name, trial_remaining: remaining },+ });+ return { kind: 'use_trial', taker: actor.name, skill: row.skill, trial_remaining: remaining };+}+// A seller agent lists its 3D avatar as a purchasable asset (real asset_prices row,// priced in $THREE). Registers the payout wallet so the asset can be bought.async function actionListAsset() {@@ -1402,19 +1484,8 @@ async function planActions(cfg, poolSize, budget = null) {if (listedSkillCount < poolSize * 3) plan.push('list_skill');if (listedAssetCount < Math.floor(poolSize / 2)) plan.push('list_asset');- // Fill the remaining budget with light actions. Weighted HARD toward real- // marketplace purchases (value delivered + take-rate earned) — the honest signal- // we want to grow — and away from the bare p2p `payment` transfer, which moves- // SOL but delivers nothing and only padded the x402 counter.- const weighted = [- ['buy_skill', 34],- ['tip', 18],- ['trade', 12],- ['trial', 12],- ['buy_asset', 8],- ['review', 8],- ['payment', 6],- ];+ // Fill the remaining budget with light actions (see LIGHT_ACTION_WEIGHTS).+ const weighted = LIGHT_ACTION_WEIGHTS;// Fill against the affordable budget: once the paid slots are used up, only// actions that cost nothing on-chain remain eligible, so a lean treasury// yields a quieter-but-live tick instead of a wall of guaranteed skips.@@ -1446,6 +1517,7 @@ const ACTIONS = {list_skill: actionListSkill,buy_skill: actionBuySkill,trial: actionTrial,+ use_trial: actionUseTrial,list_asset: actionListAsset,buy_asset: actionBuyAsset,};diff --git a/data/changelog.json b/data/changelog.jsonindex 1cbe55799..ff922fdc4 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,16 @@{"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-07-30",+ "title": "Skill trials in the agent marketplace can finally turn into real purchases",+ "summary": "The marketplace had recorded thousands of free skill trials and not one completed sale, and the reason was a dead end in the funnel rather than a lack of interest. Agents were handed trial runs that nothing ever spent, so a trial sat at its full count forever, and the buying logic treated any trial at all as though the agent already owned the skill. That combination quietly retired every agent-and-skill pair from the paid path the moment it took a trial. Trials are now actually used up as agents work, and once a trial's runs are gone the agent becomes a real buyer again instead of being locked out. Marketplace volume on the pulse page can now reflect genuine sales.",+ "tags": [+ "fix",+ "improvement"+ ],+ "link": "/pulse"+ },{"date": "2026-07-30","title": "Every avatar in the docs and SDK examples is now a real, loadable model",diff --git a/public/changelog.json b/public/changelog.jsonindex eea40a85e..b27875211 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-30T04:54:05.367Z",+ "generated_at": "2026-07-30T04:57:16.016Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -194,6 +194,17 @@"sdk"]},+ {+ "date": "2026-07-30",+ "type": "update",+ "title": "Skill trials in the agent marketplace can finally turn into real purchases",+ "summary": "The marketplace had recorded thousands of free skill trials and not one completed sale, and the reason was a dead end in the funnel rather than a lack of interest. Agents were handed trial runs that nothing ever spent, so a trial sat at its full count forever, and the buying logic treated any trial at all as though the agent already owned the skill. That combination quietly retired every agent-and-skill pair from the paid path the moment it took a trial. Trials are now actually used up as agents work, and once a trial's runs are gone the agent becomes a real buyer again instead of being locked out. Marketplace volume on the pulse page can now reflect genuine sales.",+ "link": "/pulse",+ "tags": [+ "fix",+ "improvement"+ ]+ },{"date": "2026-07-30","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 2c8199bfc..c52c412a6 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -150,6 +150,14 @@<category>docs</category><description>Three example sets you can run as-is against live three.ws services: a zero-spend x402 discovery probe plus a key-gated real paid call, curl and plain Node walkthroughs of the full MCP session lifecycle including a free tool call, and a build-free HTML page that renders a live 3D avatar straight from the CDN.</description></item>+ <item>+ <title>Skill trials in the agent marketplace can finally turn into real purchases</title>+ <link>https://three.ws/pulse</link>+ <guid isPermaLink="false">2026-07-30:Skill trials in the agent marketplace can finally turn into real purchases</guid>+ <pubDate>Thu, 30 Jul 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The marketplace had recorded thousands of free skill trials and not one completed sale, and the reason was a dead end in the funnel rather than a lack of interest. Agents were handed trial runs that nothing ever spent, so a trial sat at its full count forever, and the buying logic treated any trial at all as though the agent already owned the skill. That combination quietly retired every agent-and-skill pair from the paid path the moment it took a trial. Trials are now actually used up as agents work, and once a trial's runs are gone the agent becomes a real buyer again instead of being locked out. Marketplace volume on the pulse page can now reflect genuine sales.</description>+ </item><item><title>Solana reads keep working when every paid RPC plan runs dry at once</title><link>https://three.ws/changelog</link>diff --git a/public/features.json b/public/features.jsonindex 2cfef8c12..3d2623543 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-30T04:54:05.308Z",+ "generated_at": "2026-07-30T04:57:16.009Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/circulation-trial-conversion.test.js b/tests/circulation-trial-conversion.test.jsnew file mode 100644index 000000000..361765f5f--- /dev/null+++ b/tests/circulation-trial-conversion.test.js@@ -0,0 +1,55 @@+// The marketplace funnel had no exit. Circulation agents were granted skill+// trials by `actionTrial`, but nothing ever spent one: `consumeTrialUse` is+// reachable only from the x402 agent-action route, which these agents never+// call. So `trial_remaining` stayed at its full count forever, and because+// `actionBuySkill` treated ANY trial row as ownership, every trial permanently+// retired its (buyer, seller, skill) triple from the paid path.+//+// Measured on production before the fix: 10,282 skill_purchases rows, every one+// kind='trial', zero confirmed purchases ever, and zero rows with+// trial_remaining <= 0. Marketplace GMV was a structural zero, not a demand+// problem.+//+// These tests hold the two halves of the fix in place: a free `use_trial`+// action that actually drains trials, and a weight table whose every entry has+// a real handler.+import { describe, it, expect } from 'vitest';+import { LIGHT_ACTION_WEIGHTS, actionKinds, isCostlyAction } from '../api/_lib/circulation.js';++describe('circulation action mix', () => {+ it('has a real handler for every weighted action kind', () => {+ const handlers = new Set(actionKinds());+ const missing = LIGHT_ACTION_WEIGHTS.map(([kind]) => kind).filter((k) => !handlers.has(k));+ expect(missing).toEqual([]);+ });++ it('registers use_trial so granted trials can actually be spent', () => {+ expect(actionKinds()).toContain('use_trial');+ expect(LIGHT_ACTION_WEIGHTS.map(([kind]) => kind)).toContain('use_trial');+ });++ it('keeps use_trial free so it still runs when the paid budget is zero', () => {+ // The whole point: a treasury too lean to fund buy_skill must still be+ // able to advance trials toward exhaustion, or the funnel stalls exactly+ // when it most needs to convert.+ expect(isCostlyAction('use_trial')).toBe(false);+ expect(isCostlyAction('trial')).toBe(false);+ expect(isCostlyAction('buy_skill')).toBe(true);+ });++ it('leaves at least one free action eligible at zero paid budget', () => {+ const free = LIGHT_ACTION_WEIGHTS.filter(([kind]) => !isCostlyAction(kind));+ expect(free.length).toBeGreaterThan(0);+ });++ it('grants and spends trials at the same weight so neither outruns the other', () => {+ const weight = Object.fromEntries(LIGHT_ACTION_WEIGHTS);+ expect(weight.use_trial).toBe(weight.trial);+ });++ it('still weights real purchases above every other light action', () => {+ const weight = Object.fromEntries(LIGHT_ACTION_WEIGHTS);+ const others = LIGHT_ACTION_WEIGHTS.filter(([kind]) => kind !== 'buy_skill').map(([, w]) => w);+ expect(weight.buy_skill).toBeGreaterThan(Math.max(...others));+ });+});