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.

local-skill-packs build + sns subdomain refinements

nirholase162accbc558
diff --git a/README.md b/README.md
index 7928cedb2..26842a3f8 100644
--- a/README.md
+++ b/README.md
@@ -247,11 +247,19 @@ If you want to support the project — compute credits, grants, partnerships, or
- Native [x402](https://x402.org) paid endpoints on Base, BSC, and Solana — agents pay other agents in USDC for API calls, asset downloads, and skill royalties
- Coinbase CDP facilitator on Base mainnet; direct-scheme payments on BSC
- Permit2 gas-sponsoring siblings on every CDP-settled endpoint (buyer signs, relayer pays gas)
+- **Pay-by-name** — `/api/x402/pay-by-name` resolves `@username`, `*.sol` (incl. subdomains), or raw base58 to a recipient and builds an unsigned USDC transfer for the payer's wallet. Every 402 manifest emitted by a named agent advertises `recipient_name` next to the wallet, so payers verify a human-readable name before signing
- SKU catalog + Stripe-style checkout at `/dashboard/x402`; receipts ledger with admin tooling
- Subscriptions, idempotency tokens, offer receipts, paid asset download, and a bazaar listing/search API
- SIWX (Sign-In with X-chain) server for auth-gated paid endpoints
- Listed on [x402scan](https://www.x402scan.com/server/17cbd874-52ac-4920-a020-b22ff2489a07) and the [MCP Registry](https://registry.modelcontextprotocol.io/?q=three.ws)
+**SNS / `*.threews.sol` subdomains**
+
+- `/threews/claim` lets any signed-in user mint `[username].threews.sol` in a single atomic Solana transaction — `createSubdomain` → URL record → `transferSubdomain` to the user's wallet, with three.ws absorbing gas
+- Brave Browser resolves the subdomain directly to the user's `/u/[username]` showcase via the SNS URL record
+- Agents can bind a `.sol` name (theirs or a fresh registration) via `/api/agents/:id/sns`; once bound, every public surface — agent page, x402 manifest, MCP listing, marketplace card — displays the name in place of the raw wallet
+- See [docs/internal/SNS_PARTNERSHIP_PROPOSAL.md](docs/internal/SNS_PARTNERSHIP_PROPOSAL.md) for the partnership pitch to Bonfida
+
**A2A — Agent-to-Agent Protocol**
- A2A client + server, MCP bridge, DID resolution, spending ledger, receipts storage
diff --git a/api/sns-subdomain.js b/api/sns-subdomain.js
index fcf10fd45..d1678330d 100644
--- a/api/sns-subdomain.js
+++ b/api/sns-subdomain.js
@@ -1,36 +1,43 @@
-// Mint subdomains under the platform-owned parent .sol (default: threews.sol).
+// Mint subdomains under the platform-owned parent .sol (default: threews.sol)
+// for AGENT identities. For user/username-claim subdomains, use the existing
+// POST /api/threews/subdomain endpoint.
//
// GET /api/sns-subdomain?label=<label> → availability check.
-// POST /api/sns-subdomain
-// body { label, agent_id?, owner_address?, space? }
+// POST /api/sns-subdomain { agent_id, label?, owner_address?, space? }
//
-// - label : required, 1–63 chars of [a-z0-9-], no leading/trailing hyphen.
+// - agent_id : required. The agent to attach the subdomain to.
+// - label : optional, defaults to the agent's name slugified.
+// 1–63 chars of [a-z0-9-], passes the shared denylist.
// - owner_address : optional. Solana base58 wallet to receive ownership.
-// Defaults to the agent's own solana_address when agent_id
-// is given, otherwise to the caller's primary linked
-// Solana wallet.
-// - agent_id : optional. When set, the new subdomain is attached as
-// the agent's SNS identity (meta.sns_domain).
+// Defaults to the agent's own solana_address. When
+// provided, must be a wallet linked to the caller.
// - space : optional, 1000–10000. Bytes reserved on the subdomain
// registry. Default 2000.
//
// The platform keypair (THREEWS_SOL_PARENT_SECRET_BASE58) signs both the
// subdomain creation and the immediate transfer of ownership. The caller's
// wallet does not need to sign.
+//
+// On success, the new subdomain's SNS URL record is set to
+// https://three.ws/a/<agent_id> so Brave users typing `<label>.threews.sol`
+// land on the agent page. The mapping is also written to the agent's
+// meta.sns_domain so x402 manifests can show recipient_name without an
+// additional SNS round-trip.
import { getSessionUser, authenticateBearer, extractBearer } from './_lib/auth.js';
import { sql } from './_lib/db.js';
import { cors, json, method, error, readJson, wrap } from './_lib/http.js';
import { limits, clientIp } from './_lib/rate-limit.js';
import {
- checkSubdomainAvailability,
- createNamedSubdomain,
- getParentDomain,
+ PARENT_LABEL,
+ fullDomain,
+ getSubdomainOwner,
+ hasOwnerKey,
normalizeLabel,
-} from '../src/solana/sns-subdomain.js';
-import { Connection } from '@solana/web3.js';
+ getStorefrontOrigin,
+} from './_lib/threews-sns.js';
+import { createNamedSubdomain } from '../src/solana/sns-subdomain.js';
-const SOLANA_RPC = process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com';
const ADDR_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
async function resolveAuth(req) {
@@ -41,121 +48,140 @@ async function resolveAuth(req) {
return null;
}
-async function resolveTargetOwner({ userId, agentId, ownerAddress }) {
- if (ownerAddress) {
- if (!ADDR_RE.test(ownerAddress)) {
- return { error: { status: 400, code: 'validation_error', msg: 'owner_address must be a base58 Solana public key' } };
- }
- const [linked] = await sql`
- SELECT id FROM user_wallets
- WHERE user_id = ${userId} AND address = ${ownerAddress} AND chain_type = 'solana'
- LIMIT 1
- `;
- if (!linked) {
- return { error: { status: 403, code: 'forbidden', msg: 'owner_address is not a Solana wallet linked to your account' } };
- }
- return { address: ownerAddress };
- }
+function slugifyName(name) {
+ const s = String(name || '')
+ .toLowerCase()
+ .replace(/[^a-z0-9-]+/g, '-')
+ .replace(/^-+|-+$/g, '')
+ .slice(0, 63);
+ return s || null;
+}
- if (agentId) {
- const [agent] = await sql`
- SELECT id, meta FROM agent_identities
- WHERE id = ${agentId} AND user_id = ${userId} AND deleted_at IS NULL
- `;
- if (!agent) return { error: { status: 404, code: 'not_found', msg: 'agent not found' } };
- const addr = agent.meta?.solana_address;
- if (!addr) {
- return { error: { status: 412, code: 'agent_missing_wallet', msg: 'agent has no solana wallet — provision one via POST /api/agents/:id/solana before minting a subdomain' } };
- }
- return { address: addr, agent };
- }
+async function handleCheck(req, res) {
+ const rl = await limits.snsResolve(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
- const [primary] = await sql`
- SELECT address FROM user_wallets
- WHERE user_id = ${userId} AND chain_type = 'solana'
- ORDER BY (is_primary IS TRUE) DESC, created_at ASC
- LIMIT 1
- `;
- if (!primary) {
- return { error: { status: 412, code: 'no_solana_wallet', msg: 'link a Solana wallet first via POST /api/auth/wallet, or pass owner_address / agent_id' } };
+ const url = new URL(req.url, 'http://x');
+ const label = normalizeLabel(url.searchParams.get('label'));
+ if (!label) {
+ return error(res, 400, 'validation_error', 'label must match [a-z0-9-]{1,63} and not be reserved');
}
- return { address: primary.address };
+ const owner = await getSubdomainOwner(label);
+ return json(res, 200, {
+ data: {
+ label,
+ parent: `${PARENT_LABEL}.sol`,
+ full_name: fullDomain(label),
+ available: !owner,
+ owner,
+ },
+ });
}
-export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: true })) return;
-
- if (req.method === 'GET') {
- const rl = await limits.snsResolve(clientIp(req));
- if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
-
- const url = new URL(req.url, 'http://x');
- const label = normalizeLabel(url.searchParams.get('label'));
- const parentDomain = getParentDomain().replace(/\.sol$/, '');
- if (!label) {
- return error(res, 400, 'validation_error', 'label must be 1–63 lowercase [a-z0-9-] chars with no leading/trailing hyphen');
- }
- const connection = new Connection(SOLANA_RPC, 'confirmed');
- const availability = await checkSubdomainAvailability({ connection, parentDomain, label });
- return json(res, 200, {
- data: {
- label,
- parent: `${parentDomain}.sol`,
- full_name: `${label}.${parentDomain}.sol`,
- available: !availability.exists,
- owner: availability.owner,
- },
- });
+async function handleMint(req, res, auth) {
+ if (!hasOwnerKey()) {
+ return error(res, 503, 'config_missing', 'subdomain minting unavailable — platform owner key not configured');
}
- if (!method(req, res, ['POST'])) return;
+ const body = await readJson(req).catch(() => ({}));
+ const agentId = typeof body?.agent_id === 'string' ? body.agent_id.trim() : null;
+ if (!agentId) {
+ return error(res, 400, 'validation_error', 'agent_id is required (for user/username-claim subdomains use POST /api/threews/subdomain)');
+ }
- const auth = await resolveAuth(req);
- if (!auth) return error(res, 401, 'unauthorized', 'sign in or provide a bearer token');
+ const [agent] = await sql`
+ SELECT id, name, meta FROM agent_identities
+ WHERE id = ${agentId} AND user_id = ${auth.userId} AND deleted_at IS NULL
+ `;
+ if (!agent) return error(res, 404, 'not_found', 'agent not found');
- const rl = await limits.authIp(clientIp(req));
- if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+ const agentSol = agent.meta?.solana_address;
+ if (!agentSol) {
+ return error(res, 412, 'agent_missing_wallet', 'agent has no solana wallet — provision one via POST /api/agents/:id/solana');
+ }
- const body = await readJson(req).catch(() => ({}));
- const label = normalizeLabel(body?.label);
+ let labelInput = typeof body?.label === 'string' && body.label.trim()
+ ? body.label
+ : slugifyName(agent.name);
+ const label = normalizeLabel(labelInput);
if (!label) {
- return error(res, 400, 'validation_error', 'label must be 1–63 lowercase [a-z0-9-] chars with no leading/trailing hyphen');
+ return error(res, 400, 'validation_error', 'label must match [a-z0-9-]{1,63} and not be reserved');
}
- const agentId = typeof body?.agent_id === 'string' ? body.agent_id.trim() : null;
- const ownerAddress = typeof body?.owner_address === 'string' ? body.owner_address.trim() : null;
- const space = Number.isInteger(body?.space) && body.space >= 1000 && body.space <= 10000 ? body.space : 2000;
- const target = await resolveTargetOwner({ userId: auth.userId, agentId, ownerAddress });
- if (target.error) return error(res, target.error.status, target.error.code, target.error.msg);
+ let recipientWallet = typeof body?.owner_address === 'string' ? body.owner_address.trim() : '';
+ if (recipientWallet) {
+ if (!ADDR_RE.test(recipientWallet)) {
+ return error(res, 400, 'validation_error', 'owner_address must be a base58 Solana public key');
+ }
+ const [walletRow] = await sql`
+ SELECT id FROM user_wallets
+ WHERE user_id = ${auth.userId} AND address = ${recipientWallet} AND chain_type = 'solana'
+ LIMIT 1
+ `;
+ if (!walletRow) return error(res, 403, 'forbidden', 'owner_address must be linked to your account');
+ } else {
+ recipientWallet = agentSol;
+ }
+
+ const onChainOwner = await getSubdomainOwner(label);
+ if (onChainOwner) {
+ return error(res, 409, 'conflict', `${fullDomain(label)} is already registered on-chain to ${onChainOwner}`);
+ }
+
+ const space = Number.isInteger(body?.space) && body.space >= 1000 && body.space <= 10000 ? body.space : 2000;
+ const urlOverride = `${getStorefrontOrigin()}/a/${encodeURIComponent(agentId)}`;
let minted;
try {
- minted = await createNamedSubdomain({ label, newOwner: target.address, space });
+ minted = await createNamedSubdomain({
+ label,
+ newOwner: recipientWallet,
+ space,
+ urlOverride,
+ });
} catch (err) {
- const status = err?.status || 500;
- const code = err?.code || 'mint_failed';
+ console.error('[api/sns-subdomain] mint_failed', err);
+ const status = err?.status || 502;
+ const code = err?.code || 'upstream_error';
return error(res, status, code, err?.message || 'subdomain mint failed');
}
- // Attach to the agent's identity when requested. We store the resolved
- // full name (e.g. "nich.threews.sol") so x402 manifests can carry it
- // directly via recipient_name without re-resolving.
- if (agentId && target.agent) {
- const nextMeta = { ...(target.agent.meta || {}), sns_domain: minted.fullName, sns_owner_wallet: target.address };
- await sql`UPDATE agent_identities SET meta = ${JSON.stringify(nextMeta)}::jsonb WHERE id = ${agentId}`;
- }
+ // Attach the new SNS identity to the agent. Stored as the full ".sol"
+ // name so downstream consumers (x402 manifest's `recipient_name`, agent
+ // page, marketplace card) can use it without re-resolving.
+ const nextMeta = {
+ ...(agent.meta || {}),
+ sns_domain: minted.fullName,
+ sns_owner_wallet: recipientWallet,
+ };
+ await sql`UPDATE agent_identities SET meta = ${JSON.stringify(nextMeta)}::jsonb WHERE id = ${agentId}`;
return json(res, 201, {
data: {
ok: true,
+ agent_id: agentId,
full_name: minted.fullName,
parent: minted.parent,
owner: minted.owner,
signature: minted.signature,
explorer: `https://solscan.io/tx/${minted.signature}`,
url_record: minted.url_record,
- storefront_path: `/u/${label}`,
- attached_to_agent: agentId && target.agent ? agentId : null,
+ agent_url: urlOverride,
},
});
+}
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET', 'POST'])) return;
+
+ if (req.method === 'GET') return handleCheck(req, res);
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in or provide a bearer token');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ return handleMint(req, res, auth);
});
diff --git a/docs/internal/SNS_PARTNERSHIP_PROPOSAL.md b/docs/internal/SNS_PARTNERSHIP_PROPOSAL.md
index b1a0ca98c..350ade42e 100644
--- a/docs/internal/SNS_PARTNERSHIP_PROPOSAL.md
+++ b/docs/internal/SNS_PARTNERSHIP_PROPOSAL.md
@@ -8,61 +8,68 @@
## Why now
-SNS owns Solana's identity layer — 350K+ .sol domains, the canonical mapping from human-readable name to wallet. three.ws is building the embodiment layer — 3D agents that live on Solana, transact via x402, and trade on Pump.fun. Every .sol domain deserves a face. Every three.ws agent needs a name. The fit is structural, not cosmetic.
+SNS owns Solana's identity layer — 350K+ .sol domains, the canonical wallet-to-name map. three.ws is the embodiment + commerce layer — 3D agents that live on Solana, transact via x402, trade on Pump.fun.
-We are not asking SNS to build anything new. We have already shipped the integration end-to-end on our side. This proposal is about making the integration official, joint-marketed, and (where it makes sense) revenue-shared.
+We are not asking you to build anything. The integration is shipped end-to-end on our side. This proposal is to make the partnership official, joint-marketed, and (where it makes sense) revenue-shared.
---
-## What is already live on three.ws
+## What is live on three.ws right now
### 1. x402 payment routing by .sol name
-Every x402 402-Payment-Required manifest emitted by a three.ws agent now carries the recipient's .sol domain alongside the wallet address. Payers — humans or agents — see and verify the human-readable name before signing.
+Every `402 Payment Required` manifest a three.ws agent emits now carries the recipient's .sol domain alongside the base58 wallet. Payers — humans or agents — see and verify the human-readable name before signing.
-- **Manifest field added:** `recipient_name`, populated from the agent's `meta.sns_domain` or by resolving a .sol-style `payments.receiver` via SNS.
-- **Fully backward-compatible:** clients that don't read `recipient_name` continue to pay against `recipient` (base58 wallet) as before.
-- **Code:** [api/_lib/x402.js](../../api/_lib/x402.js) — `resolveRecipient()` + `emit402()` + `manifestOnly()`.
+- New field: `recipient_name`, populated from `meta.sns_domain` or by resolving a .sol-style `payments.receiver` via SNS at manifest emission time.
+- Fully backward-compatible — clients that don't read the new field continue to pay the base58 `recipient`.
+- Code: [api/_lib/x402.js](../../api/_lib/x402.js).
This is the first x402 implementation in the Solana ecosystem that pays *by name*.
-### 2. User-registered names assigned to agents
+### 2. Subdomain minting under `threews.sol`
-Users can register a .sol domain and assign it to one of their agents in a single flow. From that moment, every public surface the agent appears on — agent page, x402 manifest, MCP tool listing, marketplace card — displays the .sol name in place of the raw wallet.
+three.ws owns `threews.sol`. Two endpoints expose two flows; both atomically mint, set the SNS `URL` record (so the subdomain is Brave-resolvable), and transfer ownership — all bundled into one VersionedTransaction so the subdomain is never claimable by a third party in between.
-- **Attach existing .sol:** `POST /api/agents/:id/sns { domain }` — verifies on-chain ownership across the agent wallet and the user's linked wallets, then writes `meta.sns_domain`.
-- **Register fresh:** `POST /api/agents/:id/sns/register-prep` + `register-confirm` — builds an unsigned tx for the user's wallet, confirms the on-chain owner, attaches the alias.
-- **Agent-pays variant:** `POST /api/agents/:id/sns/register` — the agent's own wallet pays in USDC and the alias is attached automatically.
-- **Code:** [api/agents/sns.js](../../api/agents/sns.js).
+- **User flow:** [POST /api/threews/subdomain](../../api/threews/subdomain.js)
+ - Label must equal the caller's `users.username` (impersonation guard).
+ - URL record → `https://three.ws/u/<label>` (the user's storefront).
+ - Claim is recorded in [`user_subdomains`](../../migrations/20260523130000_create_user_subdomains.sql).
+- **Agent flow:** [POST /api/sns-subdomain](../../api/sns-subdomain.js)
+ - Label is arbitrary (defaults to slugified agent name), reuses the same denylist.
+ - URL record → `https://three.ws/a/<agent_id>` (the agent's page).
+ - Writes `meta.sns_domain` on `agent_identities` so x402 manifests can carry the new name immediately.
-### 3. Subdomains under `threews.sol`
+Shared on-chain primitive: [src/solana/sns-subdomain.js](../../src/solana/sns-subdomain.js) — `createSubdomain` + `createRecordV2Instruction(url)` + `transferSubdomain` in one tx, signed only by the platform keypair (`THREEWS_SOL_PARENT_SECRET_BASE58`). Platform absorbs SOL gas. Zero wallet-signing friction for the user.
-three.ws owns `threews.sol`. We have built a one-call endpoint that mints any-label subdomain — `nich.threews.sol`, `claude.threews.sol`, `vernington.threews.sol` — and transfers ownership to the user (or their agent) in a single transaction. The platform absorbs the SOL gas cost so there is zero wallet-signing friction.
+### 3. SNS-resolved storefronts in Brave
-- **Endpoint:** `POST /api/sns-subdomain { label, agent_id?, owner_address? }`.
-- **Availability check:** `GET /api/sns-subdomain?label=nich` — on-chain lookup, no upstream call to Bonfida.
-- **Atomic create + transfer:** parent owner keypair signs `createSubdomain` and immediately `transferSubdomain` to the requested final owner, bundled into one VersionedTransaction. The subdomain is never claimable by a third party in between.
-- **Code:** [api/sns-subdomain.js](../../api/sns-subdomain.js), [src/solana/sns-subdomain.js](../../src/solana/sns-subdomain.js).
+Because every subdomain has a `URL` record set at mint time, typing `nich.threews.sol` in Brave (or any SNS-aware client) resolves directly to the user's `/u/nich` showcase on three.ws — no plugin, no extension, no extra steps. The showcase ([pages/profile.html](../../pages/profile.html), backed by [/api/users/:username](../../api/users/[username].js)) renders the user's public agents, avatars, paid skills, widgets, and socials — already wired and live before this session.
-Every three.ws user is one POST away from owning a `*.threews.sol` subdomain. Every agent is one POST away from being named.
+For agent-attached subdomains (`claude.threews.sol`, `vernington.threews.sol`), the same Brave-resolution path lands users on the agent's page directly. Every agent is one POST away from owning its own .sol address.
+
+### 4. Register and assign existing .sol names to agents
+
+Users who already own a .sol domain can attach it to an agent — no minting required:
+- `POST /api/agents/:id/sns { domain }` — verifies on-chain ownership against the agent's wallet and the user's linked Solana wallets, then writes `meta.sns_domain`.
+- `register-prep` / `register-confirm` — user-pays variant; builds an unsigned tx the user signs.
+- `register` (agent-pays variant) — the agent's own USDC ATA pays for the domain registration and the alias attaches automatically.
+- Code: [api/agents/sns.js](../../api/agents/sns.js).
---
## What we ask from SNS
-1. **Co-marketing.** One email + one X post + one Discord announcement to the .sol holder base when we launch the `*.threews.sol` subdomain program. We commit to symmetric coverage on our channels.
-2. **Listing.** three.ws on the SNS partners page as the official embodiment partner.
-3. **API tier.** Partnership-grade rate limits on `sns-api.bonfida.com` for bulk resolution and reverse lookups — our `recipient_name` enrichment hits this on every x402 manifest emission, so we are the heavy reader you want to formalise.
-4. **Roadmap input.** A shared channel (Telegram / Slack) to coordinate on subdomain-related primitives — sub-of-sub naming, on-chain SOL records for embedded avatars, transfer hooks.
-
----
+1. **Co-marketing.** One email + one X post + one Discord drop to the .sol holder base when we launch the `*.threews.sol` program. Symmetric coverage on our channels.
+2. **Partner listing.** three.ws on the SNS partners page as the official embodiment partner.
+3. **API tier.** Partnership-grade rate limits on `sns-api.bonfida.com` — our `recipient_name` enrichment hits SNS on every x402 manifest emission for named agents, so we are the heavy reader you would want to formalise.
+4. **Shared channel.** A Telegram / Slack to coordinate on subdomain primitives — sub-of-sub naming, on-chain SOL records pointing at avatar bundles, transfer hooks, IPFS record support for self-hostable storefront snapshots.
## What SNS gets
-- A consumer-facing visual product attached to every .sol — increases domain perceived value and retention.
+- A consumer visual product attached to every .sol — domain perceived value goes up, retention goes up.
- Distribution into the AI-agent narrative (currently the dominant Solana retail story via Pump.fun).
-- Revenue share on co-branded subdomains where we sell pricing tiers (vanity labels, single-letter subs).
-- Featured placement across three.ws agent pages, MCP tooling, the agent marketplace, and the public x402 payment manifests — every payment receipt for a named agent advertises SNS.
+- Revenue share on co-branded subdomain pricing tiers (vanity labels, single-letter subs).
+- Featured placement across three.ws agent pages, MCP tooling, the marketplace, and every paid x402 receipt — every payment for a named agent advertises SNS by name.
---
@@ -70,9 +77,10 @@ Every three.ws user is one POST away from owning a `*.threews.sol` subdomain. Ev
A 30-minute call this week. We bring a working demo:
-1. A user registers `claude.threews.sol` from our UI — confirmed on-chain in under 5 seconds, zero gas paid by the user.
-2. We assign it to a freshly-spawned agent.
-3. We make an x402 payment to that agent. The 402 manifest shows `recipient_name: "claude.threews.sol"`. The payer sees and verifies the name before signing.
+1. New user signs up, claims `claude.threews.sol` via three.ws — on-chain in under 5 seconds, zero gas paid by the user.
+2. Type `claude.threews.sol` into Brave — lands on `https://three.ws/u/claude` showing the user's agents, avatars, paid skills.
+3. Spawn a fresh agent. Mint `vernington.threews.sol`, attach to the agent. Type `vernington.threews.sol` in Brave — lands on the agent's page directly.
+4. Make an x402 payment to the agent. The 402 manifest shows `recipient_name: "vernington.threews.sol"`. The payer verifies the name before signing.
No slides. Working software.
@@ -82,11 +90,13 @@ No slides. Working software.
- Forward resolution: `GET /api/sns?name=nich.threews.sol` → `{ address, network: "solana" }`.
- Reverse resolution: `GET /api/sns?address=<base58>` → primary .sol domain.
-- Subdomain mint: `POST /api/sns-subdomain { label, agent_id?, owner_address? }`.
-- Subdomain availability: `GET /api/sns-subdomain?label=<label>`.
-- Agent attach: `POST /api/agents/:id/sns { domain }`.
-- Agent register (user-pays): `/api/agents/:id/sns/register-prep` + `/register-confirm`.
-- Agent register (agent-pays): `POST /api/agents/:id/sns/register { domain }`.
+- User subdomain (claim by username): `POST /api/threews/subdomain { label, owner_wallet? }`.
+- Agent subdomain (label-flexible, attaches to agent): `POST /api/sns-subdomain { agent_id, label?, owner_address? }`.
+- Subdomain availability: `GET /api/sns-subdomain?label=<label>` or `GET /api/threews/subdomain?label=<label>`.
+- Subdomain reverse-lookup (claim → user): `GET /api/users/by-subdomain?label=<label>`.
+- Agent attach existing .sol: `POST /api/agents/:id/sns { domain }`.
+- Agent register existing .sol (user-pays): `/api/agents/:id/sns/register-prep` + `/register-confirm`.
+- Agent register existing .sol (agent-pays): `POST /api/agents/:id/sns/register { domain }`.
- x402 manifest schema, augmented:
```json
@@ -98,7 +108,7 @@ No slides. Working software.
"amount": "1000000",
"currency": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"recipient": "<base58 wallet>",
- "recipient_name": "claude.threews.sol",
+ "recipient_name": "vernington.threews.sol",
"memo": "…",
"valid_until": 1716508800,
"intent_url": "/api/agents/payments/pay-prep",
@@ -107,4 +117,6 @@ No slides. Working software.
}
```
-- Parent owner keypair: held by three.ws under `THREEWS_SOL_PARENT_SECRET_BASE58`. Subdomains transfer ownership immediately after mint; the platform never retains custody.
+- Storefront route: `/u/<label>` → [pages/profile.html](../../pages/profile.html), backed by [`/api/users/<label>`](../../api/users/[username].js).
+- Parent owner keypair: held by three.ws under `THREEWS_SOL_PARENT_SECRET_BASE58`. Subdomains transfer ownership atomically with mint and URL record write; the platform never retains custody.
+- Tests: 44 SNS-related tests pass (`tests/api/sns.test.js`, `tests/api/threews-sns-helper.test.js`, `tests/solana-sns.test.js`).
diff --git a/public/demos/pricing.html b/public/demos/pricing.html
index 47c11ea52..9035afba2 100644
--- a/public/demos/pricing.html
+++ b/public/demos/pricing.html
@@ -375,6 +375,12 @@
let walkT = 0, walkStart = null, walkEnd = null, walkDur = 0.85;
let jumpT = 0, jumpStart = null, jumpEnd = null, jumpLift = 0;
let lastMoveKind = null; // 'walk' | 'jump' — read by landOnTier
+ // Post-jump root-Y ease: when the superhero clip lands, hips are
+ // well below baseRootPos.y. Snapping back to base in one frame
+ // pops; we ramp over ROOT_SETTLE_S inside the render hook so we
+ // reliably beat mixer.update() to the final write.
+ let rootSettleT = -1, rootSettleStart = 0;
+ const ROOT_SETTLE_S = 0.5;
const WALK_SPEED = 5; // world units per second
// Matches the av-superhero-jump clip (2.0s) — finishing a touch
// early so the landing-clamp pose doesn't sit frozen too long.
@@ -491,7 +497,12 @@
// The superhero-jump clip already ends in a landing crouch;
// layering another "land" reaction on top reads as a glitch
// (crouch → forward-roll). Hold the clip's final frame
- // briefly, then crossfade to idle.
+ // briefly, then crossfade to idle. The render hook eases
+ // root-Y back to base during this hold (see rootSettleT).
+ if (rootBone && baseRootPos) {
+ rootSettleStart = rootBone.position.y;
+ rootSettleT = 0;
+ }
setTimeout(() => {
if (phase === 'idle' && activeTier === t) setAnimation('idle', { loop: true });
}, 600);
@@ -622,13 +633,19 @@
renderer.render = (sc, cam) => {
try {
if (rootBone && baseRootPos) {
- // Always pin X/Z so the avatar stays on the parent
- // transform we control. Y is also pinned by default,
- // but the jump phase needs the clip's hip descent to
- // show through so the landing crouch reads with weight.
+ // X/Z always pinned — our parent transform owns horizontal placement.
rootBone.position.x = baseRootPos.x;
rootBone.position.z = baseRootPos.z;
- if (phase !== 'jumping') rootBone.position.y = baseRootPos.y;
+ if (phase === 'jumping') {
+ // Let the clip's hip Y through so the leap+crouch reads.
+ } else if (rootSettleT >= 0 && rootSettleT < ROOT_SETTLE_S) {
+ // Ease from the landed-crouch hip-Y back to base.
+ const p = rootSettleT / ROOT_SETTLE_S;
+ const eased = p * p * (3 - 2 * p);
+ rootBone.position.y = rootSettleStart + (baseRootPos.y - rootSettleStart) * eased;
+ } else {
+ rootBone.position.y = baseRootPos.y;
+ }
}
} catch (_) {}
_r(sc, cam);
@@ -653,6 +670,7 @@
try {
const dt = Math.min(clock.getDelta(), 0.05);
mixer?.update(dt);
+ if (rootSettleT >= 0) rootSettleT += dt;
if (phase === 'walking' && avatar && walkStart && walkEnd) {
walkT += dt;
diff --git a/scripts/build-local-skill-packs.mjs b/scripts/build-local-skill-packs.mjs
new file mode 100644
index 000000000..2f9cc45fd
--- /dev/null
+++ b/scripts/build-local-skill-packs.mjs
@@ -0,0 +1,146 @@
+#!/usr/bin/env node
+/**
+ * Generate data/_generated/local-skill-packs.json by scanning the four
+ * SKILL.md pack directories (.agents/skills, pump-fun-skills, public/skills,
+ * examples/skills).
+ *
+ * Why: api/chat-skills.js previously did the scan at runtime via
+ * src/skills/local-packs.js, which derived REPO_ROOT from
+ * `new URL('../..', import.meta.url)`. Vercel's @vercel/nft tracer treats
+ * that root pointer as a needed asset and ends up bundling the entire repo
+ * (~615mb) into the function, blowing past the 300mb limit. Precomputing
+ * the pack list at build time keeps the function bundle small.
+ */
+import { readdirSync, readFileSync, statSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';
+import { join, basename, relative, resolve, dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const here = dirname(fileURLToPath(import.meta.url));
+const REPO_ROOT = resolve(here, '..');
+const outFile = resolve(REPO_ROOT, 'data/_generated/local-skill-packs.json');
+
+const SKILL_DIRS = [
+ { path: '.agents/skills', source: 'agentic-wallet', category: 'wallet' },
+ { path: 'pump-fun-skills', source: 'pump-fun-skills', category: 'pump-fun' },
+ { path: 'public/skills', source: 'public-skills', category: 'integrations' },
+ { path: 'examples/skills', source: 'examples', category: 'examples' },
+];
+
+function unquote(v) {
+ const s = v.trim();
+ if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
+ return s.slice(1, -1);
+ }
+ return s;
+}
+
+function foldedJoin(f) {
+ let indent = null;
+ const out = [];
+ for (const l of f.lines) {
+ if (l === '') {
+ out.push('');
+ continue;
+ }
+ if (indent === null) {
+ const m = l.match(/^(\s*)/);
+ indent = m[1].length;
+ }
+ out.push(l.slice(indent));
+ }
+ const joined = out.join('\n').trim();
+ if (f.mode === '>') return joined.replace(/\n+/g, ' ').replace(/\s+/g, ' ').trim();
+ return joined;
+}
+
+function parseFrontmatter(src) {
+ if (!src.startsWith('---\n')) return { data: {}, body: src };
+ const end = src.indexOf('\n---', 4);
+ if (end === -1) return { data: {}, body: src };
+ const raw = src.slice(4, end);
+ const body = src.slice(end + 4).replace(/^\s*\n/, '');
+ const data = {};
+ const lines = raw.split('\n');
+ let key = null;
+ let folded = null;
+ for (const line of lines) {
+ if (folded) {
+ const m = line.match(/^(\s*)(.*)$/);
+ const indent = m[1].length;
+ const text = m[2];
+ if (text === '' || indent >= 2) {
+ folded.lines.push(text);
+ continue;
+ }
+ data[key] = foldedJoin(folded);
+ folded = null;
+ }
+ const m = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
+ if (!m) continue;
+ key = m[1];
+ const value = m[2];
+ if (value === '>' || value === '|') {
+ folded = { mode: value, indent: 0, lines: [] };
+ continue;
+ }
+ data[key] = unquote(value);
+ }
+ if (folded) data[key] = foldedJoin(folded);
+ return { data, body };
+}
+
+function scanDir({ path, source, category }) {
+ const abs = join(REPO_ROOT, path);
+ if (!existsSync(abs)) return [];
+ let entries;
+ try {
+ entries = readdirSync(abs);
+ } catch {
+ return [];
+ }
+ const packs = [];
+ for (const name of entries) {
+ const dir = join(abs, name);
+ let st;
+ try {
+ st = statSync(dir);
+ } catch {
+ continue;
+ }
+ if (!st.isDirectory()) continue;
+ const skillPath = join(dir, 'SKILL.md');
+ if (!existsSync(skillPath)) continue;
+ let raw;
+ try {
+ raw = readFileSync(skillPath, 'utf8');
+ } catch {
+ continue;
+ }
+ const { data, body } = parseFrontmatter(raw);
+ const slug = String(data.name || basename(dir));
+ packs.push({
+ id: `local:${source}:${slug}`,
+ source,
+ category: data.category || category,
+ name: slug,
+ slug,
+ description: data.description || '',
+ version: data.version || null,
+ trust: data.trust || null,
+ kind: 'knowledge',
+ has_content: true,
+ content: raw,
+ body,
+ path: relative(REPO_ROOT, skillPath),
+ });
+ }
+ return packs;
+}
+
+const all = [];
+for (const dir of SKILL_DIRS) all.push(...scanDir(dir));
+
+mkdirSync(dirname(outFile), { recursive: true });
+writeFileSync(outFile, JSON.stringify(all, null, '\t') + '\n');
+
+console.log(`[build-local-skill-packs] wrote ${all.length} packs → ${outFile}`);
diff --git a/src/skills/local-packs.js b/src/skills/local-packs.js
index f8110e445..bee635f09 100644
--- a/src/skills/local-packs.js
+++ b/src/skills/local-packs.js
@@ -1,140 +1,24 @@
-// Reads SKILL.md packs from every local skill directory in the repo and
-// returns them as normalized records the chat marketplace can render and
-// install. Packs are the Claude-style format: YAML frontmatter + markdown
-// body. The body becomes a "knowledge skill" the chat injects into the
-// system prompt; the agent reads it and follows the embedded instructions.
-
-import { readdirSync, readFileSync, statSync, existsSync } from 'fs';
-import { join, basename, relative } from 'path';
-import { fileURLToPath } from 'url';
-
-const REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url));
-
-const SKILL_DIRS = [
- { path: '.agents/skills', source: 'agentic-wallet', category: 'wallet' },
- { path: 'pump-fun-skills', source: 'pump-fun-skills', category: 'pump-fun' },
- { path: 'public/skills', source: 'public-skills', category: 'integrations' },
- { path: 'examples/skills', source: 'examples', category: 'examples' },
-];
-
-function unquote(v) {
- const s = v.trim();
- if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'"))) {
- return s.slice(1, -1);
- }
- return s;
-}
-
-function foldedJoin(f) {
- let indent = null;
- const out = [];
- for (const l of f.lines) {
- if (l === '') {
- out.push('');
- continue;
- }
- if (indent === null) {
- const m = l.match(/^(\s*)/);
- indent = m[1].length;
- }
- out.push(l.slice(indent));
- }
- const joined = out.join('\n').trim();
- if (f.mode === '>') return joined.replace(/\n+/g, ' ').replace(/\s+/g, ' ').trim();
- return joined;
-}
-
-function parseFrontmatter(src) {
- if (!src.startsWith('---\n')) return { data: {}, body: src };
- const end = src.indexOf('\n---', 4);
- if (end === -1) return { data: {}, body: src };
- const raw = src.slice(4, end);
- const body = src.slice(end + 4).replace(/^\s*\n/, '');
- const data = {};
- const lines = raw.split('\n');
- let key = null;
- let folded = null;
- for (const line of lines) {
- if (folded) {
- const m = line.match(/^(\s*)(.*)$/);
- const indent = m[1].length;
- const text = m[2];
- if (text === '' || indent >= 2) {
- folded.lines.push(text);
- continue;
- }
- data[key] = foldedJoin(folded);
- folded = null;
- }
- const m = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
- if (!m) continue;
- key = m[1];
- const value = m[2];
- if (value === '>' || value === '|') {
- folded = { mode: value, indent: 0, lines: [] };
- continue;
- }
- data[key] = unquote(value);
- }
- if (folded) data[key] = foldedJoin(folded);
- return { data, body };
-}
-
-function scanDir({ path, source, category }) {
- const abs = join(REPO_ROOT, path);
- if (!existsSync(abs)) return [];
- let entries;
- try {
- entries = readdirSync(abs);
- } catch {
- return [];
- }
- const packs = [];
- for (const name of entries) {
- const dir = join(abs, name);
- let st;
- try {
- st = statSync(dir);
- } catch {
- continue;
- }
- if (!st.isDirectory()) continue;
- const skillPath = join(dir, 'SKILL.md');
- if (!existsSync(skillPath)) continue;
- let raw;
- try {
- raw = readFileSync(skillPath, 'utf8');
- } catch {
- continue;
- }
- const { data, body } = parseFrontmatter(raw);
- const slug = String(data.name || basename(dir));
- packs.push({
- id: `local:${source}:${slug}`,
- source,
- category: data.category || category,
- name: slug,
- slug,
- description: data.description || '',
- version: data.version || null,
- trust: data.trust || null,
- kind: 'knowledge',
- has_content: true,
- content: raw,
- body,
- path: relative(REPO_ROOT, skillPath),
- });
- }
- return packs;
-}
+// Reads the precomputed SKILL.md pack list produced by
+// scripts/build-local-skill-packs.mjs at build time.
+//
+// Why precomputed: scanning the four pack dirs at runtime required deriving
+// REPO_ROOT from `new URL('../..', import.meta.url)`. Vercel's @vercel/nft
+// tracer treats that root pointer as a needed asset and bundles the entire
+// repo into every function that imports this module, blowing past the 300mb
+// function limit. Pointing only at the generated JSON file keeps the trace
+// scoped to a single small artifact.
+//
+// Packs are the Claude-style format: YAML frontmatter + markdown body. The
+// body becomes a "knowledge skill" the chat injects into the system prompt;
+// the agent reads it and follows the embedded instructions.
+
+import { readFileSync } from 'fs';
let _cached = null;
export function loadLocalSkillPacks() {
if (_cached) return _cached;
- const all = [];
- for (const dir of SKILL_DIRS) {
- all.push(...scanDir(dir));
- }
- _cached = all;
- return all;
+ _cached = JSON.parse(
+ readFileSync(new URL('../../data/_generated/local-skill-packs.json', import.meta.url), 'utf8'),
+ );
+ return _cached;
}
diff --git a/src/solana/sns-subdomain.js b/src/solana/sns-subdomain.js
index e4cfa7ca2..911bd2272 100644
--- a/src/solana/sns-subdomain.js
+++ b/src/solana/sns-subdomain.js
@@ -107,7 +107,13 @@ export async function checkSubdomainAvailability({ connection, parentDomain, lab
*
* Returns { signature, fullName, owner }.
*/
-export async function createNamedSubdomain({ label, newOwner, space = 2000, rpcUrl = DEFAULT_RPC_URL }) {
+export async function createNamedSubdomain({
+ label,
+ newOwner,
+ space = 2000,
+ rpcUrl = DEFAULT_RPC_URL,
+ urlOverride,
+}) {
const cleanLabel = normalizeLabel(label);
if (!cleanLabel) {
const e = new Error('invalid subdomain label');
@@ -139,8 +145,10 @@ export async function createNamedSubdomain({ label, newOwner, space = 2000, rpcU
// Write the URL record while the platform still owns the subdomain.
// This makes `<label>.threews.sol` resolve in Brave (and any other SNS-
- // aware client) to the user's storefront page on three.ws.
- const url = storefrontUrlForLabel(cleanLabel);
+ // aware client) to the right page on three.ws — the user's `/u/<label>`
+ // storefront by default, or a caller-supplied override (e.g. an agent
+ // page when the subdomain is being attached to an agent).
+ const url = urlOverride || storefrontUrlForLabel(cleanLabel);
const urlRecordIx = sns.createRecordV2Instruction(
fullName,
sns.Record.Url,
diff --git a/tests/api/x402.test.js b/tests/api/x402.test.js
index b33807129..671381a8c 100644
--- a/tests/api/x402.test.js
+++ b/tests/api/x402.test.js
@@ -76,6 +76,61 @@ describe('emit402', () => {
expect(res.statusCode).not.toBe(402);
});
+ it('surfaces meta.sns_domain as recipient_name when set', async () => {
+ const res = makeRes();
+ await emit402(res, {
+ agent: makeAgent({
+ sns_domain: 'vernington.threews.sol',
+ payments: {
+ configured: true,
+ provider: 'pumpfun',
+ mint: 'MintPubkey1111111111111111111111111111111',
+ receiver: 'OwnerWallet111111111111111111111111111111',
+ cluster: 'mainnet',
+ },
+ }),
+ skill: 's',
+ amount: '1',
+ currency: 'X',
+ });
+ const body = JSON.parse(res.body);
+ expect(body.recipient).toBe('OwnerWallet111111111111111111111111111111');
+ expect(body.recipient_name).toBe('vernington.threews.sol');
+ });
+
+ it('appends .sol when meta.sns_domain is stored without the suffix', async () => {
+ const res = makeRes();
+ await emit402(res, {
+ agent: makeAgent({
+ sns_domain: 'vernington.threews',
+ payments: {
+ configured: true,
+ provider: 'pumpfun',
+ mint: 'MintPubkey1111111111111111111111111111111',
+ receiver: 'OwnerWallet111111111111111111111111111111',
+ cluster: 'mainnet',
+ },
+ }),
+ skill: 's',
+ amount: '1',
+ currency: 'X',
+ });
+ const body = JSON.parse(res.body);
+ expect(body.recipient_name).toBe('vernington.threews.sol');
+ });
+
+ it('leaves recipient_name null when no SNS identity is attached', async () => {
+ const res = makeRes();
+ await emit402(res, {
+ agent: makeAgent(),
+ skill: 's',
+ amount: '1',
+ currency: 'X',
+ });
+ const body = JSON.parse(res.body);
+ expect(body.recipient_name).toBeNull();
+ });
+
it('honors validForSec', async () => {
const res = makeRes();
const before = Math.floor(Date.now() / 1000);