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.

Forge free-first on standard tier; sniper Telegram notify + Oracle in nav

nirholas189d3f183cde
diff --git a/api/_lib/forge-tiers.js b/api/_lib/forge-tiers.js
index 6fc131ac0..ebd4f054c 100644
--- a/api/_lib/forge-tiers.js
+++ b/api/_lib/forge-tiers.js
@@ -118,7 +118,7 @@ export const BACKENDS = Object.freeze({
// Free NVIDIA NIM lane — no vendor credit cost. This is what makes it the
// free-first draft default per platform policy.
free: true,
- blurb: 'Free TRELLIS generation on NVIDIA NIM — the default draft lane for prompts; no vendor cost. Photo input uses the standing engine.',
+ blurb: 'Free TRELLIS generation on NVIDIA NIM — the default lane for text prompts at draft and standard tiers; no vendor cost. Photo input uses the standing engine.',
}),
trellis: Object.freeze({
id: 'trellis',
@@ -259,22 +259,25 @@ export const DEFAULT_BACKEND_FOR_PATH = Object.freeze({
sketch: 'triposg',
});
-// Free-first override: when the caller asks for the draft tier without naming a
-// backend, prefer the free NVIDIA NIM lane (platform LLM/free-first policy) on
-// the paths it serves — but only when it's actually configured, so a deployment
-// without NVIDIA_API_KEY transparently keeps the standing per-path default. Paid
-// backends (Replicate/Meshy/Tripo) stay fully selectable at every tier.
-export const FREE_DEFAULT_FOR_DRAFT = Object.freeze({
- image: 'nvidia',
+// Free-first override: when the caller asks for draft or standard tier without
+// naming a backend, prefer the free NVIDIA NIM lane (platform LLM/free-first
+// policy) on the paths it serves — but only when it's actually configured, so a
+// deployment without NVIDIA_API_KEY transparently keeps the standing per-path
+// default. Paid backends (Replicate/Meshy/Tripo) stay fully selectable at every
+// tier. High tier always goes to the full-quality paid lane.
+export const FREE_DEFAULT_FOR_TIERS = Object.freeze({
+ draft: Object.freeze({ image: 'nvidia' }),
+ standard: Object.freeze({ image: 'nvidia' }),
});
// Resolve the default backend for a (path, tier) when the caller didn't name
-// one. Tier matters because the draft tier routes to the free lane first;
+// one. Draft and standard route to the free lane first when it's configured;
// `userImages` matters because a free lane that can't take user photos
// (BACKENDS[id].userImages === false) must not be defaulted for them.
function defaultBackendFor(p, tierId, userImages) {
- if (tierId === 'draft') {
- const free = FREE_DEFAULT_FOR_DRAFT[p];
+ const freeMap = FREE_DEFAULT_FOR_TIERS[tierId];
+ if (freeMap) {
+ const free = freeMap[p];
const b = free && BACKENDS[free];
if (
b &&
diff --git a/api/_lib/migrations/20260616180000_sniper_telegram_notify.sql b/api/_lib/migrations/20260616180000_sniper_telegram_notify.sql
new file mode 100644
index 000000000..71932e79e
--- /dev/null
+++ b/api/_lib/migrations/20260616180000_sniper_telegram_notify.sql
@@ -0,0 +1,5 @@
+-- Sniper: per-strategy Telegram notification chat ID.
+-- When set, buy/sell alerts fire to this chat instead of the global ops channel.
+alter table agent_sniper_strategies
+ add column if not exists telegram_chat_id text
+ check (telegram_chat_id ~ '^-?[0-9]+$');
diff --git a/api/_lib/sniper/notify.js b/api/_lib/sniper/notify.js
index 0ffd3b524..b61535740 100644
--- a/api/_lib/sniper/notify.js
+++ b/api/_lib/sniper/notify.js
@@ -12,13 +12,13 @@
const TIMEOUT_MS = 3000;
-function chatId() {
+function defaultChatId() {
return process.env.TELEGRAM_SNIPER_CHAT_ID || process.env.TELEGRAM_ALERTS_CHAT_ID || null;
}
-function send(text) {
+function send(text, chatIdOverride) {
const token = process.env.TELEGRAM_BOT_TOKEN;
- const id = chatId();
+ const id = chatIdOverride || defaultChatId();
if (!token || !id) return;
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
@@ -43,8 +43,9 @@ const icon = (r) => ({ take_profit: '✅', trailing_stop: '✅', stop_loss: '
/**
* Notify when the sniper opens a position (buy confirmed).
+ * chatId overrides the default ops channel — used for per-strategy personal alerts.
*/
-export function notifyBuy({ agentName, symbol, mint, solSpent, mode, sig }) {
+export function notifyBuy({ agentName, symbol, mint, solSpent, mode, sig, chatId }) {
const modeTag = mode === 'live' ? '' : ' [sim]';
const pumpLink = mint ? `https://pump.fun/coin/${mint}` : null;
const solLink = sig && sig !== 'SIMULATED' ? `https://solscan.io/tx/${sig}` : null;
@@ -56,13 +57,14 @@ export function notifyBuy({ agentName, symbol, mint, solSpent, mode, sig }) {
];
if (pumpLink) lines.push(`pump.fun: ${pumpLink}`);
if (solLink) lines.push(`tx: ${solLink}`);
- send(lines.join('\n'));
+ send(lines.join('\n'), chatId || null);
}
/**
* Notify when the sniper closes a position (sell confirmed or failed).
+ * chatId overrides the default ops channel — used for per-strategy personal alerts.
*/
-export function notifySell({ agentName, symbol, mint, pnlSol, pnlPct, exitReason, mode, sig }) {
+export function notifySell({ agentName, symbol, mint, pnlSol, pnlPct, exitReason, mode, sig, chatId }) {
const modeTag = mode === 'live' ? '' : ' [sim]';
const solLink = sig && sig !== 'SIMULATED' ? `https://solscan.io/tx/${sig}` : null;
const pumpLink = mint ? `https://pump.fun/coin/${mint}` : null;
@@ -74,5 +76,5 @@ export function notifySell({ agentName, symbol, mint, pnlSol, pnlPct, exitReason
];
if (pumpLink) lines.push(`pump.fun: ${pumpLink}`);
if (solLink) lines.push(`tx: ${solLink}`);
- send(lines.join('\n'));
+ send(lines.join('\n'), chatId || null);
}
diff --git a/api/forge.js b/api/forge.js
index cd350d51a..3e4a84d25 100644
--- a/api/forge.js
+++ b/api/forge.js
@@ -740,7 +740,7 @@ async function startJob(req, res) {
nvidiaTried = true;
if (await runNvidiaTextLane({ req, res, ip, prompt, aspect, tier, path })) return;
// nvidia failed → fall through to the image-intermediate TRELLIS path
- // below, which serves the same free draft prompt on Replicate.
+ // below, which gives the prompt a second chance on Replicate.
backendId = 'trellis';
}
diff --git a/api/sniper/strategy.js b/api/sniper/strategy.js
index 9acdd42f1..3b21d5bcd 100644
--- a/api/sniper/strategy.js
+++ b/api/sniper/strategy.js
@@ -89,6 +89,9 @@ const STRATEGY_SCHEMA = z.object({
max_concentration_top1: z.union([z.string(), z.number()]).nullable().optional(),
avoid_dev_dump: z.boolean().optional(),
allowed_categories: z.array(z.string()).nullable().optional(),
+ // Notifications: personal Telegram chat ID for this strategy's buy/sell alerts.
+ // Must be a numeric chat ID (positive = user/group, negative = supergroup/channel).
+ telegram_chat_id: z.string().regex(/^-?[0-9]+$/).nullable().optional(),
});
const atomicStr = (v, fallback = '0') => {
@@ -212,6 +215,7 @@ async function listStrategies(req, res, userId) {
max_concentration_top1: s.max_concentration_top1 != null ? Number(s.max_concentration_top1) : null,
avoid_dev_dump: s.avoid_dev_dump ?? true,
allowed_categories: s.allowed_categories || null,
+ telegram_chat_id: s.telegram_chat_id || null,
summary: {
open_positions: sum ? Number(sum.open_positions) : 0,
closed_positions: sum ? Number(sum.closed_positions) : 0,
@@ -260,6 +264,7 @@ async function upsertStrategy(req, res, userId) {
min_oracle_score: null,
min_quality_score: null, max_bundle_score: null, max_concentration_top1: null,
avoid_dev_dump: true, allowed_categories: null,
+ telegram_chat_id: null,
};
const next = {
@@ -291,6 +296,7 @@ async function upsertStrategy(req, res, userId) {
max_concentration_top1: 'max_concentration_top1' in p ? (p.max_concentration_top1 == null || p.max_concentration_top1 === '' ? null : Math.min(100, Math.max(0, Number(p.max_concentration_top1)))) : (cur.max_concentration_top1 != null ? Number(cur.max_concentration_top1) : null),
avoid_dev_dump: p.avoid_dev_dump ?? cur.avoid_dev_dump ?? true,
allowed_categories: 'allowed_categories' in p ? (Array.isArray(p.allowed_categories) ? p.allowed_categories.filter(Boolean) : null) : (cur.allowed_categories || null),
+ telegram_chat_id: 'telegram_chat_id' in p ? (p.telegram_chat_id || null) : (cur.telegram_chat_id || null),
};
// Mandatory stop-loss — never let the DB constraint be the first line of defense.
@@ -320,7 +326,7 @@ async function upsertStrategy(req, res, userId) {
take_profit_pct, stop_loss_pct, trailing_stop_pct, max_hold_seconds,
min_oracle_score,
min_quality_score, max_bundle_score, max_concentration_top1,
- avoid_dev_dump, allowed_categories, updated_at)
+ avoid_dev_dump, allowed_categories, telegram_chat_id, updated_at)
values
(${p.agent_id}, ${userId}, ${p.network}, ${next.enabled}, ${next.kill_switch},
${next.trigger}, ${next.buy_delay_ms}, ${next.min_claim_lamports}, ${next.max_claim_lamports}, ${next.first_claim_max_age_seconds},
@@ -331,7 +337,7 @@ async function upsertStrategy(req, res, userId) {
${next.take_profit_pct}, ${next.stop_loss_pct}, ${next.trailing_stop_pct}, ${next.max_hold_seconds},
${next.min_oracle_score},
${next.min_quality_score}, ${next.max_bundle_score}, ${next.max_concentration_top1},
- ${next.avoid_dev_dump}, ${next.allowed_categories}, now())
+ ${next.avoid_dev_dump}, ${next.allowed_categories}, ${next.telegram_chat_id}, now())
on conflict (agent_id, network) do update set
enabled = excluded.enabled,
kill_switch = excluded.kill_switch,
@@ -361,6 +367,7 @@ async function upsertStrategy(req, res, userId) {
max_concentration_top1 = excluded.max_concentration_top1,
avoid_dev_dump = excluded.avoid_dev_dump,
allowed_categories = excluded.allowed_categories,
+ telegram_chat_id = excluded.telegram_chat_id,
updated_at = now()
returning *
`;
@@ -398,6 +405,7 @@ async function upsertStrategy(req, res, userId) {
max_concentration_top1: row.max_concentration_top1 != null ? Number(row.max_concentration_top1) : null,
avoid_dev_dump: row.avoid_dev_dump ?? true,
allowed_categories: row.allowed_categories || null,
+ telegram_chat_id: row.telegram_chat_id || null,
},
});
}
diff --git a/src/dashboard-next/nav.js b/src/dashboard-next/nav.js
index 6f3d723f8..f7691e20c 100644
--- a/src/dashboard-next/nav.js
+++ b/src/dashboard-next/nav.js
@@ -38,6 +38,7 @@ export const NAV = [
{ path: '/dashboard/tokens', label: 'Tokens', icon: 'token', group: 'Monetize', tags: ['pump.fun', 'launch', 'bonding curve', 'royalties', 'trade'] },
{ path: '/dashboard/copy', label: 'Copy Trading', icon: 'live', group: 'Monetize', tags: ['copy', 'copy-trade', 'mirror', 'leader', 'follow', 'traders', 'intents', 'pump.fun', 'sniper'] },
{ path: '/dashboard/sniper', label: 'Sniper Strategies', icon: 'live', group: 'Monetize', tags: ['sniper', 'autonomous', 'strategy', 'pump.fun', 'auto-trade', 'budget', 'positions', 'pnl', 'kill-switch'] },
+ { path: '/oracle', label: 'Oracle', icon: 'oracle', group: 'Monetize', tags: ['conviction', 'score', 'tier', 'pump.fun', 'signal', 'ai', 'trade intelligence', 'wins', 'proof', 'leaderboard'], external: true },
{ path: '/dashboard/portfolio', label: 'Portfolio', icon: 'portfolio', group: 'Monetize', tags: ['nft', 'holdings', 'balances', 'wallet', 'collection', 'crypto', 'tokens', 'chart', 'send'] },
{ path: '/dashboard/landscape', label: 'Landscape', icon: 'landscape', group: 'Monetize', tags: ['competitors', 'market', 'competitive', 'intelligence', 'positioning', 'tam', 'investor'] },
{ path: '/reputation', label: 'Reputation', icon: 'star', group: 'Monetize', tags: ['reviews', 'attestations', 'onchain', 'trust', 'score'], external: true },
@@ -90,6 +91,7 @@ export const ICONS = {
skills: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="14" height="14" rx="3"/><path d="M7 7h6M7 10h4M7 13h5"/></svg>',
devhub: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="16" height="12" rx="2"/><path d="M6 7l-2 2.5L6 12M14 7l2 2.5L14 12M9 13l2-8"/></svg>',
landscape: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="8" r="2"/><circle cx="14" cy="6" r="2"/><circle cx="10" cy="14" r="2"/><path d="M8 8l2 5M12 7l-2 6"/><path d="M3 3h14v14H3z" stroke-dasharray="2 2" opacity="0.3"/></svg>',
+ oracle: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="9" r="5.5"/><path d="M6.5 9a3.5 3.5 0 007 0"/><circle cx="10" cy="9" r="1.2" fill="currentColor" stroke="none"/><path d="M10 14.5v2.5M7 16.5h6"/></svg>',
bounty: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.5"/><path d="M10 6v8M7 8l3-2 3 2M7 12l3 2 3-2"/></svg>',
gift: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="8" width="14" height="9" rx="1.5"/><path d="M3 11h14M10 8v9"/><path d="M10 8S8.5 4.5 6.5 4.5a2 2 0 000 4H10zM10 8s1.5-3.5 3.5-3.5a2 2 0 010 4H10z"/></svg>',
};
diff --git a/tests/api/forge-fallback.test.js b/tests/api/forge-fallback.test.js
index 1e7ed44f3..af277952c 100644
--- a/tests/api/forge-fallback.test.js
+++ b/tests/api/forge-fallback.test.js
@@ -1,13 +1,14 @@
/**
- * Resilience tests for the free-first fallback in api/forge.js.
+ * Resilience tests for the free-first routing and fallback in api/forge.js.
*
- * The default forge flow — type a prompt, Standard tier — routes to the paid
- * image-intermediate TRELLIS lane on Replicate. When that upstream is throttled
- * or over-quota (HTTP 429/5xx) a text prompt must NEVER dead-end: it degrades to
- * the free NVIDIA NIM lane so the user always gets a model. These tests stub the
- * provider boundaries and assert the degraded request still returns a finished
- * model with provenance reporting the lane that actually ran (backend:nvidia),
- * so the downgrade is visible rather than silent.
+ * Draft and Standard tier text prompts route DIRECTLY to the free NVIDIA NIM
+ * lane — Replicate is never called for them unless NVIDIA itself fails. When
+ * the paid Replicate lane IS invoked (e.g. by explicit backend selection or an
+ * NVIDIA outage) and returns 429/5xx, a text prompt must NEVER dead-end: it
+ * degrades to the free NVIDIA NIM lane so the default flow always returns a
+ * model. These tests stub the provider boundaries and assert requests return a
+ * finished model with provenance reporting the lane that actually ran
+ * (backend:nvidia), so the routing is visible and never silent.
*/
import { describe, it, expect, vi, beforeAll } from 'vitest';
@@ -136,7 +137,7 @@ function makeRes() {
}
describe('forge free-first fallback when the paid lane is over-quota', () => {
- it('degrades a Standard text prompt to the free NVIDIA lane instead of 429ing', async () => {
+ it('routes a Standard text prompt directly to the free NVIDIA lane (no Replicate call)', async () => {
const req = makeReq({ prompt: 'a red ceramic coffee mug', tier: 'standard', path: 'image' });
const res = makeRes();
await handler(req, res);
diff --git a/tests/api/forge-tiers.test.js b/tests/api/forge-tiers.test.js
index 04dfe2909..12f837f52 100644
--- a/tests/api/forge-tiers.test.js
+++ b/tests/api/forge-tiers.test.js
@@ -1,8 +1,8 @@
// Forge backend registry — registration + default-routing contract.
//
-// Focuses on the free NVIDIA NIM lane added for the draft tier (free-first
-// platform policy): it must be the draft default WHEN configured, must never
-// disturb the existing per-path defaults at other tiers, and must stay fully
+// Focuses on the free NVIDIA NIM lane (free-first platform policy): it is the
+// default for draft AND standard tiers on text prompts WHEN configured, must
+// never disturb other tiers or the geometry path, and must stay fully
// selectable. The provider module / live behavior is covered separately.
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
@@ -39,22 +39,24 @@ describe('forge-tiers — NVIDIA NIM backend registration', () => {
expect(backendIsConfigured('nvidia')).toBe(true);
});
- describe('draft-tier default routing', () => {
+ describe('free-tier default routing', () => {
it('keeps the Replicate TRELLIS default when NIM is unconfigured', () => {
delete process.env.NVIDIA_API_KEY;
expect(resolveBackendId({ path: 'image', tier: 'draft' })).toBe('trellis');
+ expect(resolveBackendId({ path: 'image', tier: 'standard' })).toBe('trellis');
});
- it('routes the draft tier to the free NIM lane when configured', () => {
+ it('routes draft and standard tiers to the free NIM lane when configured', () => {
process.env.NVIDIA_API_KEY = 'nvapi-test';
expect(resolveBackendId({ path: 'image', tier: 'draft' })).toBe('nvidia');
+ expect(resolveBackendId({ path: 'image', tier: 'standard' })).toBe('nvidia');
});
- it('never disturbs standard/high or the geometry path', () => {
+ it('never disturbs the high tier or the geometry path', () => {
process.env.NVIDIA_API_KEY = 'nvapi-test';
- expect(resolveBackendId({ path: 'image', tier: 'standard' })).toBe('trellis');
expect(resolveBackendId({ path: 'image', tier: 'high' })).toBe('trellis');
expect(resolveBackendId({ path: 'geometry', tier: 'draft' })).toBe('meshy');
+ expect(resolveBackendId({ path: 'geometry', tier: 'standard' })).toBe('meshy');
});
});
@@ -80,20 +82,25 @@ describe('forge-tiers — NVIDIA NIM backend registration', () => {
const draftEst = nv.estimates.image.find((e) => e.tier === 'draft');
expect(draftEst.eta_seconds).toBeGreaterThan(0);
expect(draftEst.credits).toBeNull();
- // The tier-aware default map advertises the free lane for draft.
+ // The tier-aware default map advertises the free lane for draft and standard.
expect(cat.default_backend_for_tier.draft.image).toBe('nvidia');
- expect(cat.default_backend_for_tier.standard.image).toBe('trellis');
+ expect(cat.default_backend_for_tier.standard.image).toBe('nvidia');
+ expect(cat.default_backend_for_tier.high.image).toBe('trellis');
});
// NVIDIA's hosted TRELLIS preview is text-only (rejects every user-image
// input — see tasks/nvidia-nim/probes/trellis.md). Photo submissions must
// never default onto it.
- it('routes a photo draft to the standing image backend, not the text-only free lane', () => {
+ it('routes photo submissions to the standing image backend, not the text-only free lane', () => {
process.env.NVIDIA_API_KEY = 'nvapi-test';
+ // Photo uploads at draft and standard must route to trellis (NVIDIA is text-only).
expect(resolveBackendId({ path: 'image', tier: 'draft', userImages: true })).toBe('trellis');
- // Prompt-only drafts still get the free lane.
+ expect(resolveBackendId({ path: 'image', tier: 'standard', userImages: true })).toBe('trellis');
+ // Prompt-only drafts and standard requests still get the free lane.
expect(resolveBackendId({ path: 'image', tier: 'draft', userImages: false })).toBe('nvidia');
expect(resolveBackendId({ path: 'image', tier: 'draft' })).toBe('nvidia');
+ expect(resolveBackendId({ path: 'image', tier: 'standard', userImages: false })).toBe('nvidia');
+ expect(resolveBackendId({ path: 'image', tier: 'standard' })).toBe('nvidia');
});
it('honors an explicit nvidia selection in resolution (the handler owns the rejection)', () => {