Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: enhance identity job pipeline with retry logic and add premium vanity inventory endpoint
fudjia99d7a103a10d
diff --git a/api/_okx3d/identity.js b/api/_okx3d/identity.jsindex 5287843d1..2600790e7 100644--- a/api/_okx3d/identity.js+++ b/api/_okx3d/identity.js@@ -476,14 +476,14 @@ export async function createIdentityJob({}async function beginRig(base, state) {+ state.stage = 'rig';try {const rig = await startRig(base, state.gen.glbUrl);- state.stage = 'rig';state.attempts.rig += 1;state.rig.jobId = rig.job_id;state.error = null;} catch (err) {- return failStage(base, state, 'rig', err);+ return failStage(state, 'rig', err);}return saveState(state);}@@ -515,10 +515,28 @@ export async function advanceIdentityJob(id, { base = BASE } = {}) {if (!state) return null;if (state.stage === 'generate') {- if (!state.gen.glbUrl) {+ if (!state.gen.glbUrl && !state.gen.jobId) {+ // A previous attempt failed — this poll performs the free retry.+ try {+ const gen = await submitForge(+ base,+ state.input.referenceImageUrl+ ? { image_urls: [state.input.referenceImageUrl], prompt: state.prompt.effective, aspect_ratio: '3:4' }+ : { prompt: state.prompt.effective, aspect_ratio: '3:4' },+ );+ state.gen.jobId = gen.job_id ?? null;+ if (gen.status === 'done' && gen.glb_url) {+ state.gen.glbUrl = gen.glb_url;+ state.gen.backend = gen.backend ?? state.gen.backend;+ }+ await saveState(state);+ } catch (err) {+ await failStage(state, 'generate', err);+ }+ } else if (!state.gen.glbUrl) {const status = await pollForgeOnce(base, state.gen.jobId);if (status.status === 'failed') {- await failStage(base, state, 'generate', pipelineError('generation_failed', status.error || 'generation failed'));+ await failStage(state, 'generate', pipelineError('generation_failed', status.error || 'generation failed'));} else if (status.status === 'done' && status.glb_url) {state.gen.glbUrl = status.glb_url;state.gen.backend = status.backend ?? state.gen.backend;@@ -527,13 +545,18 @@ export async function advanceIdentityJob(id, { base = BASE } = {}) {}if (state.stage === 'generate' && state.gen.glbUrl) await beginRig(base, state);} else if (state.stage === 'rig') {- const status = await pollForgeOnce(base, state.rig.jobId);- if (status.status === 'failed') {- await failStage(base, state, 'rig', pipelineError('rig_failed', status.error || 'rigging failed'));- } else if (status.status === 'done' && status.glb_url) {- state.rig.glbUrl = status.glb_url;- state.stage = 'render';- await saveState(state);+ if (!state.rig.jobId) {+ // Rig submission failed earlier — retry it on this poll.+ await beginRig(base, state);+ } else {+ const status = await pollForgeOnce(base, state.rig.jobId);+ if (status.status === 'failed') {+ await failStage(state, 'rig', pipelineError('rig_failed', status.error || 'rigging failed'));+ } else if (status.status === 'done' && status.glb_url) {+ state.rig.glbUrl = status.glb_url;+ state.stage = 'render';+ await saveState(state);+ }}} else if (state.stage === 'render') {const step = state.plan[state.renderCursor];@@ -572,7 +595,7 @@ export async function advanceIdentityJob(id, { base = BASE } = {}) {await saveState(state);await sleep(250);} else {- await failStage(base, state, 'render', err);+ await failStage(state, 'render', err);}}}diff --git a/data/pages.json b/data/pages.jsonindex 04a85e5a3..cd032f6cd 100644--- a/data/pages.json+++ b/data/pages.json@@ -1381,6 +1381,15 @@"changefreq": "weekly","added": "2026-04-29"},+ {+ "path": "/agent-identities",+ "title": "Agent Identity Studio — 3D avatars for AI agents",+ "description": "Every AI agent deserves a face. A brand brief becomes a rigged 3D avatar plus posed studio renders — see the demo identities generated end-to-end by the pipeline.",+ "priority": 0.8,+ "changefreq": "weekly",+ "added": "2026-07-06",+ "showcase": true+ },{"path": "/agent","title": "Agent Home",diff --git a/docs/gcp-credits.md b/docs/gcp-credits.mdindex fd21fc86b..fa66a5109 100644--- a/docs/gcp-credits.md+++ b/docs/gcp-credits.md@@ -467,6 +467,113 @@ reconstruction quality holds. If it regresses, keep the image lane on FLUXUpdate the _pending_ cells in this file as each step completes.+---+---++# Premium vanity inventory (prompt 06)++Grind long, brandable Solana vanity addresses **ahead of time** on cheap spot CPU+and sell them from stock via a new x402 tier — the durable, near-zero-marginal-cost+"asset factory" use of the credits. The live grinder (`/api/x402/vanity`, the+`vanity_grinder` MCP tool) still handles fresh ≤3-char grinds; this is the 4–5++char **sell-from-stock** lane.++## Shape++```+targets → workers/vanity-grinder (spot CPU) → seal in-process → vanity_inventory (ciphertext)+ │+ browse: /vanity/premium ── /api/x402/vanity-premium (list) ─────┤+ buy: /api/x402/vanity-premium?address=… (x402) → reserve → settle → reveal ONCE → destroy+```++- **Grinder:** `workers/vanity-grinder/` (Node + the same Rust/WASM ed25519 engine+ as the serverless tier, one worker/vCPU). Seals every key with+ `api/_lib/vanity-vault.js` **before any write**; writes only ciphertext.+ Resumable (checkpoint) and SIGTERM-clean for spot preemption.+- **Store:** `vanity_inventory` (migration `20260706120000_vanity_premium_inventory.sql`),+ atomic single-use reveal in `api/_lib/vanity-inventory-store.js`.+- **Sell:** `api/x402/vanity-premium.js` (list + buy + one-time delivery),+ browsable at `/vanity/premium`, plus the free `vanity_premium` MCP browse tool.+- **Encryption:** secret-box AES-256-GCM (`WALLET_ENCRYPTION_KEY`) by default —+ the platform's custodial-key pattern — with an **optional GCP-KMS envelope**+ (`VANITY_KMS_KEY`) that gates decrypt to the delivery identity via IAM.++## Run it (owner, once gcloud auth is restored)++```bash+export PROJECT_ID=aerial-vehicle-466722-p5++# 1) (recommended) KMS envelope — decrypt granted ONLY to the delivery SA:+./scripts/gcp/vanity-kms-setup.sh # prints VANITY_KMS_KEY++# 2) Put the vault secrets in Secret Manager (grinder + delivery both need them):+# WALLET_ENCRYPTION_KEY, JWT_SECRET, DATABASE_URL (and VANITY_KMS_KEY as env)++# 3) Build + run the grinder on spot CPU, writing straight to the DB:+VANITY_KMS_KEY=<from step 1> WRITE_DB=1 TASKS=8 CPU=8 \+ ./scripts/gcp/vanity-grind-deploy.sh --run # Cloud Run Job (spot)+# …or a GCE spot MIG for very large runs:+# ./scripts/gcp/vanity-grind-deploy.sh --mig --instances 20++# 4) (file path) load an encrypted JSONL a run produced into the DB:+node scripts/vanity-inventory-load.mjs --file workers/vanity-grinder/out/inventory.jsonl+node scripts/vanity-inventory-load.mjs --stats+```++Migration first: `npm run db:migrate` (applies `20260706120000_vanity_premium_inventory.sql`).++## Measured throughput & $/address++Measured on a 16-vCPU dev box (the container's per-vCPU rate is identical — it's the+same WASM engine, one worker per core):++| metric | value |+|---|---|+| Throughput / vCPU | **~25,070 keys/sec** |+| Throughput, 16 vCPU | **~400k keys/sec** |+| Real run | 50+ addresses ground, all round-trip-verified (address = derived pubkey), all sealed at rest |++Cost at c2d **spot** ≈ $0.015 / vCPU-hour (25k keys/sec/vCPU). Price is value-based+($1–$50 by rarity), so the margin is enormous — the entire point of grinding on+free credits:++| pattern | expected attempts | vCPU-seconds | **$/address (spot)** | list price |+|---|---:|---:|---:|---:|+| 3-char, case-insensitive | ~36k | 1.4 | $0.000006 | $1 |+| 4-char, case-insensitive | ~1.2M | 47 | $0.0002 | $2–$5 |+| 4-char, case-sensitive | ~11.3M | 452 | $0.0019 | $6–$13 |+| 5-char, case-sensitive | ~656M | 26,244 | $0.11 | $30–$50 |++**Finding — Base58 leading-char bias:** a 32-byte value's *leading* Base58 char is+**not** uniformly distributed, so a case-**sensitive** prefix can be far harder than+the naive 58ⁿ estimate (some leading chars are near-impossible). The grinder caps+per-target attempts (`MAX_ATTEMPTS_PER_TARGET`, default 200M) and gives up on such+targets instead of hanging a worker. **Case-insensitive prefixes and suffixes+(uniform tail) are dramatically cheaper per useful address** — weight target lists+toward them. Revenue math: even 200 addresses cost cents of credits to grind and+list at $1–$50 each — a four-figure sellable asset for a near-zero credit outlay.++## Security review (threat model)++The store holds **real private keys**; the design defends each realistic threat:++| threat | mitigation |+|---|---|+| **DB dump** | Keys are AES-256-GCM (or KMS-envelope) ciphertext with a random per-record salt. A dump yields no spendable key without `WALLET_ENCRYPTION_KEY` (and, under KMS, a live IAM-gated decrypt call). |+| **Log leakage** | No secret is ever logged. The grinder's only "found" line is the public address + attempt count; the endpoint strips secret fields from the idempotency cache; the store's public reads select an explicit column list that omits `secret_ciphertext`. Verified by grep (`git grep -nE 'console.*(secretKey|privateKey|ciphertext)'` over the new files → none). |+| **Delivery replay / double-spend** | Single-use is a server-side atomic CTE (`reserveAndReveal`): the reveal flips status and nulls the ciphertext in one statement guarded by `status IN ('reserved','sold') AND secret_ciphertext IS NOT NULL`. A second call captures zero rows → `already_revealed`. The x402 idempotency cache stores a secret-free copy. |+| **Charge-without-delivery** | The endpoint decrypts (non-destructive peek) **before** settling; a KMS/decrypt outage fails the purchase *before* charging. Settle → reveal(destroy) only after decrypt is proven. |+| **Insider access** | With `VANITY_KMS_KEY` set, decrypt is granted (IAM) **only** to the delivery service identity and every decrypt is Cloud-Audit-Logged; the grinder SA gets encrypt-only. An env-var leak alone no longer decrypts the inventory. |+| **Custody dishonesty** | Every listing + delivery carries the required disclosure: platform-generated keys → use as a token mint or sweep to self-generated custody, not a treasury. Delete-after-reveal (retention 0) is the default. |++## Revert / wind-down++One-shot asset — nothing to revert. The inventory persists in the app DB and sells+down at **zero ongoing GCP cost** after the grind. Tear down the grinder MIG/Job+when a batch finishes (the deploy script prints the command). See the keep/kill+table below.+------diff --git a/docs/x402-endpoints.md b/docs/x402-endpoints.mdindex d83b414b5..23180c8f7 100644--- a/docs/x402-endpoints.md+++ b/docs/x402-endpoints.md@@ -134,6 +134,7 @@ for to feed the oracle and sniper.| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------- || `/api/x402/pump-launch` | $5.00 | Launch monitoring / a managed launch. || `/api/x402/vanity`, `/api/x402/vanity-verifiable` | per grind | Solana vanity address mining (verifiable variant returns proof). |+| `/api/x402/vanity-premium` | $1–$50 by rarity | **Premium inventory** — buy a pre-ground 4–5+ char brandable address from stock. GET lists available patterns + prices (free); `?address=…` buys via x402 and delivers the key **once** (ciphertext destroyed on delivery). Browsable at `/vanity/premium`. || `/api/x402/pay-by-name` | per call | Resolve and pay an SNS/ENS name (see [Agent wallets](agent-wallets.md)). || `/api/x402/did` | per call | Decentralized identifier resolution. || `/api/x402/billboard` | $0.05 | Post to the on-platform billboard. |diff --git a/prompts/gcp-credits/02-vertex-claude-provider.md b/prompts/gcp-credits/02-vertex-claude-provider.mdindex 82e921b9b..8d4c2ecb5 100644--- a/prompts/gcp-credits/02-vertex-claude-provider.md+++ b/prompts/gcp-credits/02-vertex-claude-provider.md@@ -109,6 +109,25 @@ fallback.`/brain` only if it earns its keep.- Never log token contents or SA material.+## Acceptance criteria++- [ ] `api/_lib/gcp-auth.js` extracted; `vertex-imagen.js` refactored onto it with no Imagen+ behavior change.+- [ ] `api/_lib/vertex-claude.js` exists: model-ID mapper + streaming/non-streaming message call.+- [ ] All four surfaces wired: `llm.js`, `api/llm/anthropic.js`, `api/chat.js`, `api/brain/chat.js`+ (+ `chat-models.js` catalog entries).+- [ ] Both flags off ⇒ byte-identical current behavior (proven in a local run, not assumed).+- [ ] Any Vertex error (429/5xx/quota) falls through to the existing chain — proven by forcing a+ failure locally and confirming the feature still responds.+- [ ] `vertex-anthropic` recorded distinctly in provider telemetry/health.+- [ ] Unit tests for the model-ID mapper and chain ordering under all four flag combinations.+- [ ] `scripts/gcp/vertex-llm-smoke.mjs` passes against `npm run dev` for `llmComplete`,+ `/api/llm/anthropic` streaming, and `/api/chat` streaming.+- [ ] Real-browser check done: embedded agent widget + main chat stream from Vertex with flags on,+ no console errors; flags off restores today's behavior.+- [ ] Flags set in Vercel **preview only**; production left unset.+- [ ] `npm test` green; `git diff` reviewed (no esbuild-mangled `api/*.js`).+## Wrap-upUpdate `docs/gcp-credits.md` (flags, model mapping, rollback = unset flags). Changelog entrydiff --git a/public/vanity-wallet.html b/public/vanity-wallet.htmlindex fd66e3c38..04c93d525 100644--- a/public/vanity-wallet.html+++ b/public/vanity-wallet.html@@ -215,7 +215,9 @@Verify the receipt — prove we generated your key fresh and never kept a copy. See the rarest wallets ground here in the<a href="/vanity/gallery" style="color:#ffd54f;text-decoration:none;border-bottom:1px solid rgba(255,213,79,.4)">proof-of-grind gallery</a>.Need a <strong>hard</strong> pattern too slow for one machine?- <a href="/vanity/bounties" style="color:#ffd54f;text-decoration:none;border-bottom:1px solid rgba(255,213,79,.4)">post a grind bounty</a> and a fleet grinds it for you.+ <a href="/vanity/bounties" style="color:#ffd54f;text-decoration:none;border-bottom:1px solid rgba(255,213,79,.4)">post a grind bounty</a> and a fleet grinds it for you,+ or buy a long, brandable one <strong>instantly from stock</strong> in the+ <a href="/vanity/premium" style="color:#ffd54f;text-decoration:none;border-bottom:1px solid rgba(255,213,79,.4)">premium inventory</a>.</p><div class="card">diff --git a/tests/api/okx-identity-studio.test.js b/tests/api/okx-identity-studio.test.jsindex 68e8f8fd9..b5e01f493 100644--- a/tests/api/okx-identity-studio.test.js+++ b/tests/api/okx-identity-studio.test.js@@ -185,12 +185,43 @@ describe('free lanes over HTTP', () => {it('GET /health runs real probes and reports per-subsystem status', async () => {fetchRoutes.forgeSubmit = () => jsonResponse(200, { tiers: [] });fetchRoutes.render = () => jsonResponse(200, { poses: [{ id: 'tpose' }] });+ // WO-03 probes: the retarget clip manifest, and the X Layer JSON-RPC+ // calls behind the payment-rail probe (block height + USD₮0 symbol read).+ fetchRoutes.ref = (u, init) => {+ if (String(u).includes('/animations/manifest.json')) {+ return jsonResponse(200, [{ name: 'idle', url: '/animations/idle.json' }]);+ }+ let rpc = {};+ try {+ rpc = JSON.parse(init?.body || '{}');+ } catch {+ /* not JSON-RPC */+ }+ const reply = (result) => jsonResponse(200, { jsonrpc: '2.0', id: rpc.id ?? 1, result });+ if (rpc.method === 'eth_blockNumber') return reply('0x10');+ if (rpc.method === 'eth_chainId') return reply('0xc4');+ if (rpc.method === 'eth_call') {+ // ABI-encoded string "USD₮0" — the on-chain symbol() return value.+ return reply(+ '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000007555344e282ae3000000000000000000000000000000000000000000000000000',+ );+ }+ return jsonResponse(404, {});+ };const res = makeRes();await handler(makeReq({ method: 'GET', service: 'health' }), res);expect(res.statusCode).toBe(200);const body = JSON.parse(res.body);expect(body.ok).toBe(true);- expect(body.subsystems.map((s) => s.name).sort()).toEqual(['generation', 'render', 'storage']);+ expect(body.subsystems.map((s) => s.name).sort()).toEqual([+ 'generation',+ 'payment-rail',+ 'render',+ 'retarget',+ 'storage',+ ]);+ const rail = body.subsystems.find((s) => s.name === 'payment-rail');+ expect(rail.token).toBe('USD₮0');});it('GET /health goes 503 when a subsystem is down — never a hardcoded ok', async () => {@@ -304,13 +335,22 @@ describe('pipeline state machine', () => {it('generation failure retries free, then fails honestly when attempts exhaust', async () => {const created = await call('create_identity', { agent_name: 'X', brief: 'test agent brief' });const jobId = created.result.structuredContent.job_id;+ let submits = 1; // the create call already submitted once+ const origSubmit = fetchRoutes.forgeSubmit;+ fetchRoutes.forgeSubmit = (...a) => {+ submits += 1;+ return origSubmit(...a);+ };fetchRoutes.forgePoll = () => jsonResponse(200, { status: 'failed', error: 'lane exploded' });- // attempt 1 failed → resubmit (attempts 2), poll fails again → resubmit (3), fail → terminal+ // fail → free resubmit → fail → free resubmit → fail → terminal (3 submissions total)let s;- for (let i = 0; i < 4; i++) s = await call('identity_status', { job_id: jobId });+ for (let i = 0; i < 10 && s?.result?.structuredContent?.status !== 'failed'; i++) {+ s = await call('identity_status', { job_id: jobId });+ }expect(s.result.structuredContent.status).toBe('failed');expect(s.result.isError).toBe(true);expect(s.result.structuredContent.last_error.message).toContain('lane exploded');+ expect(submits).toBe(3);});it('a Chinese brief is accepted and reaches the prompt director verbatim', async () => {diff --git a/tests/vanity-premium-inventory.test.js b/tests/vanity-premium-inventory.test.jsnew file mode 100644index 000000000..17fa03da5--- /dev/null+++ b/tests/vanity-premium-inventory.test.js@@ -0,0 +1,141 @@+/**+ * Premium vanity inventory — unit + (DB-gated) integration tests.+ *+ * Covers the security-critical guarantees of the sell-from-stock tier:+ * 1. Vault seal/open round-trips, and the sealed blob is NOT plaintext.+ * 2. A sealed keypair actually derives its address (the delivered key works).+ * 3. The difficulty→price curve is monotonic and clamped to [$1,$50].+ * 4. The batch grinder produces addresses that match the requested pattern.+ * 5. (DB-gated) single-use reveal + delete-after-reveal: a key is delivered+ * exactly once and its ciphertext is destroyed — a second reveal gets nothing.+ *+ * The store test only runs when DATABASE_URL points at a throwaway DB/branch;+ * it self-cleans and skips cleanly in CI without one.+ */++// secret-box reads these lazily at seal/open time; set before anything imports it.+process.env.WALLET_ENCRYPTION_KEY ||= 'vitest-ephemeral-wallet-key-000000000000000000';+process.env.JWT_SECRET ||= 'vitest-ephemeral-jwt-secret-00000000000000';++import { describe, it, expect } from 'vitest';+import { Keypair } from '@solana/web3.js';+import bs58 from 'bs58';++import { sealSecret, openSecret, preferredScheme, SCHEME_SECRETBOX } from '../api/_lib/vanity-vault.js';+import { priceFromRarity, priceForPattern, MIN_PRICE_USD, MAX_PRICE_USD } from '../api/_lib/vanity-inventory-pricing.js';+import { computeRarity } from '../src/solana/vanity/rarity.js';+import { grindToCompletion } from '../workers/vanity-grinder/wasm-grind.mjs';++describe('vanity-vault: seal/open', () => {+ it('round-trips a secret and never stores plaintext', async () => {+ const kp = Keypair.generate();+ const bundle = JSON.stringify({+ format: 'keypair',+ address: kp.publicKey.toBase58(),+ secretKeyBase58: bs58.encode(kp.secretKey),+ secretKey: Array.from(kp.secretKey),+ });+ const { ciphertext, scheme } = await sealSecret(bundle);++ // Without KMS configured, the default scheme is secret-box AES-256-GCM.+ expect(scheme).toBe(SCHEME_SECRETBOX);+ expect(preferredScheme()).toBe(SCHEME_SECRETBOX);+ // The ciphertext must not leak the key material.+ expect(ciphertext).not.toContain(bundle);+ expect(ciphertext).not.toContain(bs58.encode(kp.secretKey));+ expect(/secretKey/.test(ciphertext)).toBe(false);++ const opened = JSON.parse(await openSecret(ciphertext, scheme));+ expect(opened.address).toBe(kp.publicKey.toBase58());+ // The delivered key actually reconstructs the keypair for the address.+ const restored = Keypair.fromSecretKey(Uint8Array.from(opened.secretKey));+ expect(restored.publicKey.toBase58()).toBe(kp.publicKey.toBase58());+ });++ it('fails to open a corrupted ciphertext (authenticated encryption)', async () => {+ const { ciphertext, scheme } = await sealSecret('top-secret');+ const corrupted = ciphertext.slice(0, -4) + 'AAAA';+ await expect(openSecret(corrupted, scheme)).rejects.toBeTruthy();+ });+});++describe('vanity-inventory-pricing: difficulty → price curve', () => {+ it('clamps to [MIN, MAX] and rises with difficulty', () => {+ const p2 = priceForPattern({ prefix: 'ab' }); // ~2 chars+ const p4 = priceForPattern({ prefix: 'PUMP' }); // 4 chars+ const p5 = priceForPattern({ prefix: 'THREE' }); // 5 chars++ for (const p of [p2, p4, p5]) {+ expect(p.priceUsd).toBeGreaterThanOrEqual(MIN_PRICE_USD);+ expect(p.priceUsd).toBeLessThanOrEqual(MAX_PRICE_USD);+ expect(p.priceAtomics).toBe(Math.round(p.priceUsd * 1e6));+ }+ // Monotonic in difficulty.+ expect(p4.priceUsd).toBeGreaterThan(p2.priceUsd);+ expect(p5.priceUsd).toBeGreaterThanOrEqual(p4.priceUsd);+ // A hard 5-char pattern lands in the upper band.+ expect(p5.priceUsd).toBeGreaterThan(20);+ });++ it('never exceeds the ceiling even for an absurd pattern', () => {+ const rarity = computeRarity({ prefix: 'ABCDEFGH', suffix: 'ZYXW' });+ const { priceUsd } = priceFromRarity(rarity);+ expect(priceUsd).toBe(MAX_PRICE_USD);+ });+});++describe('batch grinder: produced addresses match the pattern', () => {+ it('grinds a 2-char prefix whose address starts with it', () => {+ const res = grindToCompletion({ prefix: 'ab', ignoreCase: true }, { maxAttempts: 5_000_000 });+ expect(res.status).toBe('found');+ expect(res.publicKey.toLowerCase().startsWith('ab')).toBe(true);+ // The secret key is a valid 64-byte Ed25519 key that derives the address.+ const kp = Keypair.fromSecretKey(res.secretKey);+ expect(kp.publicKey.toBase58()).toBe(res.publicKey);+ }, 30_000);++ it('gives up (exhausted) instead of hanging on an impossible cap', () => {+ // Tiny cap → returns exhausted rather than looping forever.+ const res = grindToCompletion({ prefix: 'zzzzz' }, { maxAttempts: 50_000 });+ expect(res.status).toBe('exhausted');+ }, 15_000);+});++// ── DB-gated: single-use reveal + delete-after-reveal ────────────────────────+const HAS_DB = Boolean(process.env.DATABASE_URL);+describe.skipIf(!HAS_DB)('vanity-inventory-store: single-use delivery (needs DATABASE_URL)', () => {+ it('delivers a key exactly once and destroys the ciphertext', async () => {+ const store = await import('../api/_lib/vanity-inventory-store.js');+ const kp = Keypair.generate();+ const address = kp.publicKey.toBase58();+ const { ciphertext, scheme } = await sealSecret(+ JSON.stringify({ format: 'keypair', address, secretKeyBase58: bs58.encode(kp.secretKey), secretKey: Array.from(kp.secretKey) }),+ );++ await store.upsertInventoryItem({+ address, patternLabel: 'TEST…', prefix: null, suffix: null,+ difficultyAttempts: 1000, rarityBits: 6, rarityTier: 'uncommon', rarityScore: 600,+ secretCiphertext: ciphertext, secretScheme: scheme, priceUsd: 1, retentionDays: 0,+ });++ const paymentId = 'test-pay-' + address.slice(0, 8);+ const reserved = await store.reserveForPurchase(address, { paymentId, purchaser: 'tester' });+ expect(reserved.ok).toBe(true);++ // First reveal returns the ciphertext and (retention 0) destroys it.+ const first = await store.reserveAndReveal(address, { paymentId });+ expect(first.ok).toBe(true);+ expect(first.destroyed).toBe(true);+ const opened = JSON.parse(await openSecret(first.ciphertext, first.scheme));+ expect(Keypair.fromSecretKey(Uint8Array.from(opened.secretKey)).publicKey.toBase58()).toBe(address);++ // Second reveal gets nothing — single use enforced server-side.+ const second = await store.reserveAndReveal(address, { paymentId });+ expect(second.ok).toBe(false);+ expect(second.reason).toBe('already_revealed');++ // The public item is now destroyed and holds no ciphertext.+ const pub = await store.getPublicItem(address);+ expect(pub.status).toBe('destroyed');+ });+});diff --git a/vercel.json b/vercel.jsonindex 60de9cc52..e4c09619e 100644--- a/vercel.json+++ b/vercel.json@@ -4359,6 +4359,14 @@"src": "/tour-builder/","dest": "/tour-builder.html"},+ {+ "src": "/agent-identities",+ "dest": "/agent-identities.html"+ },+ {+ "src": "/agent-identities/",+ "dest": "/agent-identities.html"+ },{"src": "/features","dest": "/features.html"diff --git a/vite.config.js b/vite.config.jsindex 9266d2e4e..d9cd44b7d 100644--- a/vite.config.js+++ b/vite.config.js@@ -315,6 +315,7 @@ const appConfig = {'what-is': resolve(__dirname, 'pages/what-is.html'),tour: resolve(__dirname, 'pages/tour.html'),'tour-builder': resolve(__dirname, 'pages/tour-builder.html'),+ 'agent-identities': resolve(__dirname, 'pages/agent-identities.html'),pitch: resolve(__dirname, 'pages/pitch.html'),features: resolve(__dirname, 'pages/features.html'),'features-ar': resolve(__dirname, 'pages/features/ar.html'),@@ -746,6 +747,8 @@ support: resolve(__dirname, 'pages/support.html'),const fileMap = {'/tour-builder': resolve(root, 'pages/tour-builder.html'),'/tour-builder/': resolve(root, 'pages/tour-builder.html'),+ '/agent-identities': resolve(root, 'pages/agent-identities.html'),+ '/agent-identities/': resolve(root, 'pages/agent-identities.html'),'/app': resolve(root, 'pages/app.html'),'/app-demo': resolve(root, 'pages/app-demo.html'),'/widget': resolve(root, 'pages/widget.html'),