task-28: Edge intelligence — browser Transformers.js triage, Nostr signing, cost preview, sentiment moods
## What was built Five components of Task #28 implemented: 1. js/edge-worker.js (new) — Transformers.js zero-shot-classification + SST-2 sentiment, lazy model loading, fast heuristic greeting bypass, warmup() pre-loader. 2. js/nostr-identity.js (new) — NIP-07 extension preferred (window.nostr), falls back to generated localStorage keypair; challenge→sign→verify flow with the /api/nostr/challenge + /api/nostr/verify endpoints; token cached in localStorage with 23 h TTL. 3. js/agents.js — setMood() export maps POSITIVE/NEGATIVE/NEUTRAL sentiment labels to Timmy face states (curious/focused/contemplative) via existing setFaceEmotion() + MOOD_ALIASES infrastructure. 4. js/ui.js — edge triage on every send: trivial/greeting → answered locally with "local ⚡ 0 sats" badge, no server round-trip; cost preview badge debounced 300 ms via GET /api/estimate, shows FREE / partial / full cost; sentiment-driven setMood() on every user message (auto-clears after 8 s). 5. js/payment.js, js/session.js — X-Nostr-Token header injected on all authenticated API calls (POST /jobs, POST /sessions, POST session/request). session.js also runs sentiment → setMood() on every session send. 6. js/main.js — initNostrIdentity('/api') + warmupEdgeWorker() called on firstInit. 7. vite.config.js — optimizeDeps.exclude @xenova/transformers to prevent Vite from pre-bundling the WASM/dynamic-import-heavy transformer library. 8. the-matrix/package.json — nostr-tools, @xenova/transformers added as deps. ## No server-side changes — all Task #28 work is frontend-only.
This commit is contained in: