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: launcher engine and trends updates with admin endpoint and tests

nirholas556c13d9d90c
diff --git a/api/_lib/launcher-engine.js b/api/_lib/launcher-engine.js
index d85855515..5d6e5c249 100644
--- a/api/_lib/launcher-engine.js
+++ b/api/_lib/launcher-engine.js
@@ -64,7 +64,7 @@ async function ensureSchema() {
enabled boolean not null default false,
dry_run boolean not null default true,
mode text not null default 'hybrid' check (mode in ('off','trend','meme','random','hybrid')),
- sources jsonb not null default '["coin_intel","trending","x"]'::jsonb,
+ sources jsonb not null default '["coin_intel","trending","knowyourmeme","x"]'::jsonb,
categories jsonb not null default '[]'::jsonb,
target_cadence_seconds integer not null default 60,
max_per_hour integer not null default 30,
diff --git a/api/_lib/launcher-trends.js b/api/_lib/launcher-trends.js
index b5b33b726..5cce1bca8 100644
--- a/api/_lib/launcher-trends.js
+++ b/api/_lib/launcher-trends.js
@@ -39,9 +39,12 @@ const EXTERNAL_TIMEOUT_MS = 6_000;
const MAX_TERMS = 32;
// Source weights — internal venue signals dominate; culture sources broaden.
+// knowyourmeme is the single best PURE-meme external feed (entries are literally
+// catalogued memes), so it outranks the general culture/news sources.
const SOURCE_WEIGHT = {
coin_intel: 3.0,
trending: 2.6,
+ knowyourmeme: 2.0,
x: 1.4,
hackernews: 1.2,
reddit: 1.2,
@@ -50,8 +53,10 @@ const SOURCE_WEIGHT = {
// External providers are opt-in via the config `sources` array; internal ones run
// whenever named. These ids are the vocabulary an operator enables.
-const EXTERNAL_SOURCES = new Set(['hackernews', 'reddit', 'wikipedia']);
-const DEFAULT_SOURCES = ['coin_intel', 'trending', 'x'];
+const EXTERNAL_SOURCES = new Set(['knowyourmeme', 'hackernews', 'reddit', 'wikipedia']);
+// knowyourmeme rides in the default set: it's the freshest stream of named memes
+// entering culture — exactly what the launcher exists to mint into.
+const DEFAULT_SOURCES = ['coin_intel', 'trending', 'knowyourmeme', 'x'];
// ── text hygiene ────────────────────────────────────────────────────────────────
const STOPWORDS = new Set([
@@ -167,6 +172,55 @@ async function fetchJson(url, { timeoutMs = EXTERNAL_TIMEOUT_MS, headers } = {})
}
}
+/** Like fetchJson, but for text/XML payloads (RSS). Key-less, time-bounded, never throws. */
+async function fetchText(url, { timeoutMs = EXTERNAL_TIMEOUT_MS, headers } = {}) {
+ const ctrl = new AbortController();
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
+ try {
+ const res = await fetch(url, {
+ signal: ctrl.signal,
+ headers: {
+ 'user-agent': 'three.ws-launcher/1.0 (+https://three.ws)',
+ accept: 'application/rss+xml, application/xml, text/xml, */*',
+ ...headers,
+ },
+ });
+ if (!res.ok) return null;
+ return await res.text();
+ } catch {
+ return null;
+ } finally {
+ clearTimeout(timer);
+ }
+}
+
+// Minimal, dependency-free RSS reader: pull each <item>'s <title> and <link>.
+// Handles CDATA wrappers and the channel-level title (which we skip by reading
+// inside <item> blocks only). Good enough for the well-formed feeds we consume.
+function decodeEntities(s) {
+ return String(s || '')
+ .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
+ .replace(/&(?:amp|#0*38);/gi, '&')
+ .replace(/&(?:lt|#0*60);/gi, '<')
+ .replace(/&(?:gt|#0*62);/gi, '>')
+ .replace(/&(?:quot|#0*34);/gi, '"')
+ .replace(/&(?:#0*39|apos|#x0*27);/gi, "'")
+ .replace(/&#x?[0-9a-f]+;|&[a-z]+;/gi, ' ');
+}
+function parseRssItems(xml) {
+ const items = [];
+ const blocks = String(xml || '').match(/<item\b[\s\S]*?<\/item>/gi) || [];
+ for (const b of blocks) {
+ const title = b.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
+ const link = b.match(/<link\b[^>]*>([\s\S]*?)<\/link>/i);
+ items.push({
+ title: title ? decodeEntities(title[1]).trim() : '',
+ link: link ? decodeEntities(link[1]).trim() : '',
+ });
+ }
+ return items;
+}
+
/** Memoise a provider's raw signals so a 60s tick never re-hits an external API. */
async function cached(key, ttl, fn) {
try {
@@ -343,9 +397,57 @@ async function wikipediaSignals() {
});
}
+/**
+ * Know Your Meme — the canonical catalogue of memes entering culture. Two feeds:
+ * confirmed.rss — entries newly CONFIRMED by KYM editors; each <title> IS the
+ * meme's name ("Drooling Cat", "Train Dog"), so it's the single
+ * cleanest "fresh named meme" signal anywhere.
+ * newsfeed.rss — active meme news; the meme is the /memes/<slug> in each link,
+ * which we de-slug into a theme.
+ *
+ * Both are reduced to generic THEME words (the $THREE rule): the downstream LLM
+ * riffs on the culture and invents an original identity — KYM names are never
+ * minted verbatim. Recency-decayed (feeds are newest-first), key-less, cached.
+ * @returns {Promise<Array<{term:string, weight:number, kind:string}>>}
+ */
+async function knowYourMemeSignals() {
+ return cached('launcher:trend:kym', PROVIDER_CACHE_TTL_S, async () => {
+ const [confirmedXml, newsXml] = await Promise.all([
+ fetchText('https://knowyourmeme.com/memes/confirmed.rss'),
+ fetchText('https://knowyourmeme.com/newsfeed.rss'),
+ ]);
+ const out = [];
+
+ // Confirmed entries: the title is the meme name. Titles often carry alt
+ // spellings as "Primary / Variant" — take the first clean variant.
+ const confirmed = parseRssItems(confirmedXml).slice(0, 25);
+ confirmed.forEach((item, i) => {
+ const variant = item.title.split(/\s*\/\s*/).map((v) => normTerm(v)).find(Boolean);
+ if (!variant) return;
+ const weight = Math.max(0.6, 1.5 - i * 0.04); // newest-first decay
+ out.push({ term: variant.toLowerCase(), weight, kind: 'meme' });
+ });
+
+ // Newsfeed: de-slug the /memes/<slug> link into a theme phrase.
+ const news = parseRssItems(newsXml).slice(0, 25);
+ news.forEach((item, i) => {
+ const m = item.link.match(/\/memes\/(?:[a-z-]+\/)?([a-z0-9-]+)\b/i);
+ if (!m) return;
+ const phrase = m[1].replace(/-/g, ' ').trim();
+ const n = normTerm(phrase);
+ if (!n) return;
+ const weight = Math.max(0.5, 1.1 - i * 0.03);
+ out.push({ term: n.toLowerCase(), weight, kind: 'meme' });
+ });
+
+ return out;
+ });
+}
+
const PROVIDERS = {
coin_intel: coinIntelSignals,
trending: oracleSignals,
+ knowyourmeme: knowYourMemeSignals,
x: xSignals,
hackernews: hackerNewsSignals,
reddit: redditSignals,
@@ -445,3 +547,5 @@ export async function rankNarratives({ network = 'mainnet', sources, categories
}
export { EXTERNAL_SOURCES, DEFAULT_SOURCES };
+// Exported for unit tests (pure, network-free).
+export { decodeEntities, parseRssItems, extractThemes, normTerm };
diff --git a/api/_lib/migrations/20260629060000_coin_launcher.sql b/api/_lib/migrations/20260629060000_coin_launcher.sql
index d10b69dd8..9e67a475d 100644
--- a/api/_lib/migrations/20260629060000_coin_launcher.sql
+++ b/api/_lib/migrations/20260629060000_coin_launcher.sql
@@ -38,8 +38,8 @@ create table if not exists launcher_config (
mode text not null default 'hybrid'
check (mode in ('off', 'trend', 'meme', 'random', 'hybrid')),
-- Which trend providers feed 'trend'/'hybrid' mode, e.g.
- -- ["coin_intel","trending","x"]. Empty ⇒ all configured providers.
- sources jsonb not null default '["coin_intel","trending","x"]'::jsonb,
+ -- ["coin_intel","trending","knowyourmeme","x"]. Empty ⇒ all configured providers.
+ sources jsonb not null default '["coin_intel","trending","knowyourmeme","x"]'::jsonb,
-- Restrict trend picks to these pump_coin_intel categories (meme/culture/...).
-- Empty ⇒ no category filter.
categories jsonb not null default '[]'::jsonb,
diff --git a/api/admin/launcher.js b/api/admin/launcher.js
index 248d5d09d..5478bed07 100644
--- a/api/admin/launcher.js
+++ b/api/admin/launcher.js
@@ -25,7 +25,7 @@ function isCronAuth(req) {
}
const MODES = ['off', 'trend', 'meme', 'random', 'hybrid'];
-const KNOWN_SOURCES = ['coin_intel', 'trending', 'x', 'oracle', 'hackernews', 'reddit', 'wikipedia'];
+const KNOWN_SOURCES = ['coin_intel', 'trending', 'x', 'oracle', 'knowyourmeme', 'hackernews', 'reddit', 'wikipedia'];
async function ensureGlobalRow() {
await sql`
diff --git a/tests/launcher-trends.test.js b/tests/launcher-trends.test.js
new file mode 100644
index 000000000..2f9a5a7e8
--- /dev/null
+++ b/tests/launcher-trends.test.js
@@ -0,0 +1,66 @@
+import { describe, it, expect } from 'vitest';
+import { decodeEntities, parseRssItems, normTerm } from '../api/_lib/launcher-trends.js';
+
+describe('decodeEntities', () => {
+ it('unwraps CDATA', () => {
+ expect(decodeEntities('<![CDATA[Drooling Cat]]>')).toBe('Drooling Cat');
+ });
+ it('decodes named + numeric entities', () => {
+ expect(decodeEntities('Tom &amp; Jerry')).toBe('Tom & Jerry');
+ expect(decodeEntities('Don&#39;t Swear')).toBe("Don't Swear");
+ expect(decodeEntities('Don&apos;t')).toBe("Don't");
+ });
+ it('strips unknown entities to a space rather than leaking "amp"-style garbage', () => {
+ expect(decodeEntities('A&nbsp;B')).toBe('A B');
+ });
+});
+
+describe('parseRssItems', () => {
+ const xml = `<?xml version="1.0"?><rss><channel>
+ <title>Know Your Meme Entries - Confirmed</title>
+ <link>https://knowyourmeme.com</link>
+ <item><title>Drooling Cat / Crowd of Drooling Cats</title>
+ <link>https://knowyourmeme.com/memes/drooling-cat</link></item>
+ <item><title><![CDATA[Train Dog]]></title>
+ <link>https://knowyourmeme.com/memes/train-dog</link></item>
+ </channel></rss>`;
+
+ it('reads only <item> blocks, skipping the channel-level title', () => {
+ const items = parseRssItems(xml);
+ expect(items).toHaveLength(2);
+ expect(items.map((i) => i.title)).toEqual([
+ 'Drooling Cat / Crowd of Drooling Cats',
+ 'Train Dog',
+ ]);
+ });
+ it('captures item links for slug de-referencing', () => {
+ const items = parseRssItems(xml);
+ expect(items[1].link).toBe('https://knowyourmeme.com/memes/train-dog');
+ });
+ it('returns [] for empty / malformed input, never throws', () => {
+ expect(parseRssItems('')).toEqual([]);
+ expect(parseRssItems(null)).toEqual([]);
+ expect(parseRssItems('<rss>no items here</rss>')).toEqual([]);
+ });
+});
+
+describe('KYM theme extraction shape', () => {
+ it('takes the first clean variant from a "Primary / Variant" title', () => {
+ const variant = 'Drooling Cat / Crowd of Drooling Cats'
+ .split(/\s*\/\s*/).map((v) => normTerm(v)).find(Boolean);
+ expect(variant).toBe('Drooling Cat');
+ });
+ it('falls through an emoticon variant to the readable one', () => {
+ const variant = '( ͡° ͜ʖ ͡°) / Lenny Face'
+ .split(/\s*\/\s*/).map((v) => normTerm(v)).find(Boolean);
+ expect(variant).toBe('Lenny Face');
+ });
+ it('drops overlong meme titles (no usable ticker theme)', () => {
+ expect(normTerm('She Had No Idea They Was Gonna Play In Her Face')).toBeNull();
+ });
+ it('de-slugs a /memes/<slug> link into a theme phrase', () => {
+ const m = 'https://knowyourmeme.com/memes/subcultures/chimptopia'
+ .match(/\/memes\/(?:[a-z-]+\/)?([a-z0-9-]+)\b/i);
+ expect(normTerm(m[1].replace(/-/g, ' '))).toBe('chimptopia');
+ });
+});