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
feat: add candidate sources for GitHub trends and implement moderator release functionality
qbdz9b24e4c90164
diff --git a/api/_lib/github-trending.js b/api/_lib/github-trending.jsindex e89421d7c..29e25a9fe 100644--- a/api/_lib/github-trending.js+++ b/api/_lib/github-trending.js@@ -51,7 +51,10 @@ export function buildSearchQuery({ since, window = 'new', minStars = 10, languagconst dateField = window === 'active' ? 'pushed' : 'created';if (since) parts.push(`${dateField}:>=${since}`);parts.push(`stars:>=${Math.max(0, Math.floor(minStars))}`);- if (language) parts.push(`language:${String(language).trim()}`);+ if (language) {+ const lang = String(language).trim();+ parts.push(`language:${/\s/.test(lang) ? `"${lang}"` : lang}`);+ }// Exclude obvious non-project noise that pollutes star-sorted results.parts.push('is:public');return parts.join(' ');diff --git a/api/_lib/launch/candidate-sources.js b/api/_lib/launch/candidate-sources.jsnew file mode 100644index 000000000..a5842fce5--- /dev/null+++ b/api/_lib/launch/candidate-sources.js@@ -0,0 +1,115 @@+// @ts-check+// Candidate sources — adapters that turn three.ws's REAL trend providers into a+// uniform "launch candidate" the use-case engine can name and reward. Every+// source here is live: GitHub Search (github-trending.js) and the narrative+// engine (launcher-trends.js). No fixtures, no hardcoded subjects.+//+// A candidate is the raw subject of a potential launch:+// { id, kind, subject, title, description, image, url, score, signal,+// attribution?, themes?, raw }+// `id` is a stable idempotency key so the executor can dedupe against prior+// launches. `attribution` drives reward routing for attribution-mode use cases.++import { fetchTrendingRepos, fetchTrendingCreators } from '../github-trending.js';+import { rankNarratives } from '../launcher-trends.js';++function repoCandidate(r) {+ return {+ id: `gh:repo:${r.full_name}`,+ kind: 'github-repo',+ subject: r.full_name,+ title: r.name,+ description: r.description || `${r.name} — a trending project on GitHub.`,+ image: r.owner.avatar_url,+ url: r.html_url,+ score: r.stars,+ signal: { source: 'github', detail: `★${r.stars}${r.language ? ` · ${r.language}` : ''}`, owner_type: r.owner.type },+ attribution: { kind: 'owner', github_username: r.owner.login, github_user_id: r.owner.id != null ? String(r.owner.id) : undefined },+ raw: r,+ };+}++function creatorCandidate(c) {+ const top = c.top_repo;+ return {+ id: `gh:creator:${c.login}`,+ kind: 'github-creator',+ subject: `@${c.login}`,+ title: `@${c.login}`,+ description: top+ ? `${c.login} is trending on GitHub for ${top.name}${top.description ? ` — ${top.description}` : ''}.`+ : `${c.login} is a trending GitHub creator.`,+ image: c.avatar_url,+ url: c.html_url,+ score: c.trending_stars,+ signal: { source: 'github', detail: `★${c.trending_stars} · ${c.repo_count} repo${c.repo_count === 1 ? '' : 's'}`, owner_type: c.type },+ attribution: { kind: 'creator', github_username: c.login, github_user_id: c.id != null ? String(c.id) : undefined },+ raw: c,+ };+}++function themeCandidate(t) {+ return {+ id: `theme:${t.term}`,+ kind: 'theme',+ subject: t.term,+ title: t.term,+ description: '',+ image: null,+ url: null,+ score: t.score,+ signal: { source: 'narratives', detail: (t.sources || []).join(' + '), kind: t.kind },+ themes: [t.term],+ raw: t,+ };+}++/**+ * Fetch candidates for a source kind. Reads provider-specific params off `params`.+ * Never throws — a dead provider yields []. Used by planLaunch().+ *+ * @param {string} kind+ * @param {object} params+ * @returns {Promise<Array<object>>}+ */+export async function sourceCandidates(kind, params = {}) {+ try {+ switch (kind) {+ case 'github-repos': {+ const repos = await fetchTrendingRepos({+ window: params.window || 'new',+ sinceDays: params.sinceDays ?? 30,+ minStars: params.minStars ?? 50,+ language: params.language,+ limit: params.limit ?? 12,+ });+ return repos.map(repoCandidate);+ }+ case 'github-creators': {+ const creators = await fetchTrendingCreators({+ window: params.window || 'new',+ sinceDays: params.sinceDays ?? 60,+ minStars: params.minStars ?? 50,+ language: params.language,+ creatorLimit: params.limit ?? 12,+ });+ return creators.map(creatorCandidate);+ }+ case 'narratives': {+ const res = await rankNarratives({+ network: params.network || 'mainnet',+ sources: params.sources,+ categories: params.categories || [],+ limit: params.limit ?? 12,+ });+ return (res.terms || []).map(themeCandidate);+ }+ default:+ return [];+ }+ } catch {+ return [];+ }+}++export { repoCandidate, creatorCandidate, themeCandidate };diff --git a/api/_lib/launch/usecases/github.js b/api/_lib/launch/usecases/github.jsnew file mode 100644index 000000000..66d6641f4--- /dev/null+++ b/api/_lib/launch/usecases/github.js@@ -0,0 +1,135 @@+// @ts-check+// GitHub launch use cases — attribution coins minted FOR real trending repos and+// the people who build them, with creator fees routed to the GitHub owner via the+// fee-sharing / social-fee system. Coin-agnostic: every subject is live GitHub+// data resolved at runtime, never a hardcoded project.+//+// All of these share two naming/reward strategies (repoUseCase / creatorUseCase)+// and differ only in their live query — that's the engine doing the wiring, so+// each entry is a real, complete recipe, not a stub.++import { deriveSymbol } from '../usecase-engine.js';++// A coin named for a repo: name from the repo, fees to the repo owner.+function repoUseCase({ id, title, description, tags = [], params = {} }) {+ return {+ id, title, description, category: 'github', mode: 'attribution',+ tags: ['github', 'attribution', 'rewards', ...tags],+ reward_label: 'Creator fees → the repo owner',+ source: { kind: 'github-repos', params },+ defaults: { devBuySol: 0, network: 'mainnet' },+ naming: (c) => ({+ name: c.title || c.raw?.name,+ symbol: deriveSymbol(c.raw?.name || c.title, { max: 9 }),+ description: c.description,+ image: c.image,+ }),+ rewards: (c) => ({ kind: 'github-owner', github_username: c.attribution?.github_username, github_user_id: c.attribution?.github_user_id }),+ };+}++// A coin named for a creator: name from the @handle, fees to that creator.+function creatorUseCase({ id, title, description, tags = [], params = {} }) {+ return {+ id, title, description, category: 'github', mode: 'attribution',+ tags: ['github', 'creator', 'attribution', 'rewards', ...tags],+ reward_label: 'Creator fees → the GitHub creator',+ source: { kind: 'github-creators', params },+ defaults: { devBuySol: 0, network: 'mainnet' },+ naming: (c) => {+ const login = c.raw?.login || String(c.subject || '').replace(/^@/, '');+ return {+ name: login,+ symbol: deriveSymbol(login, { max: 9 }),+ description: c.description,+ image: c.image,+ };+ },+ rewards: (c) => ({ kind: 'github-owner', github_username: c.attribution?.github_username, github_user_id: c.attribution?.github_user_id }),+ };+}++export const githubUseCases = [+ repoUseCase({+ id: 'github-trending-repos',+ title: 'Trending GitHub repos → reward coins',+ description: 'Mint a coin for each newly trending GitHub repository. Creator fees route to the repo owner — they claim by linking a Solana wallet on three.ws.',+ params: { window: 'new', sinceDays: 30, minStars: 100 },+ }),+ repoUseCase({+ id: 'github-fresh-breakouts',+ title: "This week's GitHub breakouts",+ description: 'The freshest repos to cross a star threshold in the last 7 days — catch a project the moment it breaks out, with fees routed to its owner.',+ tags: ['fresh'],+ params: { window: 'new', sinceDays: 7, minStars: 150 },+ }),+ repoUseCase({+ id: 'github-active-surge',+ title: 'Established repos surging now',+ description: 'Long-standing repositories seeing a fresh push of activity. Rides momentum on proven projects rather than brand-new ones.',+ tags: ['momentum'],+ params: { window: 'active', sinceDays: 7, minStars: 5000 },+ }),+ repoUseCase({+ id: 'github-rust-repos',+ title: 'Trending Rust projects',+ description: 'Reward coins for the Rust ecosystem — new trending crates, tools, and runtimes, with fees to their maintainers.',+ tags: ['language', 'rust'],+ params: { window: 'new', sinceDays: 45, minStars: 80, language: 'Rust' },+ }),+ repoUseCase({+ id: 'github-typescript-repos',+ title: 'Trending TypeScript projects',+ description: 'The TypeScript wave — frameworks, SDKs, and apps breaking out, each minted as a reward coin for its author.',+ tags: ['language', 'typescript'],+ params: { window: 'new', sinceDays: 45, minStars: 80, language: 'TypeScript' },+ }),+ repoUseCase({+ id: 'github-python-repos',+ title: 'Trending Python projects',+ description: 'Python’s trending edge — libraries, agents, and tools — with creator fees routed to the people shipping them.',+ tags: ['language', 'python'],+ params: { window: 'new', sinceDays: 45, minStars: 80, language: 'Python' },+ }),+ repoUseCase({+ id: 'github-ai-ml-repos',+ title: 'Trending AI / ML notebooks',+ description: 'The applied-AI surface: trending Jupyter Notebook repos — models, demos, and research — minted for their creators.',+ tags: ['ai', 'ml'],+ params: { window: 'new', sinceDays: 60, minStars: 60, language: 'Jupyter Notebook' },+ }),+ repoUseCase({+ id: 'github-go-repos',+ title: 'Trending Go projects',+ description: 'Infrastructure’s favourite language — trending Go repos for tooling, databases, and networking, with fees to maintainers.',+ tags: ['language', 'go'],+ params: { window: 'new', sinceDays: 45, minStars: 80, language: 'Go' },+ }),+ repoUseCase({+ id: 'github-solidity-repos',+ title: 'Trending Solidity / onchain repos',+ description: 'New smart-contract and onchain tooling repos trending on GitHub, minted as reward coins for their builders.',+ tags: ['language', 'solidity', 'onchain'],+ params: { window: 'new', sinceDays: 60, minStars: 40, language: 'Solidity' },+ }),+ creatorUseCase({+ id: 'github-trending-creators',+ title: 'Trending GitHub creators → reward coins',+ description: 'Mint a coin for each builder trending across GitHub right now. One coin per creator, fees routed to them — the $THREE → @nirholas pattern, automated.',+ params: { window: 'new', sinceDays: 60, minStars: 80 },+ }),+ creatorUseCase({+ id: 'github-top-builders',+ title: 'Top GitHub builders this quarter',+ description: 'The highest-signal creators by trending stars over the last 90 days — back the people, not just the projects.',+ tags: ['builders'],+ params: { window: 'new', sinceDays: 90, minStars: 150 },+ }),+ creatorUseCase({+ id: 'github-rust-builders',+ title: 'Trending Rust builders',+ description: 'The creators driving the Rust ecosystem’s trending repos, each minted a reward coin.',+ tags: ['language', 'rust', 'builders'],+ params: { window: 'new', sinceDays: 60, minStars: 80, language: 'Rust' },+ }),+];diff --git a/api/labor/release.js b/api/labor/release.jsnew file mode 100644index 000000000..7ba33352f--- /dev/null+++ b/api/labor/release.js@@ -0,0 +1,103 @@+// POST /api/labor/release — a platform moderator force-resolves a bounty's+// on-chain escrow WITHOUT ever holding or seeing the escrow private key.+//+// The escrow secret lives only on the server (LABOR_ESCROW_SECRET_BASE58). A+// moderator never owns it, never sees it, and never signs an escrow transaction+// themselves — they authorize the move through their authenticated admin session+// and the server signs. This is the human-override lane on top of the autonomous+// verifier-gated settlement: use it to resolve a stuck or disputed bounty.+//+// action: 'release' → pay the awarded worker (+ skill royalty + poster surplus)+// action: 'refund' → return the full reward to the poster (no worker blame)+//+// Both reuse runSettlement with a forced verdict, so every payout leg, the+// settle_key idempotency guard (a retry never double-pays), and the on-chain+// invocation receipt are identical to the autonomous path. An open bounty with+// no awarded worker can only be refunded.++import { cors, error, json, method, readJson, wrap } from '../_lib/http.js';+import { requireCsrf } from '../_lib/csrf.js';+import { requireAdmin } from '../_lib/admin.js';+import {+ getBounty, getJobByBounty, getJob, markJobDelivered, setBountyStatus,+ atomicsToThree, _toBig as toBig,+} from '../_lib/agent-labor.js';+import { runSettlement } from '../_lib/labor-settle.js';+import { payFromEscrow, ensureEscrowGas } from '../_lib/labor-escrow.js';+import { emitReasoning } from '../_lib/labor-match.js';+import { sql } from '../_lib/db.js';++const TERMINAL = new Set(['settled', 'failed', 'refunded', 'cancelled']);++async function posterSolanaAddress(bounty) {+ const [row] = await sql`+ SELECT meta FROM agent_identities WHERE id = ${bounty.poster_agent_id} AND deleted_at IS NULL`;+ return row?.meta?.solana_address || null;+}++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['POST'])) return;++ // Moderator gate. requireAdmin writes the 401/403 itself; the escrow key is+ // never returned to or touched by the caller.+ const admin = await requireAdmin(req, res);+ if (!admin) return;+ if (!(await requireCsrf(req, res, admin.id))) return;++ const body = (await readJson(req)) || {};+ const bountyId = body.bountyId;+ const action = body.action === 'refund' ? 'refund' : body.action === 'release' ? 'release' : null;+ if (!bountyId) return error(res, 400, 'validation_error', 'bountyId is required');+ if (!action) return error(res, 400, 'validation_error', "action must be 'release' or 'refund'");++ const bounty = await getBounty(bountyId);+ if (!bounty) return error(res, 404, 'not_found', 'bounty not found');+ if (TERMINAL.has(bounty.status)) return error(res, 409, 'already_resolved', `bounty is already ${bounty.status}`);+ if (!bounty.escrow_fund_sig) return error(res, 409, 'no_escrow', 'this bounty has no funded escrow to move');++ const moderator = { admin_id: admin.id, wallet: admin.wallet_address || null, reason: typeof body.reason === 'string' ? body.reason.slice(0, 280) : null };+ let job = await getJobByBounty(bountyId);++ // Open bounty (escrow funded, no worker awarded): only a refund makes sense.+ if (!job) {+ if (action === 'release') return error(res, 409, 'no_worker', 'no worker has been awarded — only refund is available');+ await ensureEscrowGas().catch(() => {});+ const to = await posterSolanaAddress(bounty);+ if (!to) return error(res, 409, 'no_poster_wallet', 'poster has no Solana wallet to refund to');+ let refundSig;+ try {+ refundSig = await payFromEscrow({ toAddress: to, amountAtomics: toBig(bounty.reward_atomics) });+ } catch (e) {+ return error(res, 502, 'refund_failed', `escrow refund did not land — no $THREE moved: ${e?.message || 'transfer failed'}`);+ }+ await setBountyStatus(bounty.id, 'refunded', { refundSig });+ emitReasoning({+ agentId: bounty.poster_agent_id, kind: 'labor.moderator_refund',+ summary: `Moderator refunded "${bounty.title}" — no worker awarded`,+ detail: { bounty_id: bounty.id, moderator, refund_sig: refundSig },+ });+ return json(res, 200, {+ ok: true, action, status: 'refunded', moderator, settled: false,+ refund_sig: refundSig, refund_three: atomicsToThree(bounty.reward_atomics),+ explorer: refundSig ? `https://solscan.io/tx/${refundSig}` : null,+ });+ }++ // Awarded job: the shared settlement path only claims 'delivered'/'verifying'+ // jobs, so flip a still-'working' job to delivered (moderator override) first.+ if (job.status === 'working') {+ const delivered = await markJobDelivered(job.id, { moderator_override: true, action, by: moderator });+ job = delivered || (await getJob(job.id));+ }++ const verdict = {+ pass: action === 'release',+ score: action === 'release' ? 1 : 0,+ reason: `moderator ${action} by ${moderator.wallet || moderator.admin_id}${moderator.reason ? ` — ${moderator.reason}` : ''}`,+ moderator,+ };++ const result = await runSettlement({ job, bounty, verdict });+ return json(res, 200, { ok: true, action, moderator, ...result });+});diff --git a/tests/api-labor-lifecycle.test.js b/tests/api-labor-lifecycle.test.jsindex 0265c96e2..9af09be77 100644--- a/tests/api-labor-lifecycle.test.js+++ b/tests/api-labor-lifecycle.test.js@@ -119,6 +119,38 @@ describe('runSettlement — refund path (verify fail)', () => {expect(setBountyStatus).toHaveBeenCalledWith('b1', 'failed', expect.any(Object));expect(recordInvocationReceipt).not.toHaveBeenCalled();});++ it('a moderator-forced refund marks the job refunded (no worker blame), not failed', async () => {+ // Forced verdict from POST /api/labor/release — verifier is never consulted.+ const result = await runSettlement({+ job, bounty,+ verdict: { pass: false, score: 0, reason: 'mod refund', moderator: { admin_id: 'm1', wallet: 'MOD' } },+ });++ expect(result.status).toBe('refunded');+ expect(verifyDeliverable).not.toHaveBeenCalled(); // forced verdict skips the verifier+ expect(payFromEscrow).toHaveBeenCalledWith({ toAddress: 'PADDR', amountAtomics: 1_000_000n });+ expect(markJobFailed).toHaveBeenCalledWith('job1', expect.objectContaining({ status: 'refunded' }));+ expect(setBountyStatus).toHaveBeenCalledWith('b1', 'refunded', expect.any(Object));+ });+});++describe('runSettlement — moderator forced release', () => {+ it('pays the worker on a forced pass without consulting the verifier', async () => {+ resolveSkillAuthorPayout.mockResolvedValue(null);++ const result = await runSettlement({+ job, bounty,+ verdict: { pass: true, score: 1, reason: 'moderator release by MOD', moderator: { admin_id: 'm1', wallet: 'MOD' } },+ });++ expect(result.settled).toBe(true);+ expect(result.status).toBe('settled');+ expect(verifyDeliverable).not.toHaveBeenCalled();+ const byTo = Object.fromEntries(payFromEscrow.mock.calls.map(([a]) => [a.toAddress, a.amountAtomics]));+ expect(byTo.WADDR).toBe(800_000n);+ expect(byTo.PADDR).toBe(200_000n);+ });});describe('runSettlement — idempotency', () => {diff --git a/tests/github-trending.test.js b/tests/github-trending.test.jsindex 6f9aff6f2..12cd90dae 100644--- a/tests/github-trending.test.js+++ b/tests/github-trending.test.js@@ -28,6 +28,9 @@ describe('buildSearchQuery', () => {it('adds a language qualifier when given', () => {expect(buildSearchQuery({ since: '2026-06-01', language: 'TypeScript' })).toContain('language:TypeScript');});+ it('quotes a multi-word language', () => {+ expect(buildSearchQuery({ since: '2026-06-01', language: 'Jupyter Notebook' })).toContain('language:"Jupyter Notebook"');+ });it('floors and clamps minStars to a non-negative integer', () => {expect(buildSearchQuery({ since: '2026-06-01', minStars: -5 })).toContain('stars:>=0');expect(buildSearchQuery({ since: '2026-06-01', minStars: 12.9 })).toContain('stars:>=12');