Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(launchpad): studio + publish + renderer polish

nirholas8314f320d757
diff --git a/api/_lib/migrations/2026-05-14-launchpad-pages.sql b/api/_lib/migrations/2026-05-14-launchpad-pages.sql
index 2c886eafd..5e0210df1 100644
--- a/api/_lib/migrations/2026-05-14-launchpad-pages.sql
+++ b/api/_lib/migrations/2026-05-14-launchpad-pages.sql
@@ -10,17 +10,24 @@
begin;
create table if not exists launchpad_pages (
- slug text primary key, -- url-safe, [a-z0-9-]{1,40}
- template text not null, -- token-launchpad | paid-concierge | gated-showroom
- owner_wallet text not null, -- payout address (Sol base58 or 0x EVM)
- user_id uuid references users(id) on delete set null,
- config jsonb not null, -- full editor state {identity, avatar, copy, token, skill, scene, monetize}
- is_public boolean not null default true,
- view_count integer not null default 0,
- created_at timestamptz not null default now(),
- updated_at timestamptz not null default now()
+ slug text primary key, -- url-safe, [a-z0-9-]{1,40}
+ template text not null, -- token-launchpad | paid-concierge | gated-showroom
+ owner_wallet text not null, -- payout address (Sol base58 or 0x EVM)
+ owner_secret_hash text, -- sha256 of the edit secret returned to the publisher; null = legacy / wallet-only edit
+ user_id uuid references users(id) on delete set null,
+ config jsonb not null, -- full editor state {identity, avatar, copy, token, skill, scene, monetize, agentSkills, sections}
+ token_mint text, -- once a Pump.fun launch settles, the mint pubkey
+ is_public boolean not null default true,
+ view_count integer not null default 0,
+ created_at timestamptz not null default now(),
+ updated_at timestamptz not null default now()
);
+-- Backfill columns added after the initial CREATE TABLE — safe on databases
+-- that already ran an earlier version of this migration.
+alter table launchpad_pages add column if not exists owner_secret_hash text;
+alter table launchpad_pages add column if not exists token_mint text;
+
-- Lookups by owner (dashboard "my launchpads" view).
create index if not exists launchpad_pages_owner_wallet
on launchpad_pages (lower(owner_wallet));
diff --git a/api/launchpad/publish.js b/api/launchpad/publish.js
index dff0f2801..cbeab4006 100644
--- a/api/launchpad/publish.js
+++ b/api/launchpad/publish.js
@@ -1,18 +1,25 @@
// POST /api/launchpad/publish
//
-// Persists a Launchpad Studio configuration (src/editor/launchpad-studio.js)
-// to launchpad_pages so it can be served at /p/<slug>. Anonymous publish is
-// allowed — the studio is the "Wix of 3D avatars" surface and must work for
-// drive-by creators with no account. If the request is authenticated the
-// user_id is attached so the dashboard can list owned launchpads.
+// Persists a Launchpad Studio configuration to launchpad_pages so it can be
+// served at /p/<slug> and edited later. Anonymous publish is allowed — the
+// studio is the "Wix of 3D avatars" surface and must work for drive-by
+// creators with no account.
//
-// Slug uniqueness: insert with ON CONFLICT — anonymous re-publish is
-// rejected unless the wallet matches; authed re-publish is allowed if the
-// user already owns the slug. This stops casual squat-and-overwrite without
-// requiring a heavyweight ownership flow on day one.
+// Edit auth model:
+// • First publish of a slug returns `ownerSecret` (random 32-byte hex).
+// The studio stores it in localStorage keyed by slug.
+// • Subsequent publishes that change anything must include either:
+// (a) a matching `ownerSecret` in the request body, OR
+// (b) an authenticated session whose user_id matches the row, OR
+// (c) the same payout wallet as the existing row.
+// • Without one of those, slug is treated as taken (409 slug_taken).
//
-// Body shape mirrors mountLaunchpadStudio's state object.
+// This lets anonymous CMS-style editing work end-to-end: publish from a
+// browser → edit later from the same browser → secret travels with the
+// localStorage draft. Lose the secret AND the wallet AND the session → you
+// can't edit. That's the right tradeoff for a no-auth surface.
+import { createHash, randomBytes } from 'node:crypto';
import { sql } from '../_lib/db.js';
import { authenticateBearer, extractBearer, getSessionUser } from '../_lib/auth.js';
import { cors, error, json, method, readJson, wrap } from '../_lib/http.js';
@@ -24,65 +31,76 @@ const SOL_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
const EVM_RE = /^0x[a-fA-F0-9]{40}$/;
const TEMPLATES = ['token-launchpad', 'paid-concierge', 'gated-showroom'];
+const skillSchema = z.object({
+ name: z.string().trim().min(1).max(80),
+ price: z.number().nonnegative(),
+ currency: z.string().trim().min(1).max(10),
+ chain: z.string().trim().min(1).max(20),
+ description: z.string().max(280).optional().default(''),
+});
+
const bodySchema = z.object({
slug: z.string().regex(SLUG_RE, 'slug must be 1-40 chars, lowercase alphanumeric or hyphens'),
template: z.enum(TEMPLATES),
+ ownerSecret: z.string().min(32).max(128).optional(),
identity: z.object({
slug: z.string().optional(),
brand: z.string().max(20),
wallet: z.string().min(20).max(64),
website: z.string().max(300).optional().default(''),
theme: z.enum(['light', 'dark']).default('light'),
+ socials: z.object({
+ twitter: z.string().max(200).optional().default(''),
+ telegram: z.string().max(200).optional().default(''),
+ discord: z.string().max(200).optional().default(''),
+ }).optional(),
}),
avatar: z.object({
- src: z.string().url().or(z.string().startsWith('/')),
+ src: z.string().min(1).max(500),
name: z.string().max(80),
}),
copy: z.object({
headline: z.string().max(120),
- tagline: z.string().max(280),
- cta: z.string().max(40),
+ tagline: z.string().max(280),
+ cta: z.string().max(40),
}),
token: z.object({
- name: z.string().max(80).optional().default(''),
- ticker: z.string().max(10).optional().default(''),
- supply: z.number().int().nonnegative().optional().default(0),
- }).optional(),
- skill: z.object({
- name: z.string().max(80).optional().default(''),
- priceUsdc: z.number().nonnegative().optional().default(0),
- }).optional(),
- scene: z.object({
- src: z.string().max(500).optional().default(''),
+ name: z.string().max(80).optional().default(''),
+ ticker: z.string().max(10).optional().default(''),
+ supply: z.number().int().nonnegative().optional().default(0),
+ description: z.string().max(500).optional().default(''),
+ imageUrl: z.string().max(500).optional().default(''),
+ mint: z.string().max(64).optional().default(''),
}).optional(),
+ agentSkills: z.array(skillSchema).max(20).optional().default([]),
+ scene: z.object({ src: z.string().max(500).optional().default('') }).optional(),
monetize: z.object({
- kind: z.string().max(40),
- price: z.number().nonnegative(),
+ kind: z.string().max(40),
+ price: z.number().nonnegative(),
currency: z.string().max(10),
- chain: z.string().max(20),
+ chain: z.string().max(20),
}),
});
function validateWalletForChain(wallet, chain) {
if (chain === 'solana') return SOL_RE.test(wallet);
if (chain === 'base' || chain === 'polygon' || chain === 'ethereum') return EVM_RE.test(wallet);
- // Unknown chain — accept either format.
return SOL_RE.test(wallet) || EVM_RE.test(wallet);
}
+function hashSecret(secret) {
+ return createHash('sha256').update(secret).digest('hex');
+}
+
async function resolveAuth(req) {
try {
const session = await getSessionUser(req);
if (session) return { userId: session.id };
- } catch {
- // Session decode failure is non-fatal; fall through to bearer/anon.
- }
+ } catch {}
try {
const bearer = await authenticateBearer(extractBearer(req));
if (bearer) return { userId: bearer.userId };
- } catch {
- // Same — anonymous publish remains allowed.
- }
+ } catch {}
return null;
}
@@ -114,48 +132,75 @@ export default wrap(async (req, res) => {
const auth = await resolveAuth(req);
- // Ownership check on existing slugs.
const [existing] = await sql`
- SELECT slug, owner_wallet, user_id FROM launchpad_pages WHERE slug = ${data.slug}
+ SELECT slug, owner_wallet, owner_secret_hash, user_id
+ FROM launchpad_pages WHERE slug = ${data.slug}
`;
- if (existing) {
- const wantsOwnerMatch =
- (auth && existing.user_id && existing.user_id === auth.userId) ||
- existing.owner_wallet?.toLowerCase() === data.identity.wallet.toLowerCase();
- if (!wantsOwnerMatch) {
+
+ let ownerSecret = null;
+ let ownerSecretHash = null;
+
+ if (!existing) {
+ ownerSecret = randomBytes(32).toString('hex');
+ ownerSecretHash = hashSecret(ownerSecret);
+ } else {
+ // Edit auth: any of (a) matching secret, (b) same session user, (c) same wallet.
+ const secretOk = data.ownerSecret &&
+ existing.owner_secret_hash &&
+ hashSecret(data.ownerSecret) === existing.owner_secret_hash;
+ const sessionOk = auth?.userId && existing.user_id === auth.userId;
+ const walletOk = existing.owner_wallet?.toLowerCase() === data.identity.wallet.toLowerCase();
+ if (!secretOk && !sessionOk && !walletOk) {
return error(res, 409, 'slug_taken', 'that slug is already published — pick a different one');
}
+ // Existing row keeps its secret unless the publisher is rotating it.
+ ownerSecretHash = existing.owner_secret_hash;
+ // If the row was created before secrets existed, mint one on this update.
+ if (!ownerSecretHash) {
+ ownerSecret = randomBytes(32).toString('hex');
+ ownerSecretHash = hashSecret(ownerSecret);
+ }
}
const config = {
- identity: data.identity,
- avatar: data.avatar,
- copy: data.copy,
- token: data.token || {},
- skill: data.skill || {},
- scene: data.scene || {},
- monetize: data.monetize,
+ identity: data.identity,
+ avatar: data.avatar,
+ copy: data.copy,
+ token: data.token || {},
+ agentSkills: data.agentSkills || [],
+ scene: data.scene || {},
+ monetize: data.monetize,
};
+ const tokenMint = data.token?.mint?.trim() || null;
+
await sql`
- INSERT INTO launchpad_pages (slug, template, owner_wallet, user_id, config, updated_at)
- VALUES (${data.slug}, ${data.template}, ${data.identity.wallet}, ${auth?.userId || null}, ${JSON.stringify(config)}::jsonb, now())
+ INSERT INTO launchpad_pages
+ (slug, template, owner_wallet, owner_secret_hash, user_id, config, token_mint, updated_at)
+ VALUES
+ (${data.slug}, ${data.template}, ${data.identity.wallet}, ${ownerSecretHash},
+ ${auth?.userId || null}, ${JSON.stringify(config)}::jsonb, ${tokenMint}, now())
ON CONFLICT (slug) DO UPDATE SET
- template = EXCLUDED.template,
- owner_wallet = EXCLUDED.owner_wallet,
- user_id = COALESCE(EXCLUDED.user_id, launchpad_pages.user_id),
- config = EXCLUDED.config,
- updated_at = now()
+ template = EXCLUDED.template,
+ owner_wallet = EXCLUDED.owner_wallet,
+ owner_secret_hash = COALESCE(launchpad_pages.owner_secret_hash, EXCLUDED.owner_secret_hash),
+ user_id = COALESCE(EXCLUDED.user_id, launchpad_pages.user_id),
+ config = EXCLUDED.config,
+ token_mint = EXCLUDED.token_mint,
+ updated_at = now()
`;
- const origin =
- req.headers['x-forwarded-host']
- ? `https://${req.headers['x-forwarded-host']}`
- : 'https://three.ws';
+ const origin = req.headers['x-forwarded-host']
+ ? `https://${req.headers['x-forwarded-host']}`
+ : 'https://three.ws';
- return json(res, 200, {
+ const out = {
slug: data.slug,
url: `${origin}/p/${data.slug}`,
publishedAt: new Date().toISOString(),
- });
+ };
+ // Only return the secret on first publish (or first time we minted one for
+ // a legacy row). Subsequent updates must already have it client-side.
+ if (ownerSecret) out.ownerSecret = ownerSecret;
+ return json(res, 200, out);
});
diff --git a/public/p/render.js b/public/p/render.js
index 1af62006f..12499174a 100644
--- a/public/p/render.js
+++ b/public/p/render.js
@@ -84,6 +84,7 @@ function renderPage(root, payload) {
<div class="avatar-stage">
<agent-3d
src="${esc(avatarSrc)}"
+ viewer
background="transparent"
camera-controls="auto"
auto-rotate
diff --git a/src/editor/launchpad-studio.js b/src/editor/launchpad-studio.js
index 1cae0db47..0c939dc0a 100644
--- a/src/editor/launchpad-studio.js
+++ b/src/editor/launchpad-studio.js
@@ -1,23 +1,24 @@
// Launchpad Studio — the "Wix of 3D avatars + Stripe of x402 payments" surface.
//
-// Lets a user pick a template (Token Launchpad, Paid Concierge, …), fill a
-// short form (slug, wallet, website, brand, avatar, monetization), see a live
-// preview, and publish to a hosted profile at /p/<slug> that anyone can resell
-// or embed. The same config emits a copyable agent-skill JSON for the x402
-// bazaar and a one-line <script> embed snippet for any third-party site.
+// Pick a template (Token Launchpad, Paid Concierge, …), fill the form, see a
+// live preview, hit Publish. The published config is hosted at /p/<slug>;
+// the same studio is also the CMS for that page — opening
+// /launchpad?slug=<existing> hydrates the saved state and re-publish updates
+// the live page in place. Anyone can edit if they hold the owner secret
+// (returned on first publish, kept in localStorage on the publishing browser)
+// or if they sign in as the owning user.
//
// This module is NEW — it does not replace src/editor/embed-editor.js. The
// classic embed editor remains the place-and-scale UX; this is the
-// template-driven creation surface.
+// template-driven creation + CMS surface.
//
-// Usage: import { mountLaunchpadStudio } from './launchpad-studio.js';
-// mountLaunchpadStudio(rootEl, { template, slug, wallet, website });
+// Public API: import { mountLaunchpadStudio } from './launchpad-studio.js';
+// mountLaunchpadStudio(rootEl, { slug, template, wallet, ... });
import '../element.js'; // ensures <agent-3d> is registered
// ──────────────────────────────────────────────────────────────────────────
-// Templates — each describes the public-facing page that gets generated.
-// Adding a template here surfaces it in the picker and the renderer.
+// Templates
// ──────────────────────────────────────────────────────────────────────────
const TEMPLATES = [
{
@@ -25,7 +26,6 @@ const TEMPLATES = [
label: 'Token Launchpad',
tagline: 'White-label Pump.fun launcher with a 3D avatar host',
hint: 'Visitors land on a 3D-hosted page and mint a Pump.fun coin in one click. Creator wallet receives the launch fee split.',
- fields: ['slug', 'brand', 'wallet', 'website', 'avatar', 'tokenName', 'tokenTicker', 'tagline', 'cta'],
monetize: { kind: 'pump-launch', defaultPrice: 0.02, currency: 'SOL', chain: 'solana' },
defaultCta: 'Launch your coin',
defaultTagline: 'Mint a Pump.fun coin in seconds — hosted by your own 3D agent.',
@@ -35,7 +35,6 @@ const TEMPLATES = [
label: 'Paid Concierge',
tagline: '3D avatar that answers questions for x402 USDC',
hint: 'A hosted agent page that charges a per-question fee via x402. Replies stream from the configured agent skill.',
- fields: ['slug', 'brand', 'wallet', 'website', 'avatar', 'skill', 'price', 'tagline', 'cta'],
monetize: { kind: 'x402-call', defaultPrice: 0.01, currency: 'USDC', chain: 'base' },
defaultCta: 'Ask the concierge',
defaultTagline: 'Get an answer from the team in 5 seconds — paid in USDC.',
@@ -45,7 +44,6 @@ const TEMPLATES = [
label: 'Gated 3D Showroom',
tagline: 'Pay-to-enter glTF gallery with avatar greeter',
hint: 'Visitors pay a small USDC fee to unlock a private 3D scene. Use for product reveals, premium models, or NFT preview rooms.',
- fields: ['slug', 'brand', 'wallet', 'website', 'avatar', 'sceneSrc', 'price', 'tagline', 'cta'],
monetize: { kind: 'x402-unlock', defaultPrice: 0.05, currency: 'USDC', chain: 'base' },
defaultCta: 'Unlock the room',
defaultTagline: 'Step inside a private 3D space — one-time USDC pass.',
@@ -55,7 +53,9 @@ const TEMPLATES = [
const DEFAULT_AVATAR_SRC = '/avatars/default.glb';
const AGENT_3D_VERSION = '1.5.1';
const AGENT_3D_HOST = 'https://three.ws';
-const STORAGE_KEY = 'launchpadStudio:draft';
+const DRAFT_KEY = 'launchpadStudio:draft';
+const SECRETS_KEY = 'launchpadStudio:secrets'; // { [slug]: ownerSecret }
+const RECENT_KEY = 'launchpadStudio:recent'; // [{slug, template, headline, updatedAt}, ...]
const DEMO_AVATARS = [
{ id: 'demo-cz', name: 'CZ', model_url: '/avatars/cz.glb' },
@@ -66,12 +66,15 @@ const DEMO_AVATARS = [
{ id: 'demo-xbot', name: 'Xbot', model_url: 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Xbot.glb' },
];
+// ──────────────────────────────────────────────────────────────────────────
+// Styles (single template literal; component is self-mounted into <body>)
+// ──────────────────────────────────────────────────────────────────────────
const STYLE = `
.studio-root {
position: fixed;
inset: 0;
display: grid;
- grid-template-columns: 320px 1fr 360px;
+ grid-template-columns: 320px 1fr 380px;
grid-template-rows: 56px minmax(0, 1fr);
grid-template-areas: 'topbar topbar topbar' 'sidebar stage rail';
background: #0b0d10;
@@ -88,80 +91,57 @@ const STYLE = `
background: #0f1216;
border-bottom: 1px solid #1c2128;
}
- .topbar .brand {
- display: flex;
- align-items: center;
- gap: 10px;
- font-weight: 700;
- letter-spacing: -0.01em;
- }
- .topbar .brand .dot {
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: linear-gradient(135deg, #6366f1, #ec4899);
- }
- .topbar .pill {
- padding: 4px 10px;
- font-size: 11px;
- letter-spacing: 0.04em;
- text-transform: uppercase;
- color: #a1a1aa;
- background: #1a1d22;
- border-radius: 999px;
- }
- .topbar .actions { display: flex; gap: 8px; align-items: center; }
+ .topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
+ .topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #ec4899); }
+ .topbar .pill { padding: 4px 10px; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: #a1a1aa; background: #1a1d22; border-radius: 999px; }
+ .topbar .pill.editing { background: rgba(34,197,94,0.16); color: #4ade80; }
+ .topbar .actions { display: flex; gap: 8px; align-items: center; position: relative; }
.btn {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 8px 14px;
- font: inherit;
- font-size: 13px;
- font-weight: 500;
- color: #f4f4f5;
- background: #1f2329;
- border: 1px solid #2a2f37;
- border-radius: 8px;
- cursor: pointer;
- text-decoration: none;
+ display: inline-flex; align-items: center; gap: 6px;
+ padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 500;
+ color: #f4f4f5; background: #1f2329; border: 1px solid #2a2f37;
+ border-radius: 8px; cursor: pointer; text-decoration: none;
transition: background 0.12s, border 0.12s;
}
.btn:hover { background: #262b32; border-color: #353c46; }
- .btn.primary {
- background: linear-gradient(135deg, #6366f1, #8b5cf6);
- border-color: transparent;
- }
+ .btn.primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: #a1a1aa; }
.btn.ghost:hover { color: #f4f4f5; background: #1a1d22; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn.tiny { padding: 4px 8px; font-size: 11px; }
+ .btn.danger { color: #f87171; border-color: #3a1f24; background: #1f1416; }
+ .btn.danger:hover { background: #2a1a1d; }
+
+ .dropdown {
+ position: absolute; top: calc(100% + 6px); right: 0;
+ min-width: 280px; max-width: 360px; max-height: 420px; overflow-y: auto;
+ background: #15181d; border: 1px solid #262b32; border-radius: 10px;
+ box-shadow: 0 20px 50px -10px rgba(0,0,0,0.6);
+ padding: 6px; z-index: 50;
+ }
+ .dropdown-empty { padding: 14px; color: #71717a; font-size: 12px; }
+ .dropdown-item {
+ display: block; padding: 10px 12px; border-radius: 7px; cursor: pointer;
+ text-decoration: none; color: inherit;
+ }
+ .dropdown-item:hover { background: #1c2027; }
+ .dropdown-item .di-title { font-weight: 600; font-size: 13px; }
+ .dropdown-item .di-meta { color: #71717a; font-size: 11px; margin-top: 2px; }
.sidebar {
- grid-area: sidebar;
- overflow-y: auto;
- background: #0f1216;
- border-right: 1px solid #1c2128;
- padding: 20px 0;
+ grid-area: sidebar; overflow-y: auto;
+ background: #0f1216; border-right: 1px solid #1c2128; padding: 20px 0;
}
.sidebar h3 {
- margin: 0 0 8px;
- padding: 0 20px;
- font-size: 11px;
- font-weight: 600;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: #71717a;
+ margin: 0 0 8px; padding: 0 20px;
+ font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
+ text-transform: uppercase; color: #71717a;
}
.template-card {
- display: block;
- margin: 8px 16px;
- padding: 14px;
- background: #181b21;
- border: 1px solid #232830;
- border-radius: 10px;
- cursor: pointer;
- transition: border 0.12s, background 0.12s;
+ display: block; margin: 8px 16px; padding: 14px;
+ background: #181b21; border: 1px solid #232830; border-radius: 10px;
+ cursor: pointer; transition: border 0.12s, background 0.12s;
}
.template-card:hover { border-color: #3a4150; background: #1c2027; }
.template-card.active {
@@ -173,234 +153,159 @@ const STYLE = `
.template-card .hint { color: #71717a; font-size: 11px; line-height: 1.5; margin-top: 8px; }
.stage {
- grid-area: stage;
- overflow: auto;
- background: #15181d;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 32px 28px;
+ grid-area: stage; overflow: auto; background: #15181d;
+ display: flex; flex-direction: column; align-items: center; padding: 32px 28px;
}
.stage-frame {
- width: 100%;
- max-width: 980px;
+ width: 100%; max-width: 980px;
min-height: calc(100vh - 56px - 64px);
- background: var(--page-bg, #ffffff);
- color: var(--page-fg, #0f172a);
- border-radius: 16px;
+ background: var(--page-bg, #ffffff); color: var(--page-fg, #0f172a);
+ border-radius: 16px; overflow: hidden;
box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5), 0 0 0 1px #1c2128;
- overflow: hidden;
- display: flex;
- flex-direction: column;
+ display: flex; flex-direction: column;
}
.stage-frame header {
- padding: 20px 32px;
- display: flex;
- justify-content: space-between;
- align-items: center;
+ padding: 20px 32px; display: flex; justify-content: space-between; align-items: center;
border-bottom: 1px solid rgba(0,0,0,0.06);
}
- .stage-frame header .brand {
- display: flex;
- align-items: center;
- gap: 10px;
- font-weight: 700;
- }
+ .stage-frame header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.stage-frame header .brand .swatch {
- width: 18px;
- height: 18px;
- border-radius: 5px;
- background: var(--brand, #6366f1);
- }
- .stage-frame header .links {
- display: flex;
- gap: 18px;
- font-size: 13px;
- color: #64748b;
+ width: 22px; height: 22px; border-radius: 5px;
+ background: var(--brand, #6366f1) center/cover no-repeat;
+ box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
}
+ .stage-frame header .links { display: flex; gap: 14px; font-size: 13px; color: #64748b; align-items: center; }
.stage-frame header .links a { color: inherit; text-decoration: none; }
.stage-frame header .links a:hover { color: var(--brand, #6366f1); }
.stage-frame .hero {
- flex: 1;
- display: grid;
- grid-template-columns: 1.1fr 0.9fr;
- gap: 32px;
- padding: 48px 32px 64px;
- align-items: center;
+ flex: 1; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 32px;
+ padding: 48px 32px 28px; align-items: center;
}
.stage-frame .hero-copy h1 {
- font-size: clamp(28px, 4vw, 44px);
- line-height: 1.1;
- margin: 0 0 16px;
- letter-spacing: -0.02em;
- }
- .stage-frame .hero-copy p {
- font-size: 17px;
- line-height: 1.55;
- color: #475569;
- margin: 0 0 28px;
+ font-size: clamp(28px, 4vw, 44px); line-height: 1.1;
+ margin: 0 0 16px; letter-spacing: -0.02em;
}
+ .stage-frame .hero-copy p { font-size: 17px; line-height: 1.55; color: #475569; margin: 0 0 28px; }
.stage-frame .cta {
- display: inline-flex;
- align-items: center;
- gap: 8px;
- padding: 14px 22px;
- font-size: 15px;
- font-weight: 600;
- color: #fff;
- background: var(--brand, #6366f1);
- border: 0;
- border-radius: 12px;
- cursor: pointer;
- box-shadow: 0 6px 20px -8px var(--brand, #6366f1);
+ display: inline-flex; align-items: center; gap: 8px;
+ padding: 14px 22px; font-size: 15px; font-weight: 600;
+ color: #fff; background: var(--brand, #6366f1); border: 0; border-radius: 12px;
+ cursor: pointer; box-shadow: 0 6px 20px -8px var(--brand, #6366f1);
transition: transform 0.12s;
}
.stage-frame .cta:hover { filter: brightness(1.06); }
- .stage-frame .price-chip {
- margin-left: 12px;
- font-size: 13px;
- color: #64748b;
- }
+ .stage-frame .price-chip { margin-left: 12px; font-size: 13px; color: #64748b; }
.stage-frame .avatar-stage {
- position: relative;
- min-height: 360px;
- border-radius: 16px;
+ position: relative; min-height: 380px; border-radius: 16px;
background: linear-gradient(160deg, var(--brand, #6366f1) 0%, #1e1b4b 100%);
overflow: hidden;
}
- .stage-frame .avatar-stage agent-3d {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
+ .stage-frame .avatar-stage agent-3d { position: absolute; inset: 0; width: 100%; height: 100%; }
+ .stage-frame .token-strip {
+ display: flex; align-items: center; gap: 14px;
+ padding: 16px 32px; border-top: 1px solid rgba(0,0,0,0.06);
+ background: rgba(0,0,0,0.02);
+ }
+ .stage-frame.dark .token-strip { background: rgba(255,255,255,0.02); border-top-color: rgba(255,255,255,0.06); }
+ .stage-frame .token-logo {
+ width: 44px; height: 44px; border-radius: 10px;
+ background: rgba(0,0,0,0.06) center/cover no-repeat;
+ flex: 0 0 auto;
+ }
+ .stage-frame.dark .token-logo { background-color: rgba(255,255,255,0.06); }
+ .stage-frame .token-strip .token-meta { flex: 1; min-width: 0; }
+ .stage-frame .token-strip .token-name { font-weight: 700; font-size: 14px; }
+ .stage-frame .token-strip .token-desc { font-size: 12px; color: #64748b; line-height: 1.45; margin-top: 2px; }
+ .stage-frame.dark .token-strip .token-desc { color: #94a3b8; }
+ .stage-frame .skills-row {
+ display: flex; flex-wrap: wrap; gap: 8px;
+ padding: 12px 32px 24px;
+ }
+ .stage-frame .skill-pill {
+ display: inline-flex; align-items: center; gap: 6px;
+ padding: 6px 10px 6px 12px; border-radius: 999px;
+ background: rgba(99,102,241,0.08); color: var(--brand, #6366f1);
+ font-size: 12px; font-weight: 500;
+ border: 1px solid rgba(99,102,241,0.15);
+ }
+ .stage-frame.dark .skill-pill { background: rgba(99,102,241,0.16); }
+ .stage-frame .skill-pill .price {
+ background: var(--brand, #6366f1); color: #fff;
+ padding: 2px 7px; border-radius: 999px;
+ font-size: 10px; font-weight: 600;
}
.stage-frame footer {
- padding: 14px 32px;
- font-size: 12px;
- color: #94a3b8;
- text-align: center;
+ padding: 14px 32px; font-size: 12px; color: #94a3b8; text-align: center;
border-top: 1px solid rgba(0,0,0,0.05);
}
.stage-frame footer a { color: inherit; text-decoration: underline; }
- .rail {
- grid-area: rail;
- overflow-y: auto;
- background: #0f1216;
- border-left: 1px solid #1c2128;
- }
- .panel {
- padding: 18px 20px;
- border-bottom: 1px solid #1c2128;
- }
+ .rail { grid-area: rail; overflow-y: auto; background: #0f1216; border-left: 1px solid #1c2128; }
+ .panel { padding: 18px 20px; border-bottom: 1px solid #1c2128; }
.panel h4 {
- margin: 0 0 12px;
- font-size: 11px;
- font-weight: 600;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: #71717a;
+ margin: 0 0 12px; font-size: 11px; font-weight: 600;
+ letter-spacing: 0.08em; text-transform: uppercase; color: #71717a;
+ display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
- .field label {
- display: block;
- font-size: 12px;
- color: #a1a1aa;
- margin-bottom: 5px;
- }
+ .field label { display: block; font-size: 12px; color: #a1a1aa; margin-bottom: 5px; }
.field input, .field select, .field textarea {
- width: 100%;
- box-sizing: border-box;
- padding: 8px 10px;
- font: inherit;
- font-size: 13px;
- color: #f4f4f5;
- background: #181b21;
- border: 1px solid #262b32;
- border-radius: 7px;
- outline: none;
- }
- .field input:focus, .field select:focus, .field textarea:focus {
- border-color: #6366f1;
+ width: 100%; box-sizing: border-box; padding: 8px 10px;
+ font: inherit; font-size: 13px; color: #f4f4f5;
+ background: #181b21; border: 1px solid #262b32; border-radius: 7px; outline: none;
}
+ .field input:focus, .field select:focus, .field textarea:focus { border-color: #6366f1; }
.field textarea { min-height: 60px; resize: vertical; }
.field .help { color: #71717a; font-size: 11px; margin-top: 4px; line-height: 1.4; }
.field .row { display: flex; gap: 8px; }
.field .row > * { flex: 1; }
- .color-input {
- display: flex;
- align-items: center;
- gap: 8px;
- }
+ .color-input { display: flex; align-items: center; gap: 8px; }
.color-input input[type=color] {
- width: 36px;
- height: 32px;
- padding: 0;
- border: 1px solid #262b32;
- border-radius: 6px;
- background: #181b21;
- cursor: pointer;
- }
- .color-input input[type=text] {
- font-family: ui-monospace, monospace;
- text-transform: uppercase;
+ width: 36px; height: 32px; padding: 0;
+ border: 1px solid #262b32; border-radius: 6px; background: #181b21; cursor: pointer;
}
+ .color-input input[type=text] { font-family: ui-monospace, monospace; text-transform: uppercase; }
- .avatar-grid {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- gap: 6px;
- }
+ .avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 20px; }
.avatar-tile {
- aspect-ratio: 1;
- background: #181b21;
- border: 1px solid #262b32;
- border-radius: 6px;
- cursor: pointer;
- display: flex;
- align-items: flex-end;
- justify-content: center;
- padding: 4px;
- font-size: 10px;
- color: #a1a1aa;
- text-align: center;
- overflow: hidden;
- transition: border 0.12s;
+ aspect-ratio: 1; background: #181b21;
+ border: 1px solid #262b32; border-radius: 6px; cursor: pointer;
+ display: flex; align-items: flex-end; justify-content: center;
+ padding: 4px; font-size: 10px; color: #a1a1aa; text-align: center;
+ overflow: hidden; transition: border 0.12s;
}
.avatar-tile:hover { border-color: #3a4150; }
.avatar-tile.active { border-color: #6366f1; box-shadow: inset 0 0 0 1px #6366f1; }
- .publish-status {
- font-size: 12px;
- color: #a1a1aa;
- line-height: 1.5;
+ .skill-row {
+ display: grid; grid-template-columns: 1fr 90px 80px 28px;
+ gap: 6px; align-items: center; margin-bottom: 6px;
}
- .publish-status.ok { color: #4ade80; }
- .publish-status.err { color: #f87171; }
- .share-url {
- display: flex;
- gap: 6px;
- margin-top: 10px;
+ .skill-row input, .skill-row select {
+ padding: 6px 8px; font-size: 12px;
+ background: #181b21; border: 1px solid #262b32; border-radius: 6px; color: #f4f4f5;
}
- .share-url input {
- flex: 1;
- font-family: ui-monospace, monospace;
- font-size: 11px;
+ .skill-row .skill-remove {
+ display: flex; align-items: center; justify-content: center;
+ width: 28px; height: 28px; padding: 0;
+ font-size: 14px; line-height: 1;
+ background: transparent; border: 1px solid #262b32; border-radius: 6px;
+ color: #71717a; cursor: pointer;
}
+ .skill-row .skill-remove:hover { color: #f87171; border-color: #3a1f24; background: #1f1416; }
+
+ .publish-status { font-size: 12px; color: #a1a1aa; line-height: 1.5; }
+ .publish-status.ok { color: #4ade80; }
+ .publish-status.err { color: #f87171; }
+ .share-url { display: flex; gap: 6px; margin-top: 10px; }
+ .share-url input { flex: 1; font-family: ui-monospace, monospace; font-size: 11px; padding: 8px 10px; background: #181b21; border: 1px solid #262b32; border-radius: 6px; color: #f4f4f5; }
.snippet {
- font-family: ui-monospace, monospace;
- font-size: 11px;
- line-height: 1.5;
- background: #0a0c0f;
- color: #cbd5e1;
- border: 1px solid #1c2128;
- border-radius: 8px;
- padding: 10px 12px;
- max-height: 220px;
- overflow: auto;
- white-space: pre;
+ font-family: ui-monospace, monospace; font-size: 11px; line-height: 1.5;
+ background: #0a0c0f; color: #cbd5e1;
+ border: 1px solid #1c2128; border-radius: 8px; padding: 10px 12px;
+ max-height: 220px; overflow: auto; white-space: pre;
}
.snippet-actions { display: flex; gap: 6px; margin-top: 8px; }
@@ -419,46 +324,82 @@ const $ = (sel, root = document) => root.querySelector(sel);
const esc = (s) =>
String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const slugify = (s) =>
- String(s || '')
- .toLowerCase()
- .trim()
- .replace(/[^a-z0-9]+/g, '-')
- .replace(/^-+|-+$/g, '')
- .slice(0, 40);
-
-function loadDraft() {
- try {
- const raw = localStorage.getItem(STORAGE_KEY);
- return raw ? JSON.parse(raw) : null;
- } catch {
- return null;
- }
+ String(s || '').toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
+
+function lsGet(key, fallback) {
+ try { const raw = localStorage.getItem(key); return raw ? JSON.parse(raw) : fallback; }
+ catch { return fallback; }
}
-function saveDraft(state) {
- try {
- localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
- } catch {
- // quota — non-fatal; published config is the source of truth.
- }
+function lsSet(key, value) {
+ try { localStorage.setItem(key, JSON.stringify(value)); } catch { /* quota — non-fatal */ }
}
+const secrets = {
+ get(slug) { return lsGet(SECRETS_KEY, {})[slug] || null; },
+ set(slug, secret) { const all = lsGet(SECRETS_KEY, {}); all[slug] = secret; lsSet(SECRETS_KEY, all); },
+ has(slug) { return Boolean(lsGet(SECRETS_KEY, {})[slug]); },
+};
+
+const recents = {
+ all() { return lsGet(RECENT_KEY, []); },
+ add(entry) {
+ const list = lsGet(RECENT_KEY, []).filter((e) => e.slug !== entry.slug);
+ list.unshift({ ...entry, updatedAt: new Date().toISOString() });
+ lsSet(RECENT_KEY, list.slice(0, 12));
+ },
+ remove(slug) {
+ lsSet(RECENT_KEY, lsGet(RECENT_KEY, []).filter((e) => e.slug !== slug));
+ },
+};
+
+function loadDraft() { return lsGet(DRAFT_KEY, null); }
+function saveDraft(state) { lsSet(DRAFT_KEY, state); }
+
function defaultStateFor(templateId) {
const tpl = TEMPLATES.find((t) => t.id === templateId) || TEMPLATES[0];
return {
template: tpl.id,
- identity: { slug: '', brand: '#6366f1', wallet: '', website: '', theme: 'light' },
+ identity: {
+ slug: '', brand: '#6366f1', wallet: '', website: '', theme: 'light',
+ socials: { twitter: '', telegram: '', discord: '' },
+ },
avatar: { src: DEFAULT_AVATAR_SRC, name: 'Default' },
copy: { tagline: tpl.defaultTagline, cta: tpl.defaultCta, headline: tpl.label },
- token: { name: '', ticker: '', supply: 1_000_000_000 },
- skill: { name: 'concierge', priceUsdc: 0.01 },
+ token: { name: '', ticker: '', supply: 1_000_000_000, description: '', imageUrl: '', mint: '' },
+ agentSkills: [],
scene: { src: '' },
monetize: {
- kind: tpl.monetize.kind,
- price: tpl.monetize.defaultPrice,
- currency: tpl.monetize.currency,
- chain: tpl.monetize.chain,
+ kind: tpl.monetize.kind, price: tpl.monetize.defaultPrice,
+ currency: tpl.monetize.currency, chain: tpl.monetize.chain,
},
- published: null, // { slug, url, publishedAt }
+ published: null, // { slug, url, publishedAt }
+ isEditing: false, // true when hydrated from /api/launchpad/get
+ };
+}
+
+// Hydrate state from a /api/launchpad/get payload. Returns the same shape as
+// defaultStateFor with values from the published config layered in. Missing
+// fields fall back to defaults so older rows still render.
+function stateFromPayload(payload) {
+ const tplId = payload.template || 'token-launchpad';
+ const fresh = defaultStateFor(tplId);
+ const c = payload.config || {};
+ return {
+ ...fresh,
+ template: tplId,
+ identity: {
+ ...fresh.identity, ...(c.identity || {}),
+ slug: payload.slug,
+ socials: { ...fresh.identity.socials, ...((c.identity && c.identity.socials) || {}) },
+ },
+ avatar: { ...fresh.avatar, ...(c.avatar || {}) },
+ copy: { ...fresh.copy, ...(c.copy || {}) },
+ token: { ...fresh.token, ...(c.token || {}) },
+ agentSkills: Array.isArray(c.agentSkills) ? c.agentSkills : [],
+ scene: { ...fresh.scene, ...(c.scene || {}) },
+ monetize: { ...fresh.monetize, ...(c.monetize || {}) },
+ published: { slug: payload.slug, url: `${AGENT_3D_HOST}/p/${payload.slug}`, publishedAt: payload.updatedAt || payload.createdAt },
+ isEditing: true,
};
}
@@ -472,7 +413,7 @@ function mergeOptions(state, opts) {
}
// ──────────────────────────────────────────────────────────────────────────
-// Snippets — what the user copies out
+// Snippets the user copies out
// ──────────────────────────────────────────────────────────────────────────
function buildEmbedSnippet(state) {
const slug = state.identity.slug || '<your-slug>';
@@ -482,58 +423,51 @@ function buildEmbedSnippet(state) {
data-slug="${slug}">
</script>`;
}
-
function buildSkillManifest(state) {
const tpl = TEMPLATES.find((t) => t.id === state.template) || TEMPLATES[0];
const slug = state.identity.slug || 'unpublished';
- const manifest = {
+ return JSON.stringify({
name: `launchpad.${slug}`,
version: '1.0.0',
description: `${tpl.label} hosted by ${state.copy.headline || slug} on three.ws`,
template: tpl.id,
homepage: `${AGENT_3D_HOST}/p/${slug}`,
- input_schema:
- tpl.id === 'token-launchpad'
- ? {
- type: 'object',
- properties: { tokenName: { type: 'string' }, tokenTicker: { type: 'string' } },
- required: ['tokenName', 'tokenTicker'],
- }
- : { type: 'object', properties: { question: { type: 'string' } }, required: ['question'] },
+ skills: state.agentSkills?.length
+ ? state.agentSkills.map((s) => ({
+ name: s.name, price: s.price, currency: s.currency,
+ chain: s.chain, description: s.description || '',
+ }))
+ : [{
+ name: tpl.id === 'token-launchpad' ? 'launch' : tpl.id === 'gated-showroom' ? 'unlock' : 'ask',
+ price: state.monetize.price, currency: state.monetize.currency, chain: state.monetize.chain,
+ }],
pricing: {
- price: state.monetize.price,
- currency: state.monetize.currency,
- chain: state.monetize.chain,
- payout_address: state.identity.wallet || null,
+ price: state.monetize.price, currency: state.monetize.currency,
+ chain: state.monetize.chain, payout_address: state.identity.wallet || null,
},
x402: {
endpoint: `${AGENT_3D_HOST}/api/launchpad/invoke?slug=${slug}`,
facilitator: state.monetize.chain === 'base' ? 'cdp' : 'pump',
},
- };
- return JSON.stringify(manifest, null, 2);
+ }, null, 2);
}
function formatPrice(m) {
if (!m || !m.price) return '';
const n = Number(m.price);
- if (!isFinite(n) || n <= 0) return '';
- return `${n} ${m.currency || ''}`.trim();
+ return isFinite(n) && n > 0 ? `${n} ${m.currency || ''}`.trim() : '';
}
function short(addr) {
if (!addr) return '';
const s = String(addr);
- if (s.length <= 12) return s;
- return `${s.slice(0, 6)}…${s.slice(-4)}`;
+ return s.length > 12 ? `${s.slice(0, 6)}…${s.slice(-4)}` : s;
}
function extraCopyFor(state, tpl) {
if (tpl.id === 'token-launchpad') {
- const t = state.token;
- const parts = [];
+ const t = state.token, parts = [];
if (t.name) parts.push(t.name);
if (t.ticker) parts.push(`($${t.ticker})`);
- if (parts.length)
- return `Launching ${parts.join(' ')} on Pump.fun. Creator fees route to ${short(state.identity.wallet) || 'your wallet'}.`;
+ if (parts.length) return `Launching ${parts.join(' ')} on Pump.fun. Creator fees route to ${short(state.identity.wallet) || 'your wallet'}.`;
return 'Set a token name and ticker on the right to seed the launch.';
}
if (tpl.id === 'paid-concierge') {
@@ -545,55 +479,109 @@ function extraCopyFor(state, tpl) {
return tpl.tagline;
}
-function buildPagePreviewHTML(state) {
- const tpl = TEMPLATES.find((t) => t.id === state.template) || TEMPLATES[0];
- const brand = state.identity.brand || '#6366f1';
- const headline = state.copy.headline || tpl.label;
- const tagline = state.copy.tagline || tpl.defaultTagline;
- const cta = state.copy.cta || tpl.defaultCta;
- const website = state.identity.website || '';
- const avatarSrc = state.avatar.src || DEFAULT_AVATAR_SRC;
- const themeClass = state.identity.theme === 'dark' ? 'dark' : '';
- const priceLabel = formatPrice(state.monetize);
- const slug = state.identity.slug || 'preview';
+// ──────────────────────────────────────────────────────────────────────────
+// Live preview (also rendered on /p/<slug> by public/p/render.js — keep them
+// visually consistent so creators see what visitors will see)
+// ──────────────────────────────────────────────────────────────────────────
+// Stage skeleton — built once. updateStage() mutates text / class / style
+// hooks via the data-* selectors below. Critically, the avatar mount slot
+// stays untouched across updates so the persistent <agent-3d> element keeps
+// its WebGL context alive (re-mounting tears it down mid-load and crashes
+// viewer.js with "Cannot read properties of null (reading 'reset')").
+function buildStageSkeleton() {
return `
- <div class="stage-frame ${themeClass}" style="--brand: ${esc(brand)}">
+ <div class="stage-frame" data-stage-frame>
<header>
<div class="brand">
<span class="swatch"></span>
- <span>${esc(headline)}</span>
+ <span data-headline></span>
</div>
- <nav class="links">
- ${website ? `<a href="${esc(website)}" target="_blank" rel="noopener">Website</a>` : ''}
- <a href="${AGENT_3D_HOST}/p/${esc(slug)}" target="_blank" rel="noopener">Powered by three.ws</a>
- </nav>
+ <nav class="links" data-links></nav>
</header>
<div class="hero">
<div class="hero-copy">
- <h1>${esc(tagline)}</h1>
- <p>${esc(extraCopyFor(state, tpl))}</p>
- <button class="cta" type="button" data-preview-cta>${esc(cta)}</button>
- ${priceLabel ? `<span class="price-chip">${esc(priceLabel)}</span>` : ''}
- </div>
- <div class="avatar-stage">
- <agent-3d
- src="${esc(avatarSrc)}"
- background="transparent"
- camera-controls="auto"
- auto-rotate
- ></agent-3d>
+ <h1 data-tagline></h1>
+ <p data-extra-copy></p>
+ <button class="cta" type="button" data-preview-cta></button>
+ <span class="price-chip" data-price-chip></span>
</div>
+ <div class="avatar-stage" data-avatar-mount></div>
</div>
- <footer>
- Hosted on <a href="${AGENT_3D_HOST}" target="_blank" rel="noopener">three.ws</a> ·
- wallet ${esc(short(state.identity.wallet) || 'not connected')}
- </footer>
+ <div data-token-strip></div>
+ <div data-skills-row></div>
+ <footer data-footer></footer>
</div>
`;
}
+// In-place stage updater — runs on every state change. No innerHTML on the
+// avatar-stage slot, so the agent-3d element is never disconnected.
+function updateStage(stage, state) {
+ const tpl = TEMPLATES.find((t) => t.id === state.template) || TEMPLATES[0];
+ const frame = stage.querySelector('[data-stage-frame]');
+ const brand = state.identity.brand || '#6366f1';
+ const headline = state.copy.headline || tpl.label;
+ const tagline = state.copy.tagline || tpl.defaultTagline;
+ const cta = state.copy.cta || tpl.defaultCta;
+ const website = state.identity.website || '';
+ const socials = state.identity.socials || {};
+ const priceLabel = formatPrice(state.monetize);
+ const slug = state.identity.slug || 'preview';
+ const t = state.token || {};
+ const showTokenStrip = tpl.id === 'token-launchpad' && (t.name || t.ticker || t.imageUrl || t.description);
+ const skills = (state.agentSkills || []).filter((s) => s.name);
+
+ frame.style.setProperty('--brand', brand);
+ frame.classList.toggle('dark', state.identity.theme === 'dark');
+
+ frame.querySelector('[data-headline]').textContent = headline;
+ frame.querySelector('[data-tagline]').textContent = tagline;
+ frame.querySelector('[data-extra-copy]').textContent = extraCopyFor(state, tpl);
+ frame.querySelector('[data-preview-cta]').textContent = cta;
+
+ const chip = frame.querySelector('[data-price-chip]');
+ chip.textContent = priceLabel;
+ chip.style.display = priceLabel ? '' : 'none';
+
+ frame.querySelector('[data-links]').innerHTML = `
+ ${website ? `<a href="${esc(website)}" target="_blank" rel="noopener">Website</a>` : ''}
+ ${socials.twitter ? `<a href="${esc(socials.twitter)}" target="_blank" rel="noopener">X</a>` : ''}
+ ${socials.telegram ? `<a href="${esc(socials.telegram)}" target="_blank" rel="noopener">TG</a>` : ''}
+ ${socials.discord ? `<a href="${esc(socials.discord)}" target="_blank" rel="noopener">Discord</a>` : ''}
+ <a href="${AGENT_3D_HOST}/p/${esc(slug)}" target="_blank" rel="noopener">${state.isEditing ? 'View live →' : 'Powered by three.ws'}</a>
+ `;
+
+ const tokenSlot = frame.querySelector('[data-token-strip]');
+ tokenSlot.innerHTML = showTokenStrip ? `
+ <div class="token-strip">
+ <div class="token-logo" style="${t.imageUrl ? `background-image: url('${esc(t.imageUrl)}')` : ''}"></div>
+ <div class="token-meta">
+ <div class="token-name">${esc(t.name || 'Untitled')}${t.ticker ? ` · $${esc(t.ticker)}` : ''}</div>
+ <div class="token-desc">${esc(t.description || (t.mint ? `mint ${short(t.mint)}` : 'Set token description on the right.'))}</div>
+ </div>
+ </div>
+ ` : '';
+
+ const skillsSlot = frame.querySelector('[data-skills-row]');
+ skillsSlot.innerHTML = skills.length ? `
+ <div class="skills-row">
+ ${skills.map((s) => `
+ <span class="skill-pill">
+ ${esc(s.name)}
+ <span class="price">${esc(formatPrice(s) || 'free')}</span>
+ </span>
+ `).join('')}
+ </div>
+ ` : '';
+
+ frame.querySelector('[data-footer]').innerHTML = `
+ Hosted on <a href="${AGENT_3D_HOST}" target="_blank" rel="noopener">three.ws</a> ·
+ wallet ${esc(short(state.identity.wallet) || 'not connected')}
+ `;
+}
+
// ──────────────────────────────────────────────────────────────────────────
-// Avatar gallery — pulls real public avatars from /api/avatars/public.
+// Real-API helpers
// ──────────────────────────────────────────────────────────────────────────
async function fetchPublicAvatars() {
try {
@@ -605,10 +593,12 @@ async function fetchPublicAvatars() {
return [];
}
}
-
-// ──────────────────────────────────────────────────────────────────────────
-// Publish — POST to /api/launchpad/publish, real backend.
-// ──────────────────────────────────────────────────────────────────────────
+async function fetchLaunchpad(slug) {
+ const r = await fetch(`/api/launchpad/get?slug=${encodeURIComponent(slug)}`);
+ if (r.status === 404) return null;
+ if (!r.ok) throw new Error(`Couldn't load /p/${slug} (${r.status})`);
+ return r.json();
+}
async function publishLaunchpad(state) {
const slug = slugify(state.identity.slug);
if (!slug) throw new Error('Choose a URL slug first.');
@@ -621,17 +611,22 @@ async function publishLaunchpad(state) {
avatar: state.avatar,
copy: state.copy,
token: state.token,
- skill: state.skill,
+ agentSkills: state.agentSkills,
scene: state.scene,
monetize: state.monetize,
};
+ const existingSecret = secrets.get(slug);
+ if (existingSecret) body.ownerSecret = existingSecret;
+
const r = await fetch('/api/launchpad/publish', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
});
const data = await r.json().catch(() => ({}));
- if (!r.ok) throw new Error(data?.error || `Publish failed (${r.status})`);
+ if (!r.ok) throw new Error(data?.error_description || data?.error || `Publish failed (${r.status})`);
+ if (data.ownerSecret) secrets.set(slug, data.ownerSecret);
+ recents.add({ slug, template: state.template, headline: state.copy.headline });
return data;
}
@@ -653,11 +648,12 @@ export function mountLaunchpadStudio(root, options = {}) {
<div class="brand">
<span class="dot"></span>
<span>Launchpad Studio</span>
- <span class="pill">Template-driven</span>
+ <span class="pill" data-mode-pill>Template-driven</span>
</div>
<div class="actions">
<a class="btn ghost" href="/embed" title="The original place-and-scale embed editor">Open classic editor</a>
- <button class="btn" data-action="reset">Reset draft</button>
+ <button class="btn" data-action="open-recent">My launchpads ▾</button>
+ <button class="btn" data-action="new-draft" title="Start a new draft (current draft cleared)">New</button>
<button class="btn primary" data-action="publish">Publish</button>
</div>
</div>
@@ -665,61 +661,50 @@ export function mountLaunchpadStudio(root, options = {}) {
<h3>Templates</h3>
<div data-templates></div>
<h3 style="margin-top: 18px">Avatars</h3>
- <div class="panel" style="border:0; padding-top: 0">
- <div class="avatar-grid" data-avatar-grid></div>
- </div>
+ <div class="avatar-grid" data-avatar-grid></div>
</aside>
<main class="stage" data-stage></main>
<aside class="rail" data-rail></aside>
</div>
`;
+ // Templates list
const tplWrap = $('[data-templates]', root);
- tplWrap.innerHTML = TEMPLATES.map(
- (t) => `
+ tplWrap.innerHTML = TEMPLATES.map((t) => `
<div class="template-card ${t.id === state.template ? 'active' : ''}" data-template-id="${t.id}">
<div class="label">${esc(t.label)}</div>
<div class="tagline">${esc(t.tagline)}</div>
<div class="hint">${esc(t.hint)}</div>
- </div>`,
- ).join('');
+ </div>
+ `).join('');
tplWrap.addEventListener('click', (e) => {
const card = e.target.closest('[data-template-id]');
- if (!card) return;
- const id = card.dataset.templateId;
- if (id === state.template) return;
- state.template = id;
- const tpl = TEMPLATES.find((t) => t.id === id);
+ if (!card || card.dataset.templateId === state.template) return;
+ state.template = card.dataset.templateId;
+ const tpl = TEMPLATES.find((t) => t.id === state.template);
state.copy.headline = tpl.label;
state.copy.tagline = tpl.defaultTagline;
state.copy.cta = tpl.defaultCta;
- state.monetize = {
- kind: tpl.monetize.kind,
- price: tpl.monetize.defaultPrice,
- currency: tpl.monetize.currency,
- chain: tpl.monetize.chain,
- };
+ state.monetize = { kind: tpl.monetize.kind, price: tpl.monetize.defaultPrice, currency: tpl.monetize.currency, chain: tpl.monetize.chain };
render();
});
+ // Avatar gallery
const avatarWrap = $('[data-avatar-grid]', root);
function renderAvatars(list) {
- avatarWrap.innerHTML = list
- .map(
- (a) => `
+ avatarWrap.innerHTML = list.map((a) => `
<div class="avatar-tile ${a.model_url === state.avatar.src ? 'active' : ''}"
data-avatar-src="${esc(a.model_url)}"
data-avatar-name="${esc(a.name || a.id)}"
title="${esc(a.name || a.id)}">
${esc((a.name || a.id || '').slice(0, 14))}
- </div>`,
- ).join('');
+ </div>
+ `).join('');
}
renderAvatars(DEMO_AVATARS);
fetchPublicAvatars().then((extras) => {
const seen = new Set(DEMO_AVATARS.map((a) => a.model_url));
- const merged = [...DEMO_AVATARS, ...extras.filter((a) => a.model_url && !seen.has(a.model_url))];
- renderAvatars(merged);
+ renderAvatars([...DEMO_AVATARS, ...extras.filter((a) => a.model_url && !seen.has(a.model_url))]);
});
avatarWrap.addEventListener('click', (e) => {
const tile = e.target.closest('[data-avatar-src]');
@@ -728,15 +713,41 @@ export function mountLaunchpadStudio(root, options = {}) {
render();
});
+ // Topbar + global actions (delegated)
+ let recentDropdown = null;
root.addEventListener('click', async (e) => {
const action = e.target.closest('[data-action]')?.dataset.action;
- if (!action) return;
- if (action === 'reset') {
- localStorage.removeItem(STORAGE_KEY);
+ if (!action) {
+ if (recentDropdown && !e.target.closest('.dropdown')) closeRecent();
+ return;
+ }
+ if (action === 'new-draft') {
+ if (!confirm('Discard current draft and start fresh?')) return;
+ localStorage.removeItem(DRAFT_KEY);
Object.assign(state, defaultStateFor(state.template));
+ history.replaceState(null, '', '/launchpad');
render();
return;
}
+ if (action === 'open-recent') {
+ toggleRecent(e.target.closest('button'));
+ return;
+ }
+ if (action === 'load-recent') {
+ const slug = e.target.closest('[data-slug]')?.dataset.slug;
+ if (!slug) return;
+ closeRecent();
+ await hydrateFromSlug(slug);
+ return;
+ }
+ if (action === 'forget-recent') {
+ e.stopPropagation();
+ const slug = e.target.closest('[data-slug]')?.dataset.slug;
+ if (!slug) return;
+ recents.remove(slug);
+ renderRecentDropdown();
+ return;
+ }
if (action === 'publish') {
const btn = e.target.closest('[data-action="publish"]');
btn.disabled = true;
@@ -747,8 +758,10 @@ export function mountLaunchpadStudio(root, options = {}) {
state.published = {
slug: result.slug,
url: result.url || `${AGENT_3D_HOST}/p/${result.slug}`,
- publishedAt: result.publishedAt || new Date().toISOString(),
+ publishedAt: result.publishedAt,
};
+ state.isEditing = true;
+ history.replaceState(null, '', `/launchpad?slug=${encodeURIComponent(result.slug)}`);
} catch (err) {
state.published = { error: err.message || String(err) };
} finally {
@@ -758,13 +771,23 @@ export function mountLaunchpadStudio(root, options = {}) {
}
return;
}
+ if (action === 'add-skill') {
+ state.agentSkills.push({ name: '', price: 0.001, currency: 'USDC', chain: 'base', description: '' });
+ render();
+ return;
+ }
+ if (action === 'remove-skill') {
+ const idx = Number(e.target.closest('[data-skill-idx]')?.dataset.skillIdx);
+ if (Number.isFinite(idx)) {
+ state.agentSkills.splice(idx, 1);
+ render();
+ }
+ return;
+ }
if (action === 'copy-embed' || action === 'copy-skill' || action === 'copy-share') {
- const text =
- action === 'copy-embed'
- ? buildEmbedSnippet(state)
- : action === 'copy-skill'
- ? buildSkillManifest(state)
- : state.published?.url || '';
+ const text = action === 'copy-embed' ? buildEmbedSnippet(state)
+ : action === 'copy-skill' ? buildSkillManifest(state)
+ : state.published?.url || '';
if (!text) return;
try {
await navigator.clipboard.writeText(text);
@@ -773,7 +796,6 @@ export function mountLaunchpadStudio(root, options = {}) {
btn.textContent = 'Copied';
setTimeout(() => { btn.textContent = orig; }, 1200);
} catch {
- // Clipboard blocked — select the snippet so the user can ⌘C manually.
const snip = e.target.closest('.panel')?.querySelector('.snippet');
if (snip) {
const range = document.createRange();
@@ -786,19 +808,129 @@ export function mountLaunchpadStudio(root, options = {}) {
}
});
- function render() {
- saveDraft(state);
+ // "My launchpads" dropdown
+ function toggleRecent(button) {
+ if (recentDropdown) { closeRecent(); return; }
+ recentDropdown = document.createElement('div');
+ recentDropdown.className = 'dropdown';
+ button.parentElement.appendChild(recentDropdown);
+ renderRecentDropdown();
+ }
+ function closeRecent() {
+ if (recentDropdown?.parentElement) recentDropdown.parentElement.removeChild(recentDropdown);
+ recentDropdown = null;
+ }
+ function renderRecentDropdown() {
+ if (!recentDropdown) return;
+ const list = recents.all();
+ if (!list.length) {
+ recentDropdown.innerHTML = `<div class="dropdown-empty">No published launchpads on this browser yet. Hit Publish to start the list.</div>`;
+ return;
+ }
+ recentDropdown.innerHTML = list.map((e) => `
+ <div class="dropdown-item" data-action="load-recent" data-slug="${esc(e.slug)}" style="display:flex;align-items:flex-start;gap:8px;justify-content:space-between">
+ <div style="min-width:0;flex:1">
+ <div class="di-title">${esc(e.headline || e.slug)}</div>
+ <div class="di-meta">/${esc(e.slug)} · ${esc(e.template)} · updated ${esc(new Date(e.updatedAt).toLocaleString())}</div>
+ </div>
+ <button class="btn tiny ghost" data-action="forget-recent" data-slug="${esc(e.slug)}" title="Remove from this list (does not unpublish)">×</button>
+ </div>
+ `).join('');
+ }
+
+ // Edit-mode hydration: ?slug=foo or options.slug
+ async function hydrateFromSlug(slug) {
+ try {
+ const payload = await fetchLaunchpad(slug);
+ if (!payload) {
+ // No row yet — pre-fill the slug into a fresh draft so the user
+ // can publish a new page at that URL.
+ state.identity.slug = slug;
+ state.isEditing = false;
+ render();
+ return;
+ }
+ Object.assign(state, stateFromPayload(payload));
+ history.replaceState(null, '', `/launchpad?slug=${encodeURIComponent(slug)}`);
+ render();
+ } catch (err) {
+ console.warn('[launchpad-studio] hydrate failed:', err.message);
+ // Network failure shouldn't blow up the editor — start clean.
+ state.identity.slug = slug;
+ render();
+ }
+ }
+
+ // Persistent across renders. Re-creating <agent-3d> on every keystroke
+ // triggers a WebGL context rebuild that races with model load and crashes
+ // the viewer ("Cannot read properties of null (reading 'reset')"). Keep
+ // the element alive and just swap its `src` when the avatar changes.
+ let avatarEl = null;
+ let lastAvatarSrc = null;
+ function ensureAvatarEl() {
+ if (!avatarEl) {
+ avatarEl = document.createElement('agent-3d');
+ avatarEl.setAttribute('viewer', '');
+ avatarEl.setAttribute('background', 'transparent');
+ avatarEl.setAttribute('camera-controls', 'auto');
+ avatarEl.setAttribute('auto-rotate', '');
+ }
+ if (state.avatar.src !== lastAvatarSrc) {
+ avatarEl.setAttribute('src', state.avatar.src);
+ lastAvatarSrc = state.avatar.src;
+ }
+ return avatarEl;
+ }
+
+ // Track structural state — only rebuild the rail when something changed
+ // that needs new DOM (template switch, skills array length, edit mode).
+ // Re-rendering the rail on every keystroke would steal focus from the
+ // active input mid-typing.
+ let lastTemplate = null;
+ let lastSkillCount = -1;
+ let lastEditing = null;
+
+ let stageMounted = false;
+ function renderStage() {
const stage = $('[data-stage]', root);
- stage.innerHTML = buildPagePreviewHTML(state);
- const cta = stage.querySelector('[data-preview-cta]');
- if (cta) {
- cta.addEventListener('click', () => {
- cta.style.transform = 'scale(0.97)';
- setTimeout(() => { cta.style.transform = ''; }, 120);
+ if (!stageMounted) {
+ stage.innerHTML = buildStageSkeleton();
+ stage.querySelector('[data-avatar-mount]').appendChild(ensureAvatarEl());
+ stage.querySelector('[data-preview-cta]').addEventListener('click', (ev) => {
+ ev.target.style.transform = 'scale(0.97)';
+ setTimeout(() => { ev.target.style.transform = ''; }, 120);
});
+ stageMounted = true;
+ } else {
+ // Avatar src may have changed even without a structural rebuild.
+ ensureAvatarEl();
+ }
+ updateStage(stage, state);
+ }
+
+ function renderRail(force = false) {
+ const skillCount = (state.agentSkills || []).length;
+ const needsRebuild = force ||
+ state.template !== lastTemplate ||
+ skillCount !== lastSkillCount ||
+ state.isEditing !== lastEditing;
+ if (needsRebuild) {
+ $('[data-rail]', root).innerHTML = buildRailHTML(state);
+ bindRailInputs(root, state, render);
+ lastTemplate = state.template;
+ lastSkillCount = skillCount;
+ lastEditing = state.isEditing;
+ } else {
+ // Lightweight refresh: only the publish-status block + share URL.
+ const pub = root.querySelector('[data-publish-block]');
+ if (pub) pub.innerHTML = publishStatusHTML(state);
}
- $('[data-rail]', root).innerHTML = buildRailHTML(state);
- bindRailInputs(root, state, render);
+ }
+
+ function syncTopbar() {
+ const pill = root.querySelector('[data-mode-pill]');
+ pill.textContent = state.isEditing ? 'Editing' : 'New draft';
+ pill.classList.toggle('editing', !!state.isEditing);
root.querySelectorAll('[data-template-id]').forEach((el) => {
el.classList.toggle('active', el.dataset.templateId === state.template);
});
@@ -807,32 +939,45 @@ export function mountLaunchpadStudio(root, options = {}) {
});
}
- render();
+ function render({ force = false } = {}) {
+ saveDraft(state);
+ renderStage();
+ renderRail(force);
+ syncTopbar();
+ }
+
+ // Initial render
+ if (options.slug) {
+ hydrateFromSlug(slugify(options.slug)).finally(render);
+ } else {
+ render();
+ }
return {
getState: () => JSON.parse(JSON.stringify(state)),
render,
+ hydrateFromSlug,
};
}
// ──────────────────────────────────────────────────────────────────────────
-// Right rail — form panels driven by template, plus publish + snippets.
+// Right-rail (form panels per template + publish + snippets)
// ──────────────────────────────────────────────────────────────────────────
function buildRailHTML(state) {
const tpl = TEMPLATES.find((t) => t.id === state.template) || TEMPLATES[0];
- const has = (f) => tpl.fields.includes(f);
const identityPanel = `
<div class="panel">
<h4>Identity</h4>
- ${has('slug') ? field('Public URL slug', `<input type="text" data-bind="identity.slug" value="${esc(state.identity.slug)}" placeholder="yourname" />`, `Your page will live at ${AGENT_3D_HOST}/p/${state.identity.slug || '<slug>'}`) : ''}
- ${has('brand') ? field('Brand color', `
+ ${field('Public URL slug', `<input type="text" data-bind="identity.slug" value="${esc(state.identity.slug)}" placeholder="yourname" ${state.isEditing ? 'readonly' : ''} />`,
+ state.isEditing ? `Live at ${AGENT_3D_HOST}/p/${state.identity.slug}` : `Your page will live at ${AGENT_3D_HOST}/p/${state.identity.slug || '<slug>'}`)}
+ ${field('Brand color', `
<div class="color-input">
<input type="color" data-bind="identity.brand" value="${esc(state.identity.brand)}" />
<input type="text" data-bind="identity.brand" value="${esc(state.identity.brand)}" />
- </div>`) : ''}
- ${has('wallet') ? field('Payout wallet', `<input type="text" data-bind="identity.wallet" value="${esc(state.identity.wallet)}" placeholder="${state.monetize.chain === 'solana' ? 'Sol... (base58)' : '0x... (EVM)'}" />`, 'Receives launch fees / x402 payments.') : ''}
- ${has('website') ? field('Your website (optional)', `<input type="text" data-bind="identity.website" value="${esc(state.identity.website)}" placeholder="https://your-site.com" />`) : ''}
+ </div>`)}
+ ${field('Payout wallet', `<input type="text" data-bind="identity.wallet" value="${esc(state.identity.wallet)}" placeholder="${state.monetize.chain === 'solana' ? 'Sol... (base58)' : '0x... (EVM)'}" />`, 'Receives launch fees / x402 payments. Used as the edit-key when you re-publish.')}
+ ${field('Your website (optional)', `<input type="text" data-bind="identity.website" value="${esc(state.identity.website)}" placeholder="https://your-site.com" />`)}
${field('Theme', `
<select data-bind="identity.theme">
<option value="light" ${state.identity.theme === 'light' ? 'selected' : ''}>Light</option>
@@ -841,6 +986,15 @@ function buildRailHTML(state) {
</div>
`;
+ const socialsPanel = `
+ <div class="panel">
+ <h4>Socials</h4>
+ ${field('X / Twitter', `<input type="text" data-bind="identity.socials.twitter" value="${esc(state.identity.socials?.twitter || '')}" placeholder="https://x.com/yourhandle" />`)}
+ ${field('Telegram', `<input type="text" data-bind="identity.socials.telegram" value="${esc(state.identity.socials?.telegram || '')}" placeholder="https://t.me/yourgroup" />`)}
+ ${field('Discord', `<input type="text" data-bind="identity.socials.discord" value="${esc(state.identity.socials?.discord || '')}" placeholder="https://discord.gg/invite" />`)}
+ </div>
+ `;
+
const copyPanel = `
<div class="panel">
<h4>Page copy</h4>
@@ -854,19 +1008,22 @@ function buildRailHTML(state) {
if (tpl.id === 'token-launchpad') {
templatePanel = `
<div class="panel">
- <h4>Token</h4>
+ <h4>Token (CMS) ${state.token.mint ? `<span class="pill" style="background:rgba(34,197,94,0.16);color:#4ade80">live</span>` : ''}</h4>
${field('Token name', `<input type="text" data-bind="token.name" value="${esc(state.token.name)}" placeholder="My Coin" />`)}
${field('Ticker', `<input type="text" data-bind="token.ticker" value="${esc(state.token.ticker)}" placeholder="MOON" maxlength="10" />`)}
${field('Initial supply', `<input type="number" data-bind="token.supply" value="${state.token.supply}" min="1" />`)}
- ${field('Launch fee (SOL)', `<input type="number" step="0.001" data-bind="monetize.price" value="${state.monetize.price}" />`, 'Charged to each visitor that mints. Routes to your wallet via Pump.fun creator fee split.')}
+ ${field('Description', `<textarea data-bind="token.description" placeholder="Brief description shown on the launchpad page">${esc(state.token.description || '')}</textarea>`)}
+ ${field('Token image URL', `<input type="text" data-bind="token.imageUrl" value="${esc(state.token.imageUrl || '')}" placeholder="https://.../logo.png" />`, '512×512 recommended. Used as the on-page logo and Pump.fun metadata image.')}
+ ${field('Mint address (after launch)', `<input type="text" data-bind="token.mint" value="${esc(state.token.mint || '')}" placeholder="Auto-filled once minted on Pump.fun" />`, 'Paste the mint pubkey after you launch — links the page to the live token.')}
+ ${field('Launch fee (SOL)', `<input type="number" step="0.001" data-bind="monetize.price" value="${state.monetize.price}" />`, 'Charged to each visitor that mints. Routes via Pump.fun creator fee split.')}
</div>
`;
} else if (tpl.id === 'paid-concierge') {
templatePanel = `
<div class="panel">
- <h4>Skill</h4>
- ${field('Skill name', `<input type="text" data-bind="skill.name" value="${esc(state.skill.name)}" placeholder="concierge" />`)}
- ${field('Price per call (USDC)', `<input type="number" step="0.001" data-bind="monetize.price" value="${state.monetize.price}" />`, 'x402 charges visitors per question. Settled instantly to your wallet.')}
+ <h4>Concierge</h4>
+ ${field('Default skill name', `<input type="text" data-bind="agentSkills.0.name" value="${esc(state.agentSkills[0]?.name || 'concierge')}" placeholder="concierge" />`)}
+ ${field('Price per call', `<input type="number" step="0.001" data-bind="monetize.price" value="${state.monetize.price}" />`, 'x402 charges visitors per question. Settled instantly to your wallet.')}
${field('Chain', `
<select data-bind="monetize.chain">
<option value="base" ${state.monetize.chain === 'base' ? 'selected' : ''}>Base</option>
@@ -884,13 +1041,35 @@ function buildRailHTML(state) {
`;
}
+ const skillsPanel = `
+ <div class="panel">
+ <h4>
+ Onchain agent skills
+ <button class="btn tiny" data-action="add-skill">+ Add</button>
+ </h4>
+ ${(state.agentSkills || []).length === 0
+ ? `<div class="help" style="color:#71717a;font-size:11px">No paid skills configured. Add one to charge visitors per call via x402 — each skill becomes its own pricing pill on your /p/ page.</div>`
+ : state.agentSkills.map((s, i) => `
+ <div class="skill-row" data-skill-idx="${i}">
+ <input type="text" data-bind="agentSkills.${i}.name" value="${esc(s.name)}" placeholder="skill name" />
+ <input type="number" step="0.001" data-bind="agentSkills.${i}.price" value="${s.price}" />
+ <select data-bind="agentSkills.${i}.currency">
+ <option value="USDC" ${s.currency === 'USDC' ? 'selected' : ''}>USDC</option>
+ <option value="SOL" ${s.currency === 'SOL' ? 'selected' : ''}>SOL</option>
+ <option value="ETH" ${s.currency === 'ETH' ? 'selected' : ''}>ETH</option>
+ </select>
+ <button type="button" class="skill-remove" data-action="remove-skill" data-skill-idx="${i}" title="Remove">×</button>
+ </div>
+ `).join('')}
+ </div>
+ `;
+
const publishPanel = `
<div class="panel">
<h4>Publish</h4>
- ${publishStatusHTML(state)}
+ <div data-publish-block>${publishStatusHTML(state)}</div>
</div>
`;
-
const snippetsPanel = `
<div class="panel">
<h4>Embed snippet</h4>
@@ -908,7 +1087,7 @@ function buildRailHTML(state) {
</div>
`;
- return identityPanel + copyPanel + templatePanel + publishPanel + snippetsPanel;
+ return identityPanel + socialsPanel + copyPanel + templatePanel + skillsPanel + publishPanel + snippetsPanel;
}
function publishStatusHTML(state) {
@@ -920,7 +1099,7 @@ function publishStatusHTML(state) {
}
const url = state.published.url || `${AGENT_3D_HOST}/p/${state.published.slug}`;
return `
- <div class="publish-status ok">Live at ${esc(url)}</div>
+ <div class="publish-status ok">${state.isEditing ? 'Updated · ' : 'Live at '}${esc(url)}</div>
<div class="share-url">
<input type="text" readonly value="${esc(url)}" />
<button class="btn" data-action="copy-share">Copy</button>
@@ -943,11 +1122,22 @@ function bindRailInputs(root, state, render) {
const path = el.dataset.bind.split('.');
el.addEventListener('input', () => {
let cur = state;
- for (let i = 0; i < path.length - 1; i++) cur = cur[path[i]] = cur[path[i]] || {};
+ for (let i = 0; i < path.length - 1; i++) {
+ const key = path[i];
+ // Numeric index → ensure array exists at the parent
+ if (/^\d+$/.test(key)) {
+ if (!Array.isArray(cur)) return;
+ cur[key] = cur[key] || {};
+ cur = cur[key];
+ } else {
+ cur[key] = cur[key] || (path[i + 1] && /^\d+$/.test(path[i + 1]) ? [] : {});
+ cur = cur[key];
+ }
+ }
let value = el.type === 'number' ? Number(el.value) : el.value;
if (path[path.length - 1] === 'slug') value = slugify(value);
cur[path[path.length - 1]] = value;
- // Brand color: keep both inputs in sync, hot-update preview, skip full re-render.
+ // Brand color: keep both inputs in sync, hot-update preview without re-render.
if (el.dataset.bind === 'identity.brand') {
root.querySelectorAll('[data-bind="identity.brand"]').forEach((peer) => {
if (peer !== el) peer.value = value;