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(skills): add Solana Blinks skills for parsing and executing actions

nirholasaf7df7787ad5
diff --git a/chat/src/SkillsMarketplaceModal.svelte b/chat/src/SkillsMarketplaceModal.svelte
index 6af37b7a4..45513491f 100644
--- a/chat/src/SkillsMarketplaceModal.svelte
+++ b/chat/src/SkillsMarketplaceModal.svelte
@@ -121,7 +121,12 @@
return typeof cat === 'string' ? cat : cat.slug;
}
+ let skillsAbort = /** @type {AbortController | null} */ (null);
+
async function loadSkills(reset = false) {
+ skillsAbort?.abort();
+ skillsAbort = new AbortController();
+ const signal = skillsAbort.signal;
loading = true;
fetchFailed = false;
try {
@@ -131,7 +136,7 @@
if (catSlug) p.set('category', catSlug);
if (sort) p.set('sort', sort);
if (!reset && page) p.set('cursor', page);
- const res = await fetch(`/api/skills?${p}`);
+ const res = await fetch(`/api/skills?${p}`, { signal });
if (res.status === 429) throw new Error('Too many requests — please wait a moment and try again');
if (!res.ok) throw new Error('Failed to load skills');
const data = await res.json();
@@ -139,11 +144,14 @@
page = data.next_cursor || null;
hasMore = !!data.next_cursor;
} catch (e) {
+ if (e.name === 'AbortError') return;
fetchFailed = true;
notify(e.message, 'error');
} finally {
- loading = false;
- loaded = true;
+ if (!signal.aborted) {
+ loading = false;
+ loaded = true;
+ }
}
}
diff --git a/src/agent-skills-blinks.js b/src/agent-skills-blinks.js
new file mode 100644
index 000000000..a4f8a9403
--- /dev/null
+++ b/src/agent-skills-blinks.js
@@ -0,0 +1,216 @@
+/**
+ * Solana Blinks / Actions skills
+ * --------------------------------
+ * Wraps @solana/actions so an agent can:
+ * - parse a Solana Action (blink) URL → describe what it does
+ * - execute a blink action → build + sign + send transaction
+ *
+ * Blinks are shareable links that encode on-chain actions. A GET request
+ * to the action URL returns metadata (title, description, buttons); a POST
+ * with the user's wallet returns a transaction ready to sign.
+ *
+ * Wallet: uses the same Phantom/Backpack/Solflare detection as pump skills.
+ * No keys held here. All signing is delegated to the injected wallet.
+ */
+
+import { detectSolanaWallet, SOLANA_RPC } from './erc8004/solana-deploy.js';
+
+const ACTIONS_IDENTITY_HEADER = 'x-blockchain-ids';
+const DEFAULT_NETWORK = 'mainnet';
+
+async function requireWallet() {
+ const wallet = detectSolanaWallet();
+ if (!wallet) throw new Error('No Solana wallet detected. Install Phantom or Backpack.');
+ const pubkey = await wallet.connect();
+ return { wallet, pubkey };
+}
+
+async function fetchAction(url) {
+ const r = await fetch(url, {
+ headers: { Accept: 'application/json', 'x-action-version': '2.4', 'x-blockchain-ids': 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp' },
+ });
+ if (!r.ok) throw new Error(`Action fetch failed: ${r.status} ${r.statusText}`);
+ const data = await r.json();
+ if (data.error) throw new Error(data.error.message || 'Action returned an error');
+ return data;
+}
+
+function summarizeAction(action) {
+ const title = action.title || '(no title)';
+ const description = action.description || '';
+ const links = action.links?.actions || [];
+ const buttons = links.map((l) => `"${l.label}"`).join(', ');
+ const parts = [`**${title}**`];
+ if (description) parts.push(description);
+ if (buttons) parts.push(`Available actions: ${buttons}`);
+ if (action.disabled) parts.push('⚠️ This action is currently disabled.');
+ return parts.join('\n');
+}
+
+/**
+ * Register Solana Blinks / Actions skills onto an AgentSkills instance.
+ * @param {import('./agent-skills.js').AgentSkills} skills
+ */
+export function registerBlinksSkills(skills) {
+ // ── blink-parse ─────────────────────────────────────────────────────────
+ skills.register({
+ name: 'blink-parse',
+ description: 'Parse a Solana Action (blink) URL and describe what it does.',
+ instruction:
+ 'Fetches action metadata from the given URL and returns a human-readable summary of the title, description, and available action buttons.',
+ animationHint: 'curiosity',
+ voicePattern: 'Let me read that blink for you…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ url: {
+ type: 'string',
+ description: 'A Solana Action URL (https://… or solana-action:…)',
+ },
+ },
+ required: ['url'],
+ },
+ handler: async (args) => {
+ let actionUrl = String(args?.url || '').trim();
+ if (!actionUrl) return { success: false, output: 'url is required', sentiment: -0.2 };
+
+ // Strip the solana-action: protocol wrapper if present
+ if (actionUrl.startsWith('solana-action:')) {
+ actionUrl = decodeURIComponent(actionUrl.slice('solana-action:'.length));
+ }
+
+ try {
+ const action = await fetchAction(actionUrl);
+ const summary = summarizeAction(action);
+ return {
+ success: true,
+ output: summary,
+ sentiment: 0.2,
+ data: {
+ title: action.title,
+ description: action.description,
+ icon: action.icon,
+ label: action.label,
+ disabled: action.disabled ?? false,
+ actions: action.links?.actions || [],
+ },
+ };
+ } catch (err) {
+ return {
+ success: false,
+ output: `Could not parse blink: ${err.message}`,
+ sentiment: -0.3,
+ };
+ }
+ },
+ });
+
+ // ── blink-execute ────────────────────────────────────────────────────────
+ skills.register({
+ name: 'blink-execute',
+ description: 'Execute a Solana Action blink — build the transaction, sign with the connected wallet, and broadcast it.',
+ instruction:
+ 'POSTs to the action href with the connected wallet address to obtain a transaction, signs it with the browser wallet, and sends it.',
+ animationHint: 'gesture',
+ voicePattern: 'Executing blink action…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ url: {
+ type: 'string',
+ description: 'The action href from a parsed blink (https://…)',
+ },
+ params: {
+ type: 'object',
+ description: 'Optional key-value pairs to substitute into URL template parameters (e.g. { amount: "1.5" })',
+ },
+ network: {
+ type: 'string',
+ enum: ['mainnet', 'devnet'],
+ default: 'mainnet',
+ },
+ },
+ required: ['url'],
+ },
+ handler: async (args) => {
+ let actionHref = String(args?.url || '').trim();
+ if (!actionHref) return { success: false, output: 'url is required', sentiment: -0.2 };
+ if (actionHref.startsWith('solana-action:')) {
+ actionHref = decodeURIComponent(actionHref.slice('solana-action:'.length));
+ }
+
+ const network = args.network || DEFAULT_NETWORK;
+
+ // Substitute URL template params like {amount}
+ if (args.params && typeof args.params === 'object') {
+ for (const [k, v] of Object.entries(args.params)) {
+ actionHref = actionHref.replace(
+ new RegExp(`\\{${k}\\}`, 'g'),
+ encodeURIComponent(String(v)),
+ );
+ }
+ }
+
+ try {
+ const { wallet, pubkey } = await requireWallet();
+ const [{ VersionedTransaction, Transaction, Connection }, { parseURL, serializeTransaction }] =
+ await Promise.all([
+ import('@solana/web3.js'),
+ import('@solana/actions'),
+ ]);
+
+ // POST to action endpoint with the user's account
+ const postResp = await fetch(actionHref, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ 'x-action-version': '2.4',
+ 'x-blockchain-ids': 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
+ },
+ body: JSON.stringify({ account: pubkey.toBase58() }),
+ });
+ if (!postResp.ok) {
+ const txt = await postResp.text().catch(() => postResp.status.toString());
+ throw new Error(`Action POST failed: ${postResp.status} — ${txt}`);
+ }
+ const result = await postResp.json();
+ if (result.error) throw new Error(result.error.message || 'Action returned error');
+ if (!result.transaction) throw new Error('Action returned no transaction');
+
+ const rpcUrl = SOLANA_RPC[network] || SOLANA_RPC[DEFAULT_NETWORK];
+ const connection = new Connection(rpcUrl, 'confirmed');
+
+ // Deserialize, sign, send
+ const txBytes = Buffer.from(result.transaction, 'base64');
+ let tx;
+ try {
+ tx = VersionedTransaction.deserialize(txBytes);
+ } catch {
+ tx = Transaction.from(txBytes);
+ }
+
+ const signed = await wallet.signTransaction(tx);
+ const raw = signed.serialize();
+ const sig = await connection.sendRawTransaction(raw, { skipPreflight: false });
+ await connection.confirmTransaction(sig, 'confirmed');
+
+ const message = result.message || 'Action executed successfully.';
+ return {
+ success: true,
+ output: `${message}\nSignature: ${sig}`,
+ sentiment: 0.7,
+ data: { signature: sig, network, message },
+ };
+ } catch (err) {
+ return {
+ success: false,
+ output: `Blink execution failed: ${err.message}`,
+ sentiment: -0.4,
+ };
+ }
+ },
+ });
+}
diff --git a/src/erc8004/register-ui.js b/src/erc8004/register-ui.js
index b73643cac..2ef3f717d 100644
--- a/src/erc8004/register-ui.js
+++ b/src/erc8004/register-ui.js
@@ -286,6 +286,7 @@ export class RegisterUI {
// 'current' → use `glbUrl` pre-filled from the live SPA viewer
// 'saved' → pick one from the signed-in user's saved avatars
// 'upload' → user drops a new .glb in the wizard
+ // 'url' → user pastes a hosted GLB URL directly
// 'skip' → deploy as a metadata-only agent (no 3D body)
this.wizardStep = 1;
this.form = {
@@ -294,6 +295,7 @@ export class RegisterUI {
imageUrl: initial.imageUrl || '',
glbUrl: initial.glbUrl || '',
glbFile: null,
+ pastedGlbUrl: '',
savedAvatar: null, // { id, name, url, thumbnailUrl }
defaultAvatarId: null, // id of a pre-pinned DEFAULT_AVATARS entry
avatarSource: initial.glbUrl ? 'current' : 'upload',
@@ -914,6 +916,7 @@ export class RegisterUI {
${radio('saved', 'Use a saved avatar', canPickSaved ? 'Pick one from your account library.' : 'Sign in to pick from your saved avatars.', !canPickSaved)}
${DEFAULT_AVATARS.length ? radio('default', 'Use a default avatar', 'Pick a pre-pinned starter avatar — no upload needed.') : ''}
${radio('upload', 'Upload a new GLB', 'Drop or browse a .glb / .gltf file from your machine.')}
+ ${radio('url', 'Paste a GLB URL', 'Use a GLB already hosted on IPFS, Arweave, or HTTPS.')}
${radio('skip', 'Skip — no 3D body', 'Deploy as a metadata-only agent. You can attach an avatar later via setAgentURI.')}
</div>
@@ -1004,6 +1007,16 @@ export class RegisterUI {
drop.classList.remove('erc8004-file-drop--active');
setFile(e.dataTransfer.files[0]);
});
+ } else if (s === 'url') {
+ panel.innerHTML = `
+ <div class="erc8004-url-paste">
+ <input class="erc8004-input" type="url" placeholder="https://… or ipfs://… or ar://…" value="${esc(this.form.pastedGlbUrl)}" data-role="glb-url-input" />
+ <p class="erc8004-hint">The GLB must include <strong>ARKit / Oculus viseme morph targets</strong> for lip-sync to work.</p>
+ </div>
+ `;
+ panel.querySelector('[data-role="glb-url-input"]').addEventListener('input', (e) => {
+ this.form.pastedGlbUrl = e.target.value.trim();
+ });
} else if (s === 'default') {
panel.innerHTML = `<div class="erc8004-saved-grid" data-role="grid"></div>`;
const grid = panel.querySelector('[data-role="grid"]');
@@ -1066,6 +1079,10 @@ export class RegisterUI {
this._toast('Drop a .glb file, or choose another option.', true);
return;
}
+ if (s === 'url' && !this.form.pastedGlbUrl) {
+ this._toast('Paste a GLB URL, or choose another option.', true);
+ return;
+ }
if (s === 'default' && !this.form.defaultAvatarId) {
this._toast('Pick a default avatar, or choose another option.', true);
return;
@@ -1184,6 +1201,9 @@ export class RegisterUI {
if (s === 'upload' && this.form.glbFile) {
return `Uploaded: ${esc(this.form.glbFile.name)} (${(this.form.glbFile.size / 1024).toFixed(1)} KB)`;
}
+ if (s === 'url' && this.form.pastedGlbUrl) {
+ return `URL: <code>${esc(this.form.pastedGlbUrl)}</code>`;
+ }
if (s === 'default' && this.form.defaultAvatarId) {
const def = getDefaultAvatar(this.form.defaultAvatarId);
return def ? `Default: ${esc(def.name)}` : `Default avatar`;
@@ -1216,6 +1236,8 @@ export class RegisterUI {
glbUrl = getDefaultAvatar(this.form.defaultAvatarId)?.url || null;
else if (this.form.avatarSource === 'upload' && this.form.glbFile)
glbUrl = `<pending-upload:${this.form.glbFile.name}>`;
+ else if (this.form.avatarSource === 'url' && this.form.pastedGlbUrl)
+ glbUrl = this.form.pastedGlbUrl;
return buildRegistrationJSON({
name: this.form.name,
@@ -1381,6 +1403,13 @@ export class RegisterUI {
} else {
glbFile = await this._fetchUrlAsFile(this.form.glbUrl, say, 'current avatar');
}
+ } else if (avatarSource === 'url' && this.form.pastedGlbUrl) {
+ if (_isStableUrl(this.form.pastedGlbUrl)) {
+ glbUrl = this.form.pastedGlbUrl;
+ say(`Using pasted GLB URL (no re-upload): ${glbUrl}`);
+ } else {
+ glbFile = await this._fetchUrlAsFile(this.form.pastedGlbUrl, say, 'pasted GLB');
+ }
} else if (avatarSource === 'saved' && this.form.savedAvatar) {
try {
say(`Resolving saved avatar: ${this.form.savedAvatar.name}…`);
diff --git a/src/solana/pyth-price.js b/src/solana/pyth-price.js
index 9268c7d3d..3ea62eaa6 100644
--- a/src/solana/pyth-price.js
+++ b/src/solana/pyth-price.js
@@ -64,10 +64,9 @@ export async function getPrices(symbols) {
for (let i = 0; i < syms.length; i++) {
const feed = feeds?.[i];
const p = feed?.getPriceUnchecked();
- const conf = feed?.getConfUnchecked();
result[syms[i].toUpperCase()] = {
price: toFloat(p),
- confidence: toFloat(conf),
+ confidence: p ? toFloat({ price: p.conf, expo: p.expo }) : NaN,
publishTime: p?.publishTime ?? 0,
};
}
@@ -108,8 +107,8 @@ export function subscribePrices(symbols, onUpdate) {
const sym = idToSymbol[id];
if (!sym) return;
const p = feed.getPriceUnchecked();
- const conf = feed.getConfUnchecked();
- onUpdate({ [sym]: { price: toFloat(p), confidence: toFloat(conf), publishTime: p?.publishTime ?? 0 } });
+ const confidence = p ? toFloat({ price: p.conf, expo: p.expo }) : NaN;
+ onUpdate({ [sym]: { price: toFloat(p), confidence, publishTime: p?.publishTime ?? 0 } });
});
return () => conn.unsubscribePriceFeedUpdates(ids);