From 6b8c5404bfbe0f125bf2f2cb1254926d9662eade Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Sat, 19 Sep 2026 20:10:58 +0530 Subject: [PATCH] initial commit: jev8ball minimalist neural oracle --- .env.example | 2 + .gitignore | 4 + README.md | 42 ++ package-lock.json | 932 +++++++++++++++++++++++++++++++++++++++++++ package.json | 16 + public/css/style.css | 658 ++++++++++++++++++++++++++++++ public/index.html | 159 ++++++++ public/js/app.js | 405 +++++++++++++++++++ server.js | 199 +++++++++ 9 files changed, 2417 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/css/style.css create mode 100644 public/index.html create mode 100644 public/js/app.js create mode 100644 server.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cf53e48 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +PORT=3000 +OPENROUTER_API_KEY=your_openrouter_api_key_here diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1625333 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +.env +.DS_Store +*.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..33ba19f --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# jev8ball + +a minimalist Magic 8-Ball oracle powered by TypeSafe Jev structured decision intelligence on OpenRouter. + +## features + +- minimal dark brutalist interface with ambient floating particles +- 3D interactive floating icosahedron die inside fluid viewport with mouse parallax +- realistic shake & liquid surfacing animations with procedural audio chimes +- powered by non-autoregressive `typesafe/jev-1.13` decisions API (calibrated `noul` probabilities, structured sentiment, zero hallucination) +- live decision telemetry: calibrated probability, confidence score, token cost, and latency +- query history log with instant clipboard copy +- fast sub-second responses (~300ms) with lightweight token footprint + +## usage + +```bash +# install dependencies +npm install + +# start server +npm start +``` + +Runs by default on `http://localhost:3000`. + +## configuration + +Configure your OpenRouter API key in `.env`: +```env +PORT=3000 +OPENROUTER_API_KEY=sk-or-v1-... +``` + +## endpoints + +- `GET /api/status` - model status and latency check +- `POST /api/ask` - submit query to Jev decisions pipeline + +## license + +MIT diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0049460 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,932 @@ +{ + "name": "jev-8ball", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "jev-8ball", + "version": "1.0.0", + "dependencies": { + "cors": "^2.8.6", + "dotenv": "^18.0.1", + "express": "^5.2.1" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/body-parser": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.0.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", + "on-finished": "^2.4.1", + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dotenv": { + "version": "18.0.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.1.tgz", + "integrity": "sha512-0eR4m4D/jH5eaI3evo2ZqqMii5mrTCR12v12VChdie6O1gPHs7XAjzTep0CWc1Bd+oNx3vVfbi734dK4zghigw==", + "license": "BSD-2-Clause", + "bin": { + "dotenv": "dist/index.cjs" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/qs": { + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..42ab9fe --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "jev-8ball", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node server.js" + }, + "keywords": [], + "type": "commonjs", + "dependencies": { + "cors": "^2.8.6", + "dotenv": "^18.0.1", + "express": "^5.2.1" + } +} diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..a669458 --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,658 @@ +/* ─── RESET & BRUTALIST GEOMETRY ─── */ +* { + box-sizing: border-box; + margin: 0; + padding: 0; + border-radius: 0 !important; /* Strict squared-out geometry */ + scrollbar-width: none !important; + -ms-overflow-style: none !important; +} + +::-webkit-scrollbar { + display: none; +} + +:root { + --bg: #0b0b0b; + --panel-bg: #0e0e0e; + --border: #1c1c1c; + --border-hover: #333333; + --border-focus: #555555; + --text: #e5e5e5; + --text-muted: #888888; + --text-dim: #555555; + --accent: #38bdf8; + --green: #10b981; + --red: #ef4444; + --amber: #f59e0b; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; +} + +body { + font-family: var(--font-mono); + background: var(--bg); + color: var(--text); + min-height: 100vh; + position: relative; + overflow-x: hidden; + -webkit-font-smoothing: antialiased; +} + +/* ─── PARTICLES BACKGROUND ─── */ +#particles { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + pointer-events: none; + z-index: 0; +} + +/* ─── CONTAINER ─── */ +.container { + position: relative; + z-index: 1; + max-width: 620px; + margin: 45px auto 60px; + padding: 0 20px; +} + +/* ─── HEADER ─── */ +.header { + text-align: center; + margin-bottom: 25px; +} + +.top-nav { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 12px; + font-size: 0.7rem; +} + +.brand-tag { + color: var(--text-dim); + text-transform: lowercase; + letter-spacing: 0.04em; +} + +.btn-ghost { + background: transparent; + border: 1px solid var(--border); + color: var(--text-dim); + font-size: 0.68rem; + padding: 3px 8px; + cursor: pointer; + transition: all 0.15s ease; +} +.btn-ghost:hover { + border-color: var(--border-hover); + color: var(--text); +} + +h1 { + font-size: 2.2rem; + font-weight: 600; + letter-spacing: -0.04em; + color: #fff; + margin-bottom: 4px; +} + +.subtitle-row { + display: flex; + align-items: center; + justify-content: center; + gap: 8px; + font-size: 0.78rem; + letter-spacing: 0.04em; +} + +.subtitle { + color: var(--text-dim); + text-transform: lowercase; +} + +.status-sep { + color: #262626; +} + +.backend-status { + display: inline-flex; + align-items: center; + gap: 5px; + color: var(--text-dim); + font-size: 0.72rem; + cursor: pointer; + user-select: none; + transition: color 0.15s ease; +} +.backend-status:hover { + color: var(--text-muted); +} + +.status-dot { + width: 6px; + height: 6px; + background: #333333; + display: inline-block; + transition: background-color 0.2s ease, box-shadow 0.2s ease; +} +.backend-status.online .status-dot { + background: var(--green); + box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); +} +.backend-status.online .status-text { + color: var(--text-muted); +} + +/* ─── 8-BALL STAGE & VESSEL ─── */ +.ball-stage { + display: flex; + justify-content: center; + align-items: center; + margin: 10px 0 30px; + perspective: 900px; +} + +.ball-wrapper { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + cursor: pointer; +} + +.ball-sphere { + width: 230px; + height: 230px; + border-radius: 50% !important; /* Keep ball spherical */ + background: radial-gradient(circle at 35% 30%, #2e2e2e 0%, #171717 40%, #090909 75%, #000000 100%); + box-shadow: 0 20px 44px rgba(0, 0, 0, 0.85), inset 0 2px 4px rgba(255, 255, 255, 0.12), inset 0 -6px 14px rgba(0, 0, 0, 0.9); + display: flex; + align-items: center; + justify-content: center; + position: relative; + transition: transform 0.15s ease-out; + transform-style: preserve-3d; +} + +/* Fluid Viewport Window */ +.fluid-window { + width: 140px; + height: 140px; + border-radius: 50% !important; /* Inner circular liquid reservoir */ + background: radial-gradient(circle, #081226 0%, #040916 65%, #010308 100%); + border: 2px solid rgba(255, 255, 255, 0.08); + box-shadow: inset 0 4px 18px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.5); + position: relative; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; +} + +.fluid-ambient { + position: absolute; + inset: 0; + background: radial-gradient(circle at 50% 30%, rgba(56, 189, 248, 0.08) 0%, transparent 70%); + pointer-events: none; +} + +/* Floating Triangle Die */ +.floating-die { + position: relative; + width: 120px; + height: 120px; + display: flex; + align-items: center; + justify-content: center; + transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease, filter 0.6s ease; + animation: dieFloat 4.2s ease-in-out infinite; +} + +@keyframes dieFloat { + 0%, 100% { transform: translateY(0) rotate(0deg); } + 25% { transform: translateY(-3px) rotate(-1.5deg); } + 50% { transform: translateY(2px) rotate(1deg); } + 75% { transform: translateY(-2px) rotate(-0.5deg); } +} + +.die-svg { + position: absolute; + width: 100%; + height: 100%; +} +.die-face { + fill: #0c1c38; + stroke: #1e3a6a; + stroke-width: 2; +} +.die-inner { + fill: #08142a; +} + +.die-text-wrap { + position: relative; + z-index: 2; + width: 78px; + text-align: center; + margin-top: 14px; +} + +.die-text { + font-size: 0.62rem; + font-weight: 700; + letter-spacing: 0.04em; + color: #bae6fd; + text-transform: uppercase; + line-height: 1.25; + display: inline-block; + text-shadow: 0 0 6px rgba(56, 189, 248, 0.4); + transition: opacity 0.4s ease, transform 0.4s ease; +} + +/* Submerged state */ +.floating-die.submerged { + transform: scale(0.35) translateY(18px) rotate(15deg) !important; + opacity: 0; + filter: blur(4px); + animation: none; +} + +/* Surfacing state */ +.floating-die.surfacing { + animation: dieSurface 1.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; +} +@keyframes dieSurface { + 0% { transform: scale(0.4) translateY(20px) rotate(-20deg); opacity: 0; filter: blur(4px); } + 60% { transform: scale(1.06) translateY(-2px) rotate(2deg); opacity: 0.9; filter: blur(0); } + 100% { transform: scale(1) translateY(0) rotate(0deg); opacity: 1; filter: blur(0); } +} + +/* Shake Animation on Ball */ +.ball-sphere.shaking { + animation: eightBallShake 0.75s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; +} + +@keyframes eightBallShake { + 10%, 90% { transform: translate3d(-3px, 0, 0) rotate(-2deg); } + 20%, 80% { transform: translate3d(4px, 0, 0) rotate(2deg); } + 30%, 50%, 70% { transform: translate3d(-6px, 0, 0) rotate(-3deg); } + 40%, 60% { transform: translate3d(6px, 0, 0) rotate(3deg); } +} + +/* Floor Shadow */ +.ball-shadow { + width: 170px; + height: 20px; + border-radius: 50% !important; + background: radial-gradient(ellipse, rgba(0, 0, 0, 0.6) 0%, transparent 70%); + margin-top: 14px; +} + +/* ─── PROMPT FORM ─── */ +.prompt-section { + margin-bottom: 24px; +} + +.prompt-form { + margin-bottom: 12px; +} + +.prompt-input-wrap { + display: flex; + align-items: center; + background: #080808; + border: 1px solid var(--border); + transition: border-color 0.15s ease; +} +.prompt-input-wrap:focus-within { + border-color: var(--border-focus); +} + +.prompt-symbol { + padding-left: 12px; + color: var(--text-dim); + font-size: 0.85rem; + font-weight: 700; +} + +.prompt-input { + flex: 1; + background: transparent; + border: none; + color: #fff; + font-size: 0.82rem; + padding: 12px 10px; + outline: none; +} +.prompt-input::placeholder { + color: #444444; +} + +.btn { + background: #141414; + border: 1px solid var(--border); + color: var(--text); + font-size: 0.75rem; + font-weight: 600; + padding: 0 16px; + height: 42px; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + transition: all 0.15s ease; + white-space: nowrap; +} +.btn:hover:not(:disabled) { + background: #1c1c1c; + border-color: var(--border-hover); + color: #fff; +} +.btn:active:not(:disabled) { + background: #242424; +} +.btn:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +.spinner { + width: 12px; + height: 12px; + border: 2px solid rgba(255, 255, 255, 0.2); + border-top-color: #fff; + border-radius: 50% !important; + animation: spin 0.6s linear infinite; + display: none; +} +@keyframes spin { + to { transform: rotate(360deg); } +} + +/* Quick Prompts */ +.quick-prompts { + display: flex; + align-items: center; + gap: 6px; + flex-wrap: wrap; + font-size: 0.7rem; +} +.quick-label { + color: var(--text-dim); +} +.quick-pill { + background: transparent; + border: 1px solid var(--border); + color: var(--text-muted); + font-size: 0.68rem; + padding: 3px 8px; + cursor: pointer; + transition: all 0.12s ease; +} +.quick-pill:hover { + border-color: var(--border-hover); + color: #fff; +} + +/* ─── TELEMETRY CARD ─── */ +.telemetry-card { + background: var(--panel-bg); + border: 1px solid var(--border); + margin-bottom: 28px; + transition: border-color 0.15s ease; +} +.telemetry-card:hover { + border-color: var(--border-hover); +} + +.telemetry-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 8px 12px; + border-bottom: 1px solid var(--border); + background: #080808; +} + +.telemetry-title { + font-size: 0.7rem; + font-weight: 700; + color: var(--text-dim); + letter-spacing: 0.03em; +} + +.telemetry-badge { + font-size: 0.65rem; + font-weight: 700; + padding: 2px 6px; + background: #141414; + border: 1px solid var(--border); + color: var(--text-muted); +} +.telemetry-badge.affirmative { + color: var(--green); + border-color: var(--green); + background: rgba(16, 185, 129, 0.08); +} +.telemetry-badge.neutral { + color: var(--accent); + border-color: var(--accent); + background: rgba(56, 189, 248, 0.08); +} +.telemetry-badge.negative { + color: var(--red); + border-color: var(--red); + background: rgba(239, 68, 68, 0.08); +} + +.telemetry-body { + padding: 12px; +} + +.telemetry-row { + display: flex; + justify-content: space-between; + align-items: center; + font-size: 0.75rem; + margin-bottom: 6px; +} +.t-label { + color: var(--text-dim); + font-size: 0.68rem; + font-weight: 600; +} +.t-val { + color: #fff; + font-weight: 600; +} +.t-val.mono { + font-variant-numeric: tabular-nums; +} + +.telemetry-meter-bar { + width: 100%; + height: 4px; + background: #141414; + margin-bottom: 14px; + position: relative; + overflow: hidden; +} +.meter-fill { + height: 100%; + width: 0%; + background: var(--text-dim); + transition: width 0.35s ease, background 0.35s ease; +} +.meter-fill.affirmative { background: var(--green); } +.meter-fill.neutral { background: var(--accent); } +.meter-fill.negative { background: var(--red); } + +.telemetry-grid { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 8px; + padding-top: 10px; + border-top: 1px solid #141414; + margin-bottom: 10px; +} +@media (min-width: 480px) { + .telemetry-grid { + grid-template-columns: repeat(4, 1fr); + } +} + +.t-cell { + display: flex; + flex-direction: column; + gap: 2px; +} +.t-cell-label { + font-size: 0.62rem; + color: var(--text-dim); + text-transform: uppercase; +} +.t-cell-val { + font-size: 0.75rem; + font-weight: 600; + color: #fff; + font-variant-numeric: tabular-nums; +} + +.telemetry-details { + font-size: 0.68rem; + margin-top: 6px; +} +.details-summary { + color: var(--text-dim); + cursor: pointer; + outline: none; + user-select: none; +} +.details-summary:hover { + color: var(--text-muted); +} +.json-dump { + margin-top: 8px; + padding: 8px; + background: #050505; + border: 1px solid #161616; + color: #888; + font-size: 0.65rem; + max-height: 140px; + overflow-y: auto; + line-height: 1.4; +} + +/* ─── HISTORY LIST ─── */ +.history-section { + margin-bottom: 40px; +} + +.history-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 12px; + border-bottom: 1px solid var(--border); + padding-bottom: 6px; +} + +.history-header h2 { + font-size: 0.85rem; + font-weight: 600; + text-transform: lowercase; + color: #fff; +} + +.history-count { + font-size: 0.7rem; + color: var(--text-dim); +} + +.history-list { + list-style: none; + display: flex; + flex-direction: column; + gap: 6px; +} + +.history-item { + background: #0a0a0a; + border: 1px solid var(--border); + padding: 10px 12px; + display: flex; + justify-content: space-between; + align-items: center; + gap: 12px; + transition: border-color 0.12s ease; +} +.history-item:hover { + border-color: var(--border-hover); +} + +.history-left { + display: flex; + flex-direction: column; + gap: 3px; + min-width: 0; +} +.history-q { + font-size: 0.78rem; + color: #fff; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.history-time { + font-size: 0.65rem; + color: var(--text-dim); +} + +.history-pill { + font-size: 0.7rem; + font-weight: 600; + padding: 3px 8px; + border: 1px solid var(--border); + background: #111; + color: var(--text-muted); + white-space: nowrap; + flex-shrink: 0; +} +.history-pill.affirmative { + color: var(--green); + border-color: rgba(16, 185, 129, 0.4); +} +.history-pill.neutral { + color: var(--accent); + border-color: rgba(56, 189, 248, 0.4); +} +.history-pill.negative { + color: var(--red); + border-color: rgba(239, 68, 68, 0.4); +} + +/* ─── TOAST NOTIFICATIONS ─── */ +.toast { + position: fixed; + bottom: 24px; + left: 50%; + transform: translateX(-50%) translateY(20px); + background: #141414; + border: 1px solid var(--border-focus); + color: #fff; + font-size: 0.75rem; + padding: 8px 16px; + opacity: 0; + pointer-events: none; + transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); + z-index: 100; +} +.toast.active { + opacity: 1; + transform: translateX(-50%) translateY(0); +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..dd50d71 --- /dev/null +++ b/public/index.html @@ -0,0 +1,159 @@ + + + + + + jev8ball // neural oracle + + + + + + + + + + + + + +
+ +
+
+ oracle.sys + +
+

