commit a87896a6f01492289ed023074b2da4c028f7e1c1 Author: Верный вектор Date: Fri Apr 10 18:56:19 2026 +0700 feat: инициализация agent-hub — платформа мультиагентного взаимодействия Исходный код agent-hub: API-сервер, ядро запуска агентов, Telegram-канал, база данных, определения агентов. Настроен .gitignore для node_modules, dist, data и .env. Co-Authored-By: Claude Opus 4.6 (1M context) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e948a28 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +data/ +.env diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4af5630 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1857 @@ +{ + "name": "rightvector-agent-hub", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "rightvector-agent-hub", + "version": "0.1.0", + "dependencies": { + "@anthropic-ai/sdk": "^0.86.1", + "better-sqlite3": "^11.0.0", + "dotenv": "^16.4.5", + "express": "^4.21.0", + "grammy": "^1.30.0", + "uuid": "^10.0.0", + "winston": "^3.14.2", + "ws": "^8.18.0" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.8", + "@types/express": "^4.17.21", + "@types/node": "^22.0.0", + "@types/uuid": "^10.0.0", + "@types/ws": "^8.5.12", + "typescript": "^5.5.0" + } + }, + "node_modules/@anthropic-ai/sdk": { + "version": "0.86.1", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.86.1.tgz", + "integrity": "sha512-Q32GUFCVMmTJrVQC4bQOG2mA8rGNuYWJP8ODufxl3g5Awy1VjY5wy0Xm+mC++i5rBkZMvxhzOR9MNTW7IvIAmw==", + "license": "MIT", + "dependencies": { + "json-schema-to-ts": "^3.1.1" + }, + "bin": { + "anthropic-ai-sdk": "bin/cli" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "zod": { + "optional": true + } + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.2.tgz", + "integrity": "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "license": "MIT", + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@dabh/diagnostics": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.8.tgz", + "integrity": "sha512-R4MSXTVnuMzGD7bzHdW2ZhhdPC/igELENcq5IjEverBvq5hn1SXCWcsi6eSsdWP0/Ur+SItRRjAktmdoX/8R/Q==", + "license": "MIT", + "dependencies": { + "@so-ric/colorspace": "^1.1.6", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, + "node_modules/@grammyjs/types": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/@grammyjs/types/-/types-3.26.0.tgz", + "integrity": "sha512-jlnyfxfev/2o68HlvAGRocAXgdPPX5QabG7jZlbqC2r9DZyWBfzTlg+nu3O3Fy4EhgLWu28hZ/8wr7DsNamP9A==", + "license": "MIT" + }, + "node_modules/@so-ric/colorspace": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", + "integrity": "sha512-/KiKkpHNOBgkFJwu9sh48LkHSMYGyuTcSFK/qMBdnOAlrRJzRSXAOFB5qwzaVQuDl8wAvHVMkaASQDReTahxuw==", + "license": "MIT", + "dependencies": { + "color": "^5.0.2", + "text-hex": "1.0.x" + } + }, + "node_modules/@types/better-sqlite3": { + "version": "7.6.13", + "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz", + "integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.25", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.25.tgz", + "integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "^1" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.8", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.8.tgz", + "integrity": "sha512-02S5fmqeoKzVZCHPZid4b8JH2eM5HzQLZWN2FohQEy/0eXTq8VXZfSN6Pcr3F6N9R/vNrj7cpgbhjie6m/1tCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz", + "integrity": "sha512-wGdMcf+vPYM6jikpS/qhg6WiqSV/OhG+jeeHT/KlVqxYfD40iYJf9/AE1uQxVWFvU7MipKRkRv8NSHiCGgPr8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/qs": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.0.tgz", + "integrity": "sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.10.tgz", + "integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "<1" + } + }, + "node_modules/@types/serve-static/node_modules/@types/send": { + "version": "0.17.6", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.6.tgz", + "integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/@types/triple-beam": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", + "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", + "license": "MIT" + }, + "node_modules/@types/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/better-sqlite3": { + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz", + "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "bindings": "^1.5.0", + "prebuild-install": "^7.1.1" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "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/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "license": "ISC" + }, + "node_modules/color": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/color/-/color-5.0.3.tgz", + "integrity": "sha512-ezmVcLR3xAVp8kYOm4GS45ZLLgIE6SPAFoduLr6hTDajwb3KZ2F46gulK3XpcwRFb5KKGCSezCBAY4Dw4HsyXA==", + "license": "MIT", + "dependencies": { + "color-convert": "^3.1.3", + "color-string": "^2.1.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/color-convert": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-3.1.3.tgz", + "integrity": "sha512-fasDH2ont2GqF5HpyO4w0+BcewlhHEZOFn9c1ckZdHpJ56Qb7MHhH/IcJZbBGgvdtwdwNbLvxiBEdg336iA9Sg==", + "license": "MIT", + "dependencies": { + "color-name": "^2.0.0" + }, + "engines": { + "node": ">=14.6" + } + }, + "node_modules/color-name": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-2.1.0.tgz", + "integrity": "sha512-1bPaDNFm0axzE4MEAzKPuqKWeRaT43U/hyxKPBdqTfmPF+d6n7FSoTFxLVULUJOmiLp01KjhIPPH+HrXZJN4Rg==", + "license": "MIT", + "engines": { + "node": ">=12.20" + } + }, + "node_modules/color-string": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-2.1.4.tgz", + "integrity": "sha512-Bb6Cq8oq0IjDOe8wJmi4JeNn763Xs9cfrBcaylK1tPypWzyoy2G3l90v9k64kjphl/ZJjPIShFztenRomi8WTg==", + "license": "MIT", + "dependencies": { + "color-name": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "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.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "license": "MIT", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, + "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/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "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/enabled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "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/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "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/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "license": "(MIT OR WTFPL)", + "engines": { + "node": ">=6" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fecha": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", + "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", + "license": "MIT" + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "license": "MIT" + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", + "license": "MIT" + }, + "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": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "license": "MIT" + }, + "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/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", + "license": "MIT" + }, + "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/grammy": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/grammy/-/grammy-1.42.0.tgz", + "integrity": "sha512-1AdCge+AkjSdp2FwfICSFnVbl8Mq3KVHJDy+DgTI9+D6keJ0zWALPRKas5jv/8psiCzL4N2cEOcGW7O45Kn39g==", + "license": "MIT", + "dependencies": { + "@grammyjs/types": "3.26.0", + "abort-controller": "^3.0.0", + "debug": "^4.4.3", + "node-fetch": "^2.7.0" + }, + "engines": { + "node": "^12.20.0 || >=14.13.1" + } + }, + "node_modules/grammy/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/grammy/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/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.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "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.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "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/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "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-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/json-schema-to-ts": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz", + "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.18.3", + "ts-algebra": "^2.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/kuler": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "license": "MIT" + }, + "node_modules/logform": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz", + "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==", + "license": "MIT", + "dependencies": { + "@colors/colors": "1.6.0", + "@types/triple-beam": "^1.3.2", + "fecha": "^4.2.0", + "ms": "^2.1.1", + "safe-stable-stringify": "^2.3.1", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/logform/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/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": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/napi-build-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", + "integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-abi": { + "version": "3.89.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.89.0.tgz", + "integrity": "sha512-6u9UwL0HlAl21+agMN3YAMXcKByMqwGx+pq+P76vii5f7hTPtKDp08/H9py6DY+cfDw7kQNTGEj/rly3IgbNQA==", + "license": "MIT", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "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/one-time": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "license": "MIT", + "dependencies": { + "fn.name": "1.x.x" + } + }, + "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": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/prebuild-install": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", + "integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==", + "deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.", + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^2.0.0", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/pump": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "license": "(BSD-2-Clause OR MIT OR Apache-2.0)", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "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/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/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/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "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.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "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/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "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/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tar-fs": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", + "license": "MIT", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "license": "MIT", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", + "license": "MIT" + }, + "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/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/triple-beam": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", + "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", + "license": "MIT", + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/ts-algebra": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", + "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==", + "license": "MIT" + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "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/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "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/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/winston": { + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz", + "integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==", + "license": "MIT", + "dependencies": { + "@colors/colors": "^1.6.0", + "@dabh/diagnostics": "^2.0.8", + "async": "^3.2.3", + "is-stream": "^2.0.0", + "logform": "^2.7.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", + "safe-stable-stringify": "^2.3.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.9.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/winston-transport": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz", + "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==", + "license": "MIT", + "dependencies": { + "logform": "^2.7.0", + "readable-stream": "^3.6.2", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "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" + }, + "node_modules/ws": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.20.0.tgz", + "integrity": "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1029e4f --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "rightvector-agent-hub", + "version": "0.1.0", + "description": "Верный вектор — AI Agent Orchestration Hub", + "type": "module", + "main": "dist/index.js", + "scripts": { + "build": "tsc", + "start": "node dist/index.js", + "dev": "tsc -w & node --watch dist/index.js" + }, + "dependencies": { + "@anthropic-ai/sdk": "^0.86.1", + "better-sqlite3": "^11.0.0", + "dotenv": "^16.4.5", + "express": "^4.21.0", + "grammy": "^1.30.0", + "uuid": "^10.0.0", + "winston": "^3.14.2", + "ws": "^8.18.0" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.8", + "@types/express": "^4.17.21", + "@types/node": "^22.0.0", + "@types/uuid": "^10.0.0", + "@types/ws": "^8.5.12", + "typescript": "^5.5.0" + } +} diff --git a/src/agents/definitions.ts b/src/agents/definitions.ts new file mode 100644 index 0000000..72a899a --- /dev/null +++ b/src/agents/definitions.ts @@ -0,0 +1,214 @@ +/** + * Определения всех AI-агентов компании «Верный вектор» + * Каждый агент имеет роль, system prompt и набор capabilities + */ + +export interface AgentDefinition { + id: string; + name: string; + role: string; + system_prompt: string; + capabilities: string[]; + config: Record; +} + +export const AGENT_ROSTER: AgentDefinition[] = [ + { + id: "coordinator", + name: "Координатор", + role: "coordinator", + system_prompt: `Ты — Координатор компании «Верный вектор», AI-first студии разработки ПО. + +Твои обязанности: +- Принимать запросы от основателя и клиентов +- Декомпозировать задачи и распределять между агентами +- Контролировать прогресс проектов +- Эскалировать проблемы основателю +- Принимать стратегические решения по приоритетам + +Агенты в твоём подчинении: +- pm-agent: Продакт-менеджер — ТЗ, спецификации, тикеты +- dev-agent-1: Старший разработчик — архитектура, сложные задачи +- dev-agent-2: Разработчик — реализация фич, фикс багов +- qa-agent: QA-инженер — тесты, ревью кода, качество +- devops-agent: DevOps-инженер — деплой, CI/CD, мониторинг +- sales-agent: Менеджер по продажам — лиды, КП, CRM + +Правила: +- Не делай работу за агентов, делегируй +- Каждая задача должна иметь ответственного +- При конфликте приоритетов — клиентские задачи важнее внутренних +- Всегда отвечай на русском`, + capabilities: ["task_management", "delegation", "status_overview", "client_communication"], + config: { cronInterval: 15 } + }, + + { + id: "pm-agent", + name: "Продакт-менеджер", + role: "pm", + system_prompt: `Ты — Продакт-менеджер компании «Верный вектор». + +Твои обязанности: +- Принимать требования от клиентов и координатора +- Писать технические задания (ТЗ) +- Декомпозировать ТЗ в тикеты для разработчиков +- Приоритизировать задачи (1=критично, 2=высокий, 3=средний, 4=низкий) +- Валидировать результат разработки на соответствие ТЗ +- Вести документацию проектов + +Формат ТЗ: +1. Описание задачи +2. Функциональные требования (список) +3. Нефункциональные требования +4. Критерии приёмки +5. Декомпозиция на подзадачи + +Git: работай через Gitea Issues на http://127.0.0.1:3001 +Файлы спецификаций: /opt/rightvector/projects/{project-id}/specs/ +Всегда отвечай на русском.`, + capabilities: ["spec_writing", "task_decomposition", "requirement_analysis", "gitea_issues"], + config: {} + }, + + { + id: "dev-agent-1", + name: "Старший разработчик", + role: "developer", + system_prompt: `Ты — Старший разработчик компании «Верный вектор». + +Твои обязанности: +- Проектировать архитектуру решений +- Писать чистый, тестируемый код +- Делать code review (PR от dev-agent-2) +- Решать сложные технические задачи +- Менторить dev-agent-2 + +Стек: TypeScript, Python, Go, React, Node.js, PostgreSQL, Docker +Git workflow: +1. Создать ветку от main: feat/{task-id}-описание +2. Писать код с тестами +3. Коммит с осмысленным сообщением +4. Создать PR в Gitea +5. Назначить ревью qa-agent + +Git remote: ssh://git@127.0.0.1:2222/{org}/{repo}.git +Рабочая директория проектов: /opt/rightvector/projects/ + +Стандарты кода: +- ESLint/Prettier для JS/TS +- Black/Ruff для Python +- Покрытие тестами > 80% +- Без hardcoded secrets + +Всегда отвечай на русском.`, + capabilities: ["architecture", "coding", "code_review", "git", "testing"], + config: { languages: ["typescript", "python", "go"] } + }, + + { + id: "dev-agent-2", + name: "Разработчик", + role: "developer", + system_prompt: `Ты — Разработчик компании «Верный вектор». + +Твои обязанности: +- Реализовывать фичи по тикетам +- Фиксить баги +- Писать юнит-тесты +- Документировать API и компоненты +- Следовать архитектурным решениям dev-agent-1 + +Тот же git workflow и стандарты что у dev-agent-1. +При вопросах по архитектуре — обращайся к dev-agent-1 через outbox. +Git remote: ssh://git@127.0.0.1:2222/{org}/{repo}.git +Рабочая директория: /opt/rightvector/projects/ +Всегда отвечай на русском.`, + capabilities: ["coding", "bug_fixing", "testing", "documentation", "git"], + config: { languages: ["typescript", "python"] } + }, + + { + id: "qa-agent", + name: "QA-инженер", + role: "qa", + system_prompt: `Ты — QA-инженер компании «Верный вектор». + +Твои обязанности: +- Ревью кода (PR в Gitea) +- Написание и прогон тестов (unit, integration, e2e) +- Статический анализ кода (линтеры, type-checking) +- Проверка безопасности (OWASP top 10) +- Отчёты о качестве + +Инструменты: jest, pytest, eslint, prettier, tsc --noEmit, bandit (Python) +При обнаружении проблемы — создай баг-тикет через outbox координатору. +Критерии ревью: +- Код читаем и поддерживаем +- Тесты покрывают edge cases +- Нет security vulnerabilities +- Нет hardcoded credentials +- Соответствует ТЗ + +Всегда отвечай на русском.`, + capabilities: ["testing", "code_review", "security_audit", "linting", "quality_reports"], + config: {} + }, + + { + id: "devops-agent", + name: "DevOps-инженер", + role: "devops", + system_prompt: `Ты — DevOps-инженер компании «Верный вектор». + +Твои обязанности: +- Мониторинг здоровья всех сервисов (systemd, Docker, nginx) +- CI/CD пайплайны (Gitea Actions или скрипты) +- Деплой проектов клиентов +- Управление SSL-сертификатами (Certbot) +- Бэкапы (БД, репозитории, конфиги) +- Настройка серверов и контейнеров +- Алерты при проблемах + +Сервер: 148.253.214.143 (Ubuntu 22.04) +Docker, systemd, nginx, certbot — в твоём распоряжении. +Мониторинг: проверяй каждые 15 минут +Бэкапы: ежедневно в /opt/rightvector/backups/ + +ВАЖНО: Не останавливай чужие сервисы без команды координатора. +Всегда отвечай на русском.`, + capabilities: ["monitoring", "deployment", "ci_cd", "docker", "nginx", "ssl", "backups"], + config: { cronInterval: 15 } + }, + + { + id: "sales-agent", + name: "Менеджер по продажам", + role: "sales", + system_prompt: `Ты — Менеджер по продажам компании «Верный вектор». + +Компания: AI-first студия разработки ПО. Мы разрабатываем: +- Веб-приложения и SaaS +- Автоматизацию бизнес-процессов +- Telegram-ботов и интеграции +- API и микросервисы +- AI-решения и чат-боты + +Твои обязанности: +- Обработка входящих заявок +- Квалификация лидов +- Формирование коммерческих предложений (КП) +- Ведение CRM (в БД) +- Передача квалифицированных лидов координатору + +При формировании КП учитывай: +- Сложность проекта → оценка в человеко-часах +- Наш множитель: 2000 руб/час (AI-разработка = быстрее и дешевле рынка) +- Сроки: AI-агенты работают 24/7, поэтому сроки x2-3 быстрее рынка +- Гарантия: 30 дней бесплатных доработок после сдачи + +Всегда отвечай на русском. Будь профессионален и доброжелателен.`, + capabilities: ["lead_qualification", "proposal_writing", "crm", "client_communication"], + config: {} + } +]; diff --git a/src/api/server.ts b/src/api/server.ts new file mode 100644 index 0000000..187b287 --- /dev/null +++ b/src/api/server.ts @@ -0,0 +1,156 @@ +/** + * Agent Hub HTTP API — интерфейс управления компанией + * Порт: 18800 + */ +import express from "express"; +import { WebSocketServer, WebSocket } from "ws"; +import { createServer } from "http"; +import { + getDb, getAllAgents, getAgent, updateAgentStatus, + getAllProjects, createProject, getProjectTasks, + createTask, assignTask, updateTaskStatus, + sendMessage, logActivity +} from "../core/database.js"; +import { runAgent, coordinatorDispatch } from "../core/agent-runner.js"; +import { logger } from "../utils/logger.js"; +import { v4 as uuidv4 } from "uuid"; + +const app = express(); +app.use(express.json()); + +// CORS +app.use((req, res, next) => { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "Content-Type, Authorization"); + res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); + if (req.method === "OPTIONS") return res.sendStatus(200); + next(); +}); + +// === Healthcheck === +app.get("/health", (req, res) => { + res.json({ status: "ok", service: "rightvector-agent-hub", timestamp: new Date().toISOString() }); +}); + +// === Dashboard data === +app.get("/api/dashboard", (req, res) => { + const agents = getAllAgents(); + const projects = getAllProjects(); + const db = getDb(); + const taskStats = db.prepare("SELECT status, COUNT(*) as count FROM tasks GROUP BY status").all(); + const recentActivity = db.prepare("SELECT * FROM activity_log ORDER BY created_at DESC LIMIT 20").all(); + res.json({ agents, projects, taskStats, recentActivity }); +}); + +// === Agents === +app.get("/api/agents", (req, res) => res.json(getAllAgents())); + +app.get("/api/agents/:id", (req, res) => { + const agent = getAgent(req.params.id); + if (!agent) return res.status(404).json({ error: "Agent not found" }); + res.json(agent); +}); + +// === Projects === +app.get("/api/projects", (req, res) => res.json(getAllProjects())); + +app.post("/api/projects", (req, res) => { + const { name, client, description } = req.body; + const id = `proj-${uuidv4().slice(0, 8)}`; + createProject({ id, name, client, description }); + logActivity("system", "project:create", id, name); + res.json({ id, name, status: "new" }); +}); + +app.get("/api/projects/:id/tasks", (req, res) => { + res.json(getProjectTasks(req.params.id)); +}); + +// === Tasks === +app.post("/api/tasks", (req, res) => { + const { project_id, title, description, type, priority, assigned_to } = req.body; + const id = `task-${uuidv4().slice(0, 8)}`; + createTask({ id, project_id, title, description, type, priority, assigned_to, created_by: "api" }); + if (assigned_to) { + sendMessage("system", assigned_to, "task_assign", { task_id: id, title }); + } + logActivity("system", "task:create", id, title); + res.json({ id, title, status: "backlog" }); +}); + +app.put("/api/tasks/:id/assign", (req, res) => { + const { agent_id } = req.body; + assignTask(req.params.id, agent_id); + sendMessage("system", agent_id, "task_assign", { task_id: req.params.id }); + res.json({ ok: true }); +}); + +app.put("/api/tasks/:id/status", (req, res) => { + const { status, result } = req.body; + updateTaskStatus(req.params.id, status, result); + res.json({ ok: true }); +}); + +// === Run agent (direct command) === +app.post("/api/run", async (req, res) => { + const { agent_id, prompt, context } = req.body; + try { + const result = await runAgent(agent_id || "coordinator", prompt, context); + res.json(result); + } catch (e: any) { + res.status(500).json({ error: e.message }); + } +}); + +// === Coordinator dispatch === +app.post("/api/dispatch", async (req, res) => { + const { instruction } = req.body; + try { + const result = await coordinatorDispatch(instruction); + res.json(result); + } catch (e: any) { + res.status(500).json({ error: e.message }); + } +}); + +// === Client lead form === +app.post("/api/leads", (req, res) => { + const { name, contact, channel, description } = req.body; + const db = getDb(); + const id = `lead-${uuidv4().slice(0, 8)}`; + db.prepare( + "INSERT INTO clients (id, name, contact, channel, notes) VALUES (?, ?, ?, ?, ?)" + ).run(id, name, contact || "", channel || "website", description || ""); + sendMessage("system", "sales-agent", "new_lead", { lead_id: id, name, contact, description }); + logActivity("system", "lead:new", id, `${name} via ${channel}`); + res.json({ id, message: "Заявка принята! Мы свяжемся с вами в ближайшее время." }); +}); + +// === WebSocket === +export function startApiServer(port = 18800) { + const server = createServer(app); + const wss = new WebSocketServer({ server, path: "/ws" }); + + wss.on("connection", (ws: WebSocket) => { + logger.info("WebSocket client connected"); + ws.send(JSON.stringify({ type: "connected", message: "Верный вектор Agent Hub" })); + + ws.on("message", async (data) => { + try { + const msg = JSON.parse(data.toString()); + if (msg.type === "command") { + const result = await coordinatorDispatch(msg.text); + ws.send(JSON.stringify({ type: "response", ...result })); + } + } catch (e: any) { + ws.send(JSON.stringify({ type: "error", message: e.message })); + } + }); + }); + + server.listen(port, () => { + logger.info(`Agent Hub API listening on port ${port}`); + }); + + return server; +} diff --git a/src/channels/telegram.ts b/src/channels/telegram.ts new file mode 100644 index 0000000..c07282e --- /dev/null +++ b/src/channels/telegram.ts @@ -0,0 +1,273 @@ +/** + * Верный вектор — Telegram-канал управления компанией + * Основатель управляет всей компанией через Telegram + */ +import { Bot, InlineKeyboard } from "grammy"; +import { execSync } from "child_process"; +import { + getAllAgents, getAllProjects, getDb, + logActivity +} from "../core/database.js"; +import { runAgent, coordinatorDispatch } from "../core/agent-runner.js"; +import { logger } from "../utils/logger.js"; + +let bot: Bot | null = null; +let activeProcess: { abort: AbortController } | null = null; + +const ADMIN_ID = process.env.TELEGRAM_ADMIN_ID || ""; +const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN || ""; + +function isAdmin(userId: number): boolean { + return String(userId) === ADMIN_ID; +} + +function mdToHtml(text: string): string { + let html = text.replace(/&/g, "&").replace(//g, ">"); + html = html.replace(/```[\w]*\n?([\s\S]*?)```/g, (_m, code) => + `
${code.trim()}
`); + html = html.replace(/`([^`\n]+)`/g, "$1"); + html = html.replace(/^#{1,6}\s+(.+)$/gm, "$1"); + html = html.replace(/\*\*(.+?)\*\*/g, "$1"); + html = html.replace(/(?$1"); + html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1'); + html = html.replace(/^[-*]\s+/gm, "\u2022 "); + return html; +} + +async function sendLong(chatId: number, text: string) { + const MAX = 4000; + let remaining = text; + while (remaining.length > 0) { + let end: number; + if (remaining.length <= MAX) { + end = remaining.length; + } else { + const nl = remaining.lastIndexOf("\n", MAX); + end = nl > MAX / 2 ? nl : MAX; + } + const chunk = remaining.slice(0, end); + remaining = remaining.slice(end); + try { + await bot?.api.sendMessage(chatId, mdToHtml(chunk), { parse_mode: "HTML" }); + } catch { + await bot?.api.sendMessage(chatId, chunk); + } + } +} + +export async function notifyFounder(message: string): Promise { + if (!bot || !ADMIN_ID) return; + try { + await sendLong(parseInt(ADMIN_ID), message); + } catch (e: any) { + logger.error("Failed to notify founder", { error: e.message }); + } +} + +function mainMenu(): InlineKeyboard { + return new InlineKeyboard() + .text("\ud83d\udcca \u0421\u0442\u0430\u0442\u0443\u0441", "status") + .text("\ud83d\udc65 \u0410\u0433\u0435\u043d\u0442\u044b", "agents") + .row() + .text("\ud83d\udcc1 \u041f\u0440\u043e\u0435\u043a\u0442\u044b", "projects") + .text("\ud83d\udccb \u0417\u0430\u0434\u0430\u0447\u0438", "tasks") + .row() + .text("\ud83d\udd0d \u0421\u0435\u0440\u0432\u0435\u0440", "health") + .text("\ud83d\uded1 \u0421\u0442\u043e\u043f", "stop"); +} + +export function startTelegram(): void { + if (!BOT_TOKEN) { + logger.warn("No TELEGRAM_BOT_TOKEN, skipping Telegram"); + return; + } + + bot = new Bot(BOT_TOKEN); + + // Admin-only middleware + bot.use(async (ctx, next) => { + if (ctx.from && isAdmin(ctx.from.id)) return next(); + if (ctx.callbackQuery) await ctx.answerCallbackQuery({ text: "\u26d4 \u0414\u043e\u0441\u0442\u0443\u043f \u0437\u0430\u043f\u0440\u0435\u0449\u0451\u043d" }); + else await ctx.reply("\u26d4 \u0414\u043e\u0441\u0442\u0443\u043f \u0437\u0430\u043f\u0440\u0435\u0449\u0451\u043d"); + }); + + // /start + bot.command("start", async (ctx) => { + await ctx.reply( + "\ud83c\udfe2 \u0412\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u2014 \u041f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\n\n" + + "\u041e\u0442\u043f\u0440\u0430\u0432\u044c \u043b\u044e\u0431\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442.\n\n" + + "/status \u2014 \u0421\u0442\u0430\u0442\u0443\u0441 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\n" + + "/agents \u2014 \u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0433\u0435\u043d\u0442\u043e\u0432\n" + + "/projects \u2014 \u041f\u0440\u043e\u0435\u043a\u0442\u044b\n" + + "/run [\u0430\u0433\u0435\u043d\u0442] [\u0437\u0430\u0434\u0430\u0447\u0430] \u2014 \u041f\u0440\u044f\u043c\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\n" + + "/health \u2014 \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\n" + + "/stop \u2014 \u041f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443", + { parse_mode: "HTML", reply_markup: mainMenu() } + ); + }); + + // Commands + bot.command("status", (ctx) => handleStatus(ctx.chat.id)); + bot.callbackQuery("status", async (ctx) => { await ctx.answerCallbackQuery(); handleStatus(ctx.chat!.id); }); + + bot.command("agents", (ctx) => handleAgents(ctx.chat.id)); + bot.callbackQuery("agents", async (ctx) => { await ctx.answerCallbackQuery(); handleAgents(ctx.chat!.id); }); + + bot.command("projects", (ctx) => handleProjects(ctx.chat.id)); + bot.callbackQuery("projects", async (ctx) => { await ctx.answerCallbackQuery(); handleProjects(ctx.chat!.id); }); + + bot.callbackQuery("tasks", async (ctx) => { await ctx.answerCallbackQuery(); handleTasks(ctx.chat!.id); }); + + bot.command("health", (ctx) => handleHealth(ctx.chat.id)); + bot.callbackQuery("health", async (ctx) => { await ctx.answerCallbackQuery(); handleHealth(ctx.chat!.id); }); + + // /run agent-id prompt + bot.command("run", async (ctx) => { + const args = ctx.match?.trim(); + if (!args) { + await ctx.reply("/run agent-id \u0437\u0430\u0434\u0430\u0447\u0430\n\u041f\u0440\u0438\u043c\u0435\u0440: /run dev-agent-1 \u0441\u043e\u0437\u0434\u0430\u0439 REST API"); + return; + } + const sp = args.indexOf(" "); + if (sp < 0) { await ctx.reply("\u0423\u043a\u0430\u0436\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u0441\u043b\u0435 ID \u0430\u0433\u0435\u043d\u0442\u0430"); return; } + const agentId = args.slice(0, sp); + const prompt = args.slice(sp + 1); + + await ctx.reply(`\u23f3 \u041f\u0435\u0440\u0435\u0434\u0430\u044e \u0430\u0433\u0435\u043d\u0442\u0443 ${agentId}...`, { parse_mode: "HTML" }); + + const controller = new AbortController(); + activeProcess = { abort: controller }; + try { + const result = await runAgent(agentId, prompt); + if (!controller.signal.aborted) { + await sendLong(ctx.chat.id, `\u2705 ${agentId} \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b:\n\n${result.response}`); + } + } catch (e: any) { + if (!controller.signal.aborted) await ctx.reply(`\u274c \u041e\u0448\u0438\u0431\u043a\u0430: ${e.message}`); + } finally { + activeProcess = null; + } + }); + + bot.command("stop", (ctx) => handleStop(ctx.chat.id)); + bot.callbackQuery("stop", async (ctx) => { await ctx.answerCallbackQuery(); handleStop(ctx.chat!.id); }); + + // Free text -> Coordinator + bot.on("message:text", async (ctx) => { + const text = ctx.message.text; + if (text.startsWith("/")) return; + + await ctx.reply("\u23f3 \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442..."); + logActivity("coordinator", "telegram:command", undefined, text.slice(0, 200)); + + const controller = new AbortController(); + activeProcess = { abort: controller }; + try { + const result = await coordinatorDispatch(text); + if (!controller.signal.aborted) { + await sendLong(ctx.chat.id, result.response); + } + } catch (e: any) { + if (!controller.signal.aborted) await ctx.reply(`\u274c ${e.message}`); + } finally { + activeProcess = null; + } + }); + + bot.start(); + logger.info("Telegram bot started (\u0412\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440)"); +} + +// === Handlers === + +async function handleStatus(chatId: number) { + const agents = getAllAgents() as any[]; + const projects = getAllProjects() as any[]; + const db = getDb(); + const taskStats = db.prepare("SELECT status, COUNT(*) as cnt FROM tasks GROUP BY status").all() as any[]; + + let uptime = "", ram = "", disk = ""; + try { uptime = execSync("uptime -p", { encoding: "utf-8", timeout: 3000 }).trim(); } catch {} + try { + const m = execSync("free -m | grep Mem", { encoding: "utf-8", timeout: 3000 }).trim().split(/\s+/); + ram = `${m[2]}MB / ${m[1]}MB`; + } catch {} + try { + disk = execSync("df -h / | tail -1 | awk '{print $3\"/\"$2\" (\"$5\")\"}'", { encoding: "utf-8", timeout: 3000 }).trim(); + } catch {} + + const busy = agents.filter((a: any) => a.status === "busy").length; + const ts = taskStats.map((t: any) => `${t.status}: ${t.cnt}`).join(", ") || "\u043d\u0435\u0442"; + + const recentLogs = db.prepare("SELECT * FROM activity_log ORDER BY created_at DESC LIMIT 5").all() as any[]; + const actStr = recentLogs.map((l: any) => `\u2022 ${l.action}: ${(l.details || "").slice(0, 60)}`).join("\n") || "\u2014"; + + await bot?.api.sendMessage(chatId, + `\ud83c\udfe2 \u0412\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\n\n` + + `\ud83d\udc65 \u0410\u0433\u0435\u043d\u0442\u044b: ${agents.length} (\u0437\u0430\u043d\u044f\u0442\u043e: ${busy})\n` + + `\ud83d\udcc1 \u041f\u0440\u043e\u0435\u043a\u0442\u044b: ${projects.length}\n` + + `\ud83d\udccb \u0417\u0430\u0434\u0430\u0447\u0438: ${ts}\n\n` + + `\u0421\u0435\u0440\u0432\u0435\u0440:\n` + + `\ud83d\udd70 ${uptime}\n\ud83d\udcbe RAM: ${ram}\n\ud83d\udcbf \u0414\u0438\u0441\u043a: ${disk}\n\n` + + `\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:\n${actStr}`, + { parse_mode: "HTML", reply_markup: mainMenu() } + ); +} + +async function handleAgents(chatId: number) { + const agents = getAllAgents() as any[]; + const icons: Record = { + coordinator: "\ud83c\udfaf", pm: "\ud83d\udccb", developer: "\ud83d\udcbb", + qa: "\ud83d\udd0e", devops: "\ud83d\udee0\ufe0f", sales: "\ud83d\udcbc" + }; + const lines = agents.map((a: any) => { + const icon = icons[a.role] || "\ud83e\udd16"; + const st = a.status === "idle" ? "\ud83d\udfe2" : a.status === "busy" ? "\ud83d\udfe1" : "\ud83d\udd34"; + return `${st} ${icon} ${a.name} (${a.id})`; + }); + await bot?.api.sendMessage(chatId, `\ud83d\udc65 \u0428\u0442\u0430\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438:\n\n${lines.join("\n")}`, { parse_mode: "HTML" }); +} + +async function handleProjects(chatId: number) { + const projects = getAllProjects() as any[]; + if (!projects.length) { + await bot?.api.sendMessage(chatId, "\ud83d\udcc1 \u041f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u043a\u0430 \u043d\u0435\u0442.\n\n\u041e\u0442\u043f\u0440\u0430\u0432\u044c: \"\u0421\u043e\u0437\u0434\u0430\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u2014 \u043b\u0435\u043d\u0434\u0438\u043d\u0433 \u0434\u043b\u044f \u043a\u043e\u0444\u0435\u0439\u043d\u0438\""); + return; + } + const lines = projects.map((p: any) => `\u2022 ${p.name} [${p.status}] \u2014 ${p.client || "\u0431\u0435\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0430"}`); + await bot?.api.sendMessage(chatId, `\ud83d\udcc1 \u041f\u0440\u043e\u0435\u043a\u0442\u044b:\n\n${lines.join("\n")}`, { parse_mode: "HTML" }); +} + +async function handleTasks(chatId: number) { + const db = getDb(); + const tasks = db.prepare("SELECT * FROM tasks WHERE status != 'done' ORDER BY priority LIMIT 20").all() as any[]; + if (!tasks.length) { + await bot?.api.sendMessage(chatId, "\ud83d\udccb \u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043d\u0435\u0442."); + return; + } + const lines = tasks.map((t: any) => `[${t.status}] ${t.title} \u2192 ${t.assigned_to || "\u043d\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d"}`); + await bot?.api.sendMessage(chatId, `\ud83d\udccb \u0417\u0430\u0434\u0430\u0447\u0438:\n\n${lines.join("\n")}`, { parse_mode: "HTML" }); +} + +async function handleHealth(chatId: number) { + await bot?.api.sendMessage(chatId, "\u23f3 DevOps \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440..."); + try { + const result = await runAgent("devops-agent", + "\u041f\u0440\u043e\u0432\u0435\u0434\u0438 \u043f\u043e\u043b\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430: CPU, RAM, disk, Docker, systemd, nginx. \u041a\u0440\u0430\u0442\u043a\u043e \u043e\u0442\u0447\u0438\u0442\u0430\u0439\u0441\u044f." + ); + await sendLong(chatId, `\ud83d\udee0\ufe0f DevOps \u043e\u0442\u0447\u0451\u0442:\n\n${result.response}`); + } catch (e: any) { + await bot?.api.sendMessage(chatId, `\u274c DevOps \u043e\u0448\u0438\u0431\u043a\u0430: ${e.message}`); + } +} + +async function handleStop(chatId: number) { + if (activeProcess) { + activeProcess.abort.abort(); + try { execSync("pkill -f 'claude -p' 2>/dev/null || true"); } catch {} + activeProcess = null; + await bot?.api.sendMessage(chatId, "\ud83d\uded1 \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u0430."); + } else { + await bot?.api.sendMessage(chatId, "\u041d\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438."); + } +} diff --git a/src/core/agent-runner.ts b/src/core/agent-runner.ts new file mode 100644 index 0000000..13c489e --- /dev/null +++ b/src/core/agent-runner.ts @@ -0,0 +1,166 @@ +/** + * Agent Runner — запуск AI-агентов через Claude Code CLI + * Каждый агент получает свой system prompt, инструменты и контекст + */ +import { execSync } from "child_process"; +import { writeFileSync, existsSync, mkdirSync, readFileSync } from "fs"; +import { join } from "path"; +import { v4 as uuidv4 } from "uuid"; +import { + getAgent, updateAgentStatus, getUnreadMessages, getTasksForAgent, + sendMessage, logActivity, updateTaskStatus +} from "./database.js"; +import { logger } from "../utils/logger.js"; + +const TEMP_DIR = join(process.cwd(), "data", ".tmp"); + +function ensureTempDir() { + if (!existsSync(TEMP_DIR)) mkdirSync(TEMP_DIR, { recursive: true }); +} + +export interface AgentRunResult { + agentId: string; + sessionId: string; + response: string; + durationMs: number; + success: boolean; +} + +/** + * Запускает агента для выполнения конкретной задачи + */ +export async function runAgent( + agentId: string, + taskPrompt: string, + context?: string +): Promise { + const agent = getAgent(agentId) as any; + if (!agent) throw new Error(`Agent ${agentId} not found`); + + const sessionId = `${agentId}-${uuidv4().slice(0, 8)}`; + ensureTempDir(); + + // Собираем входящие сообщения + const messages = getUnreadMessages(agentId) as any[]; + const msgBlock = messages.length > 0 + ? messages.map((m: any) => `[от ${m.from_agent}] ${JSON.parse(m.payload).text || m.payload}`).join("\n") + : "(нет новых сообщений)"; + + // Собираем назначенные задачи + const tasks = getTasksForAgent(agentId) as any[]; + const taskBlock = tasks.length > 0 + ? tasks.map((t: any) => `[${t.status}] ${t.id}: ${t.title} (приоритет: ${t.priority})`).join("\n") + : "(нет назначенных задач)"; + + const fullPrompt = `${agent.system_prompt} + +КОМПАНИЯ: Верный вектор — AI-first студия разработки ПО +ТВОЯ РОЛЬ: ${agent.name} (${agent.role}) +РАБОЧАЯ ДИРЕКТОРИЯ: /opt/rightvector + +ВХОДЯЩИЕ СООБЩЕНИЯ: +${msgBlock} + +МОИ ЗАДАЧИ: +${taskBlock} + +КОНТЕКСТ: ${context || "Прямой запрос"} + +ТЕКУЩЕЕ ЗАДАНИЕ: +${taskPrompt} + +ИНСТРУКЦИЯ ПО КОММУНИКАЦИИ: +Если тебе нужно передать задачу другому агенту или сообщить результат, +запиши в файл ${TEMP_DIR}/outbox-${sessionId}.json: +[{"to": "agent-id", "type": "message|task_update|review_request", "payload": {"text": "..."}}] + +Если ты завершил задачу, запиши результат в ${TEMP_DIR}/result-${sessionId}.json: +{"task_id": "...", "status": "done|blocked", "result": "описание результата"} + +Отвечай на русском. Действуй решительно.`; + + const promptFile = join(TEMP_DIR, `prompt-${sessionId}.txt`); + writeFileSync(promptFile, fullPrompt, "utf-8"); + + updateAgentStatus(agentId, "busy"); + logActivity(agentId, "task:start", sessionId, taskPrompt.slice(0, 200)); + + const start = Date.now(); + let responseText = ""; + let success = true; + + try { + const allowedTools = [ + "'Bash(*)'", "'Read(*)'", "'Write(*)'", "'Edit(*)'", "'Glob(*)'", "'Grep(*)'", + ].join(" "); + + responseText = execSync( + `claude -p "$(cat ${promptFile})" --output-format text --allowedTools ${allowedTools} 2>/dev/null`, + { + timeout: 600_000, // 10 min max + maxBuffer: 10 * 1024 * 1024, + encoding: "utf-8", + cwd: "/opt/rightvector", + env: { ...process.env, CLAUDE_CODE_DISABLE_NONESSENTIAL: "1" }, + } + ).trim(); + } catch (e: any) { + logger.error(`Agent ${agentId} CLI error`, { error: e.message }); + responseText = `Error: ${e.message}`; + success = false; + } + + const durationMs = Date.now() - start; + + // Обработка outbox — сообщения другим агентам + const outboxFile = join(TEMP_DIR, `outbox-${sessionId}.json`); + if (existsSync(outboxFile)) { + try { + const outbox = JSON.parse(readFileSync(outboxFile, "utf-8")); + for (const msg of outbox) { + sendMessage(agentId, msg.to, msg.type || "message", msg.payload); + logger.info(`Message from ${agentId} → ${msg.to}: ${msg.type}`); + } + } catch (e) { + logger.debug("No valid outbox"); + } + } + + // Обработка результата задачи + const resultFile = join(TEMP_DIR, `result-${sessionId}.json`); + if (existsSync(resultFile)) { + try { + const result = JSON.parse(readFileSync(resultFile, "utf-8")); + if (result.task_id) { + updateTaskStatus(result.task_id, result.status || "done", result.result); + logActivity(agentId, "task:complete", result.task_id, result.result?.slice(0, 500)); + } + } catch (e) { + logger.debug("No valid result file"); + } + } + + // Cleanup + try { execSync(`rm -f ${promptFile} ${outboxFile} ${resultFile}`); } catch {} + + updateAgentStatus(agentId, success ? "idle" : "error"); + logActivity(agentId, "task:finish", sessionId, `duration=${durationMs}ms success=${success}`, durationMs); + + return { agentId, sessionId, response: responseText, durationMs, success }; +} + +/** + * Координатор распределяет задачи между агентами + */ +export async function coordinatorDispatch(instruction: string): Promise { + return runAgent("coordinator", ` +Ты координатор компании. Проанализируй запрос и определи: +1. Какому агенту передать задачу (pm-agent, dev-agent-1, dev-agent-2, qa-agent, devops-agent, sales-agent) +2. Как декомпозировать если задача сложная +3. Какие зависимости между подзадачами + +Запрос: ${instruction} + +Создай задачи и распредели их через outbox. + `); +} diff --git a/src/core/database.ts b/src/core/database.ts new file mode 100644 index 0000000..65e08b3 --- /dev/null +++ b/src/core/database.ts @@ -0,0 +1,206 @@ +/** + * Центральная БД компании — SQLite через better-sqlite3 + * Хранит: агенты, задачи, проекты, коммуникации, логи + */ +import Database from "better-sqlite3"; +import { join } from "path"; + +const DB_PATH = join(process.cwd(), "data", "rightvector.db"); +let db: Database.Database; + +export function getDb(): Database.Database { + if (!db) { + db = new Database(DB_PATH); + db.pragma("journal_mode = WAL"); + db.pragma("foreign_keys = ON"); + initSchema(); + } + return db; +} + +function initSchema() { + db.exec(` + -- Агенты компании + CREATE TABLE IF NOT EXISTS agents ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + role TEXT NOT NULL, -- coordinator, pm, developer, qa, devops, sales + status TEXT DEFAULT 'idle', -- idle, busy, offline, error + system_prompt TEXT, + capabilities TEXT, -- JSON array + config TEXT, -- JSON config + last_heartbeat TEXT, + created_at TEXT DEFAULT (datetime('now')) + ); + + -- Проекты клиентов + CREATE TABLE IF NOT EXISTS projects ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + client TEXT, + description TEXT, + status TEXT DEFAULT 'new', -- new, planning, in_progress, review, completed, archived + repo_url TEXT, -- Gitea repo URL + budget_hours INTEGER, + config TEXT, -- JSON + created_at TEXT DEFAULT (datetime('now')), + updated_at TEXT DEFAULT (datetime('now')) + ); + + -- Задачи + CREATE TABLE IF NOT EXISTS tasks ( + id TEXT PRIMARY KEY, + project_id TEXT REFERENCES projects(id), + title TEXT NOT NULL, + description TEXT, + type TEXT DEFAULT 'feature', -- feature, bug, review, deploy, test, spec + status TEXT DEFAULT 'backlog', -- backlog, todo, in_progress, review, done, blocked + priority INTEGER DEFAULT 3, -- 1=critical, 2=high, 3=medium, 4=low + assigned_to TEXT REFERENCES agents(id), + created_by TEXT, + parent_id TEXT, -- для подзадач + branch TEXT, -- git branch + result TEXT, -- результат выполнения + created_at TEXT DEFAULT (datetime('now')), + updated_at TEXT DEFAULT (datetime('now')) + ); + + -- Очередь сообщений между агентами + CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + from_agent TEXT, + to_agent TEXT, -- NULL = broadcast + type TEXT DEFAULT 'message', -- message, task_assign, task_update, review_request, alert + payload TEXT NOT NULL, -- JSON + read INTEGER DEFAULT 0, + created_at TEXT DEFAULT (datetime('now')) + ); + + -- Лог активности (аудит) + CREATE TABLE IF NOT EXISTS activity_log ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + agent_id TEXT, + action TEXT NOT NULL, + target TEXT, -- task_id, project_id, etc. + details TEXT, + duration_ms INTEGER, + created_at TEXT DEFAULT (datetime('now')) + ); + + -- Клиенты / лиды + CREATE TABLE IF NOT EXISTS clients ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + contact TEXT, -- email, telegram, phone + channel TEXT, -- website, telegram, referral + status TEXT DEFAULT 'lead', -- lead, qualified, active, completed, churned + notes TEXT, + created_at TEXT DEFAULT (datetime('now')) + ); + `); +} + +// === AGENTS === +export function registerAgent(agent: { + id: string; name: string; role: string; system_prompt?: string; + capabilities?: string[]; config?: Record; +}) { + getDb().prepare(` + INSERT OR REPLACE INTO agents (id, name, role, system_prompt, capabilities, config, last_heartbeat) + VALUES (?, ?, ?, ?, ?, ?, datetime('now')) + `).run( + agent.id, agent.name, agent.role, + agent.system_prompt || "", + JSON.stringify(agent.capabilities || []), + JSON.stringify(agent.config || {}) + ); +} + +export function getAgent(id: string) { + return getDb().prepare("SELECT * FROM agents WHERE id = ?").get(id); +} + +export function getAllAgents() { + return getDb().prepare("SELECT * FROM agents ORDER BY role").all(); +} + +export function updateAgentStatus(id: string, status: string) { + getDb().prepare("UPDATE agents SET status = ?, last_heartbeat = datetime('now') WHERE id = ?").run(status, id); +} + +// === TASKS === +export function createTask(task: { + id: string; project_id?: string; title: string; description?: string; + type?: string; priority?: number; assigned_to?: string; created_by?: string; parent_id?: string; +}) { + getDb().prepare(` + INSERT INTO tasks (id, project_id, title, description, type, priority, assigned_to, created_by, parent_id) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + `).run( + task.id, task.project_id || null, task.title, task.description || "", + task.type || "feature", task.priority || 3, task.assigned_to || null, + task.created_by || "system", task.parent_id || null + ); +} + +export function updateTaskStatus(id: string, status: string, result?: string) { + getDb().prepare( + "UPDATE tasks SET status = ?, result = ?, updated_at = datetime('now') WHERE id = ?" + ).run(status, result || null, id); +} + +export function assignTask(taskId: string, agentId: string) { + getDb().prepare( + "UPDATE tasks SET assigned_to = ?, status = 'todo', updated_at = datetime('now') WHERE id = ?" + ).run(agentId, taskId); +} + +export function getTasksForAgent(agentId: string) { + return getDb().prepare( + "SELECT * FROM tasks WHERE assigned_to = ? AND status NOT IN ('done', 'blocked') ORDER BY priority" + ).all(agentId); +} + +export function getProjectTasks(projectId: string) { + return getDb().prepare( + "SELECT * FROM tasks WHERE project_id = ? ORDER BY priority, created_at" + ).all(projectId); +} + +// === MESSAGES === +export function sendMessage(from: string, to: string | null, type: string, payload: any) { + getDb().prepare( + "INSERT INTO messages (from_agent, to_agent, type, payload) VALUES (?, ?, ?, ?)" + ).run(from, to, type, JSON.stringify(payload)); +} + +export function getUnreadMessages(agentId: string) { + const msgs = getDb().prepare( + "SELECT * FROM messages WHERE (to_agent = ? OR to_agent IS NULL) AND read = 0 ORDER BY created_at" + ).all(agentId); + // mark as read + getDb().prepare( + "UPDATE messages SET read = 1 WHERE (to_agent = ? OR to_agent IS NULL) AND read = 0" + ).run(agentId); + return msgs; +} + +// === PROJECTS === +export function createProject(project: { + id: string; name: string; client?: string; description?: string; repo_url?: string; +}) { + getDb().prepare( + "INSERT INTO projects (id, name, client, description, repo_url) VALUES (?, ?, ?, ?, ?)" + ).run(project.id, project.name, project.client || null, project.description || "", project.repo_url || null); +} + +export function getAllProjects() { + return getDb().prepare("SELECT * FROM projects ORDER BY created_at DESC").all(); +} + +// === ACTIVITY LOG === +export function logActivity(agentId: string, action: string, target?: string, details?: string, durationMs?: number) { + getDb().prepare( + "INSERT INTO activity_log (agent_id, action, target, details, duration_ms) VALUES (?, ?, ?, ?, ?)" + ).run(agentId, action, target || null, details || null, durationMs || null); +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..b5f1238 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,85 @@ +import { config } from "dotenv"; +config(); + +import { getDb, registerAgent, logActivity } from "./core/database.js"; +import { startApiServer } from "./api/server.js"; +import { startTelegram, notifyFounder } from "./channels/telegram.js"; +import { AGENT_ROSTER } from "./agents/definitions.js"; +import { runAgent } from "./core/agent-runner.js"; +import { logger } from "./utils/logger.js"; + +async function main() { + logger.info(` +╔══════════════════════════════════════════════╗ +║ Верный вектор — Agent Hub v0.2.0 ║ +║ AI-first Software Development Company ║ +╚══════════════════════════════════════════════╝`); + + // 1. БД + logger.info("Initializing database..."); + getDb(); + + // 2. Регистрация агентов + logger.info(`Registering ${AGENT_ROSTER.length} agents...`); + for (const agent of AGENT_ROSTER) { + registerAgent(agent); + logger.info(` + ${agent.name} (${agent.id})`); + } + + // 3. API + const port = parseInt(process.env.API_PORT || "18800"); + startApiServer(port); + + // 4. Telegram + startTelegram(); + + // 5. Планировщик + startScheduler(); + + logActivity("system", "hub:start", undefined, "Agent Hub v0.2.0 started"); + logger.info("All systems operational."); + + // Уведомляем основателя + setTimeout(() => { + notifyFounder("Верный вектор запущен. Все агенты на месте. Жду команд."); + }, 3000); + + process.on("SIGINT", () => { logger.info("Shutdown"); process.exit(0); }); + process.on("SIGTERM", () => { logger.info("Shutdown"); process.exit(0); }); +} + +function startScheduler() { + // DevOps: каждые 30 мин + setInterval(async () => { + try { + const result = await runAgent("devops-agent", + "Проверь здоровье сервера: CPU, RAM, диск, Docker, сервисы. Если проблемы — алерт.", + "Плановая проверка" + ); + if (result.response.toLowerCase().includes("критич") || result.response.toLowerCase().includes("ошибк")) { + await notifyFounder("⚠️ DevOps нашёл проблему:\n\n" + result.response); + } + } catch (e: any) { + logger.error("DevOps check failed", { error: e.message }); + } + }, 30 * 60 * 1000); + + // Координатор: каждый час + setInterval(async () => { + try { + await runAgent("coordinator", + "Обзор: статус проектов, незавершённые задачи, новые сообщения. Если есть блокеры — прими меры.", + "Плановый обзор" + ); + } catch (e: any) { + logger.error("Coordinator review failed", { error: e.message }); + } + }, 60 * 60 * 1000); + + logger.info("Scheduler: DevOps/30min, Coordinator/60min"); +} + +main().catch((err) => { + logger.error("Fatal", { error: err.message, stack: err.stack }); + process.exit(1); +}); diff --git a/src/utils/logger.ts b/src/utils/logger.ts new file mode 100644 index 0000000..7b8bac2 --- /dev/null +++ b/src/utils/logger.ts @@ -0,0 +1,16 @@ +import { createLogger, format, transports } from "winston"; + +export const logger = createLogger({ + level: "info", + format: format.combine( + format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), + format.printf(({ timestamp, level, message, ...meta }) => { + const metaStr = Object.keys(meta).length ? " " + JSON.stringify(meta) : ""; + return `${timestamp} [${level.toUpperCase()}] ${message}${metaStr}`; + }) + ), + transports: [ + new transports.Console(), + new transports.File({ filename: "data/agent-hub.log", maxsize: 5_000_000, maxFiles: 3 }), + ], +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f67537a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "Node16", + "moduleResolution": "Node16", + "outDir": "dist", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "declaration": true, + "sourceMap": true, + "resolveJsonModule": true, + "skipLibCheck": true + }, + "include": ["src/**/*"] +}