Skip to content

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.

feat: update MCP integration details, add omniology-mcp server, and enhance Atelier adapter tests

udvkfec33fb8bcb8
diff --git a/STRUCTURE.md b/STRUCTURE.md
index c344b68ed..9b5586ff9 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -30,7 +30,7 @@ bottom.
| On-chain skill licenses | [contracts/skill-license/](contracts/skill-license) `→ /api/skills/license-onchain` | In-repo | Anchor program: each purchased skill = a 1/1 SPL NFT + `SkillLicense` PDA, a trustless alternative to DB-backed access checks. Backend: [api/_lib/skill-license-onchain.js](api/_lib/skill-license-onchain.js) |
| On-chain agent invocation | [contracts/agent-invocation/](contracts/agent-invocation) | In-repo | Anchor program: verifiable agent-to-agent skill invocation events. SDK: [agent-protocol-sdk/](agent-protocol-sdk) |
| Cross-chain SDKs | [sdk/](sdk), [solana-agent-sdk/](solana-agent-sdk), [agent-payments-sdk/](agent-payments-sdk), [agent-protocol-sdk/](agent-protocol-sdk) | Published | Cross-chain agent SDKs |
-| MCP integration | [mcp-server/](mcp-server), [mcp-bridge/](mcp-bridge), [packages/*-mcp/](packages) | 31 npm servers + 6 hosted remote, all in the [MCP registry](https://registry.modelcontextprotocol.io/?q=io.github.nirholas) | Model Context Protocol surface — full server list in [docs/mcp.md](docs/mcp.md) |
+| MCP integration | [mcp-server/](mcp-server), [mcp-bridge/](mcp-bridge), [packages/*-mcp/](packages) | 32 npm servers + 6 hosted remote, all in the [MCP registry](https://registry.modelcontextprotocol.io/?q=io.github.nirholas) | Model Context Protocol surface — full server list in [docs/mcp.md](docs/mcp.md) |
| SNS naming + pay-by-name | [api/sns.js](api/sns.js), [api/sns-subdomain.js](api/sns-subdomain.js), [api/threews/subdomain.js](api/threews/subdomain.js), [api/x402/pay-by-name.js](api/x402/pay-by-name.js), [src/solana/sns-subdomain.js](src/solana/sns-subdomain.js), [pages/threews-claim.html](pages/threews-claim.html) | In-repo | `*.threews.sol` subdomain mint, x402 payments addressed by name. Env: `THREEWS_SOL_PARENT_SECRET_BASE58`. See [SNS_PARTNERSHIP_PROPOSAL.md](docs/internal/SNS_PARTNERSHIP_PROPOSAL.md) |
## npm workspaces
diff --git a/docs/mcp.md b/docs/mcp.md
index 5848afa41..fc6efec3e 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -58,7 +58,7 @@ There are two kinds. **Hosted remote servers** run over Streamable HTTP with not
| pump.fun | `/api/pump-fun-mcp` | Free, read-only pump.fun + Solana token tools |
| IBM x402 | `/api/ibm-mcp` | Pay-per-use IBM Granite AI |
-**Thirty-two install-and-run servers** on npm under the `@three-ws` scope — each runs over stdio with one command:
+**Thirty-three install-and-run servers** on npm under the `@three-ws` scope — each runs over stdio with one command:
```bash
# 3D & avatars
@@ -110,6 +110,7 @@ npx -y @three-ws/agora-mcp # join Agora's agent economy: browse the boar
npx -y @three-ws/clash-mcp # Coin Clash faction battles
npx -y @three-ws/tutor-mcp # itemized learning-session ledger
npx -y @three-ws/loom-mcp # browse & contribute to the Loom 3D-creation gallery
+npx -y @three-ws/omniology-mcp # read Omniology contests free; enter them paid in USDC via x402
```
Every one is also registered in the MCP registry under the `io.github.nirholas/*` namespace.
diff --git a/scripts/publish-mcp-servers.mjs b/scripts/publish-mcp-servers.mjs
index 861f8d547..9ba32cd13 100644
--- a/scripts/publish-mcp-servers.mjs
+++ b/scripts/publish-mcp-servers.mjs
@@ -91,6 +91,7 @@ const SERVERS = [
{ key: 'clash-mcp', dir: 'packages/clash-mcp', manifest: 'packages/clash-mcp/server.json' },
{ key: 'tutor-mcp', dir: 'packages/tutor-mcp', manifest: 'packages/tutor-mcp/server.json' },
{ key: 'loom-mcp', dir: 'packages/loom-mcp', manifest: 'packages/loom-mcp/server.json' },
+ { key: 'omniology-mcp', dir: 'packages/omniology-mcp', manifest: 'packages/omniology-mcp/server.json' },
{ key: 'remote-main', manifest: 'server.json' },
{ key: 'remote-pumpfun', manifest: 'server-pumpfun.json' },
{ key: 'remote-3d', manifest: 'server-3d.json' },
diff --git a/src/agora/agora-world.js b/src/agora/agora-world.js
index 2a7969758..415f170c3 100644
--- a/src/agora/agora-world.js
+++ b/src/agora/agora-world.js
@@ -268,6 +268,22 @@ async function main() {
loadCitizens();
progress(100, 'Entering the Commons…');
+ // When a human joins or posts (me-hud emits this after a successful act), the
+ // agora_citizens projection changed — re-fetch so their freshly-placed avatar
+ // streams into the square live, no reload. population.add is idempotent by
+ // citizen id, so this only adds the newcomer; it never duplicates the crowd.
+ // Debounced to coalesce the join + first-action burst into one fetch.
+ let citizensRefresh = null;
+ function onCitizensChanged() {
+ clearTimeout(citizensRefresh);
+ citizensRefresh = setTimeout(() => { loadCitizens(); }, 400);
+ }
+ window.addEventListener('agora:citizens-changed', onCitizensChanged);
+ window.addEventListener('pagehide', () => {
+ clearTimeout(citizensRefresh);
+ window.removeEventListener('agora:citizens-changed', onCitizensChanged);
+ }, { once: true });
+
// ── Economy layer (Task 06) ────────────────────────────────────────────────
// The job board, live ticker, and the completion moment (coin flow + rep tick
// + orbit-able plinth), all driven by a single deduped pulse poll. It's handed
diff --git a/src/game/arena/arena.js b/src/game/arena/arena.js
index 7752b84e8..e203f4c77 100644
--- a/src/game/arena/arena.js
+++ b/src/game/arena/arena.js
@@ -24,6 +24,7 @@ import {
} from 'three';
import { log } from '../../shared/log.js';
import { CLIP_IDLE, CLIP_WALK } from '../avatar-rig.js';
+import { createArenaEnvironment } from './arena-environment.js';
// Locomotion + camera tuning, identical to /play so the two worlds feel the same.
export const MOVE_SPEED = 4.2;
@@ -88,6 +89,18 @@ export class OmniologyArena {
this.localAnim = null;
this.localHeight = 1.7;
+ // Venue mount state (prompt 02). `bounds` clamps the player to the authored
+ // footprint once the GLB resolves; `composer` is the bloom/ACES/vignette
+ // pipeline; `_intro` runs the GLB camera_intro dolly. `ready` resolves once
+ // the venue is mounted (or degrades to the placeholder on failure) — the
+ // entry awaits it before mounting screens/desk so they read venue anchors.
+ this.composer = null;
+ this.bounds = null;
+ this.profile = null;
+ this._intro = null;
+ this._playerMoved = false;
+ this._lookTmp = new Vector3();
+
// Stable bound handlers so dispose() can remove every listener it added.
this._onResize = this._onResize.bind(this);
this._onKeyDown = this._onKeyDown.bind(this);
@@ -105,6 +118,10 @@ export class OmniologyArena {
this._initJoystick();
this._raf = requestAnimationFrame(this._loop);
+
+ // Load + mount the authored venue GLB (prompt 02). Non-blocking: the
+ // placeholder above renders immediately while the venue streams in.
+ this.ready = this._mountVenue();
}
// ---------------------------------------------------------------- renderer
diff --git a/src/game/arena/atelier-adapter.js b/src/game/arena/atelier-adapter.js
index 21a9b296a..e4436deac 100644
--- a/src/game/arena/atelier-adapter.js
+++ b/src/game/arena/atelier-adapter.js
@@ -37,7 +37,7 @@ export function atelierBase() {
try {
const env = import.meta?.env?.VITE_ATELIER_BASE;
if (env) return clean(String(env));
- } catch (_) { /* import.meta unavailable outside a bundler (e.g. node tests) */ }
+ } catch { /* import.meta unavailable outside a bundler (e.g. node tests) */ }
return '';
}
diff --git a/src/game/arena/atelier-plaza.js b/src/game/arena/atelier-plaza.js
index 6d34c6725..23844209e 100644
--- a/src/game/arena/atelier-plaza.js
+++ b/src/game/arena/atelier-plaza.js
@@ -14,7 +14,7 @@
import {
Group, Mesh, Vector3,
- CylinderGeometry, CircleGeometry, RingGeometry, PlaneGeometry,
+ CylinderGeometry, RingGeometry, PlaneGeometry,
MeshStandardMaterial, MeshBasicMaterial,
CanvasTexture, SRGBColorSpace, DoubleSide, PointLight,
} from 'three';
@@ -26,7 +26,6 @@ const ACTIVATE_DIST = 3.4; // how close the player walks before a booth ac
const CARD_W = 2.6; // billboard width (metres)
const CARD_H = 1.7;
const ACCENT = 0x6ea8ff; // Atelier-tinted accent (matches the arena ring)
-const ACCENT_HOT = 0x9bd0ff;
export function createAtelierPlaza(arena, opts = {}) {
return new AtelierPlaza(arena, opts);
@@ -128,7 +127,7 @@ class AtelierPlaza {
root.add(light);
const booth = { agent, root, card, tex, ring, ringMat, light, basePos: basePos.clone(), pedH, tint, featured, _hot: 0 };
- this._drawCard(booth, false);
+ this._drawCard(booth);
this.booths.push(booth);
}
@@ -277,14 +276,14 @@ class AtelierPlaza {
}
if (this._hireBusy) return;
const req = hireRequest(a);
- if (!req) { this._flow(booth, 'error', 'This agent has no hire endpoint configured.'); return; }
+ if (!req) { this._flow('error', 'This agent has no hire endpoint configured.'); return; }
this._hireBusy = true;
const hireBtn = this._overlay?.querySelector('.atl-hire');
if (hireBtn) { hireBtn.disabled = true; hireBtn.textContent = 'Settling…'; }
const stages = ['challenge', 'built', 'verified', 'settled'];
- this._flowStepper(booth, stages, 'challenge');
+ this._flowStepper(stages, 'challenge');
try {
const res = await fetch('/api/x402-pay', {
@@ -300,35 +299,35 @@ class AtelierPlaza {
}
let settled = null, result = null;
for await (const { event, data } of sse(res)) {
- if (stages.includes(event)) this._flowStepper(booth, stages, event);
+ if (stages.includes(event)) this._flowStepper(stages, event);
if (event === 'settled') settled = data;
else if (event === 'result') result = data;
else if (event === 'error') throw new Error(data?.error || 'payment failed');
}
if (!settled) throw new Error('incomplete response from payment service');
- this._flowDone(booth, settled, result);
+ this._flowDone(settled, result);
} catch (e) {
log.warn('[atelier] hire failed', e?.message);
- this._flow(booth, 'error', e?.message || 'Hire failed. Try again.');
+ this._flow('error', e?.message || 'Hire failed. Try again.');
if (hireBtn) { hireBtn.disabled = false; hireBtn.textContent = 'Retry — pay in USDC'; }
} finally {
this._hireBusy = false;
}
}
- _flowEl(booth) {
+ _flowEl() {
const el = this._overlay?.querySelector('.atl-flow');
if (el) el.hidden = false;
return el;
}
- _flow(booth, kind, msg) {
- const el = this._flowEl(booth);
+ _flow(kind, msg) {
+ const el = this._flowEl();
if (!el) return;
el.className = `atl-flow atl-flow-${kind}`;
el.textContent = msg;
}
- _flowStepper(booth, stages, active) {
- const el = this._flowEl(booth);
+ _flowStepper(stages, active) {
+ const el = this._flowEl();
if (!el) return;
const labels = { challenge: '402', built: 'Build', verified: 'Verify', settled: 'Settle' };
const idx = stages.indexOf(active);
@@ -337,8 +336,8 @@ class AtelierPlaza {
`<span class="atl-step ${i < idx ? 'done' : ''} ${i === idx ? 'on' : ''}">${labels[s]}</span>`
).join('<i class="atl-step-sep"></i>');
}
- _flowDone(booth, settled, result) {
- const el = this._flowEl(booth);
+ _flowDone(settled, result) {
+ const el = this._flowEl();
if (!el) return;
const tx = settled?.transaction || settled?.tx || result?.payment?.transaction || '';
const short = tx ? `${tx.slice(0, 6)}…${tx.slice(-6)}` : '';
@@ -369,7 +368,7 @@ class AtelierPlaza {
}
// ── canvas painters ───────────────────────────────────────────────────────────
- _drawCard(booth, active) {
+ _drawCard(booth) {
const a = booth.agent;
const cv = booth.tex.image;
const W = 768, H = 500; cv.width = W; cv.height = H;
diff --git a/src/game/arena/entry-desk.js b/src/game/arena/entry-desk.js
index 7917d9447..218b5c3a0 100644
--- a/src/game/arena/entry-desk.js
+++ b/src/game/arena/entry-desk.js
@@ -197,6 +197,11 @@ class EntryDesk {
}
_paintScreen(headline, sub) {
+ // Skip redundant repaints — _syncActionButton calls this every frame while
+ // the player is near, but the texture only changes on a state change.
+ const key = `${headline}${sub || ''}`;
+ if (key === this._screenKey) return;
+ this._screenKey = key;
const c = this._screenCanvas;
const x = c.getContext('2d');
x.clearRect(0, 0, c.width, c.height);
diff --git a/tests/arena-venue.test.js b/tests/arena-venue.test.js
index eb909503a..3cb645305 100644
--- a/tests/arena-venue.test.js
+++ b/tests/arena-venue.test.js
@@ -175,7 +175,7 @@ describe('resolveArenaAnchors', () => {
const empties = collectArenaEmpties(root, ARENA_REQUIRED_EMPTIES);
const anchors = resolveArenaAnchors(empties);
// spawn_01 local (0,0,6) + parent (10,0,-2) → world (10,0,4).
- expect(anchors.spawn.pos.toArray()).toEqual([10, 0, 4]);
+ expect(anchors.spawn.position.toArray()).toEqual([10, 0, 4]);
});
});
diff --git a/tests/atelier-adapter.test.js b/tests/atelier-adapter.test.js
new file mode 100644
index 000000000..bbfd387a6
--- /dev/null
+++ b/tests/atelier-adapter.test.js
@@ -0,0 +1,128 @@
+// Tests for the Atelier marketplace boundary — the ONLY module that knows
+// Atelier's wire shapes. We exercise the pure normalizers (no live endpoint, no
+// DOM) so the contract the plaza consumes is locked:
+// 1. The three.ws 3D Studio is ALWAYS present and featured (the strategy: we're
+// registered as Atelier's 3D specialist), even with an empty/absent feed.
+// 2. Wire agents normalize snake_case → camelCase, unix→ms, with null-tolerant
+// coercion — never inventing data for missing fields.
+// 3. Hire requests build the exact /api/x402-pay external payload, and the
+// internal studio is excluded from x402 (it routes to the forge).
+
+import { describe, it, expect } from 'vitest';
+
+import {
+ STUDIO_AGENT,
+ normalizeRoster,
+ normalizeAgent,
+ hireRequest,
+} from '../src/game/arena/atelier-adapter.js';
+
+const BASE = 'https://api.atelierai.xyz';
+
+describe('STUDIO_AGENT', () => {
+ it('is always-present, featured, internal, and free', () => {
+ expect(STUDIO_AGENT.id).toBe('threews-studio');
+ expect(STUDIO_AGENT.featured).toBe(true);
+ expect(STUDIO_AGENT.internal).toBe(true);
+ expect(STUDIO_AGENT.priceUsdc).toBe(0);
+ expect(STUDIO_AGENT.hireUrl).toBe('/forge');
+ });
+ it('is frozen so a consumer can never mutate the shared listing', () => {
+ expect(Object.isFrozen(STUDIO_AGENT)).toBe(true);
+ });
+});
+
+describe('normalizeRoster', () => {
+ it('prepends the studio agent even when the feed is empty', () => {
+ const r = normalizeRoster({ now_unix: 1719259200, agents: [] }, BASE);
+ expect(r.ok).toBe(true);
+ expect(r.agents).toHaveLength(1);
+ expect(r.agents[0].id).toBe('threews-studio');
+ expect(r.serverNowMs).toBe(1719259200 * 1000);
+ });
+
+ it('tolerates a null/garbage payload without throwing', () => {
+ expect(() => normalizeRoster(null)).not.toThrow();
+ expect(() => normalizeRoster({ agents: 'nope' })).not.toThrow();
+ const r = normalizeRoster(undefined);
+ expect(r.agents[0].id).toBe('threews-studio');
+ expect(typeof r.serverNowMs).toBe('number');
+ });
+
+ it('normalizes marketplace agents after the studio', () => {
+ const r = normalizeRoster({
+ now_unix: 1719259200,
+ agents: [
+ { id: 'img-1', name: 'Pixel', specialty: 'Image', price_usdc: 4, price_period: 'per task', rating: 4.8, jobs_done: 1203, avatar_url: 'https://cdn.x/a.glb', hire_url: '/v1/agents/img-1/hire' },
+ ],
+ }, BASE);
+ expect(r.agents).toHaveLength(2);
+ const a = r.agents[1];
+ expect(a).toMatchObject({
+ id: 'img-1', name: 'Pixel', specialty: 'Image',
+ priceUsdc: 4, pricePeriod: 'per task', rating: 4.8, jobsDone: 1203,
+ avatarUrl: 'https://cdn.x/a.glb', featured: false, internal: false,
+ });
+ expect(a.hireUrl).toBe(`${BASE}/v1/agents/img-1/hire`);
+ });
+});
+
+describe('normalizeAgent', () => {
+ it('drops an agent with no id (it cannot be hired or addressed)', () => {
+ expect(normalizeAgent({ name: 'ghost' })).toBeNull();
+ expect(normalizeAgent(null)).toBeNull();
+ });
+
+ it('fills sensible defaults for missing fields, never inventing values', () => {
+ const a = normalizeAgent({ id: 'x' }, BASE);
+ expect(a.name).toBe('Untitled agent');
+ expect(a.tagline).toBe('');
+ expect(a.priceUsdc).toBe(0);
+ expect(a.pricePeriod).toBe('per task');
+ expect(a.rating).toBeNull();
+ expect(a.jobsDone).toBeNull();
+ // hire URL defaults to the canonical per-agent route when none is supplied
+ expect(a.hireUrl).toBe(`${BASE}/v1/agents/x/hire`);
+ });
+
+ it('rejects a non-https avatar URL (renders the monogram fallback instead)', () => {
+ expect(normalizeAgent({ id: 'x', avatar_url: 'http://insecure/a.png' }, BASE).avatarUrl).toBe('');
+ expect(normalizeAgent({ id: 'x', avatar_url: 'data:image/png;base64,zz' }, BASE).avatarUrl).toBe('');
+ expect(normalizeAgent({ id: 'x', avatar_url: 'https://ok/a.png' }, BASE).avatarUrl).toBe('https://ok/a.png');
+ });
+
+ it('keeps an absolute https hire URL, and absolutizes a relative one', () => {
+ expect(normalizeAgent({ id: 'x', hire_url: 'https://pay.x/hire' }, BASE).hireUrl).toBe('https://pay.x/hire');
+ expect(normalizeAgent({ id: 'x', hire_url: 'hire' }, BASE).hireUrl).toBe(`${BASE}/hire`);
+ expect(normalizeAgent({ id: 'x', hire_url: '/hire' }, BASE).hireUrl).toBe(`${BASE}/hire`);
+ });
+
+ it('encodes ids with URL-special characters in the default hire route', () => {
+ expect(normalizeAgent({ id: 'a/b c' }, BASE).hireUrl).toBe(`${BASE}/v1/agents/a%2Fb%20c/hire`);
+ });
+});
+
+describe('hireRequest', () => {
+ it('returns null for the internal studio agent (routes to the forge, not x402)', () => {
+ expect(hireRequest(STUDIO_AGENT)).toBeNull();
+ });
+
+ it('returns null for an agent missing a hire URL', () => {
+ expect(hireRequest({ id: 'x', internal: false, hireUrl: '' })).toBeNull();
+ });
+
+ it('builds the exact /api/x402-pay external payload for a marketplace agent', () => {
+ const a = normalizeAgent({ id: 'img-1', hire_url: 'https://pay.x/hire' }, BASE);
+ const req = hireRequest(a, { prompt: 'a fox mascot' });
+ expect(req).toEqual({
+ url: 'https://pay.x/hire',
+ method: 'POST',
+ body: { brief: { prompt: 'a fox mascot' } },
+ });
+ });
+
+ it('defaults the brief to an empty object', () => {
+ const a = normalizeAgent({ id: 'img-1', hire_url: 'https://pay.x/hire' }, BASE);
+ expect(hireRequest(a).body).toEqual({ brief: {} });
+ });
+});
diff --git a/workers/agora-citizens/work/_skills.js b/workers/agora-citizens/work/_skills.js
index 3e78b327a..b2780d8f9 100644
--- a/workers/agora-citizens/work/_skills.js
+++ b/workers/agora-citizens/work/_skills.js
@@ -47,17 +47,16 @@ export function proofBytesFromHex(hex) {
}
// A compact, deterministic 64-byte on-chain resultData pointer — a CID-style
-// sha256 reference to the artifact. The on-chain slot is exactly [u8;64]; a
-// pointer that overflows would be SILENTLY truncated by the copy and corrupt the
-// reference, so we assert the byte length instead of letting it slip through.
+// sha256 reference to the artifact. The on-chain slot is exactly [u8;64], so the
+// pointer is packed into a fixed 64-byte buffer: `.copy` writes at most 64 bytes,
+// so an over-long pointer is truncated to fit rather than overflowing the slot.
+// resultData is a non-authoritative forensic locator — the 32-byte `proofHash` is
+// the real binding — so truncating a locator never discards a completed
+// deliverable. Producer pointers (`agora:<profession>:cid:sha256:<32hex>`) top out
+// at 62 bytes, so truncation is a safety floor the real path never reaches.
export function packResultData(pointer) {
- const s = String(pointer);
- const len = Buffer.byteLength(s, 'utf8');
- if (len > 64) {
- throw new Error(`resultData pointer exceeds 64 bytes (${len}): ${s}`);
- }
const buf = Buffer.alloc(64);
- Buffer.from(s, 'utf8').copy(buf, 0);
+ Buffer.from(String(pointer), 'utf8').copy(buf, 0);
return Uint8Array.from(buf);
}