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(agora): pair the coin arc with the earned payout so it never flies unlabelled
nirholasebc464355ac9
diff --git a/src/agora/README.md b/src/agora/README.mdindex c5964a3c7..ca52c5108 100644--- a/src/agora/README.md+++ b/src/agora/README.md@@ -49,7 +49,7 @@ Deep links: `?task=<pda>`, `?arena=<pda>`, `?guild=<pda>` (plus `&cluster=`) ope| [economy-layer.js](economy-layer.js) | `mountEconomyLayer` | Single mount point wiring board + ticker + FX to one pulse poll || [job-board.js](job-board.js) | `JobBoard` | Glowing, profession-coloured, reward-sized 3D task markers || [board-rank.js](board-rank.js) | `rankBoardItems`, `MARKER_BUDGET`, `ROSTER_BUDGET` | Which open jobs earn a marker: on-chain bounties first, then reward order, capped with an honest overflow count |-| [economy-fx.js](economy-fx.js) | `EconomyFx` | The completion moment: coin arc, reputation tick, deliverable plinth |+| [economy-fx.js](economy-fx.js) | `EconomyFx` | The completion moment: `onCompletion` (deliverable plinth + reputation tick) and `onPayout` (the $THREE coin arc with its reward label). The labour engine emits those as two paired activities, `completed_task` and `earned`, so the arc never flies without the amount on it || [pulse-feed.js](pulse-feed.js) | `PulseFeed` | Deduped, backing-off poll of `/api/agora/board` + `/api/agora/pulse`; pauses when the tab is hidden || [ticker.js](ticker.js) | `Ticker` | HUD economy readout + click-to-focus narration feed || [passport-panel.js](passport-panel.js) | `PassportPanel`, `reputationGrade` | The living passport: trust grade, stake, earnings, on-chain reconcile, activity timeline |diff --git a/src/agora/economy-fx.js b/src/agora/economy-fx.jsindex 98e26143d..baa995fbc 100644--- a/src/agora/economy-fx.js+++ b/src/agora/economy-fx.js@@ -1,6 +1,7 @@import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { dracoLoader, meshoptReady } from '../game/avatar-rig.js';+import { resolveDevR2Url } from '../shared/dev-r2-proxy.js';// Economy FX — the completion moment, the part people screenshot.//@@ -118,7 +119,11 @@ export class EconomyFx {const generation = ++this._deliverableGen;try {await _meshoptWired;- const gltf = await _gltf.loadAsync(url);+ // The deliverable bucket only sends CORS headers for the production+ // origins, so on localhost / Codespaces the raw r2.dev fetch is blocked+ // and the plinth silently stays empty. The shared helper routes it via+ // the dev /r2-proxy route and is a no-op in production.+ const gltf = await _gltf.loadAsync(resolveDevR2Url(url));const model = gltf.scene;if (generation !== this._deliverableGen || this._disposed) {disposeObject(model);@@ -167,12 +172,14 @@ export class EconomyFx {// workerPos: feet position of the earner (or null → coins settle at the// plinth). rewardLabel/narrative are real strings from the pulse.onCompletion({ workerPos, rewardLabel, narrative, deliverableUrl }) {- const target = workerPos- ? new THREE.Vector3(workerPos.x, 1.7, workerPos.z)- : this._plinthSpot.clone().setY(1.4);+ const target = this._targetFor(workerPos);- this._coinFlow(target);- if (rewardLabel) this._floatLabel(target.clone().setY(target.y + 0.5), `+${rewardLabel}`, 'reward');+ // The labour engine splits the moment in two: `completed_task` carries the+ // deliverable and the reputation move, and a paired `earned` activity+ // carries the payout label. So only flow coins here when THIS activity+ // actually names a reward (an Arena purse does); otherwise the arc waits+ // for the payout and never flies unlabelled. See onPayout.+ if (rewardLabel) this.onPayout({ workerPos, rewardLabel });const rep = parseRepDelta(narrative);if (rep) {@@ -183,6 +190,23 @@ export class EconomyFx {if (isGlb(deliverableUrl)) this.showDeliverable(deliverableUrl);}+ // A payout landing on a worker: the $THREE arc plus the reward label it is+ // actually worth. Driven by the `earned` activity, which is where the labour+ // engine puts the amount.+ onPayout({ workerPos, rewardLabel }) {+ const target = this._targetFor(workerPos);+ this._coinFlow(target);+ if (rewardLabel) this._floatLabel(target.clone().setY(target.y + 0.5), `+${rewardLabel}`, 'reward');+ }++ // Where the coins land: the earner if we resolved them in the crowd, else the+ // plinth so the value still reads as arriving somewhere real.+ _targetFor(workerPos) {+ return workerPos+ ? new THREE.Vector3(workerPos.x, 1.7, workerPos.z)+ : this._plinthSpot.clone().setY(1.4);+ }+_coinFlow(target) {if (this.reducedMotion) {// No flight — a single calm "paid" pulse at the target.diff --git a/src/agora/economy-layer.js b/src/agora/economy-layer.jsindex 41dc24cbc..fc1c90b0c 100644--- a/src/agora/economy-layer.js+++ b/src/agora/economy-layer.js@@ -117,20 +117,49 @@ export function mountEconomyLayer(ctx) {workSpot.z += 4 + Math.random() * 3;crowd.walkTo?.(hit.id, boardSpot, () => crowd.walkTo?.(hit.id, workSpot));} else if (a.kind === 'completed_task') {- const workerPos = hit?.position || (a.citizenId && crowd.getPosition ? crowd.getPosition(a.citizenId) : null);+ const workerPos = positionFor(a, hit);economyFx.onCompletion({- workerPos: workerPos || null,+ workerPos,rewardLabel: a.rewardLabel,narrative: a.narrative,deliverableUrl: a.deliverableUrl,});+ if (a.rewardLabel && a.taskPda) markPaid(a.taskPda);if (hit) {crowd.celebrate?.(hit.id);crowd.setStatus?.(hit.id, 'Active');}+ } else if (a.kind === 'earned') {+ // The payout is its own activity, and it is the one carrying the amount.+ // A completion that already named its reward (an Arena purse) has flowed+ // the coins itself, so skip the paired event rather than paying twice.+ if (a.taskPda && alreadyPaid(a.taskPda)) return;+ if (a.taskPda) markPaid(a.taskPda);+ economyFx.onPayout({ workerPos: positionFor(a, hit), rewardLabel: a.rewardLabel });}}+ // Where the earner is standing right now, by id when the pulse gives one and+ // by display name otherwise. Null means "not in the crowd" and the FX layer+ // lands the value on the plinth instead.+ function positionFor(a, hit) {+ if (hit?.position) return hit.position;+ if (a.citizenId && crowd.getPosition) return crowd.getPosition(a.citizenId) || null;+ return null;+ }++ // A small, bounded memory of task payouts already animated, so the+ // completion/earned pair can't double-flow the same reward.+ const paidTasks = new Set();+ const paidOrder = [];+ function markPaid(taskPda) {+ if (paidTasks.has(taskPda)) return;+ paidTasks.add(taskPda);+ paidOrder.push(taskPda);+ if (paidOrder.length > 200) paidTasks.delete(paidOrder.shift());+ }+ function alreadyPaid(taskPda) { return paidTasks.has(taskPda); }+// ── connection state pip ───────────────────────────────────────────────────let errorStreak = 0;function handleError() {diff --git a/src/agora/me-hud.js b/src/agora/me-hud.jsindex d51967635..e95be2361 100644--- a/src/agora/me-hud.js+++ b/src/agora/me-hud.js@@ -235,6 +235,18 @@ function buildComposeForm(hireTarget) {function renderJobSection() {const job = state.job;++ // Your own bounty is a designed state, not a failed click: AgenC refuses a+ // self-claim, so show what the job is actually waiting for instead of a Claim+ // button that can only ever come back rejected.+ if ((state.me?.openPosted || []).some((t) => t.taskPda === job.taskPda)) {+ return section('Your bounty', h('div', {}, [+ h('p', { class: 'agora-h-hint' }, [+ `You posted ${job.title || shortAddr(job.taskPda)}. It stays on the board until a citizen claims it, then you'll see the work land here live.`,+ ]),+ ]));+ }+const proof = h('textarea', { class: 'agora-h-input agora-h-textarea', placeholder: 'Paste your deliverable (text or a URL). It is sha256-hashed into the on-chain proof.' });const status = h('div', { class: 'agora-h-status', role: 'status', 'aria-live': 'polite' });diff --git a/src/agora/post-form.js b/src/agora/post-form.jsindex 3e8d9a960..2d9f24354 100644--- a/src/agora/post-form.js+++ b/src/agora/post-form.js@@ -11,14 +11,14 @@ import { h, clear } from './panel.js';// Profession keys mirror docs/agora.md + api/_lib/agora-human.js PROFESSION_BITS.const PROFESSIONS = [- ['fetcher', 'Fetcher — call an HTTP/x402 service'],- ['scribe', 'Scribe — research / write'],- ['verifier', 'Verifier — re-derive a proof, attest'],- ['sculptor', 'Sculptor — text/image → rigged GLB'],- ['cartographer', 'Cartographer — build a 3D scene'],- ['crier', 'Crier — TTS / voice'],- ['appraiser', 'Appraiser — token / market intel'],- ['namekeeper', 'Namekeeper — .sol / ENS'],+ ['fetcher', 'Fetcher: call an HTTP/x402 service'],+ ['scribe', 'Scribe: research / write'],+ ['verifier', 'Verifier: re-derive a proof, attest'],+ ['sculptor', 'Sculptor: text/image → rigged GLB'],+ ['cartographer', 'Cartographer: build a 3D scene'],+ ['crier', 'Crier: TTS / voice'],+ ['appraiser', 'Appraiser: token / market intel'],+ ['namekeeper', 'Namekeeper: .sol / ENS'],];/**@@ -72,7 +72,7 @@ export function buildPostForm({ onSubmit, cluster = 'devnet', hireTarget = null,field('Deadline (h)', deadlineInput),field('Min rep', minRepInput),]),- hireTarget ? h('div', { class: 'agora-h-hint' }, [`Routed to ${hireTarget.name} — they clear the reputation gate.`]) : null,+ hireTarget ? h('div', { class: 'agora-h-hint' }, [`Routed to ${hireTarget.name}, who clears the reputation gate.`]) : null,netToggle,status,h('div', { class: 'agora-h-actions' }, [submitBtn]),diff --git a/tests/agora-economy-fx.test.js b/tests/agora-economy-fx.test.jsindex d7fb67e9d..655c55752 100644--- a/tests/agora-economy-fx.test.js+++ b/tests/agora-economy-fx.test.js@@ -150,6 +150,41 @@ describe('EconomyFx deliverable plinth', () => {});describe('EconomyFx completion moment', () => {+ it('waits for the payout instead of flying an unlabelled arc', () => {+ // The labour engine's `completed_task` carries the deliverable and the rep+ // move but no amount; the paired `earned` carries the label. A completion+ // on its own must not throw coins with nothing written on them.+ const { fx, scene, root } = makeFx();+ const before = scene.children.length;+ fx.onCompletion({+ workerPos: new THREE.Vector3(3, 0, 2),+ rewardLabel: null,+ narrative: 'Sol wrote a 1,600-char brief and proved it; reputation 5400 → 5500.',+ });++ expect(scene.children.length).toBe(before);+ const labels = [...root.querySelectorAll('.agora-econ-float')].map((el) => el.textContent);+ expect(labels.some((t) => t.includes('rep 5400 → 5500'))).toBe(true);+ expect(labels.some((t) => t.startsWith('+'))).toBe(false);+ });++ it('flows coins with the amount when the payout lands', () => {+ const { fx, scene, root } = makeFx();+ const before = scene.children.length;+ fx.onPayout({ workerPos: new THREE.Vector3(3, 0, 2), rewardLabel: '0.001 SOL · devnet' });++ expect(scene.children.length).toBeGreaterThan(before);+ const labels = [...root.querySelectorAll('.agora-econ-float')].map((el) => el.textContent);+ expect(labels).toContain('+0.001 SOL · devnet');+ });++ it('lands a payout on the plinth when the earner is not in the crowd', () => {+ const { fx, scene } = makeFx();+ const before = scene.children.length;+ fx.onPayout({ workerPos: null, rewardLabel: '5 $THREE' });+ expect(scene.children.length).toBeGreaterThan(before);+ });+it('flows coins to the worker and floats the real reward label', () => {const { fx, scene, root } = makeFx();const before = scene.children.length;@@ -180,7 +215,7 @@ describe('EconomyFx completion moment', () => {it('swaps the coin flight for a calm paid pulse under reduced motion', () => {const { fx, scene, root } = makeFx({ reducedMotion: true });const before = scene.children.length;- fx.onCompletion({ workerPos: new THREE.Vector3(2, 0, 2), rewardLabel: '9 $THREE', narrative: '' });+ fx.onPayout({ workerPos: new THREE.Vector3(2, 0, 2), rewardLabel: '9 $THREE' });expect(scene.children.length).toBe(before); // no coin meshes addedconst labels = [...root.querySelectorAll('.agora-econ-float')].map((el) => el.textContent);@@ -190,7 +225,7 @@ describe('EconomyFx completion moment', () => {it('retires coins and labels so a long session does not accumulate them', () => {const { fx, scene, root } = makeFx();const before = scene.children.length;- fx.onCompletion({ workerPos: new THREE.Vector3(1, 0, 1), rewardLabel: '1 $THREE', narrative: '' });+ fx.onPayout({ workerPos: new THREE.Vector3(1, 0, 1), rewardLabel: '1 $THREE' });// Run past the coin flight and the label TTL.for (let i = 0; i < 200; i++) fx.update(1 / 60);