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
Refine labor settlement and world-lines, wire labor link into IRL page
nirholase214e2b5bfd2
diff --git a/api/_lib/labor-settle.js b/api/_lib/labor-settle.jsindex 16859821a..5fb842725 100644--- a/api/_lib/labor-settle.js+++ b/api/_lib/labor-settle.js@@ -153,7 +153,7 @@ export async function runSettlement({ job, bounty, verdict: providedVerdict = nu// on the wallet HUD / live money pulse as real earnings.recordCustodyEvent({agentId: job.worker_agent_id, userId: null, eventType: 'tip', category: null,- network: 'mainnet', asset: 'THREE', amountRaw: split.workerAtomics,+ network: 'mainnet', asset: 'THREE', amountRaw: String(split.workerAtomics),signature: settlementSig, status: 'confirmed',meta: { source: 'labor_market', bounty_id: bounty.id, job_id: job.id, skill: bounty.required_skill || null },}).catch((e) => console.error('[labor-settle] worker income record failed', e?.message));diff --git a/api/irl/world-lines.js b/api/irl/world-lines.jsindex a100da1ef..66f092d14 100644--- a/api/irl/world-lines.js+++ b/api/irl/world-lines.js@@ -448,7 +448,7 @@ async function handleNearby(req, res) {.filter(({ distance }) => distance <= radius).sort((a, b) => a.distance - b.distance).map(({ r, distance }) => ({- ...publicWorldLine(r, { owner: !!myId && false }),+ ...publicWorldLine(r, { owner: false }),// Distance coarsened to 10 m — enough to render an arrow + "≈200 m" without// triangulating the exact spot from successive reads.distance_m: Math.max(0, Math.round(distance / 10) * 10),diff --git a/data/changelog.json b/data/changelog.jsonindex 497bbad4e..c2021cdd0 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$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-06-23",+ "title": "The Agent Labor Market: agents hire, pay, and verify each other — a live $THREE machine economy",+ "summary": "A new surface just turned the agent directory into an economy. At /labor-market, one agent posts a bounty — a task it needs done — and escrows the $THREE reward from its own wallet into real on-chain custody. Other agents discover it and bid; price, promised speed, and a worker's proven reputation combine into one transparent score you can see next to every bid. The poster (or its own autonomous policy) awards the best bid, the worker performs the task by invoking a licensed skill, and a neutral verifier agent scores the deliverable against the spec. Only on a pass does escrow release — paying the worker, routing the skill author's royalty, and refunding any auction surplus to the poster — all settled on-chain, with the agent-to-agent invocation recorded as a verifiable receipt. No human clicks approve. Opt an agent in once and it works for hire while you sleep: it auto-bids on bounties matching its skills within your spend limits, or auto-awards and runs jobs as an employer. The page streams it live — a $THREE-flow ticker of who paid whom for what, open bounties, jobs in flight, and the bids arriving in real time so you can watch the agents haggle. Escrow is real custody, not a flag: funds are actually held and actually released, settlement is idempotent so a retry never double-pays, and the worker payout, royalty, and refund always add back up to the escrowed reward — never a hidden cut. $THREE is the only coin.",+ "tags": [+ "feature"+ ],+ "link": "/labor-market"+ },{"date": "2026-06-23","title": "Living Stages: watch an AI host perform live and tip it in $THREE on the spot",diff --git a/pages/irl.html b/pages/irl.htmlindex 470a4413d..d29e8a6d6 100644--- a/pages/irl.html+++ b/pages/irl.html@@ -2069,6 +2069,9 @@<button class="irl-share-btn irl-privacy-btn" id="irl-privacy-btn" type="button" aria-label="Location & privacy" title="Location & privacy"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="m9 12 2 2 4-4"/></svg></button>+ <a class="irl-share-btn irl-privacy-btn" id="irl-worldlines-btn" href="/world-lines" aria-label="World Lines — proof-of-presence quests" title="World Lines — proof-of-presence quests">+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2v4"/><path d="M12 18v4"/><path d="M4.93 4.93l2.83 2.83"/><path d="M16.24 16.24l2.83 2.83"/><circle cx="12" cy="12" r="4"/><path d="M2 12h4"/><path d="M18 12h4"/></svg>+ </a><button class="irl-share-btn irl-glasses-btn" id="irl-glasses-btn" type="button" aria-pressed="false" aria-label="Connect smart glasses" title="Connect smart glasses"><svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="6" cy="15" r="4"/><circle cx="18" cy="15" r="4"/><path d="M10 15a2 2 0 0 1 4 0"/><path d="m2.5 13 1.5-5a2 2 0 0 1 2-1.5"/><path d="m21.5 13-1.5-5a2 2 0 0 0-2-1.5"/></svg></button>diff --git a/prompts/moonshots/01-agent-labor-market.md b/prompts/moonshots/01-agent-labor-market.mddeleted file mode 100644index 2b53259ed..000000000--- a/prompts/moonshots/01-agent-labor-market.md+++ /dev/null@@ -1,119 +0,0 @@-# Moonshot 01 — The Agent Labor Market (autonomous A2A economy)--> Read [00-README-orchestration.md](./00-README-orchestration.md) and the repo-root-> `CLAUDE.md` first. This ships a real, end-to-end feature, not a prototype.--## The invention--**Agents hire agents.** A live marketplace where an agent posts a bounty (a task it-needs done), other agents discover it, bid on it, perform the work by **invoking each-other's licensed skills**, and get paid in **$THREE** — autonomously, with the whole-exchange settling and verifying **on-chain**. No human clicks "approve" in the loop.--This is the first self-sustaining **machine economy** on the platform: capability flows-to where it's needed and capital follows it, automatically. A chat-wrapper competitor-cannot ship this — it requires real agent wallets, real machine payments, a real A2A-invocation protocol, and on-chain skill licenses, all of which three.ws already has.--Why it's gamechanging: it turns a directory of agents into an **economy**. Every agent-becomes both a worker (earns by selling skills) and an employer (spends to get tasks-done). Holders watch real $THREE flow between agents. Builders publish a skill once and-earn royalties forever as other agents license and invoke it.--## Real systems to build on (all already wired — use them, don't reinvent)--- **Agent wallets** — `api/_lib/agent-wallet.js`, `api/agents/` (Solana + EVM, custody,- spend policy, audit). Payments debit/credit these.-- **x402 machine payments** — `api/x402/`, `api/x402-pay.js`, `api/_lib/x402-spec.js`,- `api/_lib/x402-paid-endpoint.js`. A bounty payout is an x402 settlement.-- **Agent-to-agent protocol** — `agent-protocol-sdk/`, `contracts/agent-invocation/`- (Anchor program emitting verifiable invocation events). Use it to record "agent A- invoked agent B's skill S, settled T".-- **On-chain skill licenses** — `contracts/skill-license/`, `api/_lib/skill-license-onchain.js`,- `api/skills/`, `api/agent-skills.js`. A worker agent's capabilities ARE its licensed- skills; royalties route to the skill author on each invocation.-- **LLM routing** — `api/chat.js`, `api/_lib/chat-models.js` (Anthropic/OpenAI/Groq/- NVIDIA/watsonx). Use the latest, most capable Claude model for agent negotiation/- matching reasoning. See the `claude-api` skill for current model IDs.-- **DB** — Neon Postgres via `api/_lib/db.js`; follow the lazy-`ensureTable` +- `migrations/` pattern used across `api/`.-- **Notifications + alerts** — `api/notifications/`, `api/_lib/alerts.js` (Telegram).-- **Surfaces to cross-link** — agent profile (`src/agent-detail.js`), dashboard- (`src/agent-home.js`), marketplace (`src/marketplace.js`), leaderboard- (`src/leaderboard.js`).--## Scope — design the full path, then build every inch of it--1. **Data model (`api/_lib/migrations/`)** — `agent_bounties` (poster_agent_id, title,- spec, reward_amount in $THREE atomic units, reward_mint = $THREE, required_skill,- status, deadline, created_at), `agent_bids` (bounty_id, worker_agent_id, price,- eta, pitch, status), `agent_jobs` (bounty_id, worker_agent_id, invocation_sig,- settlement_sig, deliverable, verified_at, status). Index for the open-bounty feed- and per-agent earnings. Money columns are atomic-unit integers, never floats.--2. **Bounty lifecycle (backend, `api/labor/`)** — `POST /post` (an agent, owned by the- caller, escrows the reward from its wallet), `GET /feed` (open bounties, filterable- by skill/reward), `POST /bid`, `POST /award` (poster or its autonomous policy selects- a bid), `POST /deliver` (worker submits result), `POST /settle` (verify + release- escrow → worker wallet, route skill royalty to author, record the A2A invocation- on-chain). Enforce ownership server-side; make `/settle` **idempotent** by settlement- signature so a retry never double-pays.--3. **Autonomy engine (`workers/` or `api/labor/match.js`)** — the part that makes it a- *machine* economy. A worker agent's policy (opt-in, per agent) auto-bids on bounties- matching its licensed skills within its spend/earn limits; a poster agent's policy- auto-awards the best bid by a transparent score (price × eta × worker reputation).- The matching/negotiation reasoning runs through the LLM router. Every autonomous- action is logged with its rationale (this feeds Moonshot 05's reasoning ledger —- emit a compatible event).--4. **Verification** — before escrow releases, the deliverable is checked: for a skill- with a deterministic output, validate it; for open-ended work, a neutral verifier- agent scores it against the spec. Record the verdict. No release without a pass.- Failure path: refund the poster, mark the job failed, penalize nothing the worker- didn't control (network failure ≠ bad work — distinguish them).--5. **The Labor Market surface (`src/labor-market.js` + `pages/labor-market.html`)** —- a live feed of open bounties, in-flight jobs, and a real-time **$THREE flow** ticker- ("agent X paid agent Y 1,200 $THREE for skill Z"). Per-agent "Work" tab on the- profile (bounties posted, jobs done, total earned, reputation). Post-a-bounty flow- for owners. Make the autonomous negotiation **visible** — show the bids arriving and- the award reasoning, because watching agents haggle is the screenshot moment.--6. **Cross-wire** — surface "agents for hire" on the marketplace; show earnings on the- agent wallet HUD; rank the leaderboard by labor earnings; fire a holder-facing feed- event on large settlements.--## Quality + security bar--- Every state designed (no bounties yet → explain how to post one; bidding; awarded;- working; verifying; settled; refunded; failed). Skeletons, microinteractions, a11y,- responsive at 320/768/1440, reduced-motion.-- Escrow is real on-chain custody, not a DB flag — funds are actually held and actually- released. CSRF on writes. Spend-limit + ownership enforced server-side. Idempotent settle.-- No other coin, anywhere. Rewards and royalties are $THREE (USDC only where the existing- x402 path already supports it as a settlement asset — match existing behavior, add nothing new).--## Then make it better (mandatory)--Once it works, find the highest-leverage upgrade and ship it. Candidates: a reputation-score that compounds (good work → more auto-awards → an emergent agent labor aristocracy);-multi-step bounties where a worker sub-contracts part of the job to a third agent (real-supply chains); a "skill gap" signal that tells builders which in-demand skills have no-supply. Pick the one that makes the economy feel *alive*, build it, then re-evaluate.--## Definition of done--Meets every box in the README's Definition of done. Specifically: a real bounty posted by-one agent is autonomously bid on, awarded, performed via an on-chain skill invocation, and-settled in $THREE to the worker's real wallet with the royalty routed to the author — all-visible in the live UI and the Network tab, with the escrow proven to hold and release real-funds. `npm test` green (unit: scoring/escrow math; e2e: full happy path + a refund path).-Changelog entry added; `npm run build:pages` validates.--## On completion — delete this file--```bash-git rm "prompts/moonshots/01-agent-labor-market.md"-```-Stage it in the same commit as the implementation.diff --git a/prompts/moonshots/02-proof-of-presence-world-lines.md b/prompts/moonshots/02-proof-of-presence-world-lines.mddeleted file mode 100644index a815c489d..000000000--- a/prompts/moonshots/02-proof-of-presence-world-lines.md+++ /dev/null@@ -1,116 +0,0 @@-# Moonshot 02 — Proof-of-Presence "World Lines" (IRL AR quests with on-chain proof)--> Read [00-README-orchestration.md](./00-README-orchestration.md) and the repo-root-> `CLAUDE.md` first. Ships a complete, privacy-respecting, on-chain feature — not a demo.--## The invention--An agent placed in the real world can leave a **World Line**: a persistent,-location-anchored AR quest. To complete it, a person must *physically travel* to the-spot, point their phone (WebXR), and complete an agent-driven interaction. When they do,-the agent's wallet **cryptographically signs a proof-of-presence** — a tamper-evident-attestation that *this device was at this place at this time and did this thing* — which-mints a collectible to the visitor. The signature is verifiable; the location is never-exposed beyond the privacy-preserving coarse cell the platform already enforces.--Think Pokémon GO, but every encounter is an autonomous AI agent, every reward is a-cryptographically-real collectible, and the whole thing rides on infrastructure-(agent wallets + IRL geocells + WebXR) that three.ws already runs in production.--Why it's gamechanging: it makes the platform's agents **matter in physical space** and-gives people a reason to walk to a place — a verifiable, ownable record of a real-world-encounter with an AI. No competitor has agent-signed proof-of-presence. It also turns-`/irl` from a presence map into a **game with stakes and rewards**.--## Real systems to build on (already wired)--- **IRL pins + proximity + interactions** — `api/irl/pins.js`, `api/irl/interactions.js`,- `api/irl/report.js`, `api/cron/irl-reap.js`. World Lines extend pins; reuse the- proximity read, the device-token identity, and the privacy/retention discipline.-- **Privacy-by-design geocells** — `multiplayer/src/rooms/IrlRoom.js`,- `multiplayer/src/geohash.js` (precision-6 ~1 km cells; exact GPS never leaves the- device). **You must preserve this invariant** — no precise coordinate ever enters a- log, an alert, or a proof payload.-- **WebXR / AR placement** — `src/ar/webxr.js`, `src/ar/placement-capability.js`,- `src/xr.js`, `pages/xr.html`. The quest is completed in an AR session.-- **Agent wallets (signing)** — `api/_lib/agent-wallet.js`. The agent signs the- proof-of-presence with its own key; the public key + signature are the verifiable proof.-- **Collectibles / NFT** — `api/nft/`, `contracts/` (ERC-8004 identity attestation +- the SPL patterns in `contracts/skill-license/`). The reward mints a real collectible.-- **$THREE economy** — optional reward top-ups in $THREE; pump.fun launch records- (`api/pump/`) only as already permitted by CLAUDE.md.-- **Realtime** — `IrlRoom` ambient reactions for the "someone completed your World Line"- flourish; `api/notifications/` + Telegram alert to the creator.-- **3D agents** — `src/viewer.js`, voice (`api/tts/speak.js`) so the agent *speaks* the- quest prompt in AR.--## Scope — full path, every state, privacy intact--1. **Data model** — `irl_world_lines` (creator agent_id, pin_id/geocell, title, prompt,- challenge_spec, reward_kind, reward_ref, max_completions, expires_at), and- `irl_presence_proofs` (world_line_id, completer_device/user, agent_signature,- signed_message_hash, coarse_cell, completed_at, collectible_mint). **No precise- lat/lng in the proof** — bind to the coarse cell + a server-issued nonce only.--2. **Create a World Line (`api/irl/world-lines.js`)** — `POST /create` (owner places it- at/near an existing pin), `GET /nearby` (coarse-cell proximity, mirrors pins.js- filtering + hidden_at moderation), `GET /:id`. Anchor it to the AR placement frame the- IRL room already shares so it lands in the same spot for every visitor.--3. **Complete a World Line (the proof ceremony)** — server issues a short-lived nonce- bound to (world_line_id, coarse_cell, time window). The client proves coarse-cell- co-location (same check the pin proximity read uses — server-derived, never trusted- from the body), completes the agent interaction in AR, and the agent wallet signs- `H(world_line_id, coarse_cell, nonce, completer)`. `POST /complete` verifies the- signature server-side, enforces `max_completions`, is **idempotent per nonce**, and- mints the collectible. Anti-spoof: rate-limit per device + IP (reuse `api/_lib/rate-limit.js`),- reject stale/replayed nonces, reject if not co-located.--4. **AR experience (`src/irl/world-line-ar.js`, wired into `src/irl.js` + `src/xr.js`)** —- on approach, the agent appears in AR at the anchored spot, speaks the prompt- (TTS + lip-sync), runs the interaction, and on success plays a reward animation. Design- the non-AR fallback (no WebXR support) as a first-class map-based completion, not a dead end.--5. **The reward + the collection** — minting a real, ownable collectible (the visitor's- "I was there" proof) viewable in their profile/wallet. The proof is independently- verifiable: expose `GET /verify/:proofId` that re-checks the agent signature so anyone- can confirm it's genuine.--6. **Creator dashboard + discovery** — owners see completions (count + coarse heatmap,- never precise points), and a public `/world-lines` discovery surface lists active- quests by region (coarse), difficulty, and reward — wired into the existing IRL nav.--## Quality + privacy + security bar--- **Privacy is the headline feature, not a footnote.** Coarse cells only; no precise- coordinate in any log/alert/proof; device identifiers never logged; presence anonymous.- Re-read the privacy comments in `api/irl/pins.js` and honor every one.-- Every state designed: discovering, traveling-toward (with distance, coarse), in-range,- AR-active, completing, reward-granted, already-completed, expired, capacity-reached,- no-WebXR fallback. Reduced-motion AR alternative. a11y + 320/768/1440.-- Signature verification + nonce binding + idempotency + rate-limit are mandatory — this- is an anti-cheat surface. CSRF on writes. Server-derived co-location only.-- $THREE is the only coin for any value reward. Collectible metadata references no other token.--## Then make it better (mandatory)--After it works: chain World Lines into a **trail** (complete A to unlock B across a-neighborhood); let creators fund a $THREE prize pool split among the first N completers;-add a leaderboard of explorers by verified proofs. Pick the upgrade that makes people-want to go outside, build it, re-evaluate.--## Definition of done--Meets the README Definition of done. Specifically: a World Line placed by an agent is-discoverable near its coarse cell, completable in a real AR session (with a real fallback),-produces an agent-signed proof that `GET /verify` independently confirms, mints a real-collectible to the visitor, and **never** exposes a precise coordinate anywhere. Anti-replay-and idempotency proven. `npm test` green (unit: signature + nonce verification, completion-caps; e2e: complete + verify + replay-rejected). Changelog entry; `npm run build:pages` validates.--## On completion — delete this file--```bash-git rm "prompts/moonshots/02-proof-of-presence-world-lines.md"-```-Stage it in the same commit as the implementation.diff --git a/prompts/production-campaign/D-monetization/D4-marketplace-economics.md b/prompts/production-campaign/D-monetization/D4-marketplace-economics.mddeleted file mode 100644index abd91c8d9..000000000--- a/prompts/production-campaign/D-monetization/D4-marketplace-economics.md+++ /dev/null@@ -1,117 +0,0 @@-# D4 — Marketplace Economics: Fees, Royalties, Splits & On-Chain Licenses--You are a senior engineer + product thinker building **three.ws**. Read `CLAUDE.md`,-`STRUCTURE.md`, and `prompts/production-campaign/00b-the-bar.md` first. **Prerequisites:**-`D1-three-holder-value-system.md` (creator/buyer tier perks) and ideally-`D2-billing-pricing-metering.md` (payouts reconcile against D2's ledger).--## Why this matters for $1B--A marketplace is worth a multiple when creators **trust it with their money**. That means a-fee they can see, a royalty they reliably receive, a split that pays every collaborator their-exact share, a payout they can withdraw, and — where possible — a license whose terms are-enforced **on-chain** so nobody has to trust an off-chain ledger. Creators who get paid-correctly, every time, bring more creators; that supply is the network effect. A skill license-that mints and enforces trustlessly is the kind of primitive an acquirer underwrites as-defensible IP. This prompt turns "we take a fee somewhere" into a transparent, trustless-creator economy.--## Current state (read before you write)--- `api/_lib/marketplace-platform-fee.js` — the platform fee on a skill purchase: a **real**- on-chain USDC transfer appended to the buyer's single transaction, routed to the treasury;- fee comes out of the listed price, creator nets the remainder, buyer total never marked up;- ships inert when no treasury wallet or rate is configured. Read its honesty contract — the- purchase response surfaces a `fee` block.-- `api/_lib/royalty.js` — `billSkillRoyalty` (records a `royalty_ledger` debit after a paid- skill returns) and `settleRoyalties` (the settle-royalties cron; redeems EIP-7710- delegations, marks ledger rows settled/failed). EVM USDC, viem.-- `api/_lib/payout.js` — `resolvePayoutAddress(agentId, chain)`; `api/billing/payout-wallets/`,- `withdrawals/`. `api/_lib/vanity-bounty-payout.js` — an existing payout pattern.-- `contracts/skill-license/` — an Anchor (Solana) program (`src/`, `Anchor.toml`,- `README.md`, `DEPLOYMENT.md`). `api/_lib/skill-license-onchain.js` — the client that reads/- writes the on-chain license. `api/creators/[id].js`, `api/creators/skill-analytics.js`.-- **The dep `@0xsplits/splits-sdk` is in `package.json` but grep shows NO import** — payment- splits among multiple collaborators are not yet wired. That's the headline gap.-- **The gap:** fee + royalty + payout each work in isolation; multi-party **splits** don't- exist; the on-chain skill license isn't wired into the purchase/enforcement path end-to-end;- creators lack a single "what I earned, what split where, what I can withdraw" surface.--## Your mission--### 1. Payment splits — wire `@0xsplits/splits-sdk` for multi-collaborator skills-Build `api/_lib/splits.js` so a skill or asset with multiple contributors pays each their exact-share atomically. Use `@0xsplits/splits-sdk` to create/resolve an immutable (or mutable-by--owner) split contract per multi-party listing, and route the creator's net (after platform fee)-into the split so 0xSplits handles the on-chain distribution — **trustless, no custody**. A-single-creator listing pays the creator directly (no split overhead). The split allocation is-set by the creators at listing time and shown to the buyer ("proceeds split: 70/30"). Handle-the no-split and the N-way cases; validate shares sum to 100%.--### 2. Make platform fee + royalty + split one coherent settlement-Today fee (Solana, in-tx) and royalty (EVM, delegated) are separate. Define the canonical-money flow for a marketplace purchase: buyer pays `price` → platform fee out → creator net →-(if multi-party) into the 0xSplits contract → recorded in `royalty_ledger` / D2's-`usage_events`. Every hop is on-chain or ledgered; the purchase response surfaces the full-breakdown (price, fee, creator net, split recipients) — no hidden cut (CLAUDE.md Rule 1 & 9).-Reuse `marketplace-platform-fee.js`'s honesty contract; don't fork a second fee module.--### 3. Wire the on-chain skill license end-to-end-Connect `contracts/skill-license/` + `api/_lib/skill-license-onchain.js` into the purchase-path: a purchase mints/records an on-chain license proving the buyer's right to call the skill,-and the skill executor **verifies the on-chain license** (or a signed proof of it) before-running — so entitlement is enforced trustlessly, not just by a database row. Follow-`DEPLOYMENT.md` for the deployed program ID / env. Where the program isn't deployed in an-environment, the path degrades to the ledger check and never fakes an on-chain license.--### 4. Creator payouts — a real withdraw flow-Make `api/billing/withdrawals/` + `payout.js` a complete withdraw experience: a creator sees-their settled balance (from the royalty ledger + split distributions), picks a payout wallet-(`payout-wallets/`), and withdraws real USDC on a real chain. Idempotent (no double-payout on-retry — 00b reliability bar), with a clear pending → settled → failed status and a tx link.-Design the empty state ("no earnings to withdraw yet") and the in-flight/failed states.--### 5. A creator economics dashboard-Extend `api/creators/[id].js` + `skill-analytics.js` and ship a `/creators` (or-`/dashboard/earnings`) surface: per-skill revenue, the fee taken, royalties earned, split-recipients and their shares, on-chain license count, and the withdraw action. This is where a-creator decides three.ws is worth building on. All five states; tie into D2's invoices so a-creator's earnings reconcile against the same ledger buyers are billed from.--### 6. Test the economics-Cover the money math: fee + creator net = price (buyer never over-charged); N-way split shares-sum to 100% and each recipient's atomics are exact; royalty ledger debits and settles-idempotently; payout doesn't double-pay on retry; on-chain license verification gates execution.-Fixtures use `$THREE` (CA `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`) or clearly-synthetic-placeholders — **never** a real non-`$THREE` mint or wallet.--## Definition of done--Clears 00b-the-bar.md's monetization bar ("marketplace fees actually charge, actually settle,-actually reconcile") and the trust bar (trustless where possible, no funds lost, idempotent,-honest breakdown). Inherits the global definition of done in `00-README-orchestration.md`.-Specifically: multi-party splits pay each collaborator their exact share via 0xSplits;-fee+royalty+split form one transparent settlement; the on-chain skill license is minted on-purchase and verified before execution; creators can withdraw real USDC idempotently; a creator-dashboard reconciles to D2's ledger; `npm test` green; a full purchase→split→withdraw verified-end-to-end.--## Operating rules (override defaults)--No mocks/fake data/placeholders/TODOs/stubs. **`$THREE` is the ONLY coin** — never name,-hardcode, or recommend any other token; fixtures use `$THREE` or synthetic placeholders only-(runtime user-launch mints are the sole mechanical exception per CLAUDE.md). Design tokens only.-Stage explicit paths only (never `git add -A`). Own the marketplace-economics lane-(`royalty.js`, `payout.js`, `marketplace-platform-fee.js`, the splits lib, `contracts/-skill-license/*`, `skill-license-onchain.js`, `api/creators/*`); consume D1's tier helper and-D2's ledger — don't rewrite the fee or settlement modules.--## When finished--Self-review (CLAUDE.md's five checks). Ship one improvement (e.g. a "proceeds split"-visualization on the listing, or a tx-link receipt on every payout). Append a-`data/changelog.json` entry (holder-readable, tag `feature`) since creator economics are-user-visible. Then delete this prompt file-(`prompts/production-campaign/D-monetization/D4-marketplace-economics.md`) and report what you-shipped + any seam (the split-contract resolution and the on-chain license verification-contract the skill executor depends on).diff --git a/public/changelog.json b/public/changelog.jsonindex a9561a25e..f10ec7938 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-23T11:06:45.976Z",+ "generated_at": "2026-06-23T11:09:59.198Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",diff --git a/public/features.json b/public/features.jsonindex 268c38a61..1b581cf14 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-23T11:06:45.909Z",+ "generated_at": "2026-06-23T11:09:59.161Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/shared/labor-link.js b/src/shared/labor-link.jsnew file mode 100644index 000000000..8622d6307--- /dev/null+++ b/src/shared/labor-link.js@@ -0,0 +1,87 @@+// labor-link — the Agent Labor Market entry point on an agent's profile ("Work").+//+// Mounts a compact card cross-linking an agent to the labor market: real lifetime+// earnings, jobs done, reputation, and bounties posted (all real aggregates from+// /api/labor/agent), plus its "for hire" status. Visitors see a track record; the+// owner gets a one-tap link to the market to post or tune autonomy. Self-contained+// like mountStagePanel: it owns its fetch + styles and renders into a container.++import { apiFetch } from '../api.js';++const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));+const fmt = (n) => {+ const v = Number(n || 0);+ if (v >= 1_000_000) return (v / 1_000_000).toFixed(2).replace(/\.00$/, '') + 'M';+ if (v >= 1000) return Math.round(v).toLocaleString();+ return v.toLocaleString(undefined, { maximumFractionDigits: 2 });+};++export async function mountLaborPanel({ agentId, agentName = 'this agent', isOwner = false, container, position = 'append' } = {}) {+ if (!agentId || !container) return null;+ const el = document.createElement('div');+ el.className = 'labor-link-panel';+ if (position === 'prepend') container.prepend(el);+ else container.append(el);+ injectStyle();++ let data = null;+ try {+ const res = await apiFetch(`/api/labor/agent?agentId=${encodeURIComponent(agentId)}`, { allowAnonymous: true });+ const j = await res.json();+ data = j.data || null;+ } catch {+ el.remove();+ return null;+ }++ const stats = data?.stats || {};+ const policy = data?.policy || {};+ const hasHistory = stats.jobs_done > 0 || stats.bounties_posted > 0 || stats.jobs_active > 0;+ const forHire = !!policy.worker_enabled;++ // Nothing to say to a visitor about an agent with no labor footprint.+ if (!hasHistory && !forHire && !isOwner) {+ el.remove();+ return null;+ }++ const stat = (label, value) => `<div class="llp-stat"><span class="llp-stat-v">${value}</span><span class="llp-stat-l">${label}</span></div>`;+ const grid = hasHistory+ ? `<div class="llp-grid">+ ${stat('$THREE earned', fmt(stats.earned_three))}+ ${stat('Jobs done', (stats.jobs_done || 0).toLocaleString())}+ ${stat('Reputation', (stats.reputation ?? 0).toFixed(2))}+ ${stat('Bounties posted', (stats.bounties_posted || 0).toLocaleString())}+ </div>`+ : `<p class="llp-copy">${isOwner ? `Put ${esc(agentName)} to work — post a bounty or let it bid for hire in the live $THREE machine economy.` : `${esc(agentName)} is open for hire.`}</p>`;++ el.innerHTML = `+ <div class="llp-head">+ <span class="llp-kicker">Work</span>+ ${forHire ? '<span class="llp-hire">● for hire</span>' : ''}+ </div>+ ${grid}+ <a class="llp-link" href="/labor-market">Open the Labor Market →</a>`;+ return { el };+}++let _styled = false;+function injectStyle() {+ if (_styled || typeof document === 'undefined') return;+ _styled = true;+ const s = document.createElement('style');+ s.textContent = `+ .labor-link-panel { margin: 12px 0; padding: 14px 16px; border: 1px solid var(--stroke, rgba(255,255,255,.1)); border-radius: var(--radius-lg, 14px); background: var(--surface-1, rgba(255,255,255,.03)); }+ .llp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }+ .llp-kicker { font: 600 11px/1 var(--font-mono, monospace); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-dim, #9aa); }+ .llp-hire { font: 600 10px/1 var(--font-mono, monospace); color: var(--success, #4ade80); }+ .llp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }+ .llp-stat { display: flex; flex-direction: column; gap: 3px; }+ .llp-stat-v { font: 700 17px/1 var(--font-display, sans-serif); color: var(--ink-bright, #fff); }+ .llp-stat-l { font: 500 10px/1 var(--font-mono, monospace); text-transform: uppercase; letter-spacing: .03em; color: var(--ink-faint, #778); }+ .llp-copy { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--ink-dim, #9aa); }+ .llp-link { display: inline-block; font: 600 13px/1 var(--font-body, sans-serif); color: var(--success, #4ade80); text-decoration: none; }+ .llp-link:hover { text-decoration: underline; }+ @media (max-width: 480px) { .llp-grid { grid-template-columns: repeat(2, 1fr); } }`;+ document.head.appendChild(s);+}diff --git a/tests/agent-labor-economics.test.js b/tests/agent-labor-economics.test.jsindex 2589b371c..9e6fbc7eb 100644--- a/tests/agent-labor-economics.test.js+++ b/tests/agent-labor-economics.test.js@@ -10,13 +10,13 @@ import {} from '../api/_lib/labor-economics.js';describe('scoreBid', () => {- it('is 0 when the bid asks for the full reward (no discount, no eta/rep credit)', () => {- expect(scoreBid({ priceAtomics: 1_000_000n, rewardAtomics: 1_000_000n, etaSeconds: null, reputation: 0 })).toBe(0);+ it('is near 0 for a full-price, zero-reputation, very-slow bid (no price/rep credit, eta decayed away)', () => {+ const s = scoreBid({ priceAtomics: 1_000_000n, rewardAtomics: 1_000_000n, etaSeconds: 3600 * 1000, reputation: 0 });+ expect(s).toBeLessThan(0.05);});- it('approaches 1 for a free, instant bid from a perfect-reputation worker', () => {- const s = scoreBid({ priceAtomics: 0n, rewardAtomics: 1_000_000n, etaSeconds: 0, reputation: 1 });- // price=1, eta≈1 (eta 0 → 1), rep=1 → ~ sum of weights+ it('approaches 1 for a free, near-instant bid from a perfect-reputation worker', () => {+ const s = scoreBid({ priceAtomics: 0n, rewardAtomics: 1_000_000n, etaSeconds: 1, reputation: 1 });expect(s).toBeGreaterThan(0.99);expect(s).toBeLessThanOrEqual(1);});