Connect the Cloudflare Worker so the brain runs even when this tab is closed. One-time setup, free tier covers everything.
๐ฏ What this solves
The browser brain only runs while a tab is open. Close Chrome โ brain stops. Re-open โ brain starts from scratch (only learns from new captures going forward).
The worker fixes this:
Runs 24/7 on Cloudflare's edge โ every minute, polls Finnhub, runs capture/resolve/train, persists state in KV.
Historical bootstrap works โ no CORS limits server-side. Finnhub's /stock/candle works from the worker even though it's blocked from your browser.
wrangler kv:namespace create BRAIN_KV
# Output gives you an `id = "..."` โ copy that
# Paste it into wrangler.toml (replace REPLACE_WITH_KV_ID_FROM_WRANGLER_OUTPUT)
4. Set secrets
wrangler secret put FINNHUB_API_KEY
# (paste your Finnhub key when prompted โ same one you use in settings.html)
wrangler secret put ADMIN_TOKEN
# (make up a random long string โ used to trigger bootstrap)
5. Deploy
wrangler deploy
# Returns a URL like:
# https://bpleone-brain-worker.YOUR-SUBDOMAIN.workers.dev
# Copy that URL.
6. Trigger the initial bootstrap
Pulls 250 days of Yahoo Finance daily bars across 71 symbols, computes rich features (RSI, ATR, momentum, range position, SMA distance), and trains the model for 5 epochs. Takes 30-90 seconds depending on Cloudflare plan (Pro = 30s CPU/req).
curl -X POST -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
https://bpleone-brain-worker.YOUR-SUBDOMAIN.workers.dev/brain/bootstrap
7. Connect this browser to the worker
Paste the worker URL below and click connect. From this moment, every page reads brain state from the worker.
๐ก Live worker status
Connected
โ
Last tick
โ
Journal (server)
โ
Model n_trained
โ
Auto-refreshes every 15 seconds. Expected worker version: pass-201.
๐ Disconnect
Falls back to browser-only brain. Worker keeps running in Cloudflare โ you just stop reading from it.