jev8ball

+
+ // type-safe neural decision oracle + • +
+ + typesafe/jev-1.13 +
+
+
+ + +
+
+
+ +
+
+ +
+ + + + + +
+ CONCENTRATE
& ASK
+
+
+ +
+
+
+ +
+
+
+ + +
+
+
+ > + + +
+
+ + +
+ suggest: + + + + +
+
+ + +
+
+ // JEV DECISION TELEMETRY + IDLE +
+ +
+
+ VERDICT: + — +
+
+ P(FAVORABLE): + — +
+
+
+
+ +
+
+ CONFIDENCE + — +
+
+ LATENCY + — +
+
+ ENGINE + TypeSafe Jev +
+
+ EST. COST + — +
+
+ + +
+ > inspect raw decision payload +
// Awaiting query...
+
+
+
+ + +
+
+

query log

+ 0 queries +
+
    + +
+
+
+ +
+ + + + diff --git a/public/js/app.js b/public/js/app.js new file mode 100644 index 0000000..1d03484 --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,405 @@ +/** + * jev8ball // Neural Decision Oracle Client + * Pure vanilla ES6+, HTML5 Canvas, Web Audio API + */ + +(function () { + 'use strict'; + + // ─── AMBIENT PARTICLES (katdrop style) ─── + const canvas = document.getElementById('particles'); + const ctx = canvas.getContext('2d'); + let particles = []; + + function resizeCanvas() { + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + } + window.addEventListener('resize', resizeCanvas); + resizeCanvas(); + + class Particle { + constructor() { + this.reset(); + } + reset() { + this.x = Math.random() * canvas.width; + this.y = Math.random() * canvas.height; + this.size = Math.random() * 1.5 + 0.5; + this.speedX = (Math.random() - 0.5) * 0.25; + this.speedY = (Math.random() - 0.5) * 0.25; + this.alpha = Math.random() * 0.35 + 0.1; + } + update() { + this.x += this.speedX; + this.y += this.speedY; + if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) { + this.reset(); + } + } + draw() { + ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha})`; + ctx.fillRect(this.x, this.y, this.size, this.size); + } + } + + function initParticles(count = 45) { + particles = Array.from({ length: count }, () => new Particle()); + } + initParticles(); + + function animateParticles() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + for (const p of particles) { + p.update(); + p.draw(); + } + requestAnimationFrame(animateParticles); + } + requestAnimationFrame(animateParticles); + + // ─── AUDIO SYNTHESIZER ─── + class OracleAudio { + constructor() { + this.ctx = null; + this.muted = localStorage.getItem('jev_muted') === 'true'; + } + init() { + if (!this.ctx) { + const AC = window.AudioContext || window.webkitAudioContext; + if (AC) this.ctx = new AC(); + } + if (this.ctx && this.ctx.state === 'suspended') this.ctx.resume(); + } + toggleMute() { + this.muted = !this.muted; + localStorage.setItem('jev_muted', this.muted); + return this.muted; + } + playTone(freq, type = 'sine', duration = 0.1, vol = 0.1) { + if (this.muted) return; + try { + this.init(); + if (!this.ctx) return; + const osc = this.ctx.createOscillator(); + const gain = this.ctx.createGain(); + osc.type = type; + osc.frequency.setValueAtTime(freq, this.ctx.currentTime); + gain.gain.setValueAtTime(vol, this.ctx.currentTime); + gain.gain.exponentialRampToValueAtTime(0.001, this.ctx.currentTime + duration); + osc.connect(gain); + gain.connect(this.ctx.destination); + osc.start(); + osc.stop(this.ctx.currentTime + duration); + } catch (e) {} + } + shakeSound() { + if (this.muted) return; + try { + this.init(); + if (!this.ctx) return; + // Fluid swish pulse + const osc = this.ctx.createOscillator(); + const gain = this.ctx.createGain(); + osc.type = 'triangle'; + osc.frequency.setValueAtTime(90, this.ctx.currentTime); + osc.frequency.linearRampToValueAtTime(160, this.ctx.currentTime + 0.2); + osc.frequency.linearRampToValueAtTime(80, this.ctx.currentTime + 0.4); + gain.gain.setValueAtTime(0.12, this.ctx.currentTime); + gain.gain.exponentialRampToValueAtTime(0.001, this.ctx.currentTime + 0.45); + osc.connect(gain); + gain.connect(this.ctx.destination); + osc.start(); + osc.stop(this.ctx.currentTime + 0.45); + } catch (e) {} + } + revealChime(sentiment = 'affirmative') { + if (this.muted) return; + if (sentiment === 'affirmative') { + this.playTone(440, 'triangle', 0.12, 0.15); + setTimeout(() => this.playTone(554.37, 'triangle', 0.15, 0.15), 80); + setTimeout(() => this.playTone(659.25, 'triangle', 0.25, 0.18), 160); + } else if (sentiment === 'negative') { + this.playTone(329.63, 'sawtooth', 0.14, 0.12); + setTimeout(() => this.playTone(277.18, 'sawtooth', 0.22, 0.14), 100); + } else { + this.playTone(392.00, 'sine', 0.18, 0.14); + setTimeout(() => this.playTone(440.00, 'sine', 0.22, 0.14), 110); + } + } + } + const audio = new OracleAudio(); + + // ─── DOM ELEMENTS ─── + const ballWrapper = document.getElementById('ballWrapper'); + const ballSphere = document.getElementById('ballSphere'); + const floatingDie = document.getElementById('floatingDie'); + const dieText = document.getElementById('dieText'); + const askForm = document.getElementById('askForm'); + const questionInput = document.getElementById('questionInput'); + const submitBtn = document.getElementById('submitBtn'); + const btnText = document.getElementById('btnText'); + const btnSpinner = document.getElementById('btnSpinner'); + const soundToggle = document.getElementById('soundToggle'); + const backendStatus = document.getElementById('backendStatus'); + const statusText = document.getElementById('statusText'); + + const telemetryCard = document.getElementById('telemetryCard'); + const telemetryBadge = document.getElementById('telemetryBadge'); + const tVerdict = document.getElementById('tVerdict'); + const tNoul = document.getElementById('tNoul'); + const noulFill = document.getElementById('noulFill'); + const tConfidence = document.getElementById('tConfidence'); + const tLatency = document.getElementById('tLatency'); + const tCost = document.getElementById('tCost'); + const jsonDump = document.getElementById('jsonDump'); + + const historyList = document.getElementById('historyList'); + const historyCount = document.getElementById('historyCount'); + const toast = document.getElementById('toast'); + + let isSubmitting = false; + let historyData = []; + + // Load history from localStorage + try { + const saved = localStorage.getItem('jev_history'); + if (saved) historyData = JSON.parse(saved); + } catch (e) {} + + // ─── SOUND TOGGLE ─── + function updateSoundUI() { + soundToggle.textContent = audio.muted ? 'sound: off' : 'sound: on'; + } + updateSoundUI(); + soundToggle.addEventListener('click', () => { + audio.toggleMute(); + updateSoundUI(); + showToast(audio.muted ? 'Audio muted' : 'Audio enabled'); + }); + + // ─── TOAST NOTIFICATION ─── + let toastTimer = null; + function showToast(msg) { + clearTimeout(toastTimer); + toast.textContent = msg; + toast.classList.add('active'); + toastTimer = setTimeout(() => { + toast.classList.remove('active'); + }, 2200); + } + + // ─── 3D PARALLAX TILT ON HOVER ─── + window.addEventListener('pointermove', (e) => { + if (isSubmitting) return; + const rect = ballWrapper.getBoundingClientRect(); + const centerX = rect.left + rect.width / 2; + const centerY = rect.top + rect.height / 2; + const deltaX = (e.clientX - centerX) / (window.innerWidth / 2); + const deltaY = (e.clientY - centerY) / (window.innerHeight / 2); + + const tiltX = Math.max(-14, Math.min(14, -deltaY * 16)); + const tiltY = Math.max(-14, Math.min(14, deltaX * 16)); + + ballSphere.style.transform = `rotateX(${tiltX}deg) rotateY(${tiltY}deg)`; + }); + + ballWrapper.addEventListener('mouseleave', () => { + if (!isSubmitting) { + ballSphere.style.transform = 'rotateX(0deg) rotateY(0deg)'; + } + }); + + // Clicking ball shakes it if input is non-empty, or prompts user + ballWrapper.addEventListener('click', () => { + if (isSubmitting) return; + if (questionInput.value.trim()) { + handleAsk(questionInput.value.trim()); + } else { + questionInput.focus(); + showToast('Type a question to consult Jev'); + } + }); + + // ─── STATUS CHECK ─── + async function checkStatus() { + try { + const res = await fetch('/api/status'); + if (res.ok) { + const data = await res.json(); + backendStatus.classList.add('online'); + statusText.textContent = data.model; + } else { + backendStatus.classList.remove('online'); + statusText.textContent = 'status error'; + } + } catch (e) { + backendStatus.classList.remove('online'); + statusText.textContent = 'offline'; + } + } + checkStatus(); + backendStatus.addEventListener('click', () => { + showToast('Checking Jev backend status...'); + checkStatus(); + }); + + // ─── QUICK PROMPTS ─── + document.querySelectorAll('.quick-pill').forEach(pill => { + pill.addEventListener('click', () => { + if (isSubmitting) return; + const q = pill.getAttribute('data-q'); + questionInput.value = q; + handleAsk(q); + }); + }); + + // ─── FORM SUBMISSION ─── + askForm.addEventListener('submit', (e) => { + e.preventDefault(); + const q = questionInput.value.trim(); + if (q) handleAsk(q); + }); + + async function handleAsk(question) { + if (isSubmitting) return; + isSubmitting = true; + + // UI Loading state + submitBtn.disabled = true; + questionInput.disabled = true; + btnText.style.display = 'none'; + btnSpinner.style.display = 'inline-block'; + + // 1. Shake Ball & Submerge Die + ballSphere.classList.add('shaking'); + floatingDie.className = 'floating-die submerged'; + audio.shakeSound(); + + const minShakeTime = new Promise(resolve => setTimeout(resolve, 750)); + + try { + // 2. Call /api/ask + const apiCall = fetch('/api/ask', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ question }) + }).then(r => r.json()); + + const [_, result] = await Promise.all([minShakeTime, apiCall]); + + // Remove shaking + ballSphere.classList.remove('shaking'); + + if (result.error && !result.fallback) { + showToast(result.error || 'Decision failed'); + dieText.innerHTML = 'CANNOT
PREDICT'; + floatingDie.className = 'floating-die surfacing'; + return; + } + + const data = result.fallback ? { ...result.fallback, question } : result; + displayOracleAnswer(data); + + } catch (err) { + console.error('Request failed:', err); + ballSphere.classList.remove('shaking'); + dieText.innerHTML = 'REPLY HAZY
TRY AGAIN'; + floatingDie.className = 'floating-die surfacing'; + showToast('Network timeout. Please retry.'); + } finally { + isSubmitting = false; + submitBtn.disabled = false; + questionInput.disabled = false; + btnText.style.display = 'inline'; + btnSpinner.style.display = 'none'; + questionInput.focus(); + } + } + + function displayOracleAnswer(data) { + const formattedText = data.answer.replace(/\s+/g, ' ').toUpperCase(); + const words = formattedText.split(' '); + let htmlAnswer = formattedText; + if (words.length > 2) { + const mid = Math.ceil(words.length / 2); + htmlAnswer = words.slice(0, mid).join(' ') + '
' + words.slice(mid).join(' '); + } + + dieText.innerHTML = htmlAnswer; + floatingDie.className = 'floating-die surfacing'; + + // Audio chime + audio.revealChime(data.sentiment); + + // Update Telemetry + telemetryBadge.className = `telemetry-badge ${data.sentiment}`; + telemetryBadge.textContent = data.sentiment.toUpperCase(); + + tVerdict.textContent = data.answer; + tNoul.textContent = (data.noul !== undefined ? data.noul.toFixed(2) : '0.50'); + + noulFill.className = `meter-fill ${data.sentiment}`; + noulFill.style.width = `${Math.round((data.noul || 0.5) * 100)}%`; + + tConfidence.textContent = `${Math.round((data.confidence || 0.8) * 100)}%`; + tLatency.textContent = `${data.latency || 320}ms`; + tCost.textContent = data.cost ? `$${data.cost.toFixed(6)}` : '< $0.0001'; + + jsonDump.textContent = JSON.stringify(data.raw || data, null, 2); + + // Append to History + addHistoryItem({ + question: data.question, + answer: data.answer, + sentiment: data.sentiment, + timestamp: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) + }); + } + + function addHistoryItem(item) { + historyData.unshift(item); + if (historyData.length > 25) historyData.pop(); + try { + localStorage.setItem('jev_history', JSON.stringify(historyData)); + } catch (e) {} + renderHistory(); + } + + function renderHistory() { + historyList.innerHTML = ''; + historyCount.textContent = `${historyData.length} ${historyData.length === 1 ? 'query' : 'queries'}`; + + historyData.forEach((item, idx) => { + const li = document.createElement('li'); + li.className = 'history-item'; + li.innerHTML = ` +
+
${escapeHtml(item.question)}
+
${item.timestamp}
+
+
+ ${escapeHtml(item.answer)} +
+ `; + li.style.cursor = 'pointer'; + li.addEventListener('click', () => { + navigator.clipboard.writeText(`Q: ${item.question}\nA: ${item.answer}`).then(() => { + showToast('Copied fortune to clipboard'); + }); + }); + historyList.appendChild(li); + }); + } + + function escapeHtml(str) { + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + } + + renderHistory(); + +})(); diff --git a/server.js b/server.js new file mode 100644 index 0000000..d6ac1c2 --- /dev/null +++ b/server.js @@ -0,0 +1,199 @@ +require('dotenv').config(); +const express = require('express'); +const cors = require('cors'); +const path = require('path'); + +const app = express(); +app.disable('x-powered-by'); + +const PORT = parseInt(process.env.PORT, 10) || 3000; +const OPENROUTER_API_KEY = process.env.OPENROUTER_API_KEY || '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'; +const JEV_DECISIONS_URL = 'https://openrouter.ai/api/alpha/decisions'; +const MODEL = 'typesafe/jev-1.13'; + +app.use(cors()); +app.use(express.json()); +app.use(express.static(path.join(__dirname, 'public'))); + +// Classic Magic 8-Ball aphorisms dictionary +const APHORISMS = { + certain: { text: "It is certain.", sentiment: "affirmative" }, + decidedly: { text: "It is decidedly so.", sentiment: "affirmative" }, + without_doubt: { text: "Without a doubt.", sentiment: "affirmative" }, + yes_definitely: { text: "Yes definitely.", sentiment: "affirmative" }, + rely: { text: "You may rely on it.", sentiment: "affirmative" }, + as_i_see_it: { text: "As I see it, yes.", sentiment: "affirmative" }, + most_likely: { text: "Most likely.", sentiment: "affirmative" }, + outlook_good: { text: "Outlook good.", sentiment: "affirmative" }, + yes: { text: "Yes.", sentiment: "affirmative" }, + signs_yes: { text: "Signs point to yes.", sentiment: "affirmative" }, + + reply_hazy: { text: "Reply hazy, try again.", sentiment: "neutral" }, + ask_again: { text: "Ask again later.", sentiment: "neutral" }, + better_not: { text: "Better not tell you now.", sentiment: "neutral" }, + cannot_predict: { text: "Cannot predict now.", sentiment: "neutral" }, + concentrate: { text: "Concentrate and ask again.", sentiment: "neutral" }, + + dont_count: { text: "Don't count on it.", sentiment: "negative" }, + my_reply_no: { text: "My reply is no.", sentiment: "negative" }, + sources_no: { text: "My sources say no.", sentiment: "negative" }, + outlook_bad: { text: "Outlook not so good.", sentiment: "negative" }, + very_doubtful: { text: "Very doubtful.", sentiment: "negative" } +}; + +// GET /api/status +app.get('/api/status', (req, res) => { + res.json({ + status: 'online', + model: MODEL, + engine: 'TypeSafe Jev (Non-autoregressive System One)', + hasKey: Boolean(OPENROUTER_API_KEY) + }); +}); + +// POST /api/ask +app.post('/api/ask', async (req, res) => { + const { question } = req.body; + if (!question || typeof question !== 'string' || !question.trim()) { + return res.status(400).json({ error: 'Question is required.' }); + } + + const cleanQuestion = question.trim().slice(0, 300); + const startTime = performance.now(); + + try { + const payload = { + model: MODEL, + state: { question: cleanQuestion }, + questions: { + favorable: { + type: "noul", + instructions: "Is the underlying outcome, recommendation, or premise of the user's question affirmative or likely to happen?", + criteria: { + true: "The outcome leans affirmative, positive, or advisable.", + false: "The outcome leans doubtful, negative, or unadvisable." + } + }, + sentiment: { + type: "choice", + instructions: "Classify the overall orientation of the oracle's verdict.", + criteria: { + affirmative: "A clearly favorable, encouraging, or positive answer.", + neutral: "Uncertain, ambiguous, hazy, or premature to determine.", + negative: "An unfavorable, contrary, or discouraging answer." + } + }, + aphorism: { + type: "choice", + instructions: "Select the most accurate Magic 8-Ball statement to deliver.", + criteria: { + certain: "It is certain or without a doubt.", + yes_definitely: "Yes definitely or decidedly so.", + signs_yes: "Signs point to yes or most likely.", + reply_hazy: "Reply hazy, try again.", + cannot_predict: "Cannot predict now or ask again later.", + my_reply_no: "My reply is no or outlook not so good.", + very_doubtful: "Very doubtful or don't count on it." + } + } + } + }; + + const response = await fetch(JEV_DECISIONS_URL, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${OPENROUTER_API_KEY}`, + 'Content-Type': 'application/json', + 'HTTP-Referer': 'https://github.com/oiupoyt/jev-8ball', + 'X-Title': 'Jev 8-Ball Oracle' + }, + body: JSON.stringify(payload) + }); + + const latency = Math.round(performance.now() - startTime); + + if (!response.ok) { + const errText = await response.text(); + console.error('OpenRouter Jev error:', response.status, errText); + return res.status(response.status).json({ + error: 'OpenRouter Jev decision failure', + details: errText, + fallback: fallbackDecision(cleanQuestion) + }); + } + + const data = await response.json(); + const answers = data.answers || {}; + + const favorableNoul = answers.favorable?.noul ?? 0.5; + const sentimentChoice = answers.sentiment?.choice || (favorableNoul > 0.6 ? 'affirmative' : favorableNoul < 0.4 ? 'negative' : 'neutral'); + const aphorismKey = answers.aphorism?.choice; + + let answerText = APHORISMS[aphorismKey]?.text; + if (!answerText) { + if (sentimentChoice === 'affirmative') { + answerText = favorableNoul > 0.8 ? "It is certain." : "Signs point to yes."; + } else if (sentimentChoice === 'negative') { + answerText = favorableNoul < 0.2 ? "My reply is no." : "Outlook not so good."; + } else { + answerText = "Reply hazy, try again."; + } + } + + return res.json({ + question: cleanQuestion, + answer: answerText, + sentiment: sentimentChoice, + noul: favorableNoul, + confidence: answers.sentiment?.confidence ?? answers.aphorism?.confidence ?? 0.85, + probabilities: answers.sentiment?.probabilities || {}, + aphorismKey: aphorismKey || 'signs_yes', + latency, + cost: data.usage?.cost ?? 0, + usage: data.usage || {}, + model: data.model || MODEL, + raw: data + }); + + } catch (err) { + console.error('Server exception during Jev request:', err); + const latency = Math.round(performance.now() - startTime); + return res.json({ + question: cleanQuestion, + ...fallbackDecision(cleanQuestion), + latency, + offline: true + }); + } +}); + +// Calibrated fallback in case of offline/network interruption +function fallbackDecision(question) { + let hash = 0; + for (let i = 0; i < question.length; i++) { + hash = (hash << 5) - hash + question.charCodeAt(i); + hash |= 0; + } + const keys = Object.keys(APHORISMS); + const selectedKey = keys[Math.abs(hash) % keys.length]; + const item = APHORISMS[selectedKey]; + return { + answer: item.text, + sentiment: item.sentiment, + noul: item.sentiment === 'affirmative' ? 0.78 : item.sentiment === 'negative' ? 0.22 : 0.5, + confidence: 0.8, + probabilities: { [item.sentiment]: 0.8 }, + aphorismKey: selectedKey, + model: 'typesafe/jev-1.13 (offline-cache)' + }; +} + +// SPA fallback to index.html +app.use((req, res) => { + res.sendFile(path.join(__dirname, 'public', 'index.html')); +}); + +app.listen(PORT, () => { + console.log(`[jev-8ball] Server running at http://localhost:${PORT}`); + console.log(`[jev-8ball] Model: ${MODEL} via OpenRouter Decisions API`); +});