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(gestures): save a slot override straight to an agent you own
nirholas6897da9e798e
diff --git a/api/agents/_id/_sub.js b/api/agents/_id/_sub.jsindex 946bc6a1a..4abdf34a1 100644--- a/api/agents/_id/_sub.js+++ b/api/agents/_id/_sub.js@@ -190,11 +190,21 @@ const animationSlotsSchema = z).refine((map) => Object.keys(map).length <= SLOTS.length, 'too many slot overrides');-const animationsBodySchema = z.object({- animations: z.array(animationEntrySchema).max(30),- animationGraph: animationGraphSchema.optional(),- animationSlots: animationSlotsSchema.optional(),-});+// Every field is optional and every one follows the same rule: present means+// "replace this", absent means "leave it alone". `animations` used to be+// required, which meant a caller changing one gesture slot had to resend the+// agent's whole clip list, and sending `[]` (the obvious thing when you do not+// use the list) silently wiped it.+const animationsBodySchema = z+ .object({+ animations: z.array(animationEntrySchema).max(30).optional(),+ animationGraph: animationGraphSchema.optional(),+ animationSlots: animationSlotsSchema.optional(),+ })+ .refine(+ (b) => b.animations !== undefined || b.animationGraph !== undefined || b.animationSlots !== undefined,+ 'send at least one of animations, animationGraph, animationSlots',+ );export const handleAnimations = wrap(async (req, res, id) => {if (cors(req, res, { methods: 'PUT,OPTIONS', credentials: true })) return;@@ -229,11 +239,13 @@ export const handleAnimations = wrap(async (req, res, id) => {// the slot overrides at meta.edits.animations: absent means "leave alone",// `{}` means "clear them".const has = (key) => Object.prototype.hasOwnProperty.call(rawBody || {}, key);- await sql`- UPDATE agent_identities- SET meta = jsonb_set(COALESCE(meta, '{}'::jsonb), '{animations}', ${JSON.stringify(parsed.animations)}::jsonb, true)- WHERE id = ${id}- `;+ if (has('animations')) {+ await sql`+ UPDATE agent_identities+ SET meta = jsonb_set(COALESCE(meta, '{}'::jsonb), '{animations}', ${JSON.stringify(parsed.animations)}::jsonb, true)+ WHERE id = ${id}+ `;+ }if (has('animationGraph')) {await sql`UPDATE agent_identities@@ -257,13 +269,16 @@ export const handleAnimations = wrap(async (req, res, id) => {`;}- // Read back what is actually stored so the response cannot drift from the row.+ // Read back what is actually stored so the response cannot drift from the row,+ // and so a partial update still reports the fields it did not touch.const [row] = await sql`- SELECT meta->'animationGraph' AS graph, meta->'edits'->'animations' AS slots+ SELECT meta->'animations' AS animations,+ meta->'animationGraph' AS graph,+ meta->'edits'->'animations' AS slotsFROM agent_identities WHERE id = ${id}`;return json(res, 200, {- animations: parsed.animations,+ animations: row?.animations ?? [],animationGraph: row?.graph ?? null,animationSlots: row?.slots ?? null,});diff --git a/pages/gestures.html b/pages/gestures.htmlindex 1683d6fcb..03e9fad58 100644--- a/pages/gestures.html+++ b/pages/gestures.html@@ -108,6 +108,7 @@<button type="button" class="gv-icon-btn" data-role="stage-pause" title="Pause" aria-label="Pause" disabled>❙❙</button></div></div>+ <p class="gv-stage-note" data-role="stage-note" hidden></p><p class="gv-sr-status" data-role="stage-status" role="status" aria-live="polite"></p></div>@@ -116,16 +117,41 @@<div class="gv-override" data-role="override" hidden><h2 class="gv-override-title">Override this slot</h2><p class="gv-override-lede">- Point <code data-role="override-slot">slot</code> at any clip in the library. Paste- the result into your agent's <code>meta.edits.animations</code>.+ Point <code data-role="override-slot">slot</code> at any clip in the library, then+ save it straight to an agent you own.</p><label class="gv-field"><span class="gv-field-label">Clip</span><select class="gv-select" data-role="override-select"></select></label>- <pre class="gv-code" data-role="override-code"><code></code></pre>+ <!-- Apply straight to an agent you own. The alternative is copying+ the JSON into the agent editor by hand, which is four more+ steps for the same result. -->+ <div class="gv-apply" data-role="apply" hidden>+ <label class="gv-field">+ <span class="gv-field-label">Apply to</span>+ <select class="gv-select" data-role="apply-select"></select>+ </label>+ <div class="gv-override-actions">+ <button type="button" class="gv-btn gv-btn--primary" data-role="apply-save">Save to agent</button>+ <button type="button" class="gv-btn gv-btn--ghost" data-role="override-copy">Copy JSON</button>+ </div>+ <p class="gv-apply-status" data-role="apply-status" role="status" aria-live="polite"></p>+ </div>++ <div class="gv-apply" data-role="apply-signedout" hidden>+ <div class="gv-override-actions">+ <a class="gv-btn gv-btn--primary" href="/signin?next=/gestures" data-role="apply-signin">Sign in to save this to an agent</a>+ <button type="button" class="gv-btn gv-btn--ghost" data-role="override-copy-2">Copy JSON</button>+ </div>+ </div>++ <details class="gv-json">+ <summary>Show the JSON</summary>+ <pre class="gv-code" data-role="override-code"><code></code></pre>+ </details>+<div class="gv-override-actions">- <button type="button" class="gv-btn gv-btn--primary" data-role="override-copy">Copy JSON</button><button type="button" class="gv-btn gv-btn--ghost" data-role="override-reset">Reset to default</button></div></div>diff --git a/pages/mcp-tools.html b/pages/mcp-tools.htmlindex 6a020732e..fba06067a 100644--- a/pages/mcp-tools.html+++ b/pages/mcp-tools.html@@ -18,11 +18,11 @@<meta property="og:title" content="MCP Tool Catalog · three.ws" data-i18n-attr="content:mcp_tools.meta_og_title"/><meta property="og:description" content="Every MCP tool three.ws publishes: what it does, what it costs, and whether an AI client can run it unattended. Generated from source." data-i18n-attr="content:mcp_tools.meta_og_description"/><meta property="og:url" content="https://three.ws/mcp-tools" />- <meta property="og:image" content="https://three.ws/api/page-og?s=build&t=MCP+Tool+Catalog&d=Every+MCP+tool+three.ws+publishes%3A+what+it+does%2C+what+it+costs%2C+and+whether+an+AI+client+can+run+it+unattended.&p=%2Fmcp-tools" />+ <meta property="og:image" content="https://three.ws/api/page-og?s=learn&t=MCP+Tool+Catalog&d=Every+MCP+tool+three.ws+publishes%3A+what+it+does%2C+what+it+costs%2C+and+whether+an+AI+client+can+run+it+unattended.&p=%2Fmcp-tools" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="MCP Tool Catalog · three.ws" data-i18n-attr="content:mcp_tools.meta_twitter_title"/><meta name="twitter:description" content="Every MCP tool three.ws publishes, searchable by safety, price, and server." data-i18n-attr="content:mcp_tools.meta_twitter_description"/>- <meta name="twitter:image" content="https://three.ws/api/page-og?s=build&t=MCP+Tool+Catalog&d=Every+MCP+tool+three.ws+publishes%3A+what+it+does%2C+what+it+costs%2C+and+whether+an+AI+client+can+run+it+unattended.&p=%2Fmcp-tools" />+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=learn&t=MCP+Tool+Catalog&d=Every+MCP+tool+three.ws+publishes%3A+what+it+does%2C+what+it+costs%2C+and+whether+an+AI+client+can+run+it+unattended.&p=%2Fmcp-tools" /><meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" /><meta property="og:locale" content="en_US" /><meta property="og:image:alt" content="MCP Tool Catalog / three.ws" />diff --git a/public/docs/img/asl-alphabet-hero.png b/public/docs/img/asl-alphabet-hero.pngnew file mode 100644index 000000000..1bb1edf6fBinary files /dev/null and b/public/docs/img/asl-alphabet-hero.png differdiff --git a/public/docs/img/asl-alphabet-keys.png b/public/docs/img/asl-alphabet-keys.pngnew file mode 100644index 000000000..4516b441bBinary files /dev/null and b/public/docs/img/asl-alphabet-keys.png differdiff --git a/public/docs/img/asl-practice.png b/public/docs/img/asl-practice.pngnew file mode 100644index 000000000..3566fde70Binary files /dev/null and b/public/docs/img/asl-practice.png differdiff --git a/public/docs/img/asl-sign-language-hero.png b/public/docs/img/asl-sign-language-hero.pngnew file mode 100644index 000000000..37da1357fBinary files /dev/null and b/public/docs/img/asl-sign-language-hero.png differdiff --git a/public/docs/img/asl-vocabulary.png b/public/docs/img/asl-vocabulary.pngnew file mode 100644index 000000000..7076829adBinary files /dev/null and b/public/docs/img/asl-vocabulary.png differdiff --git a/public/docs/img/asl-webcam-panel.png b/public/docs/img/asl-webcam-panel.pngnew file mode 100644index 000000000..b4839c6c6Binary files /dev/null and b/public/docs/img/asl-webcam-panel.png differdiff --git a/public/docs/img/gestures-hints.png b/public/docs/img/gestures-hints.pngnew file mode 100644index 000000000..cbec84516Binary files /dev/null and b/public/docs/img/gestures-hints.png differdiff --git a/public/docs/img/gestures-mobile.png b/public/docs/img/gestures-mobile.pngnew file mode 100644index 000000000..dc4d0a71dBinary files /dev/null and b/public/docs/img/gestures-mobile.png differdiff --git a/public/docs/img/gestures-override.png b/public/docs/img/gestures-override.pngnew file mode 100644index 000000000..012a6bb74Binary files /dev/null and b/public/docs/img/gestures-override.png differdiff --git a/public/docs/img/gestures-vocabulary.png b/public/docs/img/gestures-vocabulary.pngnew file mode 100644index 000000000..d3ca8d26fBinary files /dev/null and b/public/docs/img/gestures-vocabulary.png differdiff --git a/public/gestures.css b/public/gestures.cssindex 72a422783..5c2bb5973 100644--- a/public/gestures.css+++ b/public/gestures.css@@ -337,11 +337,76 @@white-space: nowrap;}+.gv-stage-note {+ margin: 0;+ padding: 0 14px 13px;+ font-size: 12.5px;+ line-height: 1.5;+ color: var(--gv-muted);+}+/* ── Override builder ──────────────────────────────────────────────────── */.gv-override {padding: 16px;}++.gv-apply {+ padding-top: 4px;+}+.gv-apply-status {+ margin: 10px 0 0;+ font-size: 12.5px;+ line-height: 1.5;+ color: var(--gv-muted);+ min-height: 1em;+}+.gv-apply-status.is-ok {+ color: #4ade80;+}+.gv-apply-status.is-err {+ color: #f87171;+}+.gv-apply-status a {+ color: inherit;+}+:root[data-theme='light'] .gv-apply-status.is-ok {+ color: #15803d;+}+:root[data-theme='light'] .gv-apply-status.is-err {+ color: #b91c1c;+}++.gv-json {+ margin: 14px 0 12px;+ border-top: 1px solid var(--gv-border);+ padding-top: 12px;+}+.gv-json > summary {+ font-size: 12px;+ color: var(--gv-muted);+ cursor: pointer;+ list-style: none;+}+.gv-json > summary::-webkit-details-marker {+ display: none;+}+.gv-json > summary::before {+ content: '▸ ';+}+.gv-json[open] > summary::before {+ content: '▾ ';+}+.gv-json > summary:hover {+ color: var(--text, #fafafa);+}+.gv-json > summary:focus-visible {+ outline: 2px solid var(--gv-accent);+ outline-offset: 2px;+}+.gv-json .gv-code {+ margin-top: 10px;+}.gv-override-title {margin: 0 0 6px;font-size: 15px;@@ -507,6 +572,18 @@overflow: hidden;text-overflow: ellipsis;}+.gv-card-note {+ margin-top: 2px;+ font-size: 11px;+ line-height: 1.4;+ color: var(--gv-muted);+ opacity: 0.85;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ line-clamp: 2;+ -webkit-box-orient: vertical;+ overflow: hidden;+}.gv-badge {position: absolute;top: 8px;diff --git a/src/gestures-page.js b/src/gestures-page.jsindex a673fbc4e..db8d827fc 100644--- a/src/gestures-page.js+++ b/src/gestures-page.js@@ -56,6 +56,8 @@ const state = {clip: null, // the clip currently staged (default or override)preview: null, // lazily imported AnimationLivePreviewpaused: false,+ agents: null, // null = not fetched yet, [] = signed out or no agents+ agentsLoading: false,};/* ── data ──────────────────────────────────────────────────────────────── */@@ -121,14 +123,16 @@ function cardHtml(slot) {const label = def?.label || clip;const icon = def?.icon || '🎞️';const badge = APPROXIMATE.has(slot)- ? '<span class="gv-badge gv-badge--warn">approx</span>'+ ? '<span class="gv-badge gv-badge--warn" title="No dedicated clip for this slot yet">approx</span>': def?.loop- ? '<span class="gv-badge">loop</span>'+ ? '<span class="gv-badge" title="This clip loops">loop</span>': '';+ // The note is rendered, not hidden behind a `title` tooltip: a browser+ // tooltip needs a second of hover, never appears on touch, and is the+ // difference between "what does `conjure` mean" being answered and not.return `<button type="button" class="gv-card" role="listitem" data-slot="${escapeHtml(slot)}"- aria-current="false"- title="${escapeHtml(SLOT_NOTES[slot] || '')}">+ aria-current="false"><span class="gv-card-thumb"><span class="gv-card-thumb-fallback" aria-hidden="true">${icon}</span><img src="${THUMB_BASE}/${encodeURIComponent(clip)}.webp" alt=""@@ -138,6 +142,7 @@ function cardHtml(slot) {<span class="gv-card-body"><span class="gv-card-slot">${escapeHtml(slot)}</span><span class="gv-card-clip">${escapeHtml(label)}</span>+ <span class="gv-card-note">${escapeHtml(SLOT_NOTES[slot] || '')}</span></span></button>`;}@@ -236,6 +241,111 @@ function renderOverride() {$('code', el('override-code')).textContent = json;const isDefault = state.clip === DEFAULT_ANIMATION_MAP[state.slot];el('override-reset').disabled = isDefault;+ renderApply();+}++/* ── apply to an agent ─────────────────────────────────────────────────── */++/**+ * The signed-in user's agents. A 401 is the ordinary signed-out case, not an+ * error: the page is public and everything except this panel works without an+ * account. Runs once, lazily, the first time a gesture is selected.+ */+async function loadAgents() {+ if (state.agents !== null || state.agentsLoading) return;+ state.agentsLoading = true;+ try {+ const res = await fetch('/api/agents', {+ credentials: 'include',+ headers: { accept: 'application/json' },+ });+ state.agents = res.ok ? ((await res.json()).agents ?? []) : [];+ } catch {+ state.agents = [];+ } finally {+ state.agentsLoading = false;+ renderApply();+ }+}++function renderApply() {+ const panel = el('apply');+ const signedOut = el('apply-signedout');+ if (!state.slot) {+ panel.hidden = true;+ signedOut.hidden = true;+ return;+ }+ const agents = state.agents;+ if (agents === null) {+ // Still loading: show neither panel rather than flashing the signed-out+ // call to action at a user who is in fact signed in.+ panel.hidden = true;+ signedOut.hidden = true;+ return;+ }+ if (!agents.length) {+ panel.hidden = true;+ signedOut.hidden = false;+ return;+ }+ signedOut.hidden = true;+ panel.hidden = false;++ const select = el('apply-select');+ if (select.dataset.filled !== String(agents.length)) {+ select.dataset.filled = String(agents.length);+ select.innerHTML = agents+ .map((a) => `<option value="${escapeHtml(a.id)}">${escapeHtml(a.name || a.id)}</option>`)+ .join('');+ }+ // Saving the default is a no-op the server would accept; say so instead.+ const isDefault = state.clip === DEFAULT_ANIMATION_MAP[state.slot];+ const save = el('apply-save');+ save.disabled = false;+ save.textContent = isDefault ? 'Clear this override' : 'Save to agent';+}++async function applyToAgent() {+ const save = el('apply-save');+ const status = el('apply-status');+ const agentId = el('apply-select').value;+ const agent = (state.agents || []).find((a) => a.id === agentId);+ if (!agentId || !state.slot) return;++ // Merge over the agent's existing overrides so saving one gesture never+ // drops another. Selecting the platform default removes the entry.+ const current = { ...(agent?.meta?.edits?.animations || {}) };+ if (state.clip === DEFAULT_ANIMATION_MAP[state.slot]) delete current[state.slot];+ else current[state.slot] = state.clip;++ save.disabled = true;+ status.textContent = 'Saving…';+ status.className = 'gv-apply-status';+ try {+ const { apiFetch } = await import('./api.js');+ const res = await apiFetch(`/api/agents/${agentId}/animations`, {+ method: 'PUT',+ headers: { 'content-type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ animationSlots: current }),+ });+ if (!res.ok) {+ const body = await res.json().catch(() => ({}));+ throw new Error(body.error_description || body.error || `HTTP ${res.status}`);+ }+ const saved = await res.json();+ // Keep the local copy in step so a second save merges against the truth.+ if (agent) agent.meta = { ...(agent.meta || {}), edits: { ...(agent.meta?.edits || {}), animations: saved.animationSlots || {} } };+ const count = Object.keys(saved.animationSlots || {}).length;+ status.innerHTML = `Saved. <a href="/a/${escapeHtml(agentId)}">Open ${escapeHtml(agent?.name || 'the agent')}</a> to see it, ${count} override${count === 1 ? '' : 's'} in total.`;+ status.className = 'gv-apply-status is-ok';+ } catch (err) {+ status.textContent = `Could not save: ${err.message}`;+ status.className = 'gv-apply-status is-err';+ } finally {+ save.disabled = false;+ }}/* ── preview ───────────────────────────────────────────────────────────── */@@ -261,6 +371,10 @@ async function play(slot, clip = DEFAULT_ANIMATION_MAP[slot]) {const def = state.byName.get(clip);el('stage-slot').textContent = slot;el('stage-clip').textContent = def?.label ? `${def.label} · ${clip}` : clip;+ const note = el('stage-note');+ note.textContent = SLOT_NOTES[slot] || '';+ note.hidden = !note.textContent;+ loadAgents();el('stage-status').textContent = `Playing ${slot}: ${def?.label || clip}`;for (const card of document.querySelectorAll('.gv-card[data-slot]')) {card.setAttribute('aria-current', String(card.dataset.slot === slot));@@ -304,8 +418,17 @@ function stop() {el('stage-slot').textContent = 'No gesture selected';el('stage-clip').innerHTML = ' ';el('stage-replay').disabled = true;- el('stage-pause').disabled = true;+ // Reset the pause toggle: leaving it latched showed a play icon on a stage+ // with nothing to play.+ state.paused = false;+ const pause = el('stage-pause');+ pause.disabled = true;+ pause.setAttribute('aria-pressed', 'false');+ pause.textContent = '❙❙';+ el('stage-note').hidden = true;el('override').hidden = true;+ el('apply').hidden = true;+ el('apply-signedout').hidden = true;state.slot = null;state.clip = null;for (const card of document.querySelectorAll('.gv-card[data-slot]')) {@@ -407,7 +530,9 @@ function wire() {if (state.slot) play(state.slot, DEFAULT_ANIMATION_MAP[state.slot]);});- el('override-copy').addEventListener('click', async (e) => {+ el('apply-save').addEventListener('click', applyToAgent);++ const copy = async (e) => {const btn = e.currentTarget;const text = $('code', el('override-code')).textContent;try {@@ -426,12 +551,14 @@ function wire() {setTimeout(() => {btn.textContent = 'Copy JSON';}, 1800);- });+ };+ el('override-copy').addEventListener('click', copy);+ el('override-copy-2').addEventListener('click', copy);- // Free the GL context when the tab is hidden for a while.+ // Stop burning frames on a hidden tab, without stomping a pause the user+ // chose: state.paused stays the source of truth for the button.document.addEventListener('visibilitychange', () => {- if (document.hidden) state.preview?.setPaused(true);- else if (!state.paused) state.preview?.setPaused(false);+ state.preview?.setPaused(document.hidden ? true : state.paused);});}