Site assistant (Marty 2026-11-15): chat widget in the 5xYourTeam draft-night look on every page, CANNED + FACTS from this repo's code (position $10 one time, 5 picks, sponsor 25% + L2-5 5% + pot 10% + company 45%, pass-up 20 places, Monday 7 PM Central draft, earned order, 3-day return, 48 h hold, 10 open picks, no contact data), retrieval over the shared network knowledge base on the hub (netkb.js, home entries boosted, another site named = its answer), reasoning off, account problems hand off to network support. chatbot.test 187, unit 62/62, smoke 160/160, iap-tank 35/35

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 12:53:16 -06:00
parent c25ae40f8b
commit 2b91ff5b8c
51 changed files with 971 additions and 4 deletions
+9 -1
View File
@@ -114,7 +114,7 @@ listen(TG_PORT, async (q, r, b) => { TG.push({ method: q.url.split('/').pop(), t
const ENV = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, ADMIN_TOKEN: ADMIN, NODE_ENV: 'development', DOCSTORE_URL: '', ALLOW_TEST_CLOCK: '1', TANK_MODE: 'stub',
NETWORK_SSO_SECRET: SSO_SECRET, IAP_URL: 'https://iap.invalid', LS_URL: 'https://ls.invalid', NETWORK_SITES_HUB: '0', DRAFT_TICK_MS: '200', DRAFT_PICK_SECONDS: '300',
CONTRACT_ADDRESS: SHOP, PRIZE_WALLET: PRIZE, 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: 'fivex', 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: 'fivex', HUB_TICK_MS: '300', HUB_DOWN_MS: '300', HUB_CACHE_MS: '200',
TG_LIVE: '1', TG_TOKEN: 'standin-token', TG_CHAT: '-100123', TG_PAY_TOPIC: '632242', TG_API: 'http://127.0.0.1:' + TG_PORT, OWNER_USERNAME: 'coachann' });
process.on('exit', () => { try { srv && srv.kill(); } catch (e) {} });
@@ -185,6 +185,14 @@ async function main() {
let r = await anon.req('/team'); ok(r.headers.get('x-frame-options') === 'DENY', '/team is never framed');
r = await anon.req('/nobody-at-all'); ok(r.status === 404 && /Back to the draft board/.test(await r.text()), 'an unknown coach name: 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, account problems hand off, admin KB behind the token
{ const home = await (await anon.req('/')).text();
ok(/<script src="\/assets\/chat\.js\?v=\d+" defer><\/script>/.test(home) && /polhunter\.com/.test(home) && (await anon.req('/assets/chat.js')).status === 200 && (await anon.req('/assets/chat.css')).status === 200, 'chat widget on the page (PolHunter embed kept), its script and styles served'); }
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'Where does the $10 go?' }) }); const cj = await cr.json();
ok(cr.status === 200 && cj.canned && /25%/.test(cj.reply) && /45%/.test(cj.reply), 'chat: canned split answer', cj); }
{ const cr = await anon.req('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'my position did not show up' }) }); const cj = await cr.json();
ok(cj.handoff === true && /^https:\/\/instantadpay\.com\/support\?from=fivex/.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');
let b = await anon.json('/api/board');
ok(b.poolSize === 29 && b.pool.length === 24 && b.pool.every(p => p.gameWei === undefined && p.surfWei === undefined), 'the pool (stub tank: 29 draftable of 35); visitors see scouting facts but no earnings', { size: b.poolSize, keys: Object.keys(b.pool[0]) });
ok(!b.pool.some(p => /lockedlarry|hasasponsor|xx_spam_xx|temp_mail_9|brandnew|twiceadopted/.test(p.username)), 'never locked, sponsored, spam, throwaway, inside the grace or adopted twice', b.pool.map(p => p.username));