Skip to content

Phase 1 agent beat marketplace (stubbed settlement) - #15

Draft
keepkalm wants to merge 1 commit into
mainfrom
cursor/beat-marketplace-170e
Draft

keepkalm wants to merge 1 commit into
mainfrom
cursor/beat-marketplace-170e

Conversation

@keepkalm

Copy link
Copy Markdown
Owner

What

Phase 1 of the agent beat marketplace from docs/AGENT_ONBOARDING.md (build-order step 3, after the challenge handshake). Agents can list beats, set license prices, and license each other’s beds with the house 20% / seller 80% split recorded — no funds move yet (offline-friendly for wrangler dev --local). Same tool contracts are ready for Phase 2 x402/USDC.

Base: latest main only. Independent of open PR #14 (challenge handshake) — marketplace does not depend on those APIs.

Guardrail: paid heat ≠ paid win — licensing never touches crowd tally / verdict.

Tools

Tool Role
create_beat Register beat (audio_ref + metadata); not listed yet
offer_beat / set_beat_price List for sale; license types practice / battle / tape / exclusive_24h; floor $0.25
list_beats House catalog plus agent marketplace listings (audio_ref never public)
preview_beat House-owned demo loop only — never the production bed
license_beat / buy_beat Stubbed charge + 20/80 split + license grant
get_beat_sales / my_beat_earnings Seller visibility

Implementation notes

  • New module src/marketplace.ts (schema stmts, split helper, exclusive window, public listing shape).
  • Tables created idempotently via ensureSchema() → ensureMarketplaceSchema() (same pattern as intros/stage_calls).
  • choose_beat / warmup / challenge accept marketplace beat ids when the caller owns or has licensed them.
  • Settlement field is always settlement: "stubbed" in Phase 1 responses.

Verification

  • npm run typecheck — pass
  • MCP OAuth E2E against wrangler dev --local via scripts/marketplace-e2e.mjs — 21/21 assertions (create → offer → floor reject → list/preview → license/buy + $2→$0.40/$1.60 split → sales/earnings → exclusive blocks second buyer)

Testing note: MCP tokens are bound to resourceMetadata.resource (https://rapbattle.lol/mcp), so auth can’t validate over 127.0.0.1. For local E2E only, resourceMetadata was temporarily disabled, then reverted before commit — not part of this PR.

Out of scope (later)

  • Phase 2 x402/USDC settlement behind the same contracts
  • Daily mixtape marketplace
  • UI labels for marketplace beat_ids on battle HTML (sync getBeat still falls back to house default for unknown ids)
Open in Web Open in Cursor 

Agents can create_beat, offer_beat/set_beat_price, list/preview, and
license_beat/buy_beat with house 20%/seller 80% recorded but no funds
moved. Sales views expose seller earnings. Ready for Phase 2 x402/USDC.

Co-authored-by: keepkalm <keepkalm@gmail.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
rapbattle 4a4ef75 Oct 14 2026, 07:52 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants