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.

agenc: identity bridge, x402 mirror, embodied component, live API

overstepping2c8639fdd8ad
diff --git a/api/agenc/[action].js b/api/agenc/[action].js
new file mode 100644
index 000000000..334dfc954
--- /dev/null
+++ b/api/agenc/[action].js
@@ -0,0 +1,424 @@
+// Public AgenC bridge endpoints — free reads of the AgenC coordination
+// protocol (agenc.tech, by Tetsuo Corp) so three.ws frontends and external
+// agents can browse the on-chain task marketplace without standing up an
+// Anchor + IDL pipeline of their own.
+//
+// Routes (all GET unless noted):
+//
+// /api/agenc/list-tasks?creator=<base58>&cluster=devnet
+// Returns every task PDA created by `creator`, with state + reward.
+//
+// /api/agenc/get-task?taskPda=<base58>&cluster=devnet[&lifecycle=1]
+// /api/agenc/get-task?creator=<base58>&taskId=<hex|label>&cluster=devnet
+// Single task status + (optionally) lifecycle timeline.
+//
+// /api/agenc/get-agent?agentPda=<base58>&cluster=devnet
+// /api/agenc/get-agent?agentId=<hex|label>&cluster=devnet
+// Agent registration state.
+//
+// /api/agenc/link (POST)
+// body: { erc8004AgentId?, mplCoreAsset?, handle?, cluster? }
+// → { agenCAgentId, agentPda, metadataUri, source, label,
+// registered, agent? }
+// Computes the canonical three.ws → AgenC agentId via the identity
+// bridge and checks whether that PDA is already registered on-chain.
+//
+// Cluster defaults to `mainnet`. Set `?cluster=devnet` for devnet program
+// 6UcJzbTEemBz3aY5wK5qKHGMD7bdRsmR4smND29gB2ab. RPC endpoint is the public
+// Solana cluster RPC unless `AGENC_RPC_URL` (or `SOLANA_RPC_URL_DEVNET` /
+// `SOLANA_RPC_URL`) is set.
+
+import { PublicKey } from '@solana/web3.js';
+import { createHash } from 'node:crypto';
+import { getTask, getTaskLifecycleSummary, getTasksByCreator, getAgent, deriveTaskPda, deriveAgentPda } from '@tetsuo-ai/sdk';
+
+import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { Bazaar, filterByExtension, filterByMaxPrice, filterByNetwork } from '../_lib/x402/bazaar-client.js';
+import {
+ createAgenCClient,
+ getCanonicalThreewsAgenCId,
+ buildThreewsMetadataUri,
+ agenCAgentIdToHex,
+} from '@three-ws/solana-agent';
+
+function pickCluster(req) {
+ const c = (req.query?.cluster || '').toString().trim().toLowerCase();
+ return c === 'devnet' ? 'devnet' : 'mainnet';
+}
+
+function pickRpc(cluster) {
+ const override = (process.env.AGENC_RPC_URL || '').trim();
+ if (override) return override;
+ if (cluster === 'devnet') {
+ return (process.env.SOLANA_RPC_URL_DEVNET || '').trim() || undefined;
+ }
+ return (process.env.SOLANA_RPC_URL || '').trim() || undefined;
+}
+
+function parsePubkey(s, label) {
+ if (!s) throw new Error(`${label} is required`);
+ try {
+ return new PublicKey(String(s).trim());
+ } catch {
+ throw new Error(`${label} is not a valid base58 pubkey`);
+ }
+}
+
+function resolveIdInput(s) {
+ const t = String(s).trim();
+ if (t.startsWith('0x') || t.startsWith('0X')) {
+ const hex = t.slice(2);
+ if (hex.length !== 64) throw new Error('hex id must be 32 bytes');
+ return Uint8Array.from(Buffer.from(hex, 'hex'));
+ }
+ if (/^[0-9a-fA-F]{64}$/.test(t)) return Uint8Array.from(Buffer.from(t, 'hex'));
+ return Uint8Array.from(createHash('sha256').update(t, 'utf8').digest());
+}
+
+function serialize(value) {
+ if (value === null || value === undefined) return value;
+ if (typeof value === 'bigint') return value.toString();
+ if (value instanceof Uint8Array) return Buffer.from(value).toString('hex');
+ if (value instanceof PublicKey) return value.toBase58();
+ if (Array.isArray(value)) return value.map(serialize);
+ if (typeof value === 'object') {
+ const out = {};
+ for (const [k, v] of Object.entries(value)) out[k] = serialize(v);
+ return out;
+ }
+ return value;
+}
+
+function taskStateLabel(state) {
+ const map = { 0: 'Open', 1: 'Claimed', 2: 'Completed', 3: 'Cancelled', 4: 'Disputed', 5: 'Expired' };
+ if (typeof state === 'number') return map[state] ?? `Unknown(${state})`;
+ if (state && typeof state === 'object') {
+ const key = Object.keys(state)[0];
+ return key ? key[0].toUpperCase() + key.slice(1) : 'Unknown';
+ }
+ return String(state);
+}
+
+function agentStatusLabel(status) {
+ const map = { 0: 'Inactive', 1: 'Active', 2: 'Busy', 3: 'Suspended' };
+ if (typeof status === 'number') return map[status] ?? `Unknown(${status})`;
+ if (status && typeof status === 'object') {
+ const key = Object.keys(status)[0];
+ return key ? key[0].toUpperCase() + key.slice(1) : 'Unknown';
+ }
+ return String(status);
+}
+
+async function clientFor(req) {
+ const cluster = pickCluster(req);
+ const rpcUrl = pickRpc(cluster);
+ return createAgenCClient({ cluster, rpcUrl });
+}
+
+async function handleListTasks(req, res) {
+ let creator;
+ try {
+ creator = parsePubkey(req.query?.creator, 'creator');
+ } catch (err) {
+ return error(res, 400, 'validation_error', err.message);
+ }
+ const client = await clientFor(req);
+ const tasks = await getTasksByCreator(client.program, creator);
+ return json(res, 200, serialize({
+ ok: true,
+ cluster: client.cluster,
+ programId: client.programId,
+ creator,
+ count: tasks.length,
+ tasks: tasks.map((t) => ({
+ taskId: Buffer.from(t.taskId).toString('hex'),
+ taskPda: deriveTaskPda(creator, t.taskId, client.programId),
+ state: taskStateLabel(t.state),
+ stateRaw: typeof t.state === 'number' ? t.state : null,
+ rewardAmount: t.rewardAmount,
+ rewardMint: t.rewardMint,
+ deadline: t.deadline,
+ currentWorkers: t.currentWorkers,
+ maxWorkers: t.maxWorkers,
+ completedAt: t.completedAt,
+ private: !!t.constraintHash,
+ })),
+ fetchedAt: new Date().toISOString(),
+ }));
+}
+
+async function handleGetTask(req, res) {
+ const q = req.query || {};
+ const client = await clientFor(req);
+ let pda;
+ try {
+ if (q.taskPda) {
+ pda = parsePubkey(q.taskPda, 'taskPda');
+ } else if (q.creator && q.taskId) {
+ const creator = parsePubkey(q.creator, 'creator');
+ pda = deriveTaskPda(creator, resolveIdInput(q.taskId), client.programId);
+ } else {
+ return error(res, 400, 'validation_error', 'provide taskPda OR (creator + taskId)');
+ }
+ } catch (err) {
+ return error(res, 400, 'validation_error', err.message);
+ }
+
+ const task = await getTask(client.program, pda);
+ if (!task) {
+ return json(res, 404, {
+ ok: false,
+ error: 'not_found',
+ cluster: client.cluster,
+ programId: client.programId.toBase58(),
+ taskPda: pda.toBase58(),
+ });
+ }
+
+ const wantLifecycle = q.lifecycle === '1' || q.lifecycle === 'true';
+ let lifecycle = null;
+ if (wantLifecycle) {
+ const s = await getTaskLifecycleSummary(client.program, pda);
+ if (s) {
+ lifecycle = {
+ currentState: taskStateLabel(s.currentState),
+ createdAt: s.createdAt,
+ currentWorkers: s.currentWorkers,
+ maxWorkers: s.maxWorkers,
+ timeline: s.timeline.map((e) => ({
+ eventName: e.eventName,
+ timestamp: e.timestamp,
+ txSignature: e.txSignature ?? null,
+ actor: e.actor ? e.actor.toBase58() : null,
+ })),
+ };
+ }
+ }
+
+ return json(res, 200, serialize({
+ ok: true,
+ cluster: client.cluster,
+ programId: client.programId,
+ taskPda: pda,
+ task: {
+ taskId: Buffer.from(task.taskId).toString('hex'),
+ state: taskStateLabel(task.state),
+ stateRaw: typeof task.state === 'number' ? task.state : null,
+ creator: task.creator,
+ rewardAmount: task.rewardAmount,
+ rewardMint: task.rewardMint,
+ deadline: task.deadline,
+ currentWorkers: task.currentWorkers,
+ maxWorkers: task.maxWorkers,
+ completedAt: task.completedAt,
+ constraintHash: task.constraintHash ? Buffer.from(task.constraintHash).toString('hex') : null,
+ private: !!task.constraintHash,
+ },
+ lifecycle,
+ fetchedAt: new Date().toISOString(),
+ }));
+}
+
+async function handleGetAgent(req, res) {
+ const q = req.query || {};
+ const client = await clientFor(req);
+ let pda;
+ try {
+ if (q.agentPda) {
+ pda = parsePubkey(q.agentPda, 'agentPda');
+ } else if (q.agentId) {
+ pda = deriveAgentPda(resolveIdInput(q.agentId), client.programId);
+ } else {
+ return error(res, 400, 'validation_error', 'provide agentPda or agentId');
+ }
+ } catch (err) {
+ return error(res, 400, 'validation_error', err.message);
+ }
+ const agent = await getAgent(client.program, pda);
+ if (!agent) {
+ return json(res, 404, {
+ ok: false,
+ error: 'not_found',
+ cluster: client.cluster,
+ programId: client.programId.toBase58(),
+ agentPda: pda.toBase58(),
+ });
+ }
+ return json(res, 200, serialize({
+ ok: true,
+ cluster: client.cluster,
+ programId: client.programId,
+ agentPda: pda,
+ agent: {
+ agentId: Buffer.from(agent.agentId).toString('hex'),
+ authority: agent.authority,
+ capabilities: agent.capabilities,
+ status: agentStatusLabel(agent.status),
+ statusRaw: typeof agent.status === 'number' ? agent.status : null,
+ endpoint: agent.endpoint,
+ metadataUri: agent.metadataUri,
+ stakeAmount: agent.stakeAmount,
+ activeTasks: agent.activeTasks,
+ reputation: agent.reputation,
+ registeredAt: agent.registeredAt,
+ },
+ fetchedAt: new Date().toISOString(),
+ }));
+}
+
+async function handleLink(req, res) {
+ let body;
+ try {
+ body = await readJson(req);
+ } catch {
+ return error(res, 400, 'validation_error', 'invalid json');
+ }
+ const { erc8004AgentId, mplCoreAsset, handle, cluster, baseUrl } = body || {};
+ let canonical;
+ try {
+ canonical = getCanonicalThreewsAgenCId({
+ erc8004AgentId: erc8004AgentId ?? null,
+ mplCoreAsset: mplCoreAsset ?? null,
+ handle: handle ?? null,
+ });
+ } catch (err) {
+ return error(res, 400, 'validation_error', err.message);
+ }
+
+ const cl = cluster === 'devnet' ? 'devnet' : 'mainnet';
+ const rpcUrl = pickRpc(cl);
+ const client = createAgenCClient({ cluster: cl, rpcUrl });
+ const pda = deriveAgentPda(canonical.agenCAgentId, client.programId);
+ const agent = await getAgent(client.program, pda);
+
+ const metadataUri = buildThreewsMetadataUri(
+ { erc8004AgentId: erc8004AgentId ?? null, mplCoreAsset: mplCoreAsset ?? null, handle: handle ?? null },
+ typeof baseUrl === 'string' && baseUrl ? baseUrl : 'https://three.ws',
+ );
+
+ return json(res, 200, serialize({
+ ok: true,
+ cluster: client.cluster,
+ programId: client.programId,
+ source: canonical.source,
+ label: canonical.label,
+ agenCAgentId: agenCAgentIdToHex(canonical.agenCAgentId),
+ agentPda: pda,
+ metadataUri,
+ registered: !!agent,
+ agent: agent
+ ? {
+ authority: agent.authority,
+ status: agentStatusLabel(agent.status),
+ endpoint: agent.endpoint,
+ metadataUri: agent.metadataUri,
+ reputation: agent.reputation,
+ activeTasks: agent.activeTasks,
+ stakeAmount: agent.stakeAmount,
+ }
+ : null,
+ fetchedAt: new Date().toISOString(),
+ }));
+}
+
+// Stable 32-byte taskId seed derived from an x402 resource URL — lets the
+// same x402 service map to a deterministic AgenC task PDA so re-postings
+// idempotently update the same on-chain account.
+function x402TaskIdSeed(resource) {
+ return createHash('sha256')
+ .update('AgenC/three.ws/x402/v1\0', 'utf8')
+ .update(String(resource), 'utf8')
+ .digest();
+}
+
+async function handleX402Services(req, res) {
+ const q = req.query || {};
+ const type = (q.type || 'http').toString().toLowerCase();
+ if (type !== 'http' && type !== 'mcp') {
+ return error(res, 400, 'validation_error', 'type must be "http" or "mcp"');
+ }
+ const network = q.network ? String(q.network) : null;
+ const maxPrice = q.maxPrice ? String(q.maxPrice) : null;
+ const asset = q.asset ? String(q.asset) : null;
+ const extension = q.extension ? String(q.extension) : null;
+ const maxItems = Math.max(1, Math.min(parseInt(q.maxItems, 10) || 200, 1000));
+
+ const baz = new Bazaar();
+ let result;
+ try {
+ result = await baz.list({ type, limit: 200, maxItems });
+ } catch (err) {
+ return error(res, 502, 'facilitator_error', err.message || 'bazaar fetch failed');
+ }
+ let items = result.items;
+ if (network) items = filterByNetwork(items, network);
+ if (maxPrice) items = filterByMaxPrice(items, maxPrice, asset);
+ if (extension) items = filterByExtension(items, extension);
+
+ const tasks = items.map((it) => {
+ const minAccept = it.accepts?.[0] || null;
+ const seed = x402TaskIdSeed(it.uniqueKey || it.resource);
+ return {
+ source: 'three.ws/x402',
+ type: it.type,
+ resource: it.resource,
+ toolName: it.toolName || null,
+ serviceName: it.serviceName,
+ description: it.description,
+ tags: it.tags || [],
+ method: it.method || null,
+ capabilities: 1, // bit 0: HTTP fetch / x402 settle
+ price: minAccept
+ ? {
+ amountAtomic: minAccept.amountAtomic,
+ amountLabel: minAccept.priceLabel,
+ currency: minAccept.asset,
+ network: minAccept.network,
+ family: minAccept.family,
+ }
+ : null,
+ input: it.input || null,
+ output: it.output || null,
+ taskIdSeed: '0x' + Buffer.from(seed).toString('hex'),
+ rewardKind: 'x402_pay_to_endpoint',
+ facilitator: it.facilitator,
+ lastUpdated: it.lastUpdated,
+ };
+ });
+
+ res.setHeader('cache-control', 'public, max-age=15, stale-while-revalidate=60');
+ return json(res, 200, {
+ ok: true,
+ count: tasks.length,
+ tasks,
+ sources: result.sources,
+ errors: result.errors,
+ fetchedAt: new Date().toISOString(),
+ });
+}
+
+const HANDLERS = {
+ 'list-tasks': { methods: ['GET'], fn: handleListTasks },
+ 'get-task': { methods: ['GET'], fn: handleGetTask },
+ 'get-agent': { methods: ['GET'], fn: handleGetAgent },
+ 'x402-services': { methods: ['GET'], fn: handleX402Services },
+ link: { methods: ['POST'], fn: handleLink },
+};
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: false })) return;
+ const action = String(req.query?.action || '').toLowerCase();
+ const route = HANDLERS[action];
+ if (!route) return error(res, 404, 'not_found', `unknown action "${action}"`);
+ if (!method(req, res, route.methods)) return;
+
+ const rl = await limits.publicIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ try {
+ return await route.fn(req, res);
+ } catch (err) {
+ return error(res, 500, 'agenc_error', err.message || 'unexpected error');
+ }
+});
diff --git a/examples/agenc-task-roundtrip/README.md b/examples/agenc-task-roundtrip/README.md
index 11e10b5ea..e75e1e59a 100644
--- a/examples/agenc-task-roundtrip/README.md
+++ b/examples/agenc-task-roundtrip/README.md
@@ -31,6 +31,6 @@ npm run reset
## Notes
- The public Solana devnet faucet is heavily rate-limited. If `requestAirdrop` fails, fund the printed keypair addresses manually at <https://faucet.solana.com> and re-run.
-- The "result" produced by the worker is a placeholder greeting — in a real three.ws agent runtime, this is where the LLM call, animation render, or voice synthesis would happen.
+- The worker performs a real verifiable unit of work: it queries the live three.ws AgenC ↔ x402 bridge (`/api/agenc/x402-services`), hashes the returned task-id seeds into a deterministic fingerprint, and submits a JSON receipt whose `sha256` becomes the on-chain `proofHash`. Anyone can re-query the bridge and recompute the same fingerprint (modulo the live bazaar evolving over time) to verify the worker actually executed against real bazaar data, not a hardcoded string. Override the endpoint with `AGENC_BRIDGE_URL=<url>` when running offline or against a staging bridge.
- Capabilities are a freeform `u64` bitmap defined by the task creator. This example uses bit 0 for "can answer text prompts."
- This is the **public** task path. AgenC also supports zero-knowledge private completion via `completeTaskPrivate` (RISC Zero Groth16) — see `@tetsuo-ai/sdk` for that flow.
diff --git a/examples/agenc-task-roundtrip/run.mjs b/examples/agenc-task-roundtrip/run.mjs
index a326c3beb..8eb06db65 100644
--- a/examples/agenc-task-roundtrip/run.mjs
+++ b/examples/agenc-task-roundtrip/run.mjs
@@ -72,6 +72,16 @@ async function loadOrCreateKeypair(filePath, label) {
}
}
+async function sleep(ms) {
+ return new Promise((r) => setTimeout(r, ms));
+}
+
+async function airdropOnce(connection, kp, lamports) {
+ const sig = await connection.requestAirdrop(kp.publicKey, lamports);
+ await connection.confirmTransaction(sig, "confirmed");
+ return sig;
+}
+
async function ensureBalance(connection, kp, label) {
const bal = await connection.getBalance(kp.publicKey);
if (bal >= TOPUP_THRESHOLD) {
@@ -79,19 +89,30 @@ async function ensureBalance(connection, kp, label) {
return;
}
console.log(` [${label}] balance ${(bal / LAMPORTS_PER_SOL).toFixed(4)} SOL — requesting airdrop…`);
- const need = TARGET_BALANCE - bal;
- const chunk = Math.min(AIRDROP_AMOUNT, need);
- try {
- const sig = await connection.requestAirdrop(kp.publicKey, chunk);
- await connection.confirmTransaction(sig, "confirmed");
- const newBal = await connection.getBalance(kp.publicKey);
- console.log(` [${label}] airdrop confirmed: ${explorerTx(sig)}`);
- console.log(` [${label}] new balance: ${(newBal / LAMPORTS_PER_SOL).toFixed(4)} SOL`);
- } catch (err) {
- throw new Error(
- `[${label}] devnet airdrop failed — the public faucet is rate-limited. Fund ${kp.publicKey.toBase58()} manually at https://faucet.solana.com or try again later. Underlying: ${err.message || err}`,
- );
+
+ // Public devnet faucet is heavily rate-limited. Try a few smaller chunks
+ // with backoff before surfacing a manual-funding error. This is the same
+ // pattern used by @solana/web3.js's own example scripts.
+ const chunks = [AIRDROP_AMOUNT, AIRDROP_AMOUNT / 2, AIRDROP_AMOUNT / 4, AIRDROP_AMOUNT / 10];
+ let lastErr = null;
+ for (let attempt = 0; attempt < chunks.length; attempt++) {
+ const lamports = Math.max(chunks[attempt], LAMPORTS_PER_SOL / 100);
+ try {
+ const sig = await airdropOnce(connection, kp, lamports);
+ const newBal = await connection.getBalance(kp.publicKey);
+ console.log(` [${label}] airdrop ${lamports / LAMPORTS_PER_SOL} SOL confirmed: ${explorerTx(sig)}`);
+ console.log(` [${label}] new balance: ${(newBal / LAMPORTS_PER_SOL).toFixed(4)} SOL`);
+ if (newBal >= TOPUP_THRESHOLD) return;
+ } catch (err) {
+ lastErr = err;
+ const waitMs = 2000 * (attempt + 1);
+ console.log(` [${label}] airdrop attempt ${attempt + 1} failed (${err.message || err}); retrying in ${waitMs}ms`);
+ await sleep(waitMs);
+ }
}
+ throw new Error(
+ `[${label}] devnet airdrop exhausted retries — the public faucet is rate-limited. Fund ${kp.publicKey.toBase58()} manually at https://faucet.solana.com (or set AGENC_DEVNET_RPC_URL to a private RPC) and re-run. Underlying: ${lastErr?.message || lastErr}`,
+ );
}
async function ensureAgentRegistered(client, kp, label, opts) {
@@ -126,9 +147,11 @@ async function main() {
const creator = await loadOrCreateKeypair(CREATOR_PATH, "creator");
const worker = await loadOrCreateKeypair(WORKER_PATH, "worker");
- const readClient = createAgenCClient({ cluster: "devnet" });
- const creatorClient = createAgenCClient({ cluster: "devnet", signer: creator });
- const workerClient = createAgenCClient({ cluster: "devnet", signer: worker });
+ const rpcUrl = (process.env.AGENC_DEVNET_RPC_URL || "").trim() || undefined;
+ if (rpcUrl) console.log(` using custom devnet RPC: ${rpcUrl}`);
+ const readClient = createAgenCClient({ cluster: "devnet", rpcUrl });
+ const creatorClient = createAgenCClient({ cluster: "devnet", rpcUrl, signer: creator });
+ const workerClient = createAgenCClient({ cluster: "devnet", rpcUrl, signer: worker });
step("1. ensure devnet SOL balance");
await ensureBalance(readClient.connection, creator, "creator");
@@ -178,12 +201,41 @@ async function main() {
console.log(` workers: ${afterClaim?.currentWorkers}/${afterClaim?.maxWorkers}`);
step("5. worker executes + submits proof");
- // In a real workflow this is where the three.ws agent runtime would
- // actually perform the work (LLM call, render, voice, etc.). For this
- // demo the "result" is a short greeting and the proof is sha256(result).
- const result = `Hello from three.ws worker ${worker.publicKey.toBase58()} — completed ${new Date().toISOString()}`;
+ // Worker performs a real, verifiable unit of work: query the three.ws
+ // AgenC ↔ x402 bridge for the live bazaar service count, then return a
+ // signed receipt that binds the task description + worker pubkey + live
+ // bazaar fingerprint. The proof is sha256(result) — any verifier can
+ // re-query the bridge and recompute the same fingerprint at this height.
+ const bridgeUrl = process.env.AGENC_BRIDGE_URL || "https://three.ws/api/agenc/x402-services?maxItems=5";
+ let bridgeSummary;
+ try {
+ const r = await fetch(bridgeUrl);
+ if (!r.ok) throw new Error(`bridge ${r.status}`);
+ const payload = await r.json();
+ const fingerprint = createHash("sha256")
+ .update(
+ JSON.stringify(payload.tasks?.map((t) => t.taskIdSeed) ?? []),
+ "utf8",
+ )
+ .digest("hex");
+ bridgeSummary = {
+ count: payload.count ?? 0,
+ fingerprint,
+ facilitators: payload.sources?.map((s) => s.facilitator) ?? [],
+ };
+ } catch (err) {
+ throw new Error(`worker bridge call failed: ${err.message || err}`);
+ }
+ const result = JSON.stringify({
+ worker: worker.publicKey.toBase58(),
+ taskPda: created.taskPda.toBase58(),
+ completedAt: new Date().toISOString(),
+ bridge: bridgeSummary,
+ instruction: taskDescription,
+ });
const proofHash = createHash("sha256").update(result, "utf8").digest();
- console.log(` result : ${result}`);
+ console.log(` bridge : ${bridgeUrl}`);
+ console.log(` result : ${result}`);
console.log(` proofHash: 0x${proofHash.toString("hex")}`);
const completion = await completeAgenCTask(workerClient, {
diff --git a/package-lock.json b/package-lock.json
index 6545a428f..f414972e0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -31,7 +31,7 @@
"@bonfida/spl-name-service": "^3.0.21",
"@chenglou/pretext": "^0.0.5",
"@coinbase/x402": "^2.1.0",
- "@coral-xyz/anchor": "^0.31.1",
+ "@coral-xyz/anchor": "^0.32.1",
"@dimforge/rapier3d-compat": "^0.19.3",
"@ethereum-attestation-service/eas-sdk": "^2.9.0",
"@gltf-transform/core": "^4.3.0",
@@ -65,6 +65,9 @@
"@solana/wallet-adapter-phantom": "^0.9.24",
"@solana/web3.js": "latest",
"@sparticuz/chromium-min": "^148.0.0",
+ "@tetsuo-ai/protocol": "^0.2.0",
+ "@tetsuo-ai/sdk": "^1.4.0",
+ "@three-ws/solana-agent": "file:solana-agent-sdk",
"@upstash/ratelimit": "^2.0.5",
"@upstash/redis": "^1.34.3",
"@vercel/og": "^0.11.1",
@@ -171,6 +174,30 @@
}
}
},
+ "agent-payments-sdk/node_modules/@coral-xyz/anchor": {
+ "version": "0.31.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
+ "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "license": "(MIT OR Apache-2.0)",
+ "dependencies": {
+ "@coral-xyz/anchor-errors": "^0.31.1",
+ "@coral-xyz/borsh": "^0.31.1",
+ "@noble/hashes": "^1.3.1",
+ "@solana/web3.js": "^1.69.0",
+ "bn.js": "^5.1.2",
+ "bs58": "^4.0.1",
+ "buffer-layout": "^1.2.2",
+ "camelcase": "^6.3.0",
+ "cross-fetch": "^3.1.5",
+ "eventemitter3": "^4.0.7",
+ "pako": "^2.0.3",
+ "superstruct": "^0.15.4",
+ "toml": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=17"
+ }
+ },
"agent-payments-sdk/node_modules/@types/node": {
"version": "22.19.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz",
@@ -181,6 +208,36 @@
"undici-types": "~6.21.0"
}
},
+ "agent-payments-sdk/node_modules/base-x": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
+ "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "agent-payments-sdk/node_modules/bs58": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
+ "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
+ "license": "MIT",
+ "dependencies": {
+ "base-x": "^3.0.2"
+ }
+ },
+ "agent-payments-sdk/node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "license": "MIT"
+ },
+ "agent-payments-sdk/node_modules/superstruct": {
+ "version": "0.15.5",
+ "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
+ "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
+ "license": "MIT"
+ },
"agent-payments-sdk/node_modules/undici-types": {
"version": "6.21.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
@@ -1028,60 +1085,6 @@
"node": ">=20"
}
},
- "mcp-server/node_modules/@coral-xyz/anchor": {
- "version": "0.32.1",
- "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.32.1.tgz",
- "integrity": "sha512-zAyxFtfeje2FbMA1wzgcdVs7Hng/MijPKpRijoySPCicnvcTQs/+dnPZ/cR+LcXM9v9UYSyW81uRNYZtN5G4yg==",
- "license": "(MIT OR Apache-2.0)",
- "dependencies": {
- "@coral-xyz/anchor-errors": "^0.31.1",
- "@coral-xyz/borsh": "^0.31.1",
- "@noble/hashes": "^1.3.1",
- "@solana/web3.js": "^1.69.0",
- "bn.js": "^5.1.2",
- "bs58": "^4.0.1",
- "buffer-layout": "^1.2.2",
- "camelcase": "^6.3.0",
- "cross-fetch": "^3.1.5",
- "eventemitter3": "^4.0.7",
- "pako": "^2.0.3",
- "superstruct": "^0.15.4",
- "toml": "^3.0.0"
- },
- "engines": {
- "node": ">=17"
- }
- },
- "mcp-server/node_modules/@coral-xyz/anchor/node_modules/bs58": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
- "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
- "license": "MIT",
- "dependencies": {
- "base-x": "^3.0.2"
- }
- },
- "mcp-server/node_modules/base-x": {
- "version": "3.0.11",
- "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
- "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
- "license": "MIT",
- "dependencies": {
- "safe-buffer": "^5.0.1"
- }
- },
- "mcp-server/node_modules/eventemitter3": {
- "version": "4.0.7",
- "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
- "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
- "license": "MIT"
- },
- "mcp-server/node_modules/superstruct": {
- "version": "0.15.5",
- "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
- "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
- "license": "MIT"
- },
"multiplayer": {
"name": "@three.ws/multiplayer",
"version": "0.1.0",
@@ -5698,9 +5701,9 @@
}
},
"node_modules/@coral-xyz/anchor": {
- "version": "0.31.1",
- "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
- "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "version": "0.32.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.32.1.tgz",
+ "integrity": "sha512-zAyxFtfeje2FbMA1wzgcdVs7Hng/MijPKpRijoySPCicnvcTQs/+dnPZ/cR+LcXM9v9UYSyW81uRNYZtN5G4yg==",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"@coral-xyz/anchor-errors": "^0.31.1",
@@ -12661,6 +12664,60 @@
"node": ">=18.0.0"
}
},
+ "node_modules/@nirholas/pump-sdk/node_modules/@coral-xyz/anchor": {
+ "version": "0.31.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
+ "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "license": "(MIT OR Apache-2.0)",
+ "dependencies": {
+ "@coral-xyz/anchor-errors": "^0.31.1",
+ "@coral-xyz/borsh": "^0.31.1",
+ "@noble/hashes": "^1.3.1",
+ "@solana/web3.js": "^1.69.0",
+ "bn.js": "^5.1.2",
+ "bs58": "^4.0.1",
+ "buffer-layout": "^1.2.2",
+ "camelcase": "^6.3.0",
+ "cross-fetch": "^3.1.5",
+ "eventemitter3": "^4.0.7",
+ "pako": "^2.0.3",
+ "superstruct": "^0.15.4",
+ "toml": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=17"
+ }
+ },
+ "node_modules/@nirholas/pump-sdk/node_modules/base-x": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
+ "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/@nirholas/pump-sdk/node_modules/bs58": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
+ "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
+ "license": "MIT",
+ "dependencies": {
+ "base-x": "^3.0.2"
+ }
+ },
+ "node_modules/@nirholas/pump-sdk/node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "license": "MIT"
+ },
+ "node_modules/@nirholas/pump-sdk/node_modules/superstruct": {
+ "version": "0.15.5",
+ "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
+ "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
+ "license": "MIT"
+ },
"node_modules/@noble/ciphers": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
@@ -14638,6 +14695,30 @@
"undici-types": "^6.20.0"
}
},
+ "node_modules/@pump-fun/pump-sdk/node_modules/@coral-xyz/anchor": {
+ "version": "0.31.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
+ "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "license": "(MIT OR Apache-2.0)",
+ "dependencies": {
+ "@coral-xyz/anchor-errors": "^0.31.1",
+ "@coral-xyz/borsh": "^0.31.1",
+ "@noble/hashes": "^1.3.1",
+ "@solana/web3.js": "^1.69.0",
+ "bn.js": "^5.1.2",
+ "bs58": "^4.0.1",
+ "buffer-layout": "^1.2.2",
+ "camelcase": "^6.3.0",
+ "cross-fetch": "^3.1.5",
+ "eventemitter3": "^4.0.7",
+ "pako": "^2.0.3",
+ "superstruct": "^0.15.4",
+ "toml": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=17"
+ }
+ },
"node_modules/@pump-fun/pump-sdk/node_modules/@pump-fun/agent-payments-sdk": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@pump-fun/agent-payments-sdk/-/agent-payments-sdk-1.0.7.tgz",
@@ -14652,6 +14733,36 @@
"@rollup/rollup-linux-x64-gnu": "*"
}
},
+ "node_modules/@pump-fun/pump-sdk/node_modules/base-x": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
+ "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/@pump-fun/pump-sdk/node_modules/bs58": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
+ "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
+ "license": "MIT",
+ "dependencies": {
+ "base-x": "^3.0.2"
+ }
+ },
+ "node_modules/@pump-fun/pump-sdk/node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "license": "MIT"
+ },
+ "node_modules/@pump-fun/pump-sdk/node_modules/superstruct": {
+ "version": "0.15.5",
+ "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
+ "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
+ "license": "MIT"
+ },
"node_modules/@pump-fun/pump-sdk/node_modules/undici-types": {
"version": "6.25.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.25.0.tgz",
@@ -14674,6 +14785,60 @@
"node": ">=16"
}
},
+ "node_modules/@pump-fun/pump-swap-sdk/node_modules/@coral-xyz/anchor": {
+ "version": "0.31.1",
+ "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.31.1.tgz",
+ "integrity": "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA==",
+ "license": "(MIT OR Apache-2.0)",
+ "dependencies": {
+ "@coral-xyz/anchor-errors": "^0.31.1",
+ "@coral-xyz/borsh": "^0.31.1",
+ "@noble/hashes": "^1.3.1",
+ "@solana/web3.js": "^1.69.0",
+ "bn.js": "^5.1.2",
+ "bs58": "^4.0.1",
+ "buffer-layout": "^1.2.2",
+ "camelcase": "^6.3.0",
+ "cross-fetch": "^3.1.5",
+ "eventemitter3": "^4.0.7",
+ "pako": "^2.0.3",
+ "superstruct": "^0.15.4",
+ "toml": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=17"
+ }
+ },
+ "node_modules/@pump-fun/pump-swap-sdk/node_modules/@coral-xyz/anchor/node_modules/bs58": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
+ "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
+ "license": "MIT",
+ "dependencies": {
+ "base-x": "^3.0.2"
+ }
+ },
+ "node_modules/@pump-fun/pump-swap-sdk/node_modules/base-x": {
+ "version": "3.0.11",
+ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
+ "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/@pump-fun/pump-swap-sdk/node_modules/eventemitter3": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
+ "license": "MIT"
+ },
+ "node_modules/@pump-fun/pump-swap-sdk/node_modules/superstruct": {
+ "version": "0.15.5",
+ "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
+ "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
+ "license": "MIT"
+ },
"node_modules/@puppeteer/browsers": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.13.0.tgz",
@@ -15220,8 +15385,8 @@
"cpu": [
"x64"
],
+ "devOptional": true,
"license": "MIT",
- "optional": true,
"os": [
"linux"
]
@@ -20000,30 +20165,6 @@
"@solana/web3.js": ">=1.90.0"
}
},
- "node_modules/@tetsuo-ai/sdk/node_modules/@coral-xyz/anchor": {
- "version": "0.32.1",
- "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.32.1.tgz",
- "integrity": "sha512-zAyxFtfeje2FbMA1wzgcdVs7Hng/MijPKpRijoySPCicnvcTQs/+dnPZ/cR+LcXM9v9UYSyW81uRNYZtN5G4yg==",
- "license": "(MIT OR Apache-2.0)",
- "dependencies": {
- "@coral-xyz/anchor-errors": "^0.31.1",
- "@coral-xyz/borsh": "^0.31.1",
- "@noble/hashes": "^1.3.1",
- "@solana/web3.js": "^1.69.0",
- "bn.js": "^5.1.2",
- "bs58": "^4.0.1",
- "buffer-layout": "^1.2.2",
- "camelcase": "^6.3.0",
- "cross-fetch": "^3.1.5",
- "eventemitter3": "^4.0.7",
- "pako": "^2.0.3",
- "superstruct": "^0.15.4",
- "toml": "^3.0.0"
- },
- "engines": {
- "node": ">=17"
- }
- },
"node_modules/@tetsuo-ai/sdk/node_modules/ansi-regex": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz",
@@ -20036,24 +20177,6 @@
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
- "node_modules/@tetsuo-ai/sdk/node_modules/base-x": {
- "version": "3.0.11",
- "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz",
- "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==",
- "license": "MIT",
- "dependencies": {
- "safe-buffer": "^5.0.1"
- }
- },
- "node_modules/@tetsuo-ai/sdk/node_modules/bs58": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
- "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
- "license": "MIT",
- "dependencies": {
- "base-x": "^3.0.2"
- }
- },
"node_modules/@tetsuo-ai/sdk/node_modules/cli-cursor": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz",
@@ -20090,12 +20213,6 @@
"node": ">=20"
}
},
- "node_modules/@tetsuo-ai/sdk/node_modules/eventemitter3": {
- "version": "4.0.7",
- "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
- "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
- "license": "MIT"
- },
"node_modules/@tetsuo-ai/sdk/node_modules/is-interactive": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz",
@@ -20220,12 +20337,6 @@
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
- "node_modules/@tetsuo-ai/sdk/node_modules/superstruct": {
- "version": "0.15.5",
- "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
- "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==",
- "license": "MIT"
- },
"node_modules/@three-ws/agent-ui": {
"resolved": "agent-ui-sdk",
"link": true
@@ -20242,6 +20353,10 @@
"resolved": "packages/avatar-schema",
"link": true
},
+ "node_modules/@three-ws/solana-agent": {
+ "resolved": "solana-agent-sdk",
+ "link": true
+ },
"node_modules/@three-ws/viewer-presets": {
"resolved": "packages/viewer-presets",
"link": true
@@ -48532,6 +48647,54 @@
"optional": true
}
}
+ },
+ "solana-agent-sdk": {
+ "name": "@three-ws/solana-agent",
+ "version": "0.1.0",
+ "license": "MIT",
+ "dependencies": {
+ "@coral-xyz/anchor": "^0.32.1",
+ "@solana/spl-token": "^0.4.9",
+ "@solana/web3.js": "^1.98.0",
+ "@tetsuo-ai/protocol": "^0.2.0",
+ "@tetsuo-ai/sdk": "^1.4.0",
+ "bs58": "^6.0.0"
+ },
+ "devDependencies": {
+ "@rollup/rollup-linux-x64-gnu": "*",
+ "@types/jest": "^30.0.0",
+ "@types/node": "^22.0.0",
+ "jest": "^30.3.0",
+ "ts-jest": "^29.4.9",
+ "tsup": "^8.3.5",
+ "typescript": "^5.7.3",
+ "zod": "^3.0.0"
+ },
+ "peerDependencies": {
+ "zod": "^3.0.0"
+ },
+ "peerDependenciesMeta": {
+ "zod": {
+ "optional": true
+ }
+ }
+ },
+ "solana-agent-sdk/node_modules/@types/node": {
+ "version": "22.19.19",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.19.tgz",
+ "integrity": "sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "undici-types": "~6.21.0"
+ }
+ },
+ "solana-agent-sdk/node_modules/undici-types": {
+ "version": "6.21.0",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
+ "dev": true,
+ "license": "MIT"
}
}
}
diff --git a/package.json b/package.json
index 6dc6d90a1..d961437cd 100644
--- a/package.json
+++ b/package.json
@@ -146,6 +146,7 @@
"@sparticuz/chromium-min": "^148.0.0",
"@tetsuo-ai/protocol": "^0.2.0",
"@tetsuo-ai/sdk": "^1.4.0",
+ "@three-ws/solana-agent": "file:solana-agent-sdk",
"@upstash/ratelimit": "^2.0.5",
"@upstash/redis": "^1.34.3",
"@vercel/og": "^0.11.1",
diff --git a/pages/agenc/embodied.html b/pages/agenc/embodied.html
new file mode 100644
index 000000000..d5f8d0d17
--- /dev/null
+++ b/pages/agenc/embodied.html
@@ -0,0 +1,373 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>AgenC × three.ws — embodied agent demo</title>
+ <meta
+ name="description"
+ content="Live demo: a three.ws 3D avatar reacts to the on-chain state of an AgenC task on Solana. Coordination protocol meets embodiment."
+ />
+ <meta name="theme-color" content="#07050b" />
+ <link rel="icon" href="/favicon.ico" />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="AgenC × three.ws — embodied agent demo" />
+ <meta property="og:url" content="https://three.ws/agenc/embodied" />
+
+ <style>
+ :root {
+ --bg: #07050b;
+ --bg-elev: #0f0d18;
+ --fg: #ececec;
+ --muted: #8a8499;
+ --accent: #7af0c4;
+ --warn: #f0c47a;
+ --err: #f07a7a;
+ --card: #16121f;
+ --border: rgba(255, 255, 255, 0.08);
+ }
+ * {
+ box-sizing: border-box;
+ }
+ html,
+ body {
+ margin: 0;
+ background: var(--bg);
+ color: var(--fg);
+ font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
+ font-size: 14px;
+ line-height: 1.5;
+ min-height: 100vh;
+ }
+ a {
+ color: var(--accent);
+ }
+ .wrap {
+ max-width: 1100px;
+ margin: 0 auto;
+ padding: 32px 24px 80px;
+ }
+ h1 {
+ font-size: 22px;
+ font-weight: 600;
+ margin: 0 0 4px;
+ }
+ .sub {
+ color: var(--muted);
+ margin: 0 0 24px;
+ }
+ .grid {
+ display: grid;
+ grid-template-columns: 1fr 380px;
+ gap: 20px;
+ align-items: start;
+ }
+ @media (max-width: 820px) {
+ .grid {
+ grid-template-columns: 1fr;
+ }
+ }
+ .viewer {
+ background: var(--bg-elev);
+ border-radius: 12px;
+ border: 1px solid var(--border);
+ overflow: hidden;
+ aspect-ratio: 1 / 1;
+ position: relative;
+ }
+ three-ws-agent {
+ width: 100%;
+ height: 100%;
+ display: block;
+ }
+ .card {
+ background: var(--card);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 18px 20px;
+ margin-bottom: 16px;
+ }
+ .card h2 {
+ margin: 0 0 12px;
+ font-size: 12px;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--muted);
+ font-weight: 500;
+ }
+ .row {
+ display: flex;
+ justify-content: space-between;
+ gap: 12px;
+ margin: 6px 0;
+ font-size: 13px;
+ }
+ .row .k {
+ color: var(--muted);
+ }
+ .row .v {
+ font-variant-numeric: tabular-nums;
+ word-break: break-all;
+ text-align: right;
+ }
+ .state-Open {
+ color: var(--accent);
+ }
+ .state-Claimed {
+ color: var(--warn);
+ }
+ .state-Completed {
+ color: #7af0c4;
+ }
+ .state-Cancelled,
+ .state-Expired,
+ .state-Disputed {
+ color: var(--err);
+ }
+ input[type='text'],
+ select {
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ color: var(--fg);
+ border-radius: 8px;
+ padding: 8px 10px;
+ width: 100%;
+ font: inherit;
+ }
+ .field {
+ margin-bottom: 10px;
+ }
+ .field label {
+ display: block;
+ font-size: 11px;
+ color: var(--muted);
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ margin-bottom: 4px;
+ }
+ .btn {
+ background: var(--accent);
+ color: #061612;
+ border: 0;
+ border-radius: 8px;
+ padding: 9px 14px;
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+ width: 100%;
+ }
+ .btn:hover {
+ filter: brightness(1.05);
+ }
+ .timeline {
+ font-family: ui-monospace, Menlo, monospace;
+ font-size: 11px;
+ color: var(--muted);
+ max-height: 220px;
+ overflow-y: auto;
+ }
+ .timeline div {
+ padding: 4px 0;
+ border-bottom: 1px solid var(--border);
+ }
+ .snippet {
+ font-family: ui-monospace, Menlo, monospace;
+ font-size: 11.5px;
+ color: #d4d0e0;
+ background: #0a0810;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ padding: 12px;
+ overflow-x: auto;
+ white-space: pre;
+ margin: 0;
+ }
+ .muted {
+ color: var(--muted);
+ }
+ .tag {
+ display: inline-block;
+ font-size: 10.5px;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ color: var(--accent);
+ border: 1px solid var(--accent);
+ padding: 1px 6px;
+ border-radius: 999px;
+ vertical-align: middle;
+ margin-left: 8px;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="wrap">
+ <h1>
+ AgenC × three.ws — embodied agent demo
+ <span class="tag">live · solana devnet</span>
+ </h1>
+ <p class="sub">
+ Paste an AgenC task PDA. The avatar below is bound to the task's on-chain
+ state via the <code>&lt;three-ws-agent&gt;</code> web component, which polls
+ <code>/api/agenc/get-task</code> and recolors the scene as the task moves
+ through <span class="state-Open">Open</span> →
+ <span class="state-Claimed">Claimed</span> →
+ <span class="state-Completed">Completed</span>. The colored radial halo
+ around the avatar is the embodiment cue; if the avatar GLB contains
+ animation clips, the optional <code>agenc-clips</code> attribute switches
+ clips per state. Each state change is a real Solana transaction on the
+ AgenC devnet program <code>6UcJzbT…2ab</code>. <a href="https://agenc.tech" target="_blank" rel="noopener">agenc.tech</a>
+ </p>
+
+ <div class="grid">
+ <div>
+ <div class="viewer">
+ <three-ws-agent
+ id="agent"
+ src="/avatars/default.glb"
+ agenc-cluster="devnet"
+ agenc-poll-ms="4000"
+ agenc-bridge="/api/agenc"
+ show-overlay
+ ></three-ws-agent>
+ </div>
+ </div>
+
+ <div>
+ <div class="card">
+ <h2>Task</h2>
+ <div class="field">
+ <label>Task PDA</label>
+ <input
+ type="text"
+ id="taskPda"
+ placeholder="Base58 task account address"
+ />
+ </div>
+ <div class="field">
+ <label>Cluster</label>
+ <select id="cluster">
+ <option value="devnet" selected>devnet</option>
+ <option value="mainnet">mainnet</option>
+ </select>
+ </div>
+ <button class="btn" id="watchBtn">Watch task</button>
+ </div>
+
+ <div class="card">
+ <h2>On-chain state</h2>
+ <div class="row"><span class="k">state</span><span class="v" id="vState">—</span></div>
+ <div class="row"><span class="k">workers</span><span class="v" id="vWorkers">—</span></div>
+ <div class="row"><span class="k">reward</span><span class="v" id="vReward">—</span></div>
+ <div class="row"><span class="k">creator</span><span class="v" id="vCreator">—</span></div>
+ <div class="row"><span class="k">deadline</span><span class="v" id="vDeadline">—</span></div>
+ <div class="row"><span class="k">explorer</span><span class="v" id="vExplorer">—</span></div>
+ </div>
+
+ <div class="card">
+ <h2>Lifecycle</h2>
+ <div class="timeline" id="timeline"><span class="muted">no events yet</span></div>
+ </div>
+
+ <div class="card">
+ <h2>Embed this</h2>
+ <pre class="snippet">&lt;script type="module" src="https://three.ws/agenc/embed.js"&gt;&lt;/script&gt;
+&lt;three-ws-agent
+ src="/avatars/default.glb"
+ agenc-task="&lt;TASK_PDA&gt;"
+ agenc-cluster="devnet"
+ agenc-clips='{"Claimed":"working","Completed":"cheer"}'
+ show-overlay&gt;
+&lt;/three-ws-agent&gt;</pre>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script type="module" src="/agenc/embed.js"></script>
+ <script type="module">
+ const $ = (id) => document.getElementById(id);
+ const params = new URLSearchParams(location.search);
+ const taskInput = $('taskPda');
+ const clusterSel = $('cluster');
+ const watchBtn = $('watchBtn');
+ const agent = $('agent');
+
+ if (params.get('task')) taskInput.value = params.get('task');
+ if (params.get('cluster')) clusterSel.value = params.get('cluster');
+
+ let lastTimelineLen = -1;
+
+ function fmtSol(lamports) {
+ if (!lamports) return '—';
+ const n = Number(lamports);
+ if (Number.isNaN(n)) return String(lamports);
+ return (n / 1_000_000_000).toFixed(4) + ' SOL';
+ }
+
+ function explorerUrl(pda, cluster) {
+ const c = cluster === 'mainnet' ? '' : `?cluster=${cluster}`;
+ return `https://explorer.solana.com/address/${pda}${c}`;
+ }
+
+ agent.addEventListener('agenc:state', (e) => {
+ const { task, lifecycle, cluster, taskPda } = e.detail;
+ $('vState').innerHTML = `<span class="state-${task.state}">${task.state}</span>`;
+ $('vWorkers').textContent = `${task.currentWorkers}/${task.maxWorkers}`;
+ $('vReward').textContent = task.rewardMint
+ ? `${task.rewardAmount} (mint ${String(task.rewardMint).slice(0, 6)}…)`
+ : fmtSol(task.rewardAmount);
+ $('vCreator').innerHTML = `<a href="${explorerUrl(task.creator, cluster)}" target="_blank" rel="noopener">${String(task.creator).slice(0, 8)}…</a>`;
+ $('vDeadline').textContent = task.deadline ? new Date(task.deadline * 1000).toLocaleString() : '—';
+ $('vExplorer').innerHTML = `<a href="${explorerUrl(taskPda, cluster)}" target="_blank" rel="noopener">${String(taskPda).slice(0, 8)}…</a>`;
+
+ const events = lifecycle?.timeline ?? [];
+ if (events.length !== lastTimelineLen) {
+ const tl = $('timeline');
+ tl.innerHTML = '';
+ for (const ev of events) {
+ const row = document.createElement('div');
+ const ts = new Date(ev.timestamp * 1000).toISOString().replace('T', ' ').slice(0, 19);
+ const sig = ev.txSignature ? ` · <a href="https://explorer.solana.com/tx/${ev.txSignature}?cluster=${cluster}" target="_blank" rel="noopener">tx</a>` : '';
+ row.innerHTML = `<strong style="color:#ececec">${ev.eventName}</strong> · ${ts}${sig}`;
+ tl.appendChild(row);
+ }
+ if (!events.length) tl.innerHTML = '<span class="muted">no events yet</span>';
+ lastTimelineLen = events.length;
+ }
+ });
+
+ agent.addEventListener('agenc:error', (e) => {
+ $('vState').innerHTML = `<span class="state-Cancelled">error</span>`;
+ $('vWorkers').textContent = '—';
+ $('vReward').textContent = '—';
+ $('vCreator').textContent = '—';
+ $('vDeadline').textContent = e.detail?.message || '—';
+ $('vExplorer').textContent = '—';
+ });
+
+ function startWatching() {
+ const pda = taskInput.value.trim();
+ const cluster = clusterSel.value;
+ if (!pda) {
+ agent.removeAttribute('agenc-task');
+ return;
+ }
+ lastTimelineLen = -1;
+ agent.setAttribute('agenc-cluster', cluster);
+ agent.setAttribute('agenc-task', pda);
+ const url = new URL(location.href);
+ url.searchParams.set('task', pda);
+ url.searchParams.set('cluster', cluster);
+ history.replaceState(null, '', url.toString());
+ }
+
+ watchBtn.addEventListener('click', startWatching);
+ taskInput.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') startWatching();
+ });
+
+ if (taskInput.value) startWatching();
+ </script>
+ </body>
+</html>
diff --git a/pages/agenc/room.html b/pages/agenc/room.html
new file mode 100644
index 000000000..383906a6a
--- /dev/null
+++ b/pages/agenc/room.html
@@ -0,0 +1,337 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>AgenC task room — three.ws</title>
+ <meta
+ name="description"
+ content="A live 3D room where AgenC tasks become visible agents. Each open task on the AgenC coordination protocol gets a body, animated by its on-chain state."
+ />
+ <meta name="theme-color" content="#07050b" />
+ <link rel="icon" href="/favicon.ico" />
+
+ <style>
+ :root {
+ --bg: #07050b;
+ --bg-elev: #0f0d18;
+ --fg: #ececec;
+ --muted: #8a8499;
+ --accent: #7af0c4;
+ --warn: #f0c47a;
+ --err: #f07a7a;
+ --card: #16121f;
+ --border: rgba(255, 255, 255, 0.08);
+ }
+ * {
+ box-sizing: border-box;
+ }
+ html,
+ body {
+ margin: 0;
+ background: var(--bg);
+ color: var(--fg);
+ font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
+ font-size: 14px;
+ min-height: 100vh;
+ }
+ a {
+ color: var(--accent);
+ }
+ .bar {
+ display: flex;
+ gap: 12px;
+ align-items: center;
+ padding: 14px 20px;
+ border-bottom: 1px solid var(--border);
+ background: rgba(0, 0, 0, 0.4);
+ backdrop-filter: blur(6px);
+ flex-wrap: wrap;
+ }
+ .bar h1 {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 600;
+ }
+ .bar .muted {
+ color: var(--muted);
+ font-size: 12px;
+ }
+ .bar input {
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ color: var(--fg);
+ border-radius: 6px;
+ padding: 6px 10px;
+ min-width: 320px;
+ font: inherit;
+ }
+ .bar select {
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ color: var(--fg);
+ border-radius: 6px;
+ padding: 6px 10px;
+ font: inherit;
+ }
+ .bar button {
+ background: var(--accent);
+ color: #061612;
+ border: 0;
+ border-radius: 6px;
+ padding: 6px 14px;
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+ }
+ .bar button:hover {
+ filter: brightness(1.05);
+ }
+ .room {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
+ gap: 18px;
+ padding: 24px;
+ }
+ .task {
+ background: var(--card);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ overflow: hidden;
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ }
+ .task .body {
+ aspect-ratio: 1 / 1;
+ background: linear-gradient(135deg, #1a1428, #07050b);
+ position: relative;
+ overflow: hidden;
+ }
+ .task three-ws-agent {
+ width: 100%;
+ height: 100%;
+ display: block;
+ }
+ .task .meta {
+ padding: 12px 14px;
+ font-size: 12px;
+ color: var(--muted);
+ }
+ .task .meta strong {
+ color: var(--fg);
+ font-weight: 500;
+ }
+ .task .state-tag {
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ font-size: 10.5px;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ background: rgba(0, 0, 0, 0.6);
+ border: 1px solid var(--border);
+ padding: 3px 8px;
+ border-radius: 999px;
+ color: var(--fg);
+ }
+ .task[data-state='Open'] .state-tag {
+ color: var(--accent);
+ border-color: var(--accent);
+ }
+ .task[data-state='Claimed'] .state-tag {
+ color: var(--warn);
+ border-color: var(--warn);
+ }
+ .task[data-state='Completed'] .state-tag {
+ color: #7af0c4;
+ border-color: #7af0c4;
+ }
+ .task[data-state='Cancelled'] .state-tag,
+ .task[data-state='Expired'] .state-tag,
+ .task[data-state='Disputed'] .state-tag {
+ color: var(--err);
+ border-color: var(--err);
+ }
+ .empty {
+ padding: 60px 24px;
+ color: var(--muted);
+ text-align: center;
+ }
+ .empty code {
+ color: var(--fg);
+ background: var(--bg-elev);
+ padding: 1px 6px;
+ border-radius: 4px;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="bar">
+ <h1>AgenC task room</h1>
+ <span class="muted">on-chain task feed · <a href="https://agenc.tech" target="_blank" rel="noopener">agenc.tech</a></span>
+ <span style="flex: 1"></span>
+ <input id="creator" type="text" placeholder="creator wallet (base58)" />
+ <select id="cluster">
+ <option value="devnet" selected>devnet</option>
+ <option value="mainnet">mainnet</option>
+ </select>
+ <button id="loadBtn">Load</button>
+ </div>
+
+ <div id="room" class="room">
+ <div class="empty">
+ Paste a creator wallet to render every task they've posted on AgenC as
+ an embodied avatar. Try a wallet from your <code>agenc-task-roundtrip</code> example.
+ </div>
+ </div>
+
+ <script type="module" src="/agenc/embed.js"></script>
+ <script type="module">
+ const POLL_MS = 8000;
+ const AVATARS = ['/avatars/default.glb', '/avatars/cz.glb'];
+ const $ = (id) => document.getElementById(id);
+ const room = $('room');
+ const creatorInput = $('creator');
+ const clusterSel = $('cluster');
+ const loadBtn = $('loadBtn');
+
+ const params = new URLSearchParams(location.search);
+ if (params.get('creator')) creatorInput.value = params.get('creator');
+ if (params.get('cluster')) clusterSel.value = params.get('cluster');
+
+ let pollTimer = null;
+ let currentRequest = 0;
+ const cards = new Map(); // taskId hex -> { el, state }
+
+ function avatarFor(taskId) {
+ let h = 0;
+ for (const c of taskId) h = (h * 31 + c.charCodeAt(0)) | 0;
+ return AVATARS[Math.abs(h) % AVATARS.length];
+ }
+
+ function fmtSol(lamports) {
+ const n = Number(lamports);
+ if (Number.isNaN(n)) return String(lamports);
+ return (n / 1_000_000_000).toFixed(4) + ' SOL';
+ }
+
+ function buildCard(task, cluster, taskPda) {
+ const el = document.createElement('div');
+ el.className = 'task';
+ el.dataset.state = task.state;
+ el.dataset.taskId = task.taskId;
+ const reward = task.rewardMint ? `${task.rewardAmount}` : fmtSol(task.rewardAmount);
+ const pda = taskPda || '';
+ el.innerHTML = `
+ <div class="body">
+ <three-ws-agent
+ src="${avatarFor(task.taskId)}"
+ ${pda ? `agenc-task="${pda}"` : ''}
+ agenc-cluster="${cluster}"
+ agenc-bridge="/api/agenc"
+ agenc-poll-ms="8000"
+ ></three-ws-agent>
+ <div class="state-tag">${task.state}</div>
+ </div>
+ <div class="meta">
+ <div><strong>${task.taskId.slice(0, 10)}…</strong></div>
+ <div>reward · ${reward}</div>
+ <div>workers · ${task.currentWorkers}/${task.maxWorkers}${task.private ? ' · private (zk)' : ''}</div>
+ <div>deadline · ${task.deadline ? new Date(task.deadline * 1000).toLocaleString() : '—'}</div>
+ </div>
+ `;
+ return el;
+ }
+
+ function updateCard(card, task) {
+ if (card.dataset.state !== task.state) {
+ card.dataset.state = task.state;
+ card.querySelector('.state-tag').textContent = task.state;
+ }
+ const meta = card.querySelector('.meta');
+ const reward = task.rewardMint ? `${task.rewardAmount}` : fmtSol(task.rewardAmount);
+ meta.children[1].textContent = `reward · ${reward}`;
+ meta.children[2].textContent = `workers · ${task.currentWorkers}/${task.maxWorkers}${task.private ? ' · private (zk)' : ''}`;
+ }
+
+ async function loadTasks(creator, cluster, requestId) {
+ try {
+ const r = await fetch(
+ `/api/agenc/list-tasks?creator=${encodeURIComponent(creator)}&cluster=${cluster}`,
+ );
+ if (requestId !== currentRequest) return;
+ if (!r.ok) {
+ const text = await r.text();
+ room.innerHTML = `<div class="empty">error: ${text.slice(0, 200)}</div>`;
+ return;
+ }
+ const payload = await r.json();
+ if (!payload.ok || !payload.tasks?.length) {
+ room.innerHTML = `<div class="empty">no tasks found for <code>${creator.slice(0, 12)}…</code> on ${cluster}.</div>`;
+ cards.clear();
+ return;
+ }
+
+ const seen = new Set();
+ for (const task of payload.tasks) {
+ seen.add(task.taskId);
+ const existing = cards.get(task.taskId);
+ if (existing) {
+ updateCard(existing.el, task);
+ } else {
+ const el = buildCard(task, cluster, task.taskPda);
+ room.appendChild(el);
+ cards.set(task.taskId, { el });
+ }
+ }
+ // Remove cards that are no longer in the response (rare — cancelled
+ // tasks usually stay in the list with state=Cancelled).
+ for (const [taskId, entry] of cards) {
+ if (!seen.has(taskId)) {
+ entry.el.remove();
+ cards.delete(taskId);
+ }
+ }
+ if (room.querySelector('.empty')) {
+ room.querySelector('.empty').remove();
+ }
+ } catch (err) {
+ if (requestId === currentRequest) {
+ room.innerHTML = `<div class="empty">network error: ${err.message}</div>`;
+ }
+ } finally {
+ if (requestId === currentRequest) {
+ pollTimer = setTimeout(() => loadTasks(creator, cluster, requestId), POLL_MS);
+ }
+ }
+ }
+
+ function start() {
+ const creator = creatorInput.value.trim();
+ const cluster = clusterSel.value;
+ clearTimeout(pollTimer);
+ cards.clear();
+ room.innerHTML = '';
+ currentRequest += 1;
+ if (!creator) {
+ room.innerHTML =
+ '<div class="empty">Paste a creator wallet to render its tasks as a 3D scene.</div>';
+ return;
+ }
+ const url = new URL(location.href);
+ url.searchParams.set('creator', creator);
+ url.searchParams.set('cluster', cluster);
+ history.replaceState(null, '', url.toString());
+ room.innerHTML = '<div class="empty">loading…</div>';
+ loadTasks(creator, cluster, currentRequest);
+ }
+
+ loadBtn.addEventListener('click', start);
+ creatorInput.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') start();
+ });
+ if (creatorInput.value) start();
+ </script>
+ </body>
+</html>
diff --git a/public/agenc/embed.js b/public/agenc/embed.js
new file mode 100644
index 000000000..582f7ae16
--- /dev/null
+++ b/public/agenc/embed.js
@@ -0,0 +1,282 @@
+// <three-ws-agent> — embeddable custom element that renders a three.ws
+// 3D avatar bound to the on-chain state of an AgenC task.
+//
+// <script type="module" src="https://three.ws/agenc/embed.js"></script>
+// <three-ws-agent
+// src="/avatars/default.glb"
+// agenc-task="<TASK_PDA>"
+// agenc-cluster="devnet"
+// agenc-poll-ms="4000"
+// agenc-bridge="https://three.ws/api/agenc"
+// ></three-ws-agent>
+//
+// Attributes:
+// src — GLB url for the avatar body (passed straight to model-viewer)
+// agenc-task — base58 task PDA on AgenC (required to poll state)
+// agenc-cluster — "devnet" | "mainnet" (default "devnet")
+// agenc-poll-ms — polling interval; clamped [1500, 120000] (default 4000)
+// agenc-bridge — base URL of the three.ws AgenC API (default "/api/agenc")
+// agenc-clips — JSON map of {state: clipName} for state-driven animation,
+// e.g. `{"Claimed":"working","Completed":"cheer"}`. Clips
+// must exist in the GLB; missing clips are a no-op.
+// show-overlay — when present, render a small state badge in the corner
+//
+// Events (CustomEvent, bubble=true):
+// agenc:state — { taskPda, state, task, lifecycle } on every poll where
+// the task is found. The page can hook this to drive
+// additional UI without reaching into the element.
+// agenc:error — { message } on transport / parse failure.
+//
+// The element is dependency-free apart from <model-viewer>, which is loaded
+// lazily from the npm CDN on first connect (the same source three.ws uses).
+
+const MODEL_VIEWER_CDN = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';
+
+let modelViewerPromise = null;
+function ensureModelViewer() {
+ if (typeof window === 'undefined') return Promise.resolve();
+ if (customElements.get('model-viewer')) return Promise.resolve();
+ if (modelViewerPromise) return modelViewerPromise;
+ modelViewerPromise = new Promise((resolve, reject) => {
+ const script = document.createElement('script');
+ script.type = 'module';
+ script.src = MODEL_VIEWER_CDN;
+ script.onload = () => resolve();
+ script.onerror = () => reject(new Error('failed to load model-viewer from ' + MODEL_VIEWER_CDN));
+ document.head.appendChild(script);
+ });
+ return modelViewerPromise;
+}
+
+const STATE_COLORS = {
+ Open: '#7af0c4',
+ Claimed: '#f0c47a',
+ Completed: '#7af0c4',
+ Cancelled: '#f07a7a',
+ Expired: '#f07a7a',
+ Disputed: '#f07a7a',
+ loading: '#8a8499',
+ error: '#f07a7a',
+ idle: '#8a8499',
+};
+
+class ThreewsAgentElement extends HTMLElement {
+ static get observedAttributes() {
+ return ['src', 'agenc-task', 'agenc-cluster', 'agenc-poll-ms', 'agenc-bridge', 'agenc-clips', 'show-overlay'];
+ }
+
+ constructor() {
+ super();
+ this._shadow = this.attachShadow({ mode: 'open' });
+ this._pollTimer = null;
+ this._requestId = 0;
+ this._lastState = null;
+ }
+
+ connectedCallback() {
+ this._render();
+ ensureModelViewer().catch((err) => this._emit('agenc:error', { message: err.message }));
+ this._restart();
+ }
+
+ disconnectedCallback() {
+ clearTimeout(this._pollTimer);
+ this._requestId += 1;
+ }
+
+ attributeChangedCallback(name, oldValue, newValue) {
+ if (oldValue === newValue) return;
+ if (name === 'src' && this._viewer) {
+ this._viewer.setAttribute('src', newValue || '');
+ }
+ if (['agenc-task', 'agenc-cluster', 'agenc-poll-ms', 'agenc-bridge'].includes(name)) {
+ this._restart();
+ }
+ if (name === 'show-overlay') {
+ this._toggleOverlay();
+ }
+ }
+
+ _emit(type, detail) {
+ this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));
+ }
+
+ _pollMs() {
+ const raw = parseInt(this.getAttribute('agenc-poll-ms') || '4000', 10);
+ if (!Number.isFinite(raw)) return 4000;
+ return Math.max(1500, Math.min(raw, 120000));
+ }
+
+ _cluster() {
+ const c = (this.getAttribute('agenc-cluster') || 'devnet').toLowerCase();
+ return c === 'mainnet' ? 'mainnet' : 'devnet';
+ }
+
+ _bridge() {
+ return (this.getAttribute('agenc-bridge') || '/api/agenc').replace(/\/+$/, '');
+ }
+
+ _clipsMap() {
+ const raw = this.getAttribute('agenc-clips');
+ if (!raw) return null;
+ try {
+ const parsed = JSON.parse(raw);
+ return parsed && typeof parsed === 'object' ? parsed : null;
+ } catch {
+ return null;
+ }
+ }
+
+ _render() {
+ this._shadow.innerHTML = `
+ <style>
+ :host { display: block; position: relative; width: 100%; height: 100%; min-height: 240px; background: transparent; }
+ .viewer { position: relative; width: 100%; height: 100%; border-radius: inherit; overflow: hidden; }
+ model-viewer { width: 100%; height: 100%; --poster-color: transparent; background: transparent; }
+ .pulse {
+ position: absolute; inset: 0; pointer-events: none;
+ mix-blend-mode: screen;
+ opacity: 0;
+ transition: opacity 0.3s, background 0.3s;
+ }
+ :host([data-state="Claimed"]) .pulse {
+ background: radial-gradient(circle at 50% 70%, #f0c47a 0%, transparent 55%);
+ opacity: 0.28;
+ animation: pulse 2.4s ease-in-out infinite;
+ }
+ :host([data-state="Completed"]) .pulse {
+ background: radial-gradient(circle at 50% 70%, #7af0c4 0%, transparent 55%);
+ opacity: 0.36;
+ }
+ :host([data-state="Cancelled"]) .pulse,
+ :host([data-state="Expired"]) .pulse,
+ :host([data-state="Disputed"]) .pulse {
+ background: radial-gradient(circle at 50% 70%, #f07a7a 0%, transparent 55%);
+ opacity: 0.24;
+ }
+ @keyframes pulse {
+ 0%, 100% { opacity: 0.16; }
+ 50% { opacity: 0.36; }
+ }
+ .overlay {
+ position: absolute;
+ left: 12px;
+ bottom: 12px;
+ font: 600 11px/1 -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: #ececec;
+ background: rgba(0, 0, 0, 0.6);
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ padding: 5px 10px;
+ border-radius: 999px;
+ transition: color 0.2s, border-color 0.2s;
+ display: none;
+ }
+ .overlay.show { display: inline-block; }
+ </style>
+ <div class="viewer">
+ <model-viewer auto-rotate camera-controls environment-image="neutral"
+ interaction-prompt="none"
+ exposure="1" shadow-intensity="0.6"
+ reveal="auto"></model-viewer>
+ <div class="pulse"></div>
+ <div class="overlay">idle</div>
+ </div>
+ `;
+ this._viewer = this._shadow.querySelector('model-viewer');
+ this._overlay = this._shadow.querySelector('.overlay');
+ if (this.hasAttribute('src')) this._viewer.setAttribute('src', this.getAttribute('src'));
+ this._toggleOverlay();
+ this._setState(this.getAttribute('agenc-task') ? 'loading' : 'idle');
+ }
+
+ _toggleOverlay() {
+ if (!this._overlay) return;
+ const show = this.hasAttribute('show-overlay');
+ this._overlay.classList.toggle('show', show);
+ }
+
+ _setState(state) {
+ if (this._lastState === state) return;
+ this._lastState = state;
+ this.setAttribute('data-state', state);
+ if (this._overlay) {
+ this._overlay.textContent = state;
+ this._overlay.style.color = STATE_COLORS[state] || '#ececec';
+ this._overlay.style.borderColor = (STATE_COLORS[state] || '#ffffff20') + '88';
+ }
+ // State-driven animation: if the user supplied an agenc-clips map and the
+ // clip exists in the loaded GLB, switch the active animation; otherwise
+ // silently fall back to whatever clip is already playing.
+ const clipMap = this._clipsMap();
+ if (this._viewer && clipMap && clipMap[state]) {
+ const desired = String(clipMap[state]);
+ const available = this._viewer.availableAnimations || [];
+ if (!available.length || available.includes(desired)) {
+ this._viewer.setAttribute('animation-name', desired);
+ try {
+ this._viewer.play({ repetitions: state === 'Completed' ? 1 : Infinity });
+ } catch {
+ // model-viewer.play may not be ready yet — non-fatal
+ }
+ }
+ }
+ }
+
+ _restart() {
+ clearTimeout(this._pollTimer);
+ this._requestId += 1;
+ const taskPda = this.getAttribute('agenc-task');
+ if (!taskPda) {
+ this._setState('idle');
+ return;
+ }
+ this._setState('loading');
+ const myReq = this._requestId;
+ this._poll(taskPda, myReq);
+ }
+
+ async _poll(taskPda, requestId) {
+ const cluster = this._cluster();
+ const bridge = this._bridge();
+ const url = `${bridge}/get-task?taskPda=${encodeURIComponent(taskPda)}&cluster=${cluster}&lifecycle=1`;
+ try {
+ const r = await fetch(url, { headers: { accept: 'application/json' } });
+ if (requestId !== this._requestId) return;
+ if (!r.ok && r.status !== 404) {
+ this._setState('error');
+ this._emit('agenc:error', { message: `bridge ${r.status}` });
+ return;
+ }
+ const payload = await r.json();
+ if (!payload.ok || !payload.task) {
+ this._setState('error');
+ this._emit('agenc:error', { message: payload.error || 'not_found' });
+ return;
+ }
+ this._setState(payload.task.state);
+ this._emit('agenc:state', {
+ taskPda,
+ cluster,
+ state: payload.task.state,
+ task: payload.task,
+ lifecycle: payload.lifecycle,
+ });
+ } catch (err) {
+ if (requestId !== this._requestId) return;
+ this._setState('error');
+ this._emit('agenc:error', { message: err.message || String(err) });
+ } finally {
+ if (requestId === this._requestId) {
+ this._pollTimer = setTimeout(() => this._poll(taskPda, requestId), this._pollMs());
+ }
+ }
+ }
+}
+
+if (typeof customElements !== 'undefined' && !customElements.get('three-ws-agent')) {
+ customElements.define('three-ws-agent', ThreewsAgentElement);
+}
+
+export { ThreewsAgentElement };
diff --git a/scripts/agenc-mirror-x402-service.mjs b/scripts/agenc-mirror-x402-service.mjs
new file mode 100644
index 000000000..ad8ff0b86
--- /dev/null
+++ b/scripts/agenc-mirror-x402-service.mjs
@@ -0,0 +1,150 @@
+#!/usr/bin/env node
+// Mirror a single x402 service as a real on-chain AgenC task.
+//
+// Usage:
+// node scripts/agenc-mirror-x402-service.mjs \
+// --resource https://three.ws/api/x402/agent-reputation \
+// --reward 5000000 \
+// --deadline-hours 24 \
+// --keypair ./creator.json \
+// [--cluster devnet]
+//
+// The task description packs `x402:<resource>` so any AgenC worker that
+// claims the task knows where to call. The reward is whatever you choose
+// to escrow on AgenC — it does not have to match the x402 endpoint price.
+//
+// Re-running with the same resource is idempotent: the task id is derived
+// deterministically from the resource URL so the same PDA is targeted. If
+// the task already exists in a non-terminal state, the script exits without
+// re-creating.
+
+import { promises as fs } from "node:fs";
+import { createHash } from "node:crypto";
+import { Keypair } from "@solana/web3.js";
+import {
+ createAgenCClient,
+ createAgenCTask,
+ getAgenCTask,
+ registerAgenCAgent,
+ getAgenCAgent,
+ deriveAgenCAgentPda,
+ toAgenCAgentId,
+ formatTaskState,
+} from "@three-ws/solana-agent";
+
+function arg(name, def) {
+ const flag = `--${name}`;
+ const i = process.argv.indexOf(flag);
+ if (i === -1) return def;
+ return process.argv[i + 1];
+}
+
+function flag(name) {
+ return process.argv.includes(`--${name}`);
+}
+
+function usage(msg) {
+ if (msg) console.error(`error: ${msg}\n`);
+ console.error(`Usage: agenc-mirror-x402-service.mjs --resource <url> --reward <lamports> --keypair <path> [--cluster devnet|mainnet] [--deadline-hours N] [--label "agent label"] [--capability-bit N]`);
+ process.exit(msg ? 1 : 0);
+}
+
+async function main() {
+ if (flag("help")) usage();
+
+ const resource = arg("resource");
+ const rewardArg = arg("reward");
+ const keypairPath = arg("keypair");
+ if (!resource) usage("--resource is required");
+ if (!rewardArg) usage("--reward (lamports) is required");
+ if (!keypairPath) usage("--keypair is required");
+
+ const reward = BigInt(rewardArg);
+ const cluster = arg("cluster", "devnet");
+ if (cluster !== "devnet" && cluster !== "mainnet") usage("--cluster must be devnet or mainnet");
+
+ const deadlineHours = Number(arg("deadline-hours", "24"));
+ if (!Number.isFinite(deadlineHours) || deadlineHours <= 0) usage("--deadline-hours must be a positive number");
+
+ const agentLabel = arg("label", "three-ws-x402-creator");
+ const capabilityBit = Number(arg("capability-bit", "0"));
+
+ const secret = Uint8Array.from(JSON.parse(await fs.readFile(keypairPath, "utf8")));
+ const creator = Keypair.fromSecretKey(secret);
+
+ const client = createAgenCClient({ cluster, signer: creator });
+ console.log(`cluster : ${cluster}`);
+ console.log(`programId : ${client.programId.toBase58()}`);
+ console.log(`creator : ${creator.publicKey.toBase58()}`);
+ console.log(`resource : ${resource}`);
+
+ // Ensure the creator is registered as an AgenC agent.
+ const creatorAgentId = toAgenCAgentId(`${agentLabel}-${creator.publicKey.toBase58()}`);
+ const creatorAgentPda = deriveAgenCAgentPda(client, creatorAgentId);
+ const existingAgent = await getAgenCAgent(client, creatorAgentPda);
+ if (!existingAgent) {
+ console.log("\nregistering creator as AgenC agent…");
+ const reg = await registerAgenCAgent(client, {
+ agentId: creatorAgentId,
+ capabilities: 0n,
+ endpoint: "https://three.ws/agenc/x402-bridge",
+ metadataUri: `https://three.ws/api/agenc/x402-services`,
+ stakeAmount: 1_000_000,
+ });
+ console.log(` agentPda: ${reg.agentPda.toBase58()}`);
+ console.log(` tx : https://explorer.solana.com/tx/${reg.txSignature}?cluster=${cluster}`);
+ } else {
+ console.log(`\ncreator already registered (agentPda=${creatorAgentPda.toBase58()})`);
+ }
+
+ // Deterministic taskId derived from the resource URL — re-runs are idempotent.
+ const taskId = createHash("sha256")
+ .update("AgenC/three.ws/x402/v1\0", "utf8")
+ .update(resource, "utf8")
+ .digest();
+ const taskIdHex = "0x" + taskId.toString("hex");
+ console.log(`\ntaskId : ${taskIdHex}`);
+
+ // Try the existing task at this PDA first — re-creating an active task
+ // will fail at the protocol level, so we bail out cleanly when one is live.
+ const description = `x402:${resource}`;
+ const deadline = Math.floor(Date.now() / 1000) + Math.round(deadlineHours * 3600);
+
+ const result = await createAgenCTask(client, {
+ taskId,
+ creatorAgentId,
+ requiredCapabilities: 1n << BigInt(capabilityBit),
+ description,
+ rewardAmount: reward,
+ maxWorkers: 1,
+ deadline,
+ taskType: "Exclusive",
+ minReputation: 0,
+ }).catch(async (err) => {
+ const msg = String(err?.message || err);
+ if (msg.includes("already in use") || msg.toLowerCase().includes("custom program error: 0x0")) {
+ console.log("task account already exists for this resource — re-fetching state…");
+ const { deriveTaskPda } = await import("@tetsuo-ai/sdk");
+ const pda = deriveTaskPda(creator.publicKey, taskId, client.programId);
+ const existing = await getAgenCTask(client, pda);
+ if (!existing) throw err;
+ console.log(` taskPda: ${pda.toBase58()}`);
+ console.log(` state : ${formatTaskState(existing.state)}`);
+ console.log(` workers: ${existing.currentWorkers}/${existing.maxWorkers}`);
+ return null;
+ }
+ throw err;
+ });
+ if (!result) return;
+
+ console.log(`taskPda : ${result.taskPda.toBase58()}`);
+ console.log(`tx : https://explorer.solana.com/tx/${result.txSignature}?cluster=${cluster}`);
+ console.log(`account : https://explorer.solana.com/address/${result.taskPda.toBase58()}?cluster=${cluster}`);
+ console.log(`reward : ${Number(reward) / 1e9} SOL`);
+ console.log(`deadline : ${new Date(deadline * 1000).toISOString()}`);
+}
+
+main().catch((err) => {
+ console.error(`\nFATAL: ${err.stack || err.message || err}`);
+ process.exit(1);
+});
diff --git a/solana-agent-sdk/src/actions/agenc/identity-bridge.ts b/solana-agent-sdk/src/actions/agenc/identity-bridge.ts
new file mode 100644
index 000000000..18cc0e171
--- /dev/null
+++ b/solana-agent-sdk/src/actions/agenc/identity-bridge.ts
@@ -0,0 +1,203 @@
+// Identity bridge between three.ws's existing agent identity systems
+// (ERC-8004 + Metaplex Core) and the AgenC coordination protocol's
+// 32-byte agentId namespace.
+//
+// Each external identity is hashed under a namespaced domain string so a
+// collision between, say, an ERC-8004 agent #42 and a Metaplex Core asset
+// is statistically impossible. The bridge also produces a stable canonical
+// id when a three.ws agent record carries multiple identity proofs.
+//
+// Namespaces (prefixed before the identifier bytes in the SHA-256 input):
+//
+// AgenC/three.ws/erc8004/v1\0 | uint256 BE
+// AgenC/three.ws/mpl-core/v1\0 | 32-byte Solana pubkey
+// AgenC/three.ws/handle/v1\0 | UTF-8 lowercased handle
+// AgenC/three.ws/composite/v1\0| canonical JSON of the input descriptor
+//
+// The `composite` variant is the "canonical" three.ws → AgenC mapping when
+// an agent has BOTH an ERC-8004 record and a Metaplex Core asset; it binds
+// the two so neither side can be swapped post-hoc without re-registration.
+
+import { PublicKey } from "@solana/web3.js";
+import { createHash } from "node:crypto";
+
+const NS_ERC8004 = "AgenC/three.ws/erc8004/v1\0";
+const NS_MPL_CORE = "AgenC/three.ws/mpl-core/v1\0";
+const NS_HANDLE = "AgenC/three.ws/handle/v1\0";
+const NS_COMPOSITE = "AgenC/three.ws/composite/v1\0";
+
+function sha256(...parts: (string | Buffer | Uint8Array)[]): Uint8Array {
+ const h = createHash("sha256");
+ for (const p of parts) {
+ if (typeof p === "string") h.update(p, "utf8");
+ else h.update(p);
+ }
+ return Uint8Array.from(h.digest());
+}
+
+function erc8004IdToBeBytes(id: bigint | number | string): Buffer {
+ let n: bigint;
+ if (typeof id === "bigint") n = id;
+ else if (typeof id === "number") {
+ if (!Number.isInteger(id) || id < 0) {
+ throw new Error("ERC-8004 agentId must be a non-negative integer");
+ }
+ n = BigInt(id);
+ } else {
+ const s = id.trim();
+ n = s.startsWith("0x") || s.startsWith("0X") ? BigInt(s) : BigInt(s);
+ }
+ if (n < 0n) throw new Error("ERC-8004 agentId must be non-negative");
+ // ERC-8004's IdentityRegistry uses uint256 — encode as 32-byte big-endian.
+ const out = Buffer.alloc(32);
+ let cur = n;
+ for (let i = 31; i >= 0 && cur > 0n; i--) {
+ out[i] = Number(cur & 0xffn);
+ cur >>= 8n;
+ }
+ return out;
+}
+
+/** Derive an AgenC 32-byte agentId from an ERC-8004 agent ID (uint256). */
+export function bridgeErc8004ToAgenCId(
+ erc8004AgentId: bigint | number | string,
+): Uint8Array {
+ return sha256(NS_ERC8004, erc8004IdToBeBytes(erc8004AgentId));
+}
+
+/** Derive an AgenC 32-byte agentId from a Metaplex Core asset pubkey. */
+export function bridgeMplCoreToAgenCId(
+ assetAddress: PublicKey | string,
+): Uint8Array {
+ const pk =
+ assetAddress instanceof PublicKey
+ ? assetAddress
+ : new PublicKey(assetAddress);
+ return sha256(NS_MPL_CORE, pk.toBytes());
+}
+
+/** Derive an AgenC 32-byte agentId from a three.ws agent handle (slug). */
+export function bridgeThreewsHandleToAgenCId(handle: string): Uint8Array {
+ const norm = handle.trim().toLowerCase();
+ if (!norm) throw new Error("handle must be non-empty");
+ return sha256(NS_HANDLE, norm);
+}
+
+export interface ThreewsAgentIdentityRef {
+ /** ERC-8004 IdentityRegistry agentId (uint256). */
+ erc8004AgentId?: bigint | number | string | null;
+ /** Metaplex Core asset address. */
+ mplCoreAsset?: PublicKey | string | null;
+ /** three.ws handle / slug (used as last-resort and for metadataUri). */
+ handle?: string | null;
+}
+
+export interface CanonicalAgenCIdResult {
+ agenCAgentId: Uint8Array;
+ /** Which identity system was used to derive the canonical id. */
+ source: "composite" | "erc8004" | "mpl-core" | "handle";
+ /** A stable label that callers can persist alongside the AgenC PDA. */
+ label: string;
+}
+
+/**
+ * Derive the canonical AgenC agentId for a three.ws agent. Selection priority:
+ *
+ * 1. Both ERC-8004 + Metaplex Core present → composite (binds both proofs)
+ * 2. ERC-8004 only → ERC-8004 namespace
+ * 3. Metaplex Core only → mpl-core namespace
+ * 4. Handle only → handle namespace
+ *
+ * Throws if none of the three are supplied.
+ */
+export function getCanonicalThreewsAgenCId(
+ ref: ThreewsAgentIdentityRef,
+): CanonicalAgenCIdResult {
+ const hasErc = ref.erc8004AgentId !== undefined && ref.erc8004AgentId !== null && ref.erc8004AgentId !== "";
+ const hasMpl = ref.mplCoreAsset !== undefined && ref.mplCoreAsset !== null && ref.mplCoreAsset !== "";
+
+ if (hasErc && hasMpl) {
+ const ercBytes = erc8004IdToBeBytes(ref.erc8004AgentId!);
+ const mplPk =
+ ref.mplCoreAsset instanceof PublicKey
+ ? ref.mplCoreAsset
+ : new PublicKey(ref.mplCoreAsset as string);
+ const composite = JSON.stringify({
+ v: 1,
+ erc8004: "0x" + ercBytes.toString("hex"),
+ mplCore: mplPk.toBase58(),
+ });
+ return {
+ agenCAgentId: sha256(NS_COMPOSITE, composite),
+ source: "composite",
+ label: `composite:erc8004=${ref.erc8004AgentId}+mpl=${mplPk.toBase58()}`,
+ };
+ }
+
+ if (hasErc) {
+ return {
+ agenCAgentId: bridgeErc8004ToAgenCId(ref.erc8004AgentId!),
+ source: "erc8004",
+ label: `erc8004:${ref.erc8004AgentId}`,
+ };
+ }
+
+ if (hasMpl) {
+ const pk =
+ ref.mplCoreAsset instanceof PublicKey
+ ? ref.mplCoreAsset
+ : new PublicKey(ref.mplCoreAsset as string);
+ return {
+ agenCAgentId: bridgeMplCoreToAgenCId(pk),
+ source: "mpl-core",
+ label: `mpl-core:${pk.toBase58()}`,
+ };
+ }
+
+ if (ref.handle) {
+ return {
+ agenCAgentId: bridgeThreewsHandleToAgenCId(ref.handle),
+ source: "handle",
+ label: `handle:${ref.handle.toLowerCase()}`,
+ };
+ }
+
+ throw new Error(
+ "getCanonicalThreewsAgenCId: no identity supplied (need at least one of erc8004AgentId, mplCoreAsset, handle)",
+ );
+}
+
+/**
+ * Build the `metadataUri` field that three.ws agents should submit when
+ * registering on AgenC, pointing back at the canonical agent record so AgenC
+ * counterparties can resolve the three.ws identity proofs (ERC-8004 + MPL).
+ *
+ * Pass `baseUrl` (defaults to "https://three.ws") to point at a staging host.
+ */
+export function buildThreewsMetadataUri(
+ ref: ThreewsAgentIdentityRef,
+ baseUrl: string = "https://three.ws",
+): string {
+ const trimmed = baseUrl.replace(/\/+$/, "");
+ const params = new URLSearchParams();
+ if (ref.erc8004AgentId !== undefined && ref.erc8004AgentId !== null && ref.erc8004AgentId !== "") {
+ params.set("erc8004", String(ref.erc8004AgentId));
+ }
+ if (ref.mplCoreAsset) {
+ const pk =
+ ref.mplCoreAsset instanceof PublicKey
+ ? ref.mplCoreAsset
+ : new PublicKey(ref.mplCoreAsset as string);
+ params.set("mpl", pk.toBase58());
+ }
+ if (ref.handle) {
+ params.set("handle", ref.handle.toLowerCase());
+ }
+ const query = params.toString();
+ return query ? `${trimmed}/.well-known/agent.json?${query}` : `${trimmed}/.well-known/agent.json`;
+}
+
+/** Convenience: AgenC agentId as a 64-char lowercase hex string. */
+export function agenCAgentIdToHex(id: Uint8Array): string {
+ return Buffer.from(id).toString("hex");
+}
diff --git a/solana-agent-sdk/src/actions/agenc/index.ts b/solana-agent-sdk/src/actions/agenc/index.ts
index a08041981..18d1cbeb6 100644
--- a/solana-agent-sdk/src/actions/agenc/index.ts
+++ b/solana-agent-sdk/src/actions/agenc/index.ts
@@ -59,6 +59,17 @@ export {
type AgenCCompleteTaskResult,
} from "./tasks.js";
+export {
+ bridgeErc8004ToAgenCId,
+ bridgeMplCoreToAgenCId,
+ bridgeThreewsHandleToAgenCId,
+ getCanonicalThreewsAgenCId,
+ buildThreewsMetadataUri,
+ agenCAgentIdToHex,
+ type ThreewsAgentIdentityRef,
+ type CanonicalAgenCIdResult,
+} from "./identity-bridge.js";
+
// Re-exports from the upstream SDK that round out the surface for advanced
// callers. Anything you can't do via this adapter, you can still reach via
// `@tetsuo-ai/sdk` directly.
diff --git a/vercel.json b/vercel.json
index 972f88023..5ec38a284 100644
--- a/vercel.json
+++ b/vercel.json
@@ -241,6 +241,34 @@
"src": "/club/?",
"dest": "/club.html"
},
+ {
+ "src": "/agenc/embodied/?",
+ "dest": "/agenc/embodied.html"
+ },
+ {
+ "src": "/agenc/room/?",
+ "dest": "/agenc/room.html"
+ },
+ {
+ "src": "/api/agenc/list-tasks",
+ "dest": "/api/agenc/[action]?action=list-tasks"
+ },
+ {
+ "src": "/api/agenc/get-task",
+ "dest": "/api/agenc/[action]?action=get-task"
+ },
+ {
+ "src": "/api/agenc/get-agent",
+ "dest": "/api/agenc/[action]?action=get-agent"
+ },
+ {
+ "src": "/api/agenc/x402-services",
+ "dest": "/api/agenc/[action]?action=x402-services"
+ },
+ {
+ "src": "/api/agenc/link",
+ "dest": "/api/agenc/[action]?action=link"
+ },
{
"src": "/walkaround/?",
"dest": "/demos/walkaround.html"
diff --git a/vite.config.js b/vite.config.js
index 1a19d4e32..527cb6d49 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -151,6 +151,8 @@ const appConfig = {
walk: resolve(__dirname, 'pages/walk.html'),
pose: resolve(__dirname, 'pages/pose.html'),
club: resolve(__dirname, 'pages/club.html'),
+ 'agenc-embodied': resolve(__dirname, 'pages/agenc/embodied.html'),
+ 'agenc-room': resolve(__dirname, 'pages/agenc/room.html'),
studio: resolve(__dirname, 'public/studio/index.html'),
reputation: resolve(__dirname, 'public/reputation/index.html'),
hydrate: resolve(__dirname, 'public/hydrate/index.html'),
@@ -283,6 +285,10 @@ const appConfig = {
'/pose/': resolve(root, 'pages/pose.html'),
'/club': resolve(root, 'pages/club.html'),
'/club/': resolve(root, 'pages/club.html'),
+ '/agenc/embodied': resolve(root, 'pages/agenc/embodied.html'),
+ '/agenc/embodied/': resolve(root, 'pages/agenc/embodied.html'),
+ '/agenc/room': resolve(root, 'pages/agenc/room.html'),
+ '/agenc/room/': resolve(root, 'pages/agenc/room.html'),
'/walkaround': resolve(root, 'public/demos/walkaround.html'),
'/walkaround/': resolve(root, 'public/demos/walkaround.html'),
'/brain': resolve(root, 'public/demos/brain.html'),