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
Oracle: test-alert endpoint + rate limiter + SEO meta on sitemap/strategy-lab
nirholas53a2e6eaab6c
diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.jsindex 161a222a7..abd5c5814 100644--- a/api/_lib/rate-limit.js+++ b/api/_lib/rate-limit.js@@ -546,6 +546,12 @@ export const limits = {getLimiter('video:generate:global', { limit: 100, window: '1 h', critical: true }).limit('global',),+ // Oracle personal Telegram test-alert (api/oracle/test-alert). Fires a real+ // Telegram message via the bot, so keep per-IP burst tight to prevent spamming+ // third-party chats. 5 per 10 minutes is generous enough for manual setup+ // retries while blocking scripted abuse.+ oracleTelegramTestIp: (ip) =>+ getLimiter('oracle:tg-test:ip', { limit: 5, window: '10 m' }).limit(ip),};// Trust only proxy headers that Vercel itself sets and signs. Naively readingdiff --git a/api/oracle/test-alert.js b/api/oracle/test-alert.jsnew file mode 100644index 000000000..a9ec3d3b9--- /dev/null+++ b/api/oracle/test-alert.js@@ -0,0 +1,101 @@+/**+ * Oracle — send a Telegram test alert to a personal chat.+ *+ * POST /api/oracle/test-alert+ * Body: { agent_id: uuid, chat_id: string }+ *+ * Verifies the caller owns the agent, then sends a test message to the+ * supplied Telegram chat ID so the user can confirm their setup is working+ * before they arm their agent and wait for a real signal.+ *+ * Auth: session cookie or bearer token. Rate-limited to 2/min per IP.+ */++import { cors, json, method, readJson, wrap, error, rateLimited } from '../_lib/http.js';+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';+import { limits, clientIp } from '../_lib/rate-limit.js';+import { sql } from '../_lib/db.js';++const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;+const CHAT_ID_RE = /^-?\d{1,20}$|^@[A-Za-z0-9_]{3,32}$/;++async function resolveUserId(req) {+ const session = await getSessionUser(req);+ if (session) return session.id;+ const bearer = await authenticateBearer(extractBearer(req));+ if (bearer) return bearer.userId;+ return null;+}++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'POST,OPTIONS', origins: '*' })) return;+ if (!method(req, res, ['POST'])) return;++ const rl = await limits.oracleTelegramTestIp(clientIp(req));+ if (!rl.success) return rateLimited(res, rl);++ const userId = await resolveUserId(req);+ if (!userId) return error(res, 401, 'unauthorized', 'sign in to send a test alert');++ const body = await readJson(req).catch(() => null);+ const agentId = (body?.agent_id || '').trim();+ const chatId = (body?.chat_id || '').trim();++ if (!UUID_RE.test(agentId)) return error(res, 400, 'validation_error', 'invalid agent_id');+ if (!CHAT_ID_RE.test(chatId)) return error(res, 400, 'validation_error', 'chat_id must be a numeric ID or @handle');++ // Verify ownership.+ const [agent] = await sql`+ select name from agent_identities+ where id = ${agentId} and user_id = ${userId} and deleted_at is null+ limit 1+ `.catch(() => []);+ if (!agent) return error(res, 403, 'forbidden', 'you do not own this agent');++ const token = process.env.TELEGRAM_BOT_TOKEN;+ if (!token) return error(res, 503, 'not_configured', 'Telegram bot is not configured on this deployment');++ const agentName = agent.name || 'Your agent';+ const text = [+ `🔮 <b>Oracle alerts are working</b>`,+ ``,+ `<b>${agentName}</b> will send signals here when a coin crosses your conviction threshold.`,+ ``,+ `<i>This is a test message from <a href="https://three.ws/oracle">three.ws Oracle</a>.</i>`,+ ].join('\n');++ const ctrl = new AbortController();+ const timer = setTimeout(() => ctrl.abort(), 5000);+ let tgOk = false;+ let tgErr = null;+ try {+ const r = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({+ chat_id: chatId,+ text,+ parse_mode: 'HTML',+ disable_web_page_preview: true,+ }),+ signal: ctrl.signal,+ });+ const result = await r.json().catch(() => null);+ tgOk = result?.ok === true;+ if (!tgOk) tgErr = result?.description || 'Telegram rejected the message';+ } catch (e) {+ tgErr = e?.name === 'AbortError' ? 'Telegram timed out' : (e?.message || 'network error');+ } finally {+ clearTimeout(timer);+ }++ if (!tgOk) {+ return json(res, 200, {+ ok: false,+ error: tgErr || 'could not deliver test message',+ hint: 'Make sure you started a chat with @three_ws_bot and sent /start first.',+ });+ }++ return json(res, 200, { ok: true, chat_id: chatId });+});diff --git a/pages/strategy-lab.html b/pages/strategy-lab.htmlindex 828941b81..8f08f9142 100644--- a/pages/strategy-lab.html+++ b/pages/strategy-lab.html@@ -140,6 +140,8 @@.dot-watch { background: #94a3b8; }.dot-avoid { background: var(--sl-red); }</style>++ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Strategy Lab","description":"Build DCA and subscription strategies that trade on-chain on your behalf.","url":"https://three.ws/strategy-lab","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script></head><body><header><div id="nav-container"></div></header>diff --git a/public/sitemap/index.html b/public/sitemap/index.htmlindex eb8290e2d..80a43da81 100644--- a/public/sitemap/index.html+++ b/public/sitemap/index.html@@ -56,6 +56,20 @@.sm-brand img { width: 24px; height: 24px; border-radius: 5px; }.sm-brand:hover { text-decoration: none; }</style>++ <meta property="og:type" content="website">+ <meta property="og:site_name" content="three.ws">+ <meta property="og:title" content="Sitemap · three.ws">+ <meta property="og:description" content="Human-readable index of every page on three.ws.">+ <meta property="og:url" content="https://three.ws/sitemap">+ <meta property="og:image" content="https://three.ws/og-image.png">+ <meta property="og:image:width" content="1200">+ <meta property="og:image:height" content="630">+ <meta name="twitter:card" content="summary_large_image">+ <meta name="twitter:title" content="Sitemap · three.ws">+ <meta name="twitter:description" content="Human-readable index of every page on three.ws.">+ <meta name="twitter:image" content="https://three.ws/og-image.png">+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Sitemap","description":"Human-readable index of every page on three.ws.","url":"https://three.ws/sitemap","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script></head><body><header class="sm-topbar">diff --git a/src/oracle.js b/src/oracle.jsindex 26de7e23a..e24826e86 100644--- a/src/oracle.js+++ b/src/oracle.js@@ -1040,7 +1040,11 @@ function renderArmForm() {</div><div class="field" style="margin-top:12px"><label>Personal Telegram alerts <span class="chip sm" style="background:rgba(139,92,246,.15);color:#c084fc;border-color:rgba(139,92,246,.35)">optional</span></label>- <input id="agTelegram" type="text" placeholder="Your chat ID or @channel" autocomplete="off" style="font-size:12px;font-family:var(--mono,monospace)">+ <div style="display:flex;gap:6px;align-items:center">+ <input id="agTelegram" type="text" placeholder="Your chat ID or @channel" autocomplete="off" style="font-size:12px;font-family:var(--mono,monospace);flex:1;min-width:0">+ <button id="agTgTest" class="btn sm" style="white-space:nowrap;flex-shrink:0" type="button">Send test</button>+ </div>+ <div id="agTgNote" style="display:none;margin-top:5px;font-size:11.5px;line-height:1.4"></div><div class="field-hint">Chat <a href="https://t.me/three_ws_bot" target="_blank" rel="noopener">@three_ws_bot</a> on Telegram and send <code>/start</code> to get your chat ID. You'll receive a signal whenever a coin crosses your threshold.</div></div><button class="btn primary" id="agSave" style="margin-top:8px">Save configuration</button>@@ -1059,6 +1063,7 @@ function renderArmForm() {$('#agCats').addEventListener('click', (e) => { const b = e.target.closest('.cchip'); if (b) b.classList.toggle('on'); });$('#agSel').addEventListener('change', () => loadWatch($('#agSel').value));$('#agSave').addEventListener('click', saveWatch);+ $('#agTgTest').addEventListener('click', sendTelegramTest);state.agentId = state.agents[0].id;loadWatch(state.agentId);@@ -1134,6 +1139,34 @@ async function saveWatch() {}}+async function sendTelegramTest() {+ const chatId = ($('#agTelegram').value || '').trim();+ const note = $('#agTgNote');+ if (!chatId) {+ note.style.display = 'block';+ note.style.color = 'var(--warn, #fbbf24)';+ note.textContent = 'Enter your Telegram chat ID or @channel first.';+ return;+ }+ const btn = $('#agTgTest');+ btn.disabled = true; btn.textContent = 'Sending…';+ note.style.display = 'none';+ const { ok, data } = await api('/api/oracle/test-alert', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ agent_id: state.agentId, chat_id: chatId }),+ });+ btn.disabled = false; btn.textContent = 'Send test';+ note.style.display = 'block';+ if (ok && data?.ok) {+ note.style.color = 'var(--green, #34d399)';+ note.textContent = '✓ Test message delivered. Check Telegram.';+ } else {+ note.style.color = 'var(--warn, #fbbf24)';+ note.textContent = (data?.error || 'Delivery failed.') + (data?.hint ? ' ' + data.hint : '');+ }+}+async function loadActions(agentId) {const body = $('#actionsBody');const { ok, data } = await api(`/api/oracle/watch?agent_id=${encodeURIComponent(agentId)}&network=${NETWORK}`);diff --git a/vercel.json b/vercel.jsonindex 1daaf011a..a1f715d00 100644--- a/vercel.json+++ b/vercel.json@@ -211,6 +211,10 @@"includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}","maxDuration": 15},+ "api/oracle/test-alert.js": {+ "includeFiles": "{examples/skills/**,data/pages.json,data/_generated/**,sdk/src/sas-config.json}",+ "maxDuration": 10+ },"api/copy/executions.js": {"includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}","maxDuration": 30@@ -1908,6 +1912,10 @@"src": "/api/oracle/stats","dest": "/api/oracle/stats.js"},+ {+ "src": "/api/oracle/test-alert",+ "dest": "/api/oracle/test-alert.js"+ },{"src": "/api/copy/executions","dest": "/api/copy/executions.js"