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: widgets and components updates

nirholas464aa80734a9
diff --git a/src/components/ModelViewerElement.js b/src/components/ModelViewerElement.js
index 4a8e891b4..12b950257 100644
--- a/src/components/ModelViewerElement.js
+++ b/src/components/ModelViewerElement.js
@@ -1,5 +1,6 @@
import { Viewer } from '../viewer.js';
import { LinearToneMapping, ACESFilmicToneMapping } from 'three';
+import { log } from '../shared/log.js';
const STYLE_ID = 'mv-viewer-style';
const DEFAULT_ENVIRONMENT = 'Neutral';
@@ -122,7 +123,7 @@ export class ModelViewerElement extends HTMLElement {
if (typeof this._viewer.dispose === 'function') {
this._viewer.dispose();
} else {
- console.warn(
+ log.warn(
'[mv-viewer] Viewer.dispose() not available — disconnect will leak resources.',
);
}
diff --git a/src/components/payment-gate-modal.jsx b/src/components/payment-gate-modal.jsx
index aaad37368..18f865485 100644
--- a/src/components/payment-gate-modal.jsx
+++ b/src/components/payment-gate-modal.jsx
@@ -1,11 +1,12 @@
-import vhtml from 'vhtml';
-/** @jsx vhtml */
-
+import { Modal } from '../shared/modal.js';
import { isUserRejection } from '../onchain/adapters/index.js';
/**
* Show a blocking modal asking the caller to pay before a priced skill executes.
*
+ * Non-dismissible via backdrop/ESC while payment is in flight; the Cancel button
+ * is the only exit path (it is disabled once the transaction starts).
+ *
* @param {{
* skill: string,
* amount: string,
@@ -18,37 +19,40 @@ import { isUserRejection } from '../onchain/adapters/index.js';
*/
export function showPaymentGateModal({ skill, amount, currencySymbol, chain, onPay, onCancel }) {
return new Promise((resolve, reject) => {
- const overlay = document.createElement('div');
- overlay.className = 'pgm-overlay';
- overlay.innerHTML = (
- <div class="pgm-modal" role="dialog" aria-modal="true" aria-label="Skill payment required">
- <h3>This skill requires payment</h3>
- <p class="pgm-price">
- <strong>{skill}</strong> costs{' '}
- <strong>
- {amount} {currencySymbol}
- </strong>
- {chain && <span class="pgm-chain"> on {chain}</span>}
- </p>
- <p class="pgm-status" role="status" aria-live="polite"></p>
- <div class="pgm-actions">
- <button class="pgm-cancel" type="button">
- Cancel
- </button>
- <button class="pgm-pay" type="button">
- Pay
- </button>
- </div>
- </div>
- );
- document.body.appendChild(overlay);
+ // ── Body content ──────────────────────────────────────────────────────────
+ const bodyEl = document.createElement('div');
+ bodyEl.className = 'pgm-body';
+
+ const chainSpan = chain ? `<span class="pgm-chain"> on ${_esc(chain)}</span>` : '';
+ bodyEl.innerHTML = `
+ <p class="pgm-price">
+ <strong>${_esc(skill)}</strong> costs
+ <strong>${_esc(amount)} ${_esc(currencySymbol)}</strong>${chainSpan}.
+ </p>
+ <p class="pgm-status" role="status" aria-live="polite"></p>
+ `;
- const cancelBtn = overlay.querySelector('.pgm-cancel');
- const payBtn = overlay.querySelector('.pgm-pay');
- const statusEl = overlay.querySelector('.pgm-status');
+ // ── Action buttons ────────────────────────────────────────────────────────
+ const actionsEl = document.createElement('div');
+ actionsEl.innerHTML = `
+ <button class="pgm-cancel btn btn--secondary" type="button">Cancel</button>
+ <button class="pgm-pay btn btn--primary" type="button">Pay</button>
+ `;
+
+ // ── Build modal ───────────────────────────────────────────────────────────
+ const modal = new Modal({
+ title: 'This skill requires payment',
+ body: bodyEl,
+ actions: actionsEl,
+ dismissible: false,
+ });
+
+ const cancelBtn = modal.actionsEl.querySelector('.pgm-cancel');
+ const payBtn = modal.actionsEl.querySelector('.pgm-pay');
+ const statusEl = modal.bodyEl.querySelector('.pgm-status');
function close() {
- overlay.remove();
+ modal.destroy();
}
cancelBtn.addEventListener('click', () => {
@@ -75,5 +79,14 @@ export function showPaymentGateModal({ skill, amount, currencySymbol, chain, onP
cancelBtn.disabled = false;
}
});
+
+ modal.open();
});
}
+
+function _esc(s) {
+ return String(s ?? '').replace(
+ /[<>&"]/g,
+ (c) => ({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' })[c],
+ );
+}
diff --git a/src/components/screenshot-modal.js b/src/components/screenshot-modal.js
index 00f294a12..3102f3a0b 100644
--- a/src/components/screenshot-modal.js
+++ b/src/components/screenshot-modal.js
@@ -1,3 +1,4 @@
+import { log } from '../shared/log.js';
export class ScreenshotModal {
constructor(container) {
this.container = container;
@@ -83,7 +84,7 @@ export class ScreenshotModal {
btn.textContent = originalText;
}, 2000);
} catch (e) {
- console.error('Failed to copy image to clipboard:', e);
+ log.error('Failed to copy image to clipboard:', e);
btn.textContent = 'Error!';
setTimeout(() => {
btn.textContent = originalText;
diff --git a/src/widgets/bonding-curve.js b/src/widgets/bonding-curve.js
index ee5252941..c1f9a3885 100644
--- a/src/widgets/bonding-curve.js
+++ b/src/widgets/bonding-curve.js
@@ -424,7 +424,7 @@ export function mountBondingCurve(rootEl, opts = {}) {
const network = opts.network === 'devnet' ? 'devnet' : 'mainnet';
const refreshMs = Math.max(5_000, Number(opts.refreshMs) || 15_000);
const showUsd = opts.showUsd !== false;
- const accent = /^#[0-9a-fA-F]{3,8}$/.test(opts.accent || '') ? opts.accent : '#8b5cf6';
+ const accent = /^#[0-9a-fA-F]{3,8}$/.test(opts.accent || '') ? opts.accent : '#888888';
const wrap = doc.createElement('div');
wrap.className = 'bcw';
diff --git a/src/widgets/passport.js b/src/widgets/passport.js
index 42db2b515..644f9f878 100644
--- a/src/widgets/passport.js
+++ b/src/widgets/passport.js
@@ -27,6 +27,7 @@ import {
chainLabel,
} from '../widget-types.js';
import { resolveURI, isDecentralizedURI } from '../ipfs.js';
+import { log } from '../shared/log.js';
const CACHE_PREFIX = 'erc8004-passport:';
const STALE_TTL_MS = 1000 * 60 * 60 * 24; // 24h hard ceiling on stale cache
@@ -112,7 +113,7 @@ function _pickRpc(config, chainId) {
if (config.rpcURL) {
// Require HTTPS per the security spec.
if (!/^https:\/\//i.test(config.rpcURL)) {
- console.warn('[passport] ignoring non-HTTPS rpcURL');
+ log.warn('[passport] ignoring non-HTTPS rpcURL');
} else {
return config.rpcURL;
}
@@ -208,7 +209,7 @@ async function _refresh(state, panel) {
_writeCache(state.cacheKey, { data: state.data, savedAt: state.lastVerifiedAt });
_render(panel, state);
} catch (err) {
- console.warn('[passport] refresh failed:', err.message || err);
+ log.warn('[passport] refresh failed:', err.message || err);
// Leave whatever stale data we had; update the status label.
_render(panel, state, { staleReason: 'RPC error' });
}
diff --git a/src/widgets/pumpfun-feed.js b/src/widgets/pumpfun-feed.js
index b8a532c90..226f6ef71 100644
--- a/src/widgets/pumpfun-feed.js
+++ b/src/widgets/pumpfun-feed.js
@@ -459,7 +459,7 @@ function renderGraduation(ev) {
].filter(Boolean).join(' ');
const chartLinks = mint
- ? `<a href="https://dexscreener.com/solana/${m}" target="_blank" rel="noopener" style="color:#9a8cff">DEX</a>⋅<a href="https://www.defined.fi/sol/${m}" target="_blank" rel="noopener" style="color:#9a8cff">DEF</a>`
+ ? `<a href="https://dexscreener.com/solana/${m}" target="_blank" rel="noopener" style="color:#888888">DEX</a>⋅<a href="https://www.defined.fi/sol/${m}" target="_blank" rel="noopener" style="color:#888888">DEF</a>`
: '';
const toolAbbr = mint
? [
@@ -468,7 +468,7 @@ function renderGraduation(ev) {
['PDR', `https://trade.padre.gg/trade/solana/${mint}`],
['PHO', `https://photon-sol.tinyastro.io/en/r/@bonk/${mint}`],
['BLX', `https://bullx.io/terminal?chainId=1399811149&address=${mint}`],
- ].map(([l, u]) => `<a href="${attrEsc(u)}" target="_blank" rel="noopener" style="color:#9a8cff">${l}</a>`).join('⋅')
+ ].map(([l, u]) => `<a href="${attrEsc(u)}" target="_blank" rel="noopener" style="color:#888888">${l}</a>`).join('⋅')
: '';
const sig = ev.signature || ev.tx_signature;
@@ -498,8 +498,8 @@ function renderGraduation(ev) {
${toolAbbr ? `<div style="font-size:11px">🧰 ${toolAbbr}</div>` : ''}
<div style="font-family:ui-monospace,monospace;font-size:10px;opacity:0.55;margin-top:4px;word-break:break-all">${escapeHtml(mint)}</div>
<div style="font-size:10px;opacity:0.55;margin-top:2px;display:flex;gap:8px;flex-wrap:wrap">
- ${sig ? `🔗 <a href="https://solscan.io/tx/${encodeURIComponent(sig)}" target="_blank" rel="noopener" style="color:#9a8cff">TX</a>` : ''}
- ${mint ? `· <a href="https://pump.fun/coin/${m}" target="_blank" rel="noopener" style="color:#9a8cff">pump.fun</a>` : ''}
+ ${sig ? `🔗 <a href="https://solscan.io/tx/${encodeURIComponent(sig)}" target="_blank" rel="noopener" style="color:#888888">TX</a>` : ''}
+ ${mint ? `· <a href="https://pump.fun/coin/${m}" target="_blank" rel="noopener" style="color:#888888">pump.fun</a>` : ''}
${tsStr ? `· 🕐 ${escapeHtml(tsStr)}` : ''}
</div>
`;
diff --git a/src/widgets/pumpfun-reactions.js b/src/widgets/pumpfun-reactions.js
index 3dce44b6a..112c66872 100644
--- a/src/widgets/pumpfun-reactions.js
+++ b/src/widgets/pumpfun-reactions.js
@@ -47,6 +47,7 @@
/** @typedef {'chill'|'normal'|'hype'} Mood */
+import { log } from '../shared/log.js';
const MOOD_PROFILE = {
chill: { gestureScale: 0.7, threshold: 30, speakRate: 0.4 },
normal: { gestureScale: 1.0, threshold: 0, speakRate: 1.0 },
@@ -494,7 +495,7 @@ export function createReactionDispatcher(opts = {}) {
activePriority = reaction.priority ?? 0;
record(reaction, kind, ev);
try { runner(reaction); } catch (err) {
- console.warn('[pumpfun-reactions] runner threw:', err);
+ log.warn('[pumpfun-reactions] runner threw:', err);
}
}
diff --git a/src/widgets/talking-agent.js b/src/widgets/talking-agent.js
index bdf84f23d..94447e89d 100644
--- a/src/widgets/talking-agent.js
+++ b/src/widgets/talking-agent.js
@@ -16,6 +16,7 @@
import { NichAgent } from '../nich-agent.js';
import { ACTION_TYPES } from '../agent-protocol.js';
import { ThoughtBubble } from '../thought-bubble.js';
+import { log } from '../shared/log.js';
/**
* @param {import('../viewer.js').Viewer} viewer
@@ -75,13 +76,13 @@ export async function mountTalkingAgent(viewer, config, container, ctx) {
onMessage?.({ role: 'user', content: text });
onMessage?.({ role: 'assistant', content: result.reply });
} catch (cbErr) {
- console.warn('[talking-agent] onMessage callback threw', cbErr?.message);
+ log.warn('[talking-agent] onMessage callback threw', cbErr?.message);
}
}
queueMicrotask(() => runActions(result.actions, getSceneCtrl, protocol));
return { reply: result.reply, error: result.error };
} catch (err) {
- console.warn('[talking-agent] chat dispatch failed', err.message);
+ log.warn('[talking-agent] chat dispatch failed', err.message);
return { error: 'Chat is unavailable right now.' };
}
},
@@ -213,7 +214,7 @@ function runActions(actions, getSceneCtrl, protocol) {
try {
runOne(action, sceneCtrl, protocol);
} catch (err) {
- console.warn('[talking-agent] action failed', action.type, err.message);
+ log.warn('[talking-agent] action failed', action.type, err.message);
}
}
}
@@ -240,6 +241,6 @@ function runOne(action, sceneCtrl, protocol) {
}
return;
default:
- console.warn('[talking-agent] unknown action type:', action.type);
+ log.warn('[talking-agent] unknown action type:', action.type);
}
}