Site assistant (Marty 2026-11-15): chat widget in the ViralAdBlitz look on every page, CANNED + FACTS from this repo's code (Boost $5/500 views, 10% x 5 + 50% company, 20 places, 30-day delivery, ad limits, verified views), retrieval over the shared network knowledge base on the hub (netkb.js publishes this site's entries and reads the others', home entries boosted), OpenRouter deepseek-v4-flash with reasoning off, account problems hand off to network support. kb.json is a MySQL document. qa/chatbot.test.mjs 195 pass, smoke 198/198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 12:40:33 -06:00
parent 56316c0139
commit d6e36a65bc
24 changed files with 950 additions and 3 deletions
+8 -1
View File
@@ -127,7 +127,7 @@ const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA,
VISIT_SECONDS: '2', VISITS_PER_IP_DAY: '2', LINK_PROBE: '0', NETWORK_LOOKUP_URL: 'http://127.0.0.1:' + LOOKUP_PORT + '/api/network/member',
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', NETWORK_SITES_HUB: '0',
CONTRACT_ADDRESS: SHOP, CHAIN_RPC: 'http://127.0.0.1:' + CHAIN_PORT, KEEPER_KEY: KEEPER_PK, SHOP_START_BLOCK: '1', SHOP_CONFIRMATIONS: '0', SHOP_POLL_MS: '200', EXPLORER: 'https://explorer.invalid',
HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'viraladblitz', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
HUB_ENABLED: '1', NETKB: '0', HUB_URL: 'http://127.0.0.1:' + HUB_PORT, HUB_SECRET, HUB_SITE: 'viraladblitz', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
LS_TRACK_URL: 'http://127.0.0.1:' + LS_PORT, LS_SWEEP_FIRST_MS: '300', LS_SWEEP_MS: '300', LS_RETRY_MS: '300', LS_CACHE_MS: '100',
TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TG_PORT });
process.on('exit', () => { try { srv && srv.kill(); } catch (e) {} });
@@ -208,6 +208,13 @@ async function main() {
ok(/script-src[^;]*https:\/\/linkspin\.app/.test(r.headers.get('content-security-policy') || ''), 'CSP admits linkspin.app (network zones)');
r = await anon.req('/nobody-at-all'); ok(r.status === 404 && /Back to the wire/.test(await r.text()), 'a username the hub does not know: 404');
r = await anon.req('/api/my'); ok(r.status === 401, '/api/my needs sign-in');
// the site assistant (2026-11-15): widget on every page, canned answers without AI, admin KB behind the token
ok(/<script src="\/assets\/chat\.js\?v=\d+" defer><\/script>/.test(home) && (await anon.req('/assets/chat.js')).status === 200 && (await anon.req('/assets/chat.css')).status === 200, 'chat widget on the page, its script and styles served');
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'What is a Boost?' }) }); const cj = await cr.json();
ok(cr.status === 200 && cj.canned && /\$5/.test(cj.reply) && /500/.test(cj.reply) && /A Boost buys advertising, not income\./.test(cj.reply), 'chat: canned Boost answer', cj); }
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'my boost did not show up' }) }); const cj = await cr.json();
ok(cj.handoff === true && /^https:\/\/instantadpay\.com\/support\?from=viraladblitz/.test(cj.support || ''), 'chat: account problem hands off to network support', cj); }
ok((await anon.req('/api/admin/kb')).status === 401, 'admin KB needs the token');
console.log('4. promo kit');
{ const kr = await anon.req('/api/promo-kit?u=smokeleader'); const k = await kr.json();