From 11db51ff80c606d114bcc3dee19c88b5ffba3941 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 04:10:28 +0000 Subject: [PATCH 1/5] build(deps): bump rollup in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the / directory: [rollup](https://github.com/rollup/rollup). Updates `rollup` from 4.21.0 to 4.22.4 - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.21.0...v4.22.4) --- updated-dependencies: - dependency-name: rollup dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- yarn.lock | 196 +++++++++++++++++++++++++++--------------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/yarn.lock b/yarn.lock index b855fcfc..fb2a0b26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -820,85 +820,85 @@ estree-walker "^2.0.2" picomatch "^2.3.1" -"@rollup/rollup-android-arm-eabi@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.0.tgz#d941173f82f9b041c61b0dc1a2a91dcd06e4b31e" - integrity sha512-WTWD8PfoSAJ+qL87lE7votj3syLavxunWhzCnx3XFxFiI/BA/r3X7MUM8dVrH8rb2r4AiO8jJsr3ZjdaftmnfA== - -"@rollup/rollup-android-arm64@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.0.tgz#7e7157c8543215245ceffc445134d9e843ba51c0" - integrity sha512-a1sR2zSK1B4eYkiZu17ZUZhmUQcKjk2/j9Me2IDjk1GHW7LB5Z35LEzj9iJch6gtUfsnvZs1ZNyDW2oZSThrkA== - -"@rollup/rollup-darwin-arm64@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.0.tgz#f0a18a4fc8dc6eb1e94a51fa2adb22876f477947" - integrity sha512-zOnKWLgDld/svhKO5PD9ozmL6roy5OQ5T4ThvdYZLpiOhEGY+dp2NwUmxK0Ld91LrbjrvtNAE0ERBwjqhZTRAA== - -"@rollup/rollup-darwin-x64@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.0.tgz#34b7867613e5cc42d2b85ddc0424228cc33b43f0" - integrity sha512-7doS8br0xAkg48SKE2QNtMSFPFUlRdw9+votl27MvT46vo44ATBmdZdGysOevNELmZlfd+NEa0UYOA8f01WSrg== - -"@rollup/rollup-linux-arm-gnueabihf@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.0.tgz#422b19ff9ae02b05d3395183d1d43b38c7c8be0b" - integrity sha512-pWJsfQjNWNGsoCq53KjMtwdJDmh/6NubwQcz52aEwLEuvx08bzcy6tOUuawAOncPnxz/3siRtd8hiQ32G1y8VA== - -"@rollup/rollup-linux-arm-musleabihf@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.0.tgz#568aa29195ef6fc57ec6ed3f518923764406a8ee" - integrity sha512-efRIANsz3UHZrnZXuEvxS9LoCOWMGD1rweciD6uJQIx2myN3a8Im1FafZBzh7zk1RJ6oKcR16dU3UPldaKd83w== - -"@rollup/rollup-linux-arm64-gnu@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.0.tgz#22309c8bcba9a73114f69165c72bc94b2fbec085" - integrity sha512-ZrPhydkTVhyeGTW94WJ8pnl1uroqVHM3j3hjdquwAcWnmivjAwOYjTEAuEDeJvGX7xv3Z9GAvrBkEzCgHq9U1w== - -"@rollup/rollup-linux-arm64-musl@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.0.tgz#c93c388af6d33f082894b8a60839d7265b2b9bc5" - integrity sha512-cfaupqd+UEFeURmqNP2eEvXqgbSox/LHOyN9/d2pSdV8xTrjdg3NgOFJCtc1vQ/jEke1qD0IejbBfxleBPHnPw== - -"@rollup/rollup-linux-powerpc64le-gnu@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.0.tgz#493c5e19e395cf3c6bd860c7139c8a903dea72b4" - integrity sha512-ZKPan1/RvAhrUylwBXC9t7B2hXdpb/ufeu22pG2psV7RN8roOfGurEghw1ySmX/CmDDHNTDDjY3lo9hRlgtaHg== - -"@rollup/rollup-linux-riscv64-gnu@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.0.tgz#a2eab4346fbe5909165ce99adb935ba30c9fb444" - integrity sha512-H1eRaCwd5E8eS8leiS+o/NqMdljkcb1d6r2h4fKSsCXQilLKArq6WS7XBLDu80Yz+nMqHVFDquwcVrQmGr28rg== - -"@rollup/rollup-linux-s390x-gnu@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.0.tgz#0bc49a79db4345d78d757bb1b05e73a1b42fa5c3" - integrity sha512-zJ4hA+3b5tu8u7L58CCSI0A9N1vkfwPhWd/puGXwtZlsB5bTkwDNW/+JCU84+3QYmKpLi+XvHdmrlwUwDA6kqw== - -"@rollup/rollup-linux-x64-gnu@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.0.tgz#4fd36a6a41f3406d8693321b13d4f9b7658dd4b9" - integrity sha512-e2hrvElFIh6kW/UNBQK/kzqMNY5mO+67YtEh9OA65RM5IJXYTWiXjX6fjIiPaqOkBthYF1EqgiZ6OXKcQsM0hg== - -"@rollup/rollup-linux-x64-musl@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.0.tgz#10ebb13bd4469cbad1a5d9b073bd27ec8a886200" - integrity sha512-1vvmgDdUSebVGXWX2lIcgRebqfQSff0hMEkLJyakQ9JQUbLDkEaMsPTLOmyccyC6IJ/l3FZuJbmrBw/u0A0uCQ== - -"@rollup/rollup-win32-arm64-msvc@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.0.tgz#2fef1a90f1402258ef915ae5a94cc91a5a1d5bfc" - integrity sha512-s5oFkZ/hFcrlAyBTONFY1TWndfyre1wOMwU+6KCpm/iatybvrRgmZVM+vCFwxmC5ZhdlgfE0N4XorsDpi7/4XQ== - -"@rollup/rollup-win32-ia32-msvc@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.0.tgz#a18ad47a95c5f264defb60acdd8c27569f816fc1" - integrity sha512-G9+TEqRnAA6nbpqyUqgTiopmnfgnMkR3kMukFBDsiyy23LZvUCpiUwjTRx6ezYCjJODXrh52rBR9oXvm+Fp5wg== - -"@rollup/rollup-win32-x64-msvc@4.21.0": - version "4.21.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.0.tgz#20c09cf44dcb082140cc7f439dd679fe4bba3375" - integrity sha512-2jsCDZwtQvRhejHLfZ1JY6w6kEuEtfF9nzYsZxzSlNVKDX+DpsDJ+Rbjkm74nvg2rdx0gwBS+IMdvwJuq3S9pQ== +"@rollup/rollup-android-arm-eabi@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz#8b613b9725e8f9479d142970b106b6ae878610d5" + integrity sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w== + +"@rollup/rollup-android-arm64@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz#654ca1049189132ff602bfcf8df14c18da1f15fb" + integrity sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA== + +"@rollup/rollup-darwin-arm64@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz#6d241d099d1518ef0c2205d96b3fa52e0fe1954b" + integrity sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q== + +"@rollup/rollup-darwin-x64@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz#42bd19d292a57ee11734c980c4650de26b457791" + integrity sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw== + +"@rollup/rollup-linux-arm-gnueabihf@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz#f23555ee3d8fe941c5c5fd458cd22b65eb1c2232" + integrity sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ== + +"@rollup/rollup-linux-arm-musleabihf@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz#f3bbd1ae2420f5539d40ac1fde2b38da67779baa" + integrity sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg== + +"@rollup/rollup-linux-arm64-gnu@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz#7abe900120113e08a1f90afb84c7c28774054d15" + integrity sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw== + +"@rollup/rollup-linux-arm64-musl@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz#9e655285c8175cd44f57d6a1e8e5dedfbba1d820" + integrity sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA== + +"@rollup/rollup-linux-powerpc64le-gnu@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz#9a79ae6c9e9d8fe83d49e2712ecf4302db5bef5e" + integrity sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg== + +"@rollup/rollup-linux-riscv64-gnu@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz#67ac70eca4ace8e2942fabca95164e8874ab8128" + integrity sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA== + +"@rollup/rollup-linux-s390x-gnu@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz#9f883a7440f51a22ed7f99e1d070bd84ea5005fc" + integrity sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q== + +"@rollup/rollup-linux-x64-gnu@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz#70116ae6c577fe367f58559e2cffb5641a1dd9d0" + integrity sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg== + +"@rollup/rollup-linux-x64-musl@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz#f473f88219feb07b0b98b53a7923be716d1d182f" + integrity sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g== + +"@rollup/rollup-win32-arm64-msvc@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz#4349482d17f5d1c58604d1c8900540d676f420e0" + integrity sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw== + +"@rollup/rollup-win32-ia32-msvc@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz#a6fc39a15db618040ec3c2a24c1e26cb5f4d7422" + integrity sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g== + +"@rollup/rollup-win32-x64-msvc@4.22.4": + version "4.22.4" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz#3dd5d53e900df2a40841882c02e56f866c04d202" + integrity sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q== "@rushstack/node-core-library@5.7.0": version "5.7.0" @@ -4570,28 +4570,28 @@ rollup-pluginutils@^2.8.1, rollup-pluginutils@^2.8.2: estree-walker "^0.6.1" rollup@^4.20.0: - version "4.21.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.21.0.tgz#28db5f5c556a5180361d35009979ccc749560b9d" - integrity sha512-vo+S/lfA2lMS7rZ2Qoubi6I5hwZwzXeUIctILZLbHI+laNtvhhOIon2S1JksA5UEDQ7l3vberd0fxK44lTYjbQ== + version "4.22.4" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.22.4.tgz#4135a6446671cd2a2453e1ad42a45d5973ec3a0f" + integrity sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A== dependencies: "@types/estree" "1.0.5" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.21.0" - "@rollup/rollup-android-arm64" "4.21.0" - "@rollup/rollup-darwin-arm64" "4.21.0" - "@rollup/rollup-darwin-x64" "4.21.0" - "@rollup/rollup-linux-arm-gnueabihf" "4.21.0" - "@rollup/rollup-linux-arm-musleabihf" "4.21.0" - "@rollup/rollup-linux-arm64-gnu" "4.21.0" - "@rollup/rollup-linux-arm64-musl" "4.21.0" - "@rollup/rollup-linux-powerpc64le-gnu" "4.21.0" - "@rollup/rollup-linux-riscv64-gnu" "4.21.0" - "@rollup/rollup-linux-s390x-gnu" "4.21.0" - "@rollup/rollup-linux-x64-gnu" "4.21.0" - "@rollup/rollup-linux-x64-musl" "4.21.0" - "@rollup/rollup-win32-arm64-msvc" "4.21.0" - "@rollup/rollup-win32-ia32-msvc" "4.21.0" - "@rollup/rollup-win32-x64-msvc" "4.21.0" + "@rollup/rollup-android-arm-eabi" "4.22.4" + "@rollup/rollup-android-arm64" "4.22.4" + "@rollup/rollup-darwin-arm64" "4.22.4" + "@rollup/rollup-darwin-x64" "4.22.4" + "@rollup/rollup-linux-arm-gnueabihf" "4.22.4" + "@rollup/rollup-linux-arm-musleabihf" "4.22.4" + "@rollup/rollup-linux-arm64-gnu" "4.22.4" + "@rollup/rollup-linux-arm64-musl" "4.22.4" + "@rollup/rollup-linux-powerpc64le-gnu" "4.22.4" + "@rollup/rollup-linux-riscv64-gnu" "4.22.4" + "@rollup/rollup-linux-s390x-gnu" "4.22.4" + "@rollup/rollup-linux-x64-gnu" "4.22.4" + "@rollup/rollup-linux-x64-musl" "4.22.4" + "@rollup/rollup-win32-arm64-msvc" "4.22.4" + "@rollup/rollup-win32-ia32-msvc" "4.22.4" + "@rollup/rollup-win32-x64-msvc" "4.22.4" fsevents "~2.3.2" run-parallel@^1.1.9: From 8e54d9796891cc36275c97e89b1ca5f10ff585c8 Mon Sep 17 00:00:00 2001 From: tbxark Date: Sun, 29 Sep 2024 11:39:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81workers=20ai=20bas?= =?UTF-8?q?e64=E6=A0=BC=E5=BC=8F=E5=9B=BE=E7=89=87=20#293?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agent/workersai.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/agent/workersai.ts b/src/agent/workersai.ts index b098e979..680ad26e 100644 --- a/src/agent/workersai.ts +++ b/src/agent/workersai.ts @@ -1,7 +1,7 @@ import type { AgentUserConfig } from '../config/env'; -import type { ChatAgent, ChatStreamTextHandler, HistoryItem, ImageAgent, LLMChatParams } from './types'; import type { SseChatCompatibleOptions } from './request'; -import { requestChatCompletions } from './request'; +import type { ChatAgent, ChatStreamTextHandler, HistoryItem, ImageAgent, LLMChatParams } from './types'; +import { isJsonResponse, requestChatCompletions } from './request'; class WorkerBase { readonly name = 'workers'; @@ -83,6 +83,26 @@ export class WorkersImage extends WorkerBase implements ImageAgent { throw new Error('Cloudflare account ID or token is not set'); } const raw = await this.run(context.WORKERS_IMAGE_MODEL, { prompt }, id, token); + if (isJsonResponse(raw)) { + const { result } = await raw.json(); + const image = result?.image; + if (typeof image !== 'string') { + throw new TypeError('Invalid image response'); + } + return base64StringToBlob(image); + } return await raw.blob(); }; } + +async function base64StringToBlob(base64String: string): Promise { + try { + const { Buffer } = await import('node:buffer'); + const buffer = Buffer.from(base64String, 'base64'); + return new Blob([buffer], { type: 'image/png' }); + } catch { + const uint8Array = Uint8Array.from(atob(base64String), c => c.charCodeAt(0)); + return new Blob([uint8Array], { type: 'image/png' }); + } +} + From d691a66d0637cd55f75b52c645d192beb3b5d57f Mon Sep 17 00:00:00 2001 From: tbxark Date: Sun, 29 Sep 2024 14:03:46 +0800 Subject: [PATCH 3/5] chore: lint and build --- dist/buildinfo.json | 2 +- dist/index.js | 1630 +++++++++++++++--------------- dist/timestamp | 2 +- scripts/plugins/vercel/index.ts | 2 +- src/adapter/local/index.ts | 10 +- src/adapter/vercel/index.ts | 2 +- src/agent/anthropic.ts | 10 +- src/agent/azure.ts | 2 +- src/agent/chat.ts | 2 +- src/agent/cohere.ts | 6 +- src/agent/index.test.ts | 4 +- src/agent/openai.ts | 4 +- src/agent/request.ts | 2 +- src/agent/workersai.ts | 1 - src/config/context.ts | 2 +- src/config/env.ts | 2 +- src/i18n/index.ts | 4 +- src/index.ts | 2 +- src/plugins/interpolate.ts | 1 - src/route/index.ts | 12 +- src/telegram/command/auth.ts | 2 +- src/telegram/command/index.ts | 6 +- src/telegram/command/system.ts | 12 +- src/telegram/handler/chat.ts | 10 +- src/telegram/handler/group.ts | 6 +- src/telegram/handler/handlers.ts | 4 +- src/telegram/handler/index.ts | 2 +- src/telegram/utils/send.ts | 2 +- vite.config.ts | 8 +- yarn.lock | 884 ++++++++-------- 30 files changed, 1292 insertions(+), 1346 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index 939895f4..74bceb75 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"bb11947","timestamp":1726714840} \ No newline at end of file +{"sha":"db772d7","timestamp":1727589780} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index fb2ac9b1..0bf05ffb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,83 +1,11 @@ -class ConfigMerger { - static parseArray(raw) { - raw = raw.trim(); - if (raw === "") { - return []; - } - if (raw.startsWith("[") && raw.endsWith("]")) { - try { - return JSON.parse(raw); - } catch (e) { - console.error(e); - } - } - return raw.split(","); - } - static trim(source, lock) { - const config = { ...source }; - const keysSet = new Set(source?.DEFINE_KEYS || []); - for (const key of lock) { - keysSet.delete(key); - } - keysSet.add("DEFINE_KEYS"); - for (const key of Object.keys(config)) { - if (!keysSet.has(key)) { - delete config[key]; - } - } - return config; - } - static merge(target, source, exclude) { - const sourceKeys = new Set(Object.keys(source)); - for (const key of Object.keys(target)) { - if (!sourceKeys.has(key)) { - continue; - } - if (exclude && exclude.includes(key)) { - continue; - } - const t = target[key] !== null && target[key] !== void 0 ? typeof target[key] : "string"; - if (typeof source[key] !== "string") { - target[key] = source[key]; - continue; - } - switch (t) { - case "number": - target[key] = Number.parseInt(source[key], 10); - break; - case "boolean": - target[key] = (source[key] || "false") === "true"; - break; - case "string": - target[key] = source[key]; - break; - case "object": - if (Array.isArray(target[key])) { - target[key] = ConfigMerger.parseArray(source[key]); - } else { - try { - target[key] = JSON.parse(source[key]); - } catch (e) { - console.error(e); - } - } - break; - default: - target[key] = source[key]; - break; - } - } - } -} +const en = { "env": { "system_init_message": "You are a helpful assistant" }, "command": { "help": { "summary": "The following commands are currently supported:\n", "help": "Get command help", "new": "Start a new conversation", "start": "Get your ID and start a new conversation", "img": "Generate an image, the complete command format is `/img image description`, for example `/img beach at moonlight`", "version": "Get the current version number to determine whether to update", "setenv": "Set user configuration, the complete command format is /setenv KEY=VALUE", "setenvs": 'Batch set user configurations, the full format of the command is /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"}', "delenv": "Delete user configuration, the complete command format is /delenv KEY", "clearenv": "Clear all user configuration", "system": "View some system information", "redo": "Redo the last conversation, /redo with modified content or directly /redo", "echo": "Echo the message" }, "new": { "new_chat_start": "A new conversation has started" } } }; + +const pt = { "env": { "system_init_message": "Você é um assistente útil" }, "command": { "help": { "summary": "Os seguintes comandos são suportados atualmente:\n", "help": "Obter ajuda sobre comandos", "new": "Iniciar uma nova conversa", "start": "Obter seu ID e iniciar uma nova conversa", "img": "Gerar uma imagem, o formato completo do comando é `/img descrição da imagem`, por exemplo `/img praia ao luar`", "version": "Obter o número da versão atual para determinar se é necessário atualizar", "setenv": "Definir configuração do usuário, o formato completo do comando é /setenv CHAVE=VALOR", "setenvs": 'Definir configurações do usuário em lote, o formato completo do comando é /setenvs {"CHAVE1": "VALOR1", "CHAVE2": "VALOR2"}', "delenv": "Excluir configuração do usuário, o formato completo do comando é /delenv CHAVE", "clearenv": "Limpar todas as configurações do usuário", "system": "Ver algumas informações do sistema", "redo": "Refazer a última conversa, /redo com conteúdo modificado ou diretamente /redo", "echo": "Repetir a mensagem" }, "new": { "new_chat_start": "Uma nova conversa foi iniciada" } } }; const zhHans = { "env": { "system_init_message": "你是一个得力的助手" }, "command": { "help": { "summary": "当前支持以下命令:\n", "help": "获取命令帮助", "new": "发起新的对话", "start": "获取你的ID, 并发起新的对话", "img": "生成一张图片, 命令完整格式为 `/img 图片描述`, 例如`/img 月光下的沙滩`", "version": "获取当前版本号, 判断是否需要更新", "setenv": "设置用户配置,命令完整格式为 /setenv KEY=VALUE", "setenvs": '批量设置用户配置, 命令完整格式为 /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"}', "delenv": "删除用户配置,命令完整格式为 /delenv KEY", "clearenv": "清除所有用户配置", "system": "查看当前一些系统信息", "redo": "重做上一次的对话, /redo 加修改过的内容 或者 直接 /redo", "echo": "回显消息" }, "new": { "new_chat_start": "新的对话已经开始" } } }; const zhHant = { "env": { "system_init_message": "你是一個得力的助手" }, "command": { "help": { "summary": "當前支持的命令如下:\n", "help": "獲取命令幫助", "new": "開始一個新對話", "start": "獲取您的ID並開始一個新對話", "img": "生成圖片,完整命令格式為`/img 圖片描述`,例如`/img 海灘月光`", "version": "獲取當前版本號確認是否需要更新", "setenv": "設置用戶配置,完整命令格式為/setenv KEY=VALUE", "setenvs": '批量設置用户配置, 命令完整格式為 /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"}', "delenv": "刪除用戶配置,完整命令格式為/delenv KEY", "clearenv": "清除所有用戶配置", "system": "查看一些系統信息", "redo": "重做上一次的對話 /redo 加修改過的內容 或者 直接 /redo", "echo": "回显消息" }, "new": { "new_chat_start": "開始一個新對話" } } }; -const pt = { "env": { "system_init_message": "Você é um assistente útil" }, "command": { "help": { "summary": "Os seguintes comandos são suportados atualmente:\n", "help": "Obter ajuda sobre comandos", "new": "Iniciar uma nova conversa", "start": "Obter seu ID e iniciar uma nova conversa", "img": "Gerar uma imagem, o formato completo do comando é `/img descrição da imagem`, por exemplo `/img praia ao luar`", "version": "Obter o número da versão atual para determinar se é necessário atualizar", "setenv": "Definir configuração do usuário, o formato completo do comando é /setenv CHAVE=VALOR", "setenvs": 'Definir configurações do usuário em lote, o formato completo do comando é /setenvs {"CHAVE1": "VALOR1", "CHAVE2": "VALOR2"}', "delenv": "Excluir configuração do usuário, o formato completo do comando é /delenv CHAVE", "clearenv": "Limpar todas as configurações do usuário", "system": "Ver algumas informações do sistema", "redo": "Refazer a última conversa, /redo com conteúdo modificado ou diretamente /redo", "echo": "Repetir a mensagem" }, "new": { "new_chat_start": "Uma nova conversa foi iniciada" } } }; - -const en = { "env": { "system_init_message": "You are a helpful assistant" }, "command": { "help": { "summary": "The following commands are currently supported:\n", "help": "Get command help", "new": "Start a new conversation", "start": "Get your ID and start a new conversation", "img": "Generate an image, the complete command format is `/img image description`, for example `/img beach at moonlight`", "version": "Get the current version number to determine whether to update", "setenv": "Set user configuration, the complete command format is /setenv KEY=VALUE", "setenvs": 'Batch set user configurations, the full format of the command is /setenvs {"KEY1": "VALUE1", "KEY2": "VALUE2"}', "delenv": "Delete user configuration, the complete command format is /delenv KEY", "clearenv": "Clear all user configuration", "system": "View some system information", "redo": "Redo the last conversation, /redo with modified content or directly /redo", "echo": "Echo the message" }, "new": { "new_chat_start": "A new conversation has started" } } }; - function loadI18n(lang) { switch (lang?.toLowerCase()) { case "cn": @@ -190,6 +118,78 @@ class DefineKeys { DEFINE_KEYS = []; } +class ConfigMerger { + static parseArray(raw) { + raw = raw.trim(); + if (raw === "") { + return []; + } + if (raw.startsWith("[") && raw.endsWith("]")) { + try { + return JSON.parse(raw); + } catch (e) { + console.error(e); + } + } + return raw.split(","); + } + static trim(source, lock) { + const config = { ...source }; + const keysSet = new Set(source?.DEFINE_KEYS || []); + for (const key of lock) { + keysSet.delete(key); + } + keysSet.add("DEFINE_KEYS"); + for (const key of Object.keys(config)) { + if (!keysSet.has(key)) { + delete config[key]; + } + } + return config; + } + static merge(target, source, exclude) { + const sourceKeys = new Set(Object.keys(source)); + for (const key of Object.keys(target)) { + if (!sourceKeys.has(key)) { + continue; + } + if (exclude && exclude.includes(key)) { + continue; + } + const t = target[key] !== null && target[key] !== void 0 ? typeof target[key] : "string"; + if (typeof source[key] !== "string") { + target[key] = source[key]; + continue; + } + switch (t) { + case "number": + target[key] = Number.parseInt(source[key], 10); + break; + case "boolean": + target[key] = (source[key] || "false") === "true"; + break; + case "string": + target[key] = source[key]; + break; + case "object": + if (Array.isArray(target[key])) { + target[key] = ConfigMerger.parseArray(source[key]); + } else { + try { + target[key] = JSON.parse(source[key]); + } catch (e) { + console.error(e); + } + } + break; + default: + target[key] = source[key]; + break; + } + } + } +} + function createAgentUserConfig() { return Object.assign( {}, @@ -211,8 +211,8 @@ const ENV_KEY_MAPPER = { WORKERS_AI_MODEL: "WORKERS_CHAT_MODEL" }; class Environment extends EnvironmentConfig { - BUILD_TIMESTAMP = 1726714840 ; - BUILD_VERSION = "bb11947" ; + BUILD_TIMESTAMP = 1727589780 ; + BUILD_VERSION = "db772d7" ; I18N = loadI18n(); PLUGINS_ENV = {}; USER_CONFIG = createAgentUserConfig(); @@ -298,75 +298,457 @@ class Environment extends EnvironmentConfig { } const ENV = new Environment(); -class ShareContext { - botId; - botToken; - botName = null; - chatHistoryKey; - lastMessageKey; - configStoreKey; - groupAdminsKey; - constructor(token, message) { - const botId = Number.parseInt(token.split(":")[0]); - const telegramIndex = ENV.TELEGRAM_AVAILABLE_TOKENS.indexOf(token); - if (telegramIndex === -1) { - throw new Error("Token not allowed"); - } - if (ENV.TELEGRAM_BOT_NAME.length > telegramIndex) { - this.botName = ENV.TELEGRAM_BOT_NAME[telegramIndex]; - } - this.botToken = token; - this.botId = botId; - const id = message?.chat?.id; - if (id === void 0 || id === null) { - throw new Error("Chat id not found"); - } - let historyKey = `history:${id}`; - let configStoreKey = `user_config:${id}`; - if (botId) { - historyKey += `:${botId}`; - configStoreKey += `:${botId}`; +class APIClientBase { + token; + baseURL = ENV.TELEGRAM_API_DOMAIN; + constructor(token, baseURL) { + this.token = token; + if (baseURL) { + this.baseURL = baseURL; } - switch (message.chat.type) { - case "group": - case "supergroup": - if (!ENV.GROUP_CHAT_BOT_SHARE_MODE && message.from?.id) { - historyKey += `:${message.from.id}`; - configStoreKey += `:${message.from.id}`; - } - this.groupAdminsKey = `group_admin:${id}`; - break; + while (this.baseURL.endsWith("/")) { + this.baseURL = this.baseURL.slice(0, -1); } - if (message?.chat.is_forum && message?.is_topic_message) { - if (message?.message_thread_id) { - historyKey += `:${message.message_thread_id}`; - configStoreKey += `:${message.message_thread_id}`; + } + uri(method) { + return `${this.baseURL}/bot${this.token}/${method}`; + } + jsonRequest(method, params) { + return fetch(this.uri(method), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(params) + }); + } + formDataRequest(method, params) { + const formData = new FormData(); + for (const key in params) { + const value = params[key]; + if (value instanceof File) { + formData.append(key, value, value.name); + } else if (value instanceof Blob) { + formData.append(key, value, "blob"); + } else if (typeof value === "string") { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); } } - this.chatHistoryKey = historyKey; - this.lastMessageKey = `last_message_id:${historyKey}`; - this.configStoreKey = configStoreKey; - } -} -class WorkerContext { - USER_CONFIG; - SHARE_CONTEXT; - constructor(USER_CONFIG, SHARE_CONTEXT) { - this.USER_CONFIG = USER_CONFIG; - this.SHARE_CONTEXT = SHARE_CONTEXT; + return fetch(this.uri(method), { + method: "POST", + body: formData + }); } - static async from(token, message) { - const SHARE_CONTEXT = new ShareContext(token, message); - const USER_CONFIG = Object.assign({}, ENV.USER_CONFIG); - try { - const userConfig = JSON.parse(await ENV.DATABASE.get(SHARE_CONTEXT.configStoreKey)); - ConfigMerger.merge(USER_CONFIG, ConfigMerger.trim(userConfig, ENV.LOCK_USER_CONFIG_KEYS) || {}); - } catch (e) { - console.warn(e); + request(method, params) { + for (const key in params) { + if (params[key] instanceof File || params[key] instanceof Blob) { + return this.formDataRequest(method, params); + } } - return new WorkerContext(USER_CONFIG, SHARE_CONTEXT); + return this.jsonRequest(method, params); } -} + async requestJSON(method, params) { + return this.request(method, params).then((res) => res.json()); + } +} +function createTelegramBotAPI(token) { + const client = new APIClientBase(token); + return new Proxy(client, { + get(target, prop, receiver) { + if (prop in target) { + return Reflect.get(target, prop, receiver); + } + return (...args) => { + if (typeof prop === "string" && prop.endsWith("WithReturns")) { + const method = prop.slice(0, -11); + return Reflect.apply(target.requestJSON, target, [method, ...args]); + } + return Reflect.apply(target.request, target, [prop, ...args]); + }; + } + }); +} + +const INTERPOLATE_LOOP_REGEXP = /\{\{#each(?::(\w+))?\s+(\w+)\s+in\s+([\w.[\]]+)\}\}([\s\S]*?)\{\{\/each(?::\1)?\}\}/g; +const INTERPOLATE_CONDITION_REGEXP = /\{\{#if(?::(\w+))?\s+([\w.[\]]+)\}\}([\s\S]*?)(?:\{\{#else(?::\1)?\}\}([\s\S]*?))?\{\{\/if(?::\1)?\}\}/g; +const INTERPOLATE_VARIABLE_REGEXP = /\{\{([\w.[\]]+)\}\}/g; +function evaluateExpression(expr, localData) { + if (expr === ".") { + return localData["."] ?? localData; + } + try { + return expr.split(".").reduce((value, key) => { + if (key.includes("[") && key.includes("]")) { + const [arrayKey, indexStr] = key.split("["); + const indexExpr = indexStr.slice(0, -1); + let index = Number.parseInt(indexExpr, 10); + if (Number.isNaN(index)) { + index = evaluateExpression(indexExpr, localData); + } + return value?.[arrayKey]?.[index]; + } + return value?.[key]; + }, localData); + } catch (error) { + console.error(`Error evaluating expression: ${expr}`, error); + return void 0; + } +} +function interpolate(template, data, formatter = null) { + const processConditional = (condition, trueBlock, falseBlock, localData) => { + const result = evaluateExpression(condition, localData); + return result ? trueBlock : falseBlock || ""; + }; + const processLoop = (itemName, arrayExpr, loopContent, localData) => { + const array = evaluateExpression(arrayExpr, localData); + if (!Array.isArray(array)) { + console.warn(`Expression "${arrayExpr}" did not evaluate to an array`); + return ""; + } + return array.map((item) => { + const itemData = { ...localData, [itemName]: item, ".": item }; + return interpolate(loopContent, itemData); + }).join(""); + }; + const processTemplate = (tmpl, localData) => { + tmpl = tmpl.replace(INTERPOLATE_LOOP_REGEXP, (_, alias, itemName, arrayExpr, loopContent) => processLoop(itemName, arrayExpr, loopContent, localData)); + tmpl = tmpl.replace(INTERPOLATE_CONDITION_REGEXP, (_, alias, condition, trueBlock, falseBlock) => processConditional(condition, trueBlock, falseBlock, localData)); + return tmpl.replace(INTERPOLATE_VARIABLE_REGEXP, (_, expr) => { + const value = evaluateExpression(expr, localData); + if (value === void 0) { + return `{{${expr}}}`; + } + if (formatter) { + return formatter(value); + } + return String(value); + }); + }; + return processTemplate(template, data); +} + +function interpolateObject(obj, data) { + if (obj === null || obj === void 0) { + return null; + } + if (typeof obj === "string") { + return interpolate(obj, data); + } + if (Array.isArray(obj)) { + return obj.map((item) => interpolateObject(item, data)); + } + if (typeof obj === "object") { + const result = {}; + for (const [key, value] of Object.entries(obj)) { + result[key] = interpolateObject(value, data); + } + return result; + } + return obj; +} +async function executeRequest(template, data) { + const urlRaw = interpolate(template.url, data, encodeURIComponent); + const url = new URL(urlRaw); + if (template.query) { + for (const [key, value] of Object.entries(template.query)) { + url.searchParams.append(key, interpolate(value, data)); + } + } + const method = template.method; + const headers = Object.fromEntries( + Object.entries(template.headers || {}).map(([key, value]) => { + return [key, interpolate(value, data)]; + }) + ); + for (const key of Object.keys(headers)) { + if (headers[key] === null) { + delete headers[key]; + } + } + let body = null; + if (template.body) { + if (template.body.type === "json") { + body = JSON.stringify(interpolateObject(template.body.content, data)); + } else if (template.body.type === "form") { + body = new URLSearchParams(); + for (const [key, value] of Object.entries(template.body.content)) { + body.append(key, interpolate(value, data)); + } + } else { + body = interpolate(template.body.content, data); + } + } + const response = await fetch(url, { + method, + headers, + body + }); + const renderOutput = async (type, temple, response2) => { + switch (type) { + case "text": + return interpolate(temple, await response2.text()); + case "json": + default: + return interpolate(temple, await response2.json()); + } + }; + if (!response.ok) { + const content2 = await renderOutput(template.response?.error?.input_type, template.response.error?.output, response); + return { + type: template.response.error.output_type, + content: content2 + }; + } + const content = await renderOutput(template.response.content?.input_type, template.response.content?.output, response); + return { + type: template.response.content.output_type, + content + }; +} +function formatInput(input, type) { + if (type === "json") { + return JSON.parse(input); + } else if (type === "space-separated") { + return input.split(/\s+/); + } else if (type === "comma-separated") { + return input.split(/\s*,\s*/); + } else { + return input; + } +} + +const escapeChars = /([_*[\]()\\~`>#+\-=|{}.!])/g; +function escape(text) { + const lines = text.split("\n"); + const stack = []; + const result = []; + let lineTrim = ""; + for (const [i, line] of lines.entries()) { + lineTrim = line.trim(); + let startIndex = 0; + if (/^```.+/.test(lineTrim)) { + stack.push(i); + } else if (lineTrim === "```") { + if (stack.length) { + startIndex = stack.pop(); + if (!stack.length) { + const content = lines.slice(startIndex, i + 1).join("\n"); + result.push(handleEscape(content, "code")); + continue; + } + } else { + stack.push(i); + } + } + if (!stack.length) { + result.push(handleEscape(line)); + } + } + if (stack.length) { + const last = `${lines.slice(stack[0]).join("\n")} +\`\`\``; + result.push(handleEscape(last, "code")); + } + return result.join("\n"); +} +function handleEscape(text, type = "text") { + if (!text.trim()) { + return text; + } + if (type === "text") { + text = text.replace(escapeChars, "\\$1").replace(/\\\*\\\*(.*?[^\\])\\\*\\\*/g, "*$1*").replace(/\\_\\_(.*?[^\\])\\_\\_/g, "__$1__").replace(/\\_(.*?[^\\])\\_/g, "_$1_").replace(/\\~(.*?[^\\])\\~/g, "~$1~").replace(/\\\|\\\|(.*?[^\\])\\\|\\\|/g, "||$1||").replace(/\\\[([^\]]+?)\\\]\\\((.+?)\\\)/g, "[$1]($2)").replace(/\\`(.*?[^\\])\\`/g, "`$1`").replace(/\\\\\\([_*[\]()\\~`>#+\-=|{}.!])/g, "\\$1").replace(/^(\s*)\\(>.+\s*)$/gm, "$1$2").replace(/^(\s*)\\-\s*(.+)$/gm, "$1• $2").replace(/^((\\#){1,3}\s)(.+)/gm, "$1*$3*"); + } else { + const codeBlank = text.length - text.trimStart().length; + if (codeBlank > 0) { + const blankReg = new RegExp(`^\\s{${codeBlank}}`, "gm"); + text = text.replace(blankReg, ""); + } + text = text.trimEnd().replace(/([\\`])/g, "\\$1").replace(/^\\`\\`\\`([\s\S]+)\\`\\`\\`$/g, "```$1```"); + } + return text; +} + +class MessageContext { + chat_id; + message_id = null; + reply_to_message_id; + parse_mode = null; + allow_sending_without_reply = null; + disable_web_page_preview = null; + constructor(message) { + this.chat_id = message.chat.id; + if (message.chat.type === "group" || message.chat.type === "supergroup") { + this.reply_to_message_id = message.message_id; + this.allow_sending_without_reply = true; + } else { + this.reply_to_message_id = null; + } + } +} +class MessageSender { + api; + context; + constructor(token, context) { + this.api = createTelegramBotAPI(token); + this.context = context; + } + static from(token, message) { + return new MessageSender(token, new MessageContext(message)); + } + with(message) { + this.context = new MessageContext(message); + return this; + } + update(context) { + if (!this.context) { + this.context = context; + return this; + } + for (const key in context) { + this.context[key] = context[key]; + } + return this; + } + async sendMessage(message, context) { + if (context?.message_id) { + const params = { + chat_id: context.chat_id, + message_id: context.message_id, + parse_mode: context.parse_mode || void 0, + text: message + }; + if (context.disable_web_page_preview) { + params.link_preview_options = { + is_disabled: true + }; + } + return this.api.editMessageText(params); + } else { + const params = { + chat_id: context.chat_id, + parse_mode: context.parse_mode || void 0, + text: message + }; + if (context.reply_to_message_id) { + params.reply_parameters = { + message_id: context.reply_to_message_id, + chat_id: context.chat_id, + allow_sending_without_reply: context.allow_sending_without_reply || void 0 + }; + } + if (context.disable_web_page_preview) { + params.link_preview_options = { + is_disabled: true + }; + } + return this.api.sendMessage(params); + } + } + renderMessage(parse_mode, message) { + if (parse_mode === "MarkdownV2") { + return escape(message); + } + return message; + } + async sendLongMessage(message, context) { + const chatContext = { ...context }; + const limit = 4096; + if (message.length <= limit) { + const resp = await this.sendMessage(this.renderMessage(context.parse_mode, message), chatContext); + if (resp.status === 200) { + return resp; + } + } + chatContext.parse_mode = null; + let lastMessageResponse = null; + for (let i = 0; i < message.length; i += limit) { + const msg = message.slice(i, Math.min(i + limit, message.length)); + if (i > 0) { + chatContext.message_id = null; + } + lastMessageResponse = await this.sendMessage(msg, chatContext); + if (lastMessageResponse.status !== 200) { + break; + } + } + if (lastMessageResponse === null) { + throw new Error("Send message failed"); + } + return lastMessageResponse; + } + sendRichText(message, parseMode = ENV.DEFAULT_PARSE_MODE) { + if (!this.context) { + throw new Error("Message context not set"); + } + return this.sendLongMessage(message, { + ...this.context, + parse_mode: parseMode + }); + } + sendPlainText(message) { + if (!this.context) { + throw new Error("Message context not set"); + } + return this.sendLongMessage(message, { + ...this.context, + parse_mode: null + }); + } + sendPhoto(photo) { + if (!this.context) { + throw new Error("Message context not set"); + } + const params = { + chat_id: this.context.chat_id, + photo + }; + if (this.context.reply_to_message_id) { + params.reply_parameters = { + message_id: this.context.reply_to_message_id, + chat_id: this.context.chat_id, + allow_sending_without_reply: this.context.allow_sending_without_reply || void 0 + }; + } + return this.api.sendPhoto(params); + } +} + +async function loadChatRoleWithContext(message, context) { + const { groupAdminsKey } = context.SHARE_CONTEXT; + const chatId = message.chat.id; + const speakerId = message.from?.id || chatId; + if (!groupAdminsKey) { + return null; + } + let groupAdmin = null; + try { + groupAdmin = JSON.parse(await ENV.DATABASE.get(groupAdminsKey)); + } catch (e) { + console.error(e); + } + if (groupAdmin === null || !Array.isArray(groupAdmin) || groupAdmin.length === 0) { + const api = createTelegramBotAPI(context.SHARE_CONTEXT.botToken); + const result = await api.getChatAdministratorsWithReturns({ chat_id: chatId }); + if (result == null) { + return null; + } + groupAdmin = result.result; + await ENV.DATABASE.put( + groupAdminsKey, + JSON.stringify(groupAdmin), + { expiration: Date.now() / 1e3 + 120 } + ); + } + for (let i = 0; i < groupAdmin.length; i++) { + const user = groupAdmin[i]; + if (`${user.user?.id}` === `${speakerId}`) { + return user.status; + } + } + return "member"; +} class Cache { maxItems; @@ -1244,410 +1626,159 @@ class WorkersChat extends WorkerBase { }; options.errorExtractor = function(data) { return data?.errors?.[0]?.message; - }; - return requestChatCompletions(url, header, body, onStream, null, options); - }; -} -class WorkersImage extends WorkerBase { - modelKey = "WORKERS_IMAGE_MODEL"; - model = (ctx) => { - return ctx.WORKERS_IMAGE_MODEL; - }; - request = async (prompt, context) => { - const id = context.CLOUDFLARE_ACCOUNT_ID; - const token = context.CLOUDFLARE_TOKEN; - if (!id || !token) { - throw new Error("Cloudflare account ID or token is not set"); - } - const raw = await this.run(context.WORKERS_IMAGE_MODEL, { prompt }, id, token); - return await raw.blob(); - }; -} - -const CHAT_AGENTS = [ - new Anthropic(), - new AzureChatAI(), - new Cohere(), - new Gemini(), - new Mistral(), - new OpenAI(), - new WorkersChat() -]; -function loadChatLLM(context) { - for (const llm of CHAT_AGENTS) { - if (llm.name === context.AI_PROVIDER) { - return llm; - } - } - for (const llm of CHAT_AGENTS) { - if (llm.enable(context)) { - return llm; - } - } - return null; -} -const IMAGE_AGENTS = [ - new AzureImageAI(), - new Dalle(), - new WorkersImage() -]; -function loadImageGen(context) { - for (const imgGen of IMAGE_AGENTS) { - if (imgGen.name === context.AI_IMAGE_PROVIDER) { - return imgGen; - } - } - for (const imgGen of IMAGE_AGENTS) { - if (imgGen.enable(context)) { - return imgGen; - } - } - return null; -} - -function tokensCounter() { - return (text) => { - return text.length; - }; -} -async function loadHistory(key) { - let history = []; - try { - history = JSON.parse(await ENV.DATABASE.get(key)); - } catch (e) { - console.error(e); - } - if (!history || !Array.isArray(history)) { - history = []; - } - const counter = tokensCounter(); - const trimHistory = (list, initLength, maxLength, maxToken) => { - if (maxLength >= 0 && list.length > maxLength) { - list = list.splice(list.length - maxLength); - } - if (maxToken > 0) { - let tokenLength = initLength; - for (let i = list.length - 1; i >= 0; i--) { - const historyItem = list[i]; - let length = 0; - if (historyItem.content) { - length = counter(historyItem.content); - } else { - historyItem.content = ""; - } - tokenLength += length; - if (tokenLength > maxToken) { - list = list.splice(i + 1); - break; - } - } - } - return list; - }; - if (ENV.AUTO_TRIM_HISTORY && ENV.MAX_HISTORY_LENGTH > 0) { - history = trimHistory(history, 0, ENV.MAX_HISTORY_LENGTH, ENV.MAX_TOKEN_LENGTH); - } - return history; -} -async function requestCompletionsFromLLM(params, context, agent, modifier, onStream) { - const historyDisable = ENV.AUTO_TRIM_HISTORY && ENV.MAX_HISTORY_LENGTH <= 0; - const historyKey = context.SHARE_CONTEXT.chatHistoryKey; - if (!historyKey) { - throw new Error("History key not found"); - } - let history = await loadHistory(historyKey); - if (modifier) { - const modifierData = modifier(history, params.message || null); - history = modifierData.history; - params.message = modifierData.message; - } - const llmParams = { - ...params, - history, - prompt: context.USER_CONFIG.SYSTEM_INIT_MESSAGE - }; - const answer = await agent.request(llmParams, context.USER_CONFIG, onStream); - if (!historyDisable) { - const userMessage = { role: "user", content: params.message || "", images: params.images }; - if (ENV.HISTORY_IMAGE_PLACEHOLDER && userMessage.images && userMessage.images.length > 0) { - delete userMessage.images; - userMessage.content = `${ENV.HISTORY_IMAGE_PLACEHOLDER} -${userMessage.content}`; - } - history.push(userMessage); - history.push({ role: "assistant", content: answer }); - await ENV.DATABASE.put(historyKey, JSON.stringify(history)).catch(console.error); - } - return answer; -} - -class APIClientBase { - token; - baseURL = ENV.TELEGRAM_API_DOMAIN; - constructor(token, baseURL) { - this.token = token; - if (baseURL) { - this.baseURL = baseURL; - } - while (this.baseURL.endsWith("/")) { - this.baseURL = this.baseURL.slice(0, -1); - } - } - uri(method) { - return `${this.baseURL}/bot${this.token}/${method}`; - } - jsonRequest(method, params) { - return fetch(this.uri(method), { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(params) - }); - } - formDataRequest(method, params) { - const formData = new FormData(); - for (const key in params) { - const value = params[key]; - if (value instanceof File) { - formData.append(key, value, value.name); - } else if (value instanceof Blob) { - formData.append(key, value, "blob"); - } else if (typeof value === "string") { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - } - return fetch(this.uri(method), { - method: "POST", - body: formData - }); - } - request(method, params) { - for (const key in params) { - if (params[key] instanceof File || params[key] instanceof Blob) { - return this.formDataRequest(method, params); - } - } - return this.jsonRequest(method, params); - } - async requestJSON(method, params) { - return this.request(method, params).then((res) => res.json()); - } + }; + return requestChatCompletions(url, header, body, onStream, null, options); + }; } -function createTelegramBotAPI(token) { - const client = new APIClientBase(token); - return new Proxy(client, { - get(target, prop, receiver) { - if (prop in target) { - return Reflect.get(target, prop, receiver); +class WorkersImage extends WorkerBase { + modelKey = "WORKERS_IMAGE_MODEL"; + model = (ctx) => { + return ctx.WORKERS_IMAGE_MODEL; + }; + request = async (prompt, context) => { + const id = context.CLOUDFLARE_ACCOUNT_ID; + const token = context.CLOUDFLARE_TOKEN; + if (!id || !token) { + throw new Error("Cloudflare account ID or token is not set"); + } + const raw = await this.run(context.WORKERS_IMAGE_MODEL, { prompt }, id, token); + if (isJsonResponse(raw)) { + const { result } = await raw.json(); + const image = result?.image; + if (typeof image !== "string") { + throw new TypeError("Invalid image response"); } - return (...args) => { - if (typeof prop === "string" && prop.endsWith("WithReturns")) { - const method = prop.slice(0, -11); - return Reflect.apply(target.requestJSON, target, [method, ...args]); - } - return Reflect.apply(target.request, target, [prop, ...args]); - }; + return base64StringToBlob(image); } - }); + return await raw.blob(); + }; +} +async function base64StringToBlob(base64String) { + try { + const { Buffer } = await import('node:buffer'); + const buffer = Buffer.from(base64String, "base64"); + return new Blob([buffer], { type: "image/png" }); + } catch { + const uint8Array = Uint8Array.from(atob(base64String), (c) => c.charCodeAt(0)); + return new Blob([uint8Array], { type: "image/png" }); + } } -const escapeChars = /([_*[\]()\\~`>#+\-=|{}.!])/g; -function escape(text) { - const lines = text.split("\n"); - const stack = []; - const result = []; - let lineTrim = ""; - for (const [i, line] of lines.entries()) { - lineTrim = line.trim(); - let startIndex = 0; - if (/^```.+/.test(lineTrim)) { - stack.push(i); - } else if (lineTrim === "```") { - if (stack.length) { - startIndex = stack.pop(); - if (!stack.length) { - const content = lines.slice(startIndex, i + 1).join("\n"); - result.push(handleEscape(content, "code")); - continue; - } - } else { - stack.push(i); - } - } - if (!stack.length) { - result.push(handleEscape(line)); +const CHAT_AGENTS = [ + new Anthropic(), + new AzureChatAI(), + new Cohere(), + new Gemini(), + new Mistral(), + new OpenAI(), + new WorkersChat() +]; +function loadChatLLM(context) { + for (const llm of CHAT_AGENTS) { + if (llm.name === context.AI_PROVIDER) { + return llm; } } - if (stack.length) { - const last = `${lines.slice(stack[0]).join("\n")} -\`\`\``; - result.push(handleEscape(last, "code")); + for (const llm of CHAT_AGENTS) { + if (llm.enable(context)) { + return llm; + } } - return result.join("\n"); + return null; } -function handleEscape(text, type = "text") { - if (!text.trim()) { - return text; +const IMAGE_AGENTS = [ + new AzureImageAI(), + new Dalle(), + new WorkersImage() +]; +function loadImageGen(context) { + for (const imgGen of IMAGE_AGENTS) { + if (imgGen.name === context.AI_IMAGE_PROVIDER) { + return imgGen; + } } - if (type === "text") { - text = text.replace(escapeChars, "\\$1").replace(/\\\*\\\*(.*?[^\\])\\\*\\\*/g, "*$1*").replace(/\\_\\_(.*?[^\\])\\_\\_/g, "__$1__").replace(/\\_(.*?[^\\])\\_/g, "_$1_").replace(/\\~(.*?[^\\])\\~/g, "~$1~").replace(/\\\|\\\|(.*?[^\\])\\\|\\\|/g, "||$1||").replace(/\\\[([^\]]+?)\\\]\\\((.+?)\\\)/g, "[$1]($2)").replace(/\\`(.*?[^\\])\\`/g, "`$1`").replace(/\\\\\\([_*[\]()\\~`>#+\-=|{}.!])/g, "\\$1").replace(/^(\s*)\\(>.+\s*)$/gm, "$1$2").replace(/^(\s*)\\-\s*(.+)$/gm, "$1• $2").replace(/^((\\#){1,3}\s)(.+)/gm, "$1*$3*"); - } else { - const codeBlank = text.length - text.trimStart().length; - if (codeBlank > 0) { - const blankReg = new RegExp(`^\\s{${codeBlank}}`, "gm"); - text = text.replace(blankReg, ""); + for (const imgGen of IMAGE_AGENTS) { + if (imgGen.enable(context)) { + return imgGen; } - text = text.trimEnd().replace(/([\\`])/g, "\\$1").replace(/^\\`\\`\\`([\s\S]+)\\`\\`\\`$/g, "```$1```"); } - return text; + return null; } -class MessageContext { - chat_id; - message_id = null; - reply_to_message_id; - parse_mode = null; - allow_sending_without_reply = null; - disable_web_page_preview = null; - constructor(message) { - this.chat_id = message.chat.id; - if (message.chat.type === "group" || message.chat.type === "supergroup") { - this.reply_to_message_id = message.message_id; - this.allow_sending_without_reply = true; - } else { - this.reply_to_message_id = null; - } - } +function tokensCounter() { + return (text) => { + return text.length; + }; } -class MessageSender { - api; - context; - constructor(token, context) { - this.api = createTelegramBotAPI(token); - this.context = context; - } - static from(token, message) { - return new MessageSender(token, new MessageContext(message)); - } - with(message) { - this.context = new MessageContext(message); - return this; - } - update(context) { - if (!this.context) { - this.context = context; - return this; - } - for (const key in context) { - this.context[key] = context[key]; - } - return this; - } - async sendMessage(message, context) { - if (context?.message_id) { - const params = { - chat_id: context.chat_id, - message_id: context.message_id, - parse_mode: context.parse_mode || void 0, - text: message - }; - if (context.disable_web_page_preview) { - params.link_preview_options = { - is_disabled: true - }; - } - return this.api.editMessageText(params); - } else { - const params = { - chat_id: context.chat_id, - parse_mode: context.parse_mode || void 0, - text: message - }; - if (context.reply_to_message_id) { - params.reply_parameters = { - message_id: context.reply_to_message_id, - chat_id: context.chat_id, - allow_sending_without_reply: context.allow_sending_without_reply || void 0 - }; - } - if (context.disable_web_page_preview) { - params.link_preview_options = { - is_disabled: true - }; - } - return this.api.sendMessage(params); - } +async function loadHistory(key) { + let history = []; + try { + history = JSON.parse(await ENV.DATABASE.get(key)); + } catch (e) { + console.error(e); } - renderMessage(parse_mode, message) { - if (parse_mode === "MarkdownV2") { - return escape(message); - } - return message; + if (!history || !Array.isArray(history)) { + history = []; } - async sendLongMessage(message, context) { - const chatContext = { ...context }; - const limit = 4096; - if (message.length <= limit) { - const resp = await this.sendMessage(this.renderMessage(context.parse_mode, message), chatContext); - if (resp.status === 200) { - return resp; - } + const counter = tokensCounter(); + const trimHistory = (list, initLength, maxLength, maxToken) => { + if (maxLength >= 0 && list.length > maxLength) { + list = list.splice(list.length - maxLength); } - chatContext.parse_mode = null; - let lastMessageResponse = null; - for (let i = 0; i < message.length; i += limit) { - const msg = message.slice(i, Math.min(i + limit, message.length)); - if (i > 0) { - chatContext.message_id = null; - } - lastMessageResponse = await this.sendMessage(msg, chatContext); - if (lastMessageResponse.status !== 200) { - break; + if (maxToken > 0) { + let tokenLength = initLength; + for (let i = list.length - 1; i >= 0; i--) { + const historyItem = list[i]; + let length = 0; + if (historyItem.content) { + length = counter(historyItem.content); + } else { + historyItem.content = ""; + } + tokenLength += length; + if (tokenLength > maxToken) { + list = list.splice(i + 1); + break; + } } } - if (lastMessageResponse === null) { - throw new Error("Send message failed"); - } - return lastMessageResponse; + return list; + }; + if (ENV.AUTO_TRIM_HISTORY && ENV.MAX_HISTORY_LENGTH > 0) { + history = trimHistory(history, 0, ENV.MAX_HISTORY_LENGTH, ENV.MAX_TOKEN_LENGTH); } - sendRichText(message, parseMode = ENV.DEFAULT_PARSE_MODE) { - if (!this.context) { - throw new Error("Message context not set"); - } - return this.sendLongMessage(message, { - ...this.context, - parse_mode: parseMode - }); + return history; +} +async function requestCompletionsFromLLM(params, context, agent, modifier, onStream) { + const historyDisable = ENV.AUTO_TRIM_HISTORY && ENV.MAX_HISTORY_LENGTH <= 0; + const historyKey = context.SHARE_CONTEXT.chatHistoryKey; + if (!historyKey) { + throw new Error("History key not found"); } - sendPlainText(message) { - if (!this.context) { - throw new Error("Message context not set"); - } - return this.sendLongMessage(message, { - ...this.context, - parse_mode: null - }); + let history = await loadHistory(historyKey); + if (modifier) { + const modifierData = modifier(history, params.message || null); + history = modifierData.history; + params.message = modifierData.message; } - sendPhoto(photo) { - if (!this.context) { - throw new Error("Message context not set"); - } - const params = { - chat_id: this.context.chat_id, - photo - }; - if (this.context.reply_to_message_id) { - params.reply_parameters = { - message_id: this.context.reply_to_message_id, - chat_id: this.context.chat_id, - allow_sending_without_reply: this.context.allow_sending_without_reply || void 0 - }; + const llmParams = { + ...params, + history, + prompt: context.USER_CONFIG.SYSTEM_INIT_MESSAGE + }; + const answer = await agent.request(llmParams, context.USER_CONFIG, onStream); + if (!historyDisable) { + const userMessage = { role: "user", content: params.message || "", images: params.images }; + if (ENV.HISTORY_IMAGE_PLACEHOLDER && userMessage.images && userMessage.images.length > 0) { + delete userMessage.images; + userMessage.content = `${ENV.HISTORY_IMAGE_PLACEHOLDER} +${userMessage.content}`; } - return this.api.sendPhoto(params); + history.push(userMessage); + history.push({ role: "assistant", content: answer }); + await ENV.DATABASE.put(historyKey, JSON.stringify(history)).catch(console.error); } + return answer; } async function chatWithLLM(message, params, context, modifier) { @@ -1703,265 +1834,44 @@ async function chatWithLLM(message, params, context, modifier) { await new Promise((resolve) => setTimeout(resolve, (nextEnableTime ?? 0) - Date.now())); } return sender.sendRichText(answer); - } catch (e) { - let errMsg = `Error: ${e.message}`; - if (errMsg.length > 2048) { - errMsg = errMsg.substring(0, 2048); - } - return sender.sendPlainText(errMsg); - } -} -function findPhotoFileID(photos, offset) { - let sizeIndex = 0; - if (offset >= 0) { - sizeIndex = offset; - } else if (offset < 0) { - sizeIndex = photos.length + offset; - } - sizeIndex = Math.max(0, Math.min(sizeIndex, photos.length - 1)); - return photos[sizeIndex].file_id; -} -class ChatHandler { - handle = async (message, context) => { - const params = { - message: message.text || message.caption || "" - }; - if (message.photo && message.photo.length > 0) { - const id = findPhotoFileID(message.photo, ENV.TELEGRAM_PHOTO_SIZE_OFFSET); - const api = createTelegramBotAPI(context.SHARE_CONTEXT.botToken); - const file = await api.getFileWithReturns({ file_id: id }); - const url = file.result.file_path; - if (url) { - params.images = [url]; - } - } - return chatWithLLM(message, params, context, null); - }; -} - -function isTelegramChatTypeGroup(type) { - return type === "group" || type === "supergroup"; -} - -function checkMention(content, entities, botName, botId) { - let isMention = false; - for (const entity of entities) { - const entityStr = content.slice(entity.offset, entity.offset + entity.length); - switch (entity.type) { - case "mention": - if (entityStr === `@${botName}`) { - isMention = true; - content = content.slice(0, entity.offset) + content.slice(entity.offset + entity.length); - } - break; - case "text_mention": - if (`${entity.user?.id}` === `${botId}`) { - isMention = true; - content = content.slice(0, entity.offset) + content.slice(entity.offset + entity.length); - } - break; - case "bot_command": - if (entityStr.endsWith(`@${botName}`)) { - isMention = true; - const newEntityStr = entityStr.replace(`@${botName}`, ""); - content = content.slice(0, entity.offset) + newEntityStr + content.slice(entity.offset + entity.length); - } - break; - } - } - return { - isMention, - content - }; -} -class GroupMention { - handle = async (message, context) => { - if (!isTelegramChatTypeGroup(message.chat.type)) { - return null; - } - const replyMe = `${message.reply_to_message?.from?.id}` === `${context.SHARE_CONTEXT.botId}`; - if (replyMe) { - return null; - } - let botName = context.SHARE_CONTEXT.botName; - if (!botName) { - const res = await createTelegramBotAPI(context.SHARE_CONTEXT.botToken).getMeWithReturns(); - botName = res.result.username || null; - context.SHARE_CONTEXT.botName = botName; - } - if (!botName) { - throw new Error("Not set bot name"); - } - let isMention = false; - if (message.text && message.entities) { - const res = checkMention(message.text, message.entities, botName, context.SHARE_CONTEXT.botId); - isMention = res.isMention; - message.text = res.content.trim(); - } - if (message.caption && message.caption_entities) { - const res = checkMention(message.caption, message.caption_entities, botName, context.SHARE_CONTEXT.botId); - isMention = res.isMention || isMention; - message.caption = res.content.trim(); - } - if (!isMention) { - throw new Error("Not mention"); - } - if (ENV.EXTRA_MESSAGE_CONTEXT && !replyMe && message.reply_to_message && message.reply_to_message.text) { - if (message.text) { - message.text = `${message.reply_to_message.text} -${message.text}`; - } - } - return null; - }; -} - -const INTERPOLATE_LOOP_REGEXP = /\{\{#each(?::(\w+))?\s+(\w+)\s+in\s+([\w.[\]]+)\}\}([\s\S]*?)\{\{\/each(?::\1)?\}\}/g; -const INTERPOLATE_CONDITION_REGEXP = /\{\{#if(?::(\w+))?\s+([\w.[\]]+)\}\}([\s\S]*?)(?:\{\{#else(?::\1)?\}\}([\s\S]*?))?\{\{\/if(?::\1)?\}\}/g; -const INTERPOLATE_VARIABLE_REGEXP = /\{\{([\w.[\]]+)\}\}/g; -function evaluateExpression(expr, localData) { - if (expr === ".") { - return localData["."] ?? localData; - } - try { - return expr.split(".").reduce((value, key) => { - if (key.includes("[") && key.includes("]")) { - const [arrayKey, indexStr] = key.split("["); - const indexExpr = indexStr.slice(0, -1); - let index = Number.parseInt(indexExpr, 10); - if (Number.isNaN(index)) { - index = evaluateExpression(indexExpr, localData); - } - return value?.[arrayKey]?.[index]; - } - return value?.[key]; - }, localData); - } catch (error) { - console.error(`Error evaluating expression: ${expr}`, error); - return void 0; - } -} -function interpolate(template, data, formatter = null) { - const processConditional = (condition, trueBlock, falseBlock, localData) => { - const result = evaluateExpression(condition, localData); - return result ? trueBlock : falseBlock || ""; - }; - const processLoop = (itemName, arrayExpr, loopContent, localData) => { - const array = evaluateExpression(arrayExpr, localData); - if (!Array.isArray(array)) { - console.warn(`Expression "${arrayExpr}" did not evaluate to an array`); - return ""; - } - return array.map((item) => { - const itemData = { ...localData, [itemName]: item, ".": item }; - return interpolate(loopContent, itemData); - }).join(""); - }; - const processTemplate = (tmpl, localData) => { - tmpl = tmpl.replace(INTERPOLATE_LOOP_REGEXP, (_, alias, itemName, arrayExpr, loopContent) => processLoop(itemName, arrayExpr, loopContent, localData)); - tmpl = tmpl.replace(INTERPOLATE_CONDITION_REGEXP, (_, alias, condition, trueBlock, falseBlock) => processConditional(condition, trueBlock, falseBlock, localData)); - return tmpl.replace(INTERPOLATE_VARIABLE_REGEXP, (_, expr) => { - const value = evaluateExpression(expr, localData); - if (value === void 0) { - return `{{${expr}}}`; - } - if (formatter) { - return formatter(value); - } - return String(value); - }); - }; - return processTemplate(template, data); -} - -function interpolateObject(obj, data) { - if (obj === null || obj === void 0) { - return null; - } - if (typeof obj === "string") { - return interpolate(obj, data); - } - if (Array.isArray(obj)) { - return obj.map((item) => interpolateObject(item, data)); - } - if (typeof obj === "object") { - const result = {}; - for (const [key, value] of Object.entries(obj)) { - result[key] = interpolateObject(value, data); - } - return result; - } - return obj; -} -async function executeRequest(template, data) { - const urlRaw = interpolate(template.url, data, encodeURIComponent); - const url = new URL(urlRaw); - if (template.query) { - for (const [key, value] of Object.entries(template.query)) { - url.searchParams.append(key, interpolate(value, data)); - } - } - const method = template.method; - const headers = Object.fromEntries( - Object.entries(template.headers || {}).map(([key, value]) => { - return [key, interpolate(value, data)]; - }) - ); - for (const key of Object.keys(headers)) { - if (headers[key] === null) { - delete headers[key]; + } catch (e) { + let errMsg = `Error: ${e.message}`; + if (errMsg.length > 2048) { + errMsg = errMsg.substring(0, 2048); } + return sender.sendPlainText(errMsg); } - let body = null; - if (template.body) { - if (template.body.type === "json") { - body = JSON.stringify(interpolateObject(template.body.content, data)); - } else if (template.body.type === "form") { - body = new URLSearchParams(); - for (const [key, value] of Object.entries(template.body.content)) { - body.append(key, interpolate(value, data)); - } - } else { - body = interpolate(template.body.content, data); - } +} +function findPhotoFileID(photos, offset) { + let sizeIndex = 0; + if (offset >= 0) { + sizeIndex = offset; + } else if (offset < 0) { + sizeIndex = photos.length + offset; } - const response = await fetch(url, { - method, - headers, - body - }); - const renderOutput = async (type, temple, response2) => { - switch (type) { - case "text": - return interpolate(temple, await response2.text()); - case "json": - default: - return interpolate(temple, await response2.json()); - } - }; - if (!response.ok) { - const content2 = await renderOutput(template.response?.error?.input_type, template.response.error?.output, response); - return { - type: template.response.error.output_type, - content: content2 + sizeIndex = Math.max(0, Math.min(sizeIndex, photos.length - 1)); + return photos[sizeIndex].file_id; +} +class ChatHandler { + handle = async (message, context) => { + const params = { + message: message.text || message.caption || "" }; - } - const content = await renderOutput(template.response.content?.input_type, template.response.content?.output, response); - return { - type: template.response.content.output_type, - content + if (message.photo && message.photo.length > 0) { + const id = findPhotoFileID(message.photo, ENV.TELEGRAM_PHOTO_SIZE_OFFSET); + const api = createTelegramBotAPI(context.SHARE_CONTEXT.botToken); + const file = await api.getFileWithReturns({ file_id: id }); + const url = file.result.file_path; + if (url) { + params.images = [url]; + } + } + return chatWithLLM(message, params, context, null); }; } -function formatInput(input, type) { - if (type === "json") { - return JSON.parse(input); - } else if (type === "space-separated") { - return input.split(/\s+/); - } else if (type === "comma-separated") { - return input.split(/\s*,\s*/); - } else { - return input; - } + +function isTelegramChatTypeGroup(type) { + return type === "group" || type === "supergroup"; } const COMMAND_AUTH_CHECKER = { @@ -2292,41 +2202,6 @@ class EchoCommandHandler { }; } -async function loadChatRoleWithContext(message, context) { - const { groupAdminsKey } = context.SHARE_CONTEXT; - const chatId = message.chat.id; - const speakerId = message.from?.id || chatId; - if (!groupAdminsKey) { - return null; - } - let groupAdmin = null; - try { - groupAdmin = JSON.parse(await ENV.DATABASE.get(groupAdminsKey)); - } catch (e) { - console.error(e); - } - if (groupAdmin === null || !Array.isArray(groupAdmin) || groupAdmin.length === 0) { - const api = createTelegramBotAPI(context.SHARE_CONTEXT.botToken); - const result = await api.getChatAdministratorsWithReturns({ chat_id: chatId }); - if (result == null) { - return null; - } - groupAdmin = result.result; - await ENV.DATABASE.put( - groupAdminsKey, - JSON.stringify(groupAdmin), - { expiration: Date.now() / 1e3 + 120 } - ); - } - for (let i = 0; i < groupAdmin.length; i++) { - const user = groupAdmin[i]; - if (`${user.user?.id}` === `${speakerId}`) { - return user.status; - } - } - return "member"; -} - const SYSTEM_COMMANDS = [ new StartCommandHandler(), new NewCommandHandler(), @@ -2476,6 +2351,149 @@ function commandsDocument() { }).filter((item) => item.description !== ""); } +class ShareContext { + botId; + botToken; + botName = null; + chatHistoryKey; + lastMessageKey; + configStoreKey; + groupAdminsKey; + constructor(token, message) { + const botId = Number.parseInt(token.split(":")[0]); + const telegramIndex = ENV.TELEGRAM_AVAILABLE_TOKENS.indexOf(token); + if (telegramIndex === -1) { + throw new Error("Token not allowed"); + } + if (ENV.TELEGRAM_BOT_NAME.length > telegramIndex) { + this.botName = ENV.TELEGRAM_BOT_NAME[telegramIndex]; + } + this.botToken = token; + this.botId = botId; + const id = message?.chat?.id; + if (id === void 0 || id === null) { + throw new Error("Chat id not found"); + } + let historyKey = `history:${id}`; + let configStoreKey = `user_config:${id}`; + if (botId) { + historyKey += `:${botId}`; + configStoreKey += `:${botId}`; + } + switch (message.chat.type) { + case "group": + case "supergroup": + if (!ENV.GROUP_CHAT_BOT_SHARE_MODE && message.from?.id) { + historyKey += `:${message.from.id}`; + configStoreKey += `:${message.from.id}`; + } + this.groupAdminsKey = `group_admin:${id}`; + break; + } + if (message?.chat.is_forum && message?.is_topic_message) { + if (message?.message_thread_id) { + historyKey += `:${message.message_thread_id}`; + configStoreKey += `:${message.message_thread_id}`; + } + } + this.chatHistoryKey = historyKey; + this.lastMessageKey = `last_message_id:${historyKey}`; + this.configStoreKey = configStoreKey; + } +} +class WorkerContext { + USER_CONFIG; + SHARE_CONTEXT; + constructor(USER_CONFIG, SHARE_CONTEXT) { + this.USER_CONFIG = USER_CONFIG; + this.SHARE_CONTEXT = SHARE_CONTEXT; + } + static async from(token, message) { + const SHARE_CONTEXT = new ShareContext(token, message); + const USER_CONFIG = Object.assign({}, ENV.USER_CONFIG); + try { + const userConfig = JSON.parse(await ENV.DATABASE.get(SHARE_CONTEXT.configStoreKey)); + ConfigMerger.merge(USER_CONFIG, ConfigMerger.trim(userConfig, ENV.LOCK_USER_CONFIG_KEYS) || {}); + } catch (e) { + console.warn(e); + } + return new WorkerContext(USER_CONFIG, SHARE_CONTEXT); + } +} + +function checkMention(content, entities, botName, botId) { + let isMention = false; + for (const entity of entities) { + const entityStr = content.slice(entity.offset, entity.offset + entity.length); + switch (entity.type) { + case "mention": + if (entityStr === `@${botName}`) { + isMention = true; + content = content.slice(0, entity.offset) + content.slice(entity.offset + entity.length); + } + break; + case "text_mention": + if (`${entity.user?.id}` === `${botId}`) { + isMention = true; + content = content.slice(0, entity.offset) + content.slice(entity.offset + entity.length); + } + break; + case "bot_command": + if (entityStr.endsWith(`@${botName}`)) { + isMention = true; + const newEntityStr = entityStr.replace(`@${botName}`, ""); + content = content.slice(0, entity.offset) + newEntityStr + content.slice(entity.offset + entity.length); + } + break; + } + } + return { + isMention, + content + }; +} +class GroupMention { + handle = async (message, context) => { + if (!isTelegramChatTypeGroup(message.chat.type)) { + return null; + } + const replyMe = `${message.reply_to_message?.from?.id}` === `${context.SHARE_CONTEXT.botId}`; + if (replyMe) { + return null; + } + let botName = context.SHARE_CONTEXT.botName; + if (!botName) { + const res = await createTelegramBotAPI(context.SHARE_CONTEXT.botToken).getMeWithReturns(); + botName = res.result.username || null; + context.SHARE_CONTEXT.botName = botName; + } + if (!botName) { + throw new Error("Not set bot name"); + } + let isMention = false; + if (message.text && message.entities) { + const res = checkMention(message.text, message.entities, botName, context.SHARE_CONTEXT.botId); + isMention = res.isMention; + message.text = res.content.trim(); + } + if (message.caption && message.caption_entities) { + const res = checkMention(message.caption, message.caption_entities, botName, context.SHARE_CONTEXT.botId); + isMention = res.isMention || isMention; + message.caption = res.content.trim(); + } + if (!isMention) { + throw new Error("Not mention"); + } + if (ENV.EXTRA_MESSAGE_CONTEXT && !replyMe && message.reply_to_message && message.reply_to_message.text) { + if (message.text) { + message.text = `${message.reply_to_message.text} +${message.text}`; + } + } + return null; + }; +} + class SaveLastMessage { handle = async (message, context) => { if (!ENV.DEBUG_MODE) { diff --git a/dist/timestamp b/dist/timestamp index 4e4af4c8..a4eee1dc 100644 --- a/dist/timestamp +++ b/dist/timestamp @@ -1 +1 @@ -1726714840 \ No newline at end of file +1727589780 \ No newline at end of file diff --git a/scripts/plugins/vercel/index.ts b/scripts/plugins/vercel/index.ts index 6182a658..7a3f02f4 100644 --- a/scripts/plugins/vercel/index.ts +++ b/scripts/plugins/vercel/index.ts @@ -1,5 +1,5 @@ -import fs from 'node:fs/promises'; import { execSync } from 'node:child_process'; +import fs from 'node:fs/promises'; import { parse } from 'toml'; import { ENV } from '../../../src/config/env'; diff --git a/src/adapter/local/index.ts b/src/adapter/local/index.ts index f0f944d8..c55974b1 100644 --- a/src/adapter/local/index.ts +++ b/src/adapter/local/index.ts @@ -1,13 +1,13 @@ -import * as fs from 'node:fs'; -import { defaultRequestBuilder, initEnv, startServerV2 } from 'cloudflare-worker-adapter/serve'; import type { GetUpdatesResponse } from 'telegram-bot-api-types'; -import { installFetchProxy } from 'cloudflare-worker-adapter/proxy'; +import type { TelegramBotAPI } from '../../telegram/api'; +import * as fs from 'node:fs'; import { createCache } from 'cloudflare-worker-adapter/cache'; +import { installFetchProxy } from 'cloudflare-worker-adapter/proxy'; +import { defaultRequestBuilder, initEnv, startServerV2 } from 'cloudflare-worker-adapter/serve'; import { ENV } from '../../config/env'; -import type { TelegramBotAPI } from '../../telegram/api'; +import { createRouter } from '../../route'; import { createTelegramBotAPI } from '../../telegram/api'; import { handleUpdate } from '../../telegram/handler'; -import { createRouter } from '../../route'; const { CONFIG_PATH = '/app/config.json', diff --git a/src/adapter/vercel/index.ts b/src/adapter/vercel/index.ts index 24aa6a0a..bbd78bd8 100644 --- a/src/adapter/vercel/index.ts +++ b/src/adapter/vercel/index.ts @@ -1,6 +1,6 @@ +import type { VercelRequest, VercelResponse } from '@vercel/node'; import * as process from 'node:process'; import { UpStashRedis } from 'cloudflare-worker-adapter/cache/upstash'; -import type { VercelRequest, VercelResponse } from '@vercel/node'; import { ENV } from '../../config/env'; import { createRouter } from '../../route'; diff --git a/src/agent/anthropic.ts b/src/agent/anthropic.ts index 064ab635..2c2c397e 100644 --- a/src/agent/anthropic.ts +++ b/src/agent/anthropic.ts @@ -1,11 +1,11 @@ -import { imageToBase64String } from '../utils/image'; import type { AgentUserConfig } from '../config/env'; -import { ENV } from '../config/env'; -import type { ChatAgent, ChatStreamTextHandler, HistoryItem, LLMChatParams } from './types'; -import type { SSEMessage, SSEParserResult } from './stream'; -import { Stream } from './stream'; import type { SseChatCompatibleOptions } from './request'; +import type { SSEMessage, SSEParserResult } from './stream'; +import type { ChatAgent, ChatStreamTextHandler, HistoryItem, LLMChatParams } from './types'; +import { ENV } from '../config/env'; +import { imageToBase64String } from '../utils/image'; import { requestChatCompletions } from './request'; +import { Stream } from './stream'; export class Anthropic implements ChatAgent { readonly name = 'anthropic'; diff --git a/src/agent/azure.ts b/src/agent/azure.ts index 0d2c9875..d53fd781 100644 --- a/src/agent/azure.ts +++ b/src/agent/azure.ts @@ -1,7 +1,7 @@ import type { AgentUserConfig } from '../config/env'; import type { ChatAgent, ChatStreamTextHandler, ImageAgent, LLMChatParams } from './types'; -import { requestChatCompletions } from './request'; import { renderOpenAIMessage } from './openai'; +import { requestChatCompletions } from './request'; class AzureBase { readonly name = 'azure'; diff --git a/src/agent/chat.ts b/src/agent/chat.ts index 0443753f..df7b4210 100644 --- a/src/agent/chat.ts +++ b/src/agent/chat.ts @@ -1,6 +1,6 @@ import type { WorkerContext } from '../config/context'; -import { ENV } from '../config/env'; import type { ChatAgent, HistoryItem, HistoryModifier, LLMChatRequestParams } from './types'; +import { ENV } from '../config/env'; /** * @returns {(function(string): number)} diff --git a/src/agent/cohere.ts b/src/agent/cohere.ts index 1445a26f..ae88aa1a 100644 --- a/src/agent/cohere.ts +++ b/src/agent/cohere.ts @@ -1,9 +1,9 @@ import type { AgentUserConfig } from '../config/env'; -import type { ChatAgent, ChatStreamTextHandler, HistoryItem, LLMChatParams } from './types'; -import type { SSEMessage, SSEParserResult } from './stream'; -import { Stream } from './stream'; import type { SseChatCompatibleOptions } from './request'; +import type { SSEMessage, SSEParserResult } from './stream'; +import type { ChatAgent, ChatStreamTextHandler, HistoryItem, LLMChatParams } from './types'; import { requestChatCompletions } from './request'; +import { Stream } from './stream'; export class Cohere implements ChatAgent { readonly name = 'cohere'; diff --git a/src/agent/index.test.ts b/src/agent/index.test.ts index 84027563..4ed2d6b2 100644 --- a/src/agent/index.test.ts +++ b/src/agent/index.test.ts @@ -1,7 +1,7 @@ -import '../config/env.test'; -import { ENV } from '../config/env'; import type { LLMChatParams } from './types'; +import { ENV } from '../config/env'; import { loadChatLLM } from './index'; +import '../config/env.test'; { const agent = loadChatLLM({ diff --git a/src/agent/openai.ts b/src/agent/openai.ts index f6533405..844d997e 100644 --- a/src/agent/openai.ts +++ b/src/agent/openai.ts @@ -1,7 +1,7 @@ -import { imageToBase64String, renderBase64DataURI } from '../utils/image'; import type { AgentUserConfig } from '../config/env'; -import { ENV } from '../config/env'; import type { ChatAgent, ChatStreamTextHandler, HistoryItem, ImageAgent, LLMChatParams } from './types'; +import { ENV } from '../config/env'; +import { imageToBase64String, renderBase64DataURI } from '../utils/image'; import { requestChatCompletions } from './request'; export async function renderOpenAIMessage(item: HistoryItem): Promise { diff --git a/src/agent/request.ts b/src/agent/request.ts index 7a929a53..42687443 100644 --- a/src/agent/request.ts +++ b/src/agent/request.ts @@ -1,5 +1,5 @@ -import { ENV } from '../config/env'; import type { ChatStreamTextHandler } from './types'; +import { ENV } from '../config/env'; import { Stream } from './stream'; export interface SseChatCompatibleOptions { diff --git a/src/agent/workersai.ts b/src/agent/workersai.ts index 680ad26e..07b1522e 100644 --- a/src/agent/workersai.ts +++ b/src/agent/workersai.ts @@ -105,4 +105,3 @@ async function base64StringToBlob(base64String: string): Promise { return new Blob([uint8Array], { type: 'image/png' }); } } - diff --git a/src/config/context.ts b/src/config/context.ts index e402ddc6..f86aceaf 100644 --- a/src/config/context.ts +++ b/src/config/context.ts @@ -1,7 +1,7 @@ import type * as Telegram from 'telegram-bot-api-types'; -import { ConfigMerger } from './merger'; import type { AgentUserConfig } from './env'; import { ENV } from './env'; +import { ConfigMerger } from './merger'; export class ShareContext { botId: number; diff --git a/src/config/env.ts b/src/config/env.ts index e9da1e9c..c77a28a3 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -1,5 +1,5 @@ -import loadI18n from '../i18n'; import type { APIGuard, CommandConfig, KVNamespace } from './types'; +import loadI18n from '../i18n'; import { AgentShareConfig, AnthropicConfig, diff --git a/src/i18n/index.ts b/src/i18n/index.ts index e6aa5e92..2c7d9261 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -1,8 +1,8 @@ import type { I18n } from './types'; +import en from './en'; +import pt from './pt'; import zhHans from './zh-hans'; import zhHant from './zh-hant'; -import pt from './pt'; -import en from './en'; export default function loadI18n(lang?: string): I18n { switch (lang?.toLowerCase()) { diff --git a/src/index.ts b/src/index.ts index ffd98581..59fd8b33 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import { createRouter } from './route'; import { ENV } from './config/env'; +import { createRouter } from './route'; export default { async fetch(request: Request, env: any): Promise { diff --git a/src/plugins/interpolate.ts b/src/plugins/interpolate.ts index 62fadae0..b5eec0c6 100644 --- a/src/plugins/interpolate.ts +++ b/src/plugins/interpolate.ts @@ -29,7 +29,6 @@ function evaluateExpression(expr: string, localData: any): undefined | any { type Formatter = (value: any) => string; export function interpolate(template: string, data: any, formatter: Formatter | null = null): string { - // eslint-disable-next-line unicorn/consistent-function-scoping const processConditional = (condition: string, trueBlock: string, falseBlock: string, localData: any): string => { const result = evaluateExpression(condition, localData); return result ? trueBlock : (falseBlock || ''); diff --git a/src/route/index.ts b/src/route/index.ts index b8260a0a..6579d398 100644 --- a/src/route/index.ts +++ b/src/route/index.ts @@ -1,10 +1,10 @@ import type * as Telegram from 'telegram-bot-api-types'; -import { handleUpdate } from '../telegram/handler'; -import { commandsBindScope, commandsDocument } from '../telegram/command'; import type { RouterRequest } from '../utils/router'; -import { Router } from '../utils/router'; -import { createTelegramBotAPI } from '../telegram/api'; import { ENV } from '../config/env'; +import { createTelegramBotAPI } from '../telegram/api'; +import { commandsBindScope, commandsDocument } from '../telegram/command'; +import { handleUpdate } from '../telegram/handler'; +import { Router } from '../utils/router'; import { errorToString, makeResponse200, renderHTML } from './utils'; const helpLink = 'https://github.com/TBXark/ChatGPT-Telegram-Workers/blob/master/doc/en/DEPLOY.md'; @@ -91,8 +91,8 @@ async function defaultIndexAction(): Promise {

After binding the webhook, you can use the following commands to control the bot:

${ - commandsDocument().map(item => `

${item.command} - ${item.description}

`).join('') -} + commandsDocument().map(item => `

${item.command} - ${item.description}

`).join('') + }

You can get bot information by visiting the following URL:

/telegram/:token/bot - Get bot information

diff --git a/src/telegram/command/auth.ts b/src/telegram/command/auth.ts index fbad38f6..c26540ad 100644 --- a/src/telegram/command/auth.ts +++ b/src/telegram/command/auth.ts @@ -1,7 +1,7 @@ import type * as Telegram from 'telegram-bot-api-types'; import type { WorkerContext } from '../../config/context'; -import { createTelegramBotAPI } from '../api'; import { ENV } from '../../config/env'; +import { createTelegramBotAPI } from '../api'; export async function loadChatRoleWithContext(message: Telegram.Message, context: WorkerContext): Promise { const { groupAdminsKey } = context.SHARE_CONTEXT; diff --git a/src/telegram/command/index.ts b/src/telegram/command/index.ts index 6fc3dd75..06448edc 100644 --- a/src/telegram/command/index.ts +++ b/src/telegram/command/index.ts @@ -1,10 +1,11 @@ import type * as Telegram from 'telegram-bot-api-types'; import type { WorkerContext } from '../../config/context'; import type { RequestTemplate } from '../../plugins/template'; +import type { CommandHandler } from './types'; +import { ENV } from '../../config/env'; import { executeRequest, formatInput } from '../../plugins/template'; import { MessageSender } from '../utils/send'; -import { ENV } from '../../config/env'; -import type { CommandHandler } from './types'; +import { loadChatRoleWithContext } from './auth'; import { ClearEnvCommandHandler, DelEnvCommandHandler, @@ -19,7 +20,6 @@ import { SystemCommandHandler, VersionCommandHandler, } from './system'; -import { loadChatRoleWithContext } from './auth'; const SYSTEM_COMMANDS: CommandHandler[] = [ new StartCommandHandler(), diff --git a/src/telegram/command/system.ts b/src/telegram/command/system.ts index 464d9d53..facae1d8 100644 --- a/src/telegram/command/system.ts +++ b/src/telegram/command/system.ts @@ -1,14 +1,14 @@ import type * as Telegram from 'telegram-bot-api-types'; -import type { WorkerContext } from '../../config/context'; -import { isTelegramChatTypeGroup } from '../utils/utils'; import type { HistoryItem, HistoryModifierResult } from '../../agent/types'; -import { chatWithLLM } from '../handler/chat'; +import type { WorkerContext } from '../../config/context'; +import type { CommandHandler } from './types'; import { loadChatLLM, loadImageGen } from '../../agent'; +import { ENV, ENV_KEY_MAPPER } from '../../config/env'; +import { ConfigMerger } from '../../config/merger'; import { createTelegramBotAPI } from '../api'; +import { chatWithLLM } from '../handler/chat'; import { MessageSender } from '../utils/send'; -import { ConfigMerger } from '../../config/merger'; -import { ENV, ENV_KEY_MAPPER } from '../../config/env'; -import type { CommandHandler } from './types'; +import { isTelegramChatTypeGroup } from '../utils/utils'; export const COMMAND_AUTH_CHECKER = { default(chatType: string): string[] | null { diff --git a/src/telegram/handler/chat.ts b/src/telegram/handler/chat.ts index d1646976..df3703d0 100644 --- a/src/telegram/handler/chat.ts +++ b/src/telegram/handler/chat.ts @@ -1,13 +1,13 @@ import type * as Telegram from 'telegram-bot-api-types'; -import { loadChatLLM } from '../../agent'; import type { StreamResultHandler } from '../../agent/chat'; -import { requestCompletionsFromLLM } from '../../agent/chat'; import type { HistoryModifier, LLMChatRequestParams } from '../../agent/types'; import type { WorkerContext } from '../../config/context'; -import { MessageSender } from '../utils/send'; -import { createTelegramBotAPI } from '../api'; -import { ENV } from '../../config/env'; import type { MessageHandler } from './types'; +import { loadChatLLM } from '../../agent'; +import { requestCompletionsFromLLM } from '../../agent/chat'; +import { ENV } from '../../config/env'; +import { createTelegramBotAPI } from '../api'; +import { MessageSender } from '../utils/send'; export async function chatWithLLM(message: Telegram.Message, params: LLMChatRequestParams, context: WorkerContext, modifier: HistoryModifier | null): Promise { const sender = MessageSender.from(context.SHARE_CONTEXT.botToken, message); diff --git a/src/telegram/handler/group.ts b/src/telegram/handler/group.ts index b990c62b..6d3515b0 100644 --- a/src/telegram/handler/group.ts +++ b/src/telegram/handler/group.ts @@ -1,9 +1,9 @@ import type * as Telegram from 'telegram-bot-api-types'; import type { WorkerContext } from '../../config/context'; -import { isTelegramChatTypeGroup } from '../utils/utils'; -import { createTelegramBotAPI } from '../api'; -import { ENV } from '../../config/env'; import type { MessageHandler } from './types'; +import { ENV } from '../../config/env'; +import { createTelegramBotAPI } from '../api'; +import { isTelegramChatTypeGroup } from '../utils/utils'; function checkMention(content: string, entities: Telegram.MessageEntity[], botName: string, botId: number): { isMention: boolean; diff --git a/src/telegram/handler/handlers.ts b/src/telegram/handler/handlers.ts index 5fdd3c8f..c6228d5c 100644 --- a/src/telegram/handler/handlers.ts +++ b/src/telegram/handler/handlers.ts @@ -1,10 +1,10 @@ import type * as Telegram from 'telegram-bot-api-types'; import type { WorkerContext } from '../../config/context'; +import type { MessageHandler } from './types'; +import { ENV } from '../../config/env'; import { handleCommandMessage } from '../command'; import { MessageSender } from '../utils/send'; import { isTelegramChatTypeGroup } from '../utils/utils'; -import { ENV } from '../../config/env'; -import type { MessageHandler } from './types'; export class SaveLastMessage implements MessageHandler { handle = async (message: Telegram.Message, context: WorkerContext): Promise => { diff --git a/src/telegram/handler/index.ts b/src/telegram/handler/index.ts index a376aa65..558d9bb0 100644 --- a/src/telegram/handler/index.ts +++ b/src/telegram/handler/index.ts @@ -1,8 +1,8 @@ import type * as Telegram from 'telegram-bot-api-types'; +import type { MessageHandler } from './types'; import { WorkerContext } from '../../config/context'; import { ChatHandler } from './chat'; import { GroupMention } from './group'; -import type { MessageHandler } from './types'; import { CommandHandler, EnvChecker, diff --git a/src/telegram/utils/send.ts b/src/telegram/utils/send.ts index 5c322aa3..d5cea9db 100644 --- a/src/telegram/utils/send.ts +++ b/src/telegram/utils/send.ts @@ -1,7 +1,7 @@ import type * as Telegram from 'telegram-bot-api-types'; import type { TelegramBotAPI } from '../api'; -import { createTelegramBotAPI } from '../api'; import { ENV } from '../../config/env'; +import { createTelegramBotAPI } from '../api'; import { escape } from './md2tgmd'; class MessageContext implements Record { diff --git a/vite.config.ts b/vite.config.ts index c302bccf..01bc6534 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,13 +1,13 @@ -import * as path from 'node:path'; import type { LibraryFormats, Plugin } from 'vite'; -import { defineConfig } from 'vite'; +import * as path from 'node:path'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import cleanup from 'rollup-plugin-cleanup'; -import checker from 'vite-plugin-checker'; import nodeExternals from 'rollup-plugin-node-externals'; +import { defineConfig } from 'vite'; +import checker from 'vite-plugin-checker'; import dts from 'vite-plugin-dts'; -import { createVersionPlugin, versionDefine } from './scripts/plugins/version'; import { createDockerPlugin } from './scripts/plugins/docker'; +import { createVersionPlugin, versionDefine } from './scripts/plugins/version'; const { BUILD_MODE } = process.env; const plugins: Plugin[] = [ diff --git a/yarn.lock b/yarn.lock index fb2a0b26..fce75f59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,29 +3,29 @@ "@antfu/eslint-config@^3.6.2": - version "3.6.2" - resolved "https://registry.yarnpkg.com/@antfu/eslint-config/-/eslint-config-3.6.2.tgz#daacf2384922e8e40125eaa3135eb55d868c0949" - integrity sha512-cewFaIEuSSOjbIsNts8gjeMLQrrMDhZjZJHMWk+OyVGJLHRE09JiF5Yg5+XjMVYlG/7fPqeuwEehLrer+8zMfA== + version "3.7.3" + resolved "https://registry.yarnpkg.com/@antfu/eslint-config/-/eslint-config-3.7.3.tgz#74c12acd8a7b2480ce07fe91e34472d16af779dd" + integrity sha512-vzhKtzQT+f/xBV8T5U8SFy3D7uAqL2CEcjsJVqtA7F8tdKvGuC/96uWeEKMHk5lRfijgj+xRvb+c4qQn60YlIA== dependencies: "@antfu/install-pkg" "^0.4.1" "@clack/prompts" "^0.7.0" "@eslint-community/eslint-plugin-eslint-comments" "^4.4.0" "@eslint/markdown" "^6.1.0" "@stylistic/eslint-plugin" "^2.8.0" - "@typescript-eslint/eslint-plugin" "^8.5.0" - "@typescript-eslint/parser" "^8.5.0" + "@typescript-eslint/eslint-plugin" "^8.7.0" + "@typescript-eslint/parser" "^8.7.0" "@vitest/eslint-plugin" "^1.1.4" eslint-config-flat-gitignore "^0.3.0" eslint-flat-config-utils "^0.4.0" eslint-merge-processors "^0.1.0" - eslint-plugin-antfu "^2.6.0" - eslint-plugin-command "^0.2.5" - eslint-plugin-import-x "^4.2.1" - eslint-plugin-jsdoc "^50.2.3" + eslint-plugin-antfu "^2.7.0" + eslint-plugin-command "^0.2.6" + eslint-plugin-import-x "^4.3.0" + eslint-plugin-jsdoc "^50.3.0" eslint-plugin-jsonc "^2.16.0" - eslint-plugin-n "^17.10.2" + eslint-plugin-n "^17.10.3" eslint-plugin-no-only-tests "^3.3.0" - eslint-plugin-perfectionist "^3.6.0" + eslint-plugin-perfectionist "^3.7.0" eslint-plugin-regexp "^2.6.0" eslint-plugin-toml "^0.11.1" eslint-plugin-unicorn "^55.0.0" @@ -84,17 +84,17 @@ js-tokens "^4.0.0" picocolors "^1.0.0" -"@babel/parser@^7.24.7": - version "7.25.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.4.tgz#af4f2df7d02440286b7de57b1c21acfb2a6f257a" - integrity sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA== +"@babel/parser@^7.25.3": + version "7.25.6" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.6.tgz#85660c5ef388cbbf6e3d2a694ee97a38f18afe2f" + integrity sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q== dependencies: - "@babel/types" "^7.25.4" + "@babel/types" "^7.25.6" -"@babel/types@^7.25.4": - version "7.25.4" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.4.tgz#6bcb46c72fdf1012a209d016c07f769e10adcb5f" - integrity sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ== +"@babel/types@^7.25.6": + version "7.25.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.6.tgz#893942ddb858f32ae7a004ec9d3a76b3463ef8e6" + integrity sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw== dependencies: "@babel/helper-string-parser" "^7.24.8" "@babel/helper-validator-identifier" "^7.24.7" @@ -124,35 +124,35 @@ dependencies: mime "^3.0.0" -"@cloudflare/workerd-darwin-64@1.20240909.0": - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240909.0.tgz#b207ebf5203530e50f76605f1407bd3dc24cee02" - integrity sha512-nJ8jm/6PR8DPzVb4QifNAfSdrFZXNblwIdOhLTU5FpSvFFocmzFX5WgzQagvtmcC9/ZAQyxuf7WynDNyBcoe0Q== +"@cloudflare/workerd-darwin-64@1.20240925.0": + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240925.0.tgz#f78fe394f73540594609d8e05a2da7feb46c76c0" + integrity sha512-KdLnSXuzB65CbqZPm+qYzk+zkQ1tUNPaaRGYVd/jPYAxwwtfTUQdQ+ahDPwVVs2tmQELKy7ZjQjf2apqSWUfjw== -"@cloudflare/workerd-darwin-arm64@1.20240909.0": - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240909.0.tgz#b7eff16053bb2c49bfb3e48333cf42aeb057266a" - integrity sha512-gJqKa811oSsoxy9xuoQn7bS0Hr1sY+o3EUORTcEnulG6Kz9NQ6nd8QNdp2Hrk2jmmSqwrNkn+a6PZkWzk6Q0Gw== +"@cloudflare/workerd-darwin-arm64@1.20240925.0": + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240925.0.tgz#f03b17177744ad898bb12610d15cc0a9744abfe6" + integrity sha512-MiQ6uUmCXjsXgWNV+Ock2tp2/tYqNJGzjuaH6jFioeRF+//mz7Tv7J7EczOL4zq+TH8QFOh0/PUsLyazIWVGng== -"@cloudflare/workerd-linux-64@1.20240909.0": - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240909.0.tgz#8c2dc55efe87853144b777f82f3cc6ca92bc2640" - integrity sha512-sJrmtccfMg73sZljiBpe4R+lhF58TqzqhF2pQG8HRjyxkzkM1sjpZqfEFaIkNUDqd3/Ibji49fklhPCGXljKSg== +"@cloudflare/workerd-linux-64@1.20240925.0": + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240925.0.tgz#fe0366b804b957acf5012d889e94163bab806a57" + integrity sha512-Rjix8jsJMfsInmq3Hm3fmiRQ+rwzuWRPV1pg/OWhMSfNP7Qp2RCU+RGkhgeR9Z5eNAje0Sn2BMrFq4RvF9/yRA== -"@cloudflare/workerd-linux-arm64@1.20240909.0": - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240909.0.tgz#5763deb1604c9d714fab3c2ec7a3c19a1dd9445f" - integrity sha512-dTbSdceyRXPOSER+18AwYRbPQG0e/Dwl2trmfMMCETkfJhNLv1fU3FFMJPjfILijKnhTZHSnHCx0+xwHdon2fg== +"@cloudflare/workerd-linux-arm64@1.20240925.0": + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240925.0.tgz#fcf82de06def420972c661a6021c87683cd8fbdc" + integrity sha512-VYIPeMHQRtbwQoIjUwS/zULlywPxyDvo46XkTpIW5MScEChfqHvAYviQ7TzYGx6Q+gmZmN+DUB2KOMx+MEpCxA== -"@cloudflare/workerd-windows-64@1.20240909.0": - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240909.0.tgz#ae5f91e3f072b2a091f9180406e61f3e4e6a9aa0" - integrity sha512-/d4BT0kcWFa7Qc0K4K9+cwVQ1qyPNKiO42JZUijlDlco+TYTPkLO3qGEohmwbfMq+BieK7JTMSgjO81ZHpA0HQ== +"@cloudflare/workerd-windows-64@1.20240925.0": + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240925.0.tgz#0a5c82b95b03a94591cc8a1830f28d2e41ff7685" + integrity sha512-C8peGvaU5R51bIySi1VbyfRgwNSSRknqoFSnSbSBI3uTN3THTB3UnmRKy7GXJDmyjgXuT9Pcs1IgaWNubLtNtw== -"@cloudflare/workers-shared@0.5.3": - version "0.5.3" - resolved "https://registry.yarnpkg.com/@cloudflare/workers-shared/-/workers-shared-0.5.3.tgz#013be52f7934bc9999085b9cbad28c06003f1471" - integrity sha512-Yk5Im7zsyKbzd7qi+DrL7ZJR9+bdZwq9BqZWS4muDIWA8MCUeSLsUC+C9u+jdwfPSi5It2AcQG4f0iwZr6jkkQ== +"@cloudflare/workers-shared@0.5.4": + version "0.5.4" + resolved "https://registry.yarnpkg.com/@cloudflare/workers-shared/-/workers-shared-0.5.4.tgz#bbf8f03b79a6bc0169ad66a6015ebe579d36753a" + integrity sha512-PNL/0TjKRdUHa1kwgVdqUNJVZ9ez4kacsi8omz+gv859EvJmsVuGiMAClY2YfJnC9LVKhKCcjqmFgKNXG9/IXA== dependencies: mime "^3.0.0" zod "^3.22.3" @@ -589,9 +589,9 @@ eslint-visitor-keys "^3.3.0" "@eslint-community/regexpp@^4.10.0", "@eslint-community/regexpp@^4.11.0", "@eslint-community/regexpp@^4.8.0", "@eslint-community/regexpp@^4.9.1": - version "4.11.0" - resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.0.tgz#b0ffd0312b4a3fd2d6f77237e7248a5ad3a680ae" - integrity sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A== + version "4.11.1" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.1.tgz#a547badfc719eb3e5f4b556325e542fbe9d7a18f" + integrity sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q== "@eslint/compat@^1.1.1": version "1.1.1" @@ -607,6 +607,11 @@ debug "^4.3.1" minimatch "^3.1.2" +"@eslint/core@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.6.0.tgz#9930b5ba24c406d67a1760e94cdbac616a6eb674" + integrity sha512-8I2Q8ykA4J0x0o7cg67FPVnehcqWTBehu/lmY+bolPFHGjh49YzGBMXTvpqVgEbBdvNCSxj6iFgiIyHzf03lzg== + "@eslint/eslintrc@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.1.0.tgz#dbd3482bfd91efa663cbe7aa1f506839868207b6" @@ -622,16 +627,17 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.10.0": - version "9.10.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.10.0.tgz#eaa3cb0baec497970bb29e43a153d0d5650143c6" - integrity sha512-fuXtbiP5GWIn8Fz+LWoOMVf/Jxm+aajZYkhi6CuEm4SxymFM+eUWzbO9qXT+L0iCkL5+KGYMCSGxo686H19S1g== +"@eslint/js@9.11.1": + version "9.11.1" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.11.1.tgz#8bcb37436f9854b3d9a561440daf916acd940986" + integrity sha512-/qu+TWz8WwPWc7/HcIJKi+c+MOm46GdVaSlTTQcaqaL53+GsoA6MxWp5PtTx48qbSP7ylM1Kn7nhvkugfJvRSA== "@eslint/markdown@^6.1.0": - version "6.1.0" - resolved "https://registry.yarnpkg.com/@eslint/markdown/-/markdown-6.1.0.tgz#30388d83cd6e97299972997caf88b18b43d33927" - integrity sha512-cX1tyD+aIbhzKrCKe/9M5s2jZhldWGOR+cy7cIVpxG9RkoaN4XU+gG3dy6oEKtBFXjDx06GtP0OGO7jgbqa2DA== + version "6.1.1" + resolved "https://registry.yarnpkg.com/@eslint/markdown/-/markdown-6.1.1.tgz#5f496330905cebe1c964d9ccb93fe8be493ac380" + integrity sha512-Z+1js5AeqidwhNBbnIPM6Fn4eY9D5i1NleamS0UBW6BG0J4lpvhIVOKVIi22kmH5gvxDmHUp5MHkkkjda0TehA== dependencies: + "@eslint/plugin-kit" "^0.2.0" mdast-util-from-markdown "^2.0.1" mdast-util-gfm "^3.0.0" micromark-extension-gfm "^3.0.0" @@ -641,10 +647,10 @@ resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.4.tgz#9e69f8bb4031e11df79e03db09f9dbbae1740843" integrity sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ== -"@eslint/plugin-kit@^0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.1.0.tgz#809b95a0227ee79c3195adfb562eb94352e77974" - integrity sha512-autAXT203ixhqei9xt+qkYOvY8l6LAFIdT2UXc/RPNeUVfqRF1BV94GTJyVPFKT8nFM6MyVJhjLj9E8JWvf5zQ== +"@eslint/plugin-kit@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.2.0.tgz#8712dccae365d24e9eeecb7b346f85e750ba343d" + integrity sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig== dependencies: levn "^0.4.1" @@ -792,14 +798,13 @@ integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== "@rollup/plugin-node-resolve@^15.2.3": - version "15.2.3" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz#e5e0b059bd85ca57489492f295ce88c2d4b0daf9" - integrity sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ== + version "15.3.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.0.tgz#efbb35515c9672e541c08d59caba2eff492a55d5" + integrity sha512-9eO5McEICxMzJpDW9OnMYSv4Sta3hmt7VtBFz5zR9273suNOydOyq/FrGeGy+KsTRFm8w0SLVhzig2ILFT63Ag== dependencies: "@rollup/pluginutils" "^5.0.1" "@types/resolve" "1.20.2" deepmerge "^4.2.2" - is-builtin-module "^3.2.1" is-module "^1.0.0" resolve "^1.22.1" @@ -812,93 +817,93 @@ picomatch "^2.2.2" "@rollup/pluginutils@^5.0.1", "@rollup/pluginutils@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0" - integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g== + version "5.1.2" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.2.tgz#d3bc9f0fea4fd4086aaac6aa102f3fa587ce8bd9" + integrity sha512-/FIdS3PyZ39bjZlwqFnWqCOVnW7o963LtKMwQOD0NhQqw22gSr2YY1afu3FxRip4ZCZNsD5jq6Aaz6QV3D/Njw== dependencies: "@types/estree" "^1.0.0" estree-walker "^2.0.2" picomatch "^2.3.1" -"@rollup/rollup-android-arm-eabi@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz#8b613b9725e8f9479d142970b106b6ae878610d5" - integrity sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w== - -"@rollup/rollup-android-arm64@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz#654ca1049189132ff602bfcf8df14c18da1f15fb" - integrity sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA== - -"@rollup/rollup-darwin-arm64@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz#6d241d099d1518ef0c2205d96b3fa52e0fe1954b" - integrity sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q== - -"@rollup/rollup-darwin-x64@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz#42bd19d292a57ee11734c980c4650de26b457791" - integrity sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw== - -"@rollup/rollup-linux-arm-gnueabihf@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz#f23555ee3d8fe941c5c5fd458cd22b65eb1c2232" - integrity sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ== - -"@rollup/rollup-linux-arm-musleabihf@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz#f3bbd1ae2420f5539d40ac1fde2b38da67779baa" - integrity sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg== - -"@rollup/rollup-linux-arm64-gnu@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz#7abe900120113e08a1f90afb84c7c28774054d15" - integrity sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw== - -"@rollup/rollup-linux-arm64-musl@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz#9e655285c8175cd44f57d6a1e8e5dedfbba1d820" - integrity sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA== - -"@rollup/rollup-linux-powerpc64le-gnu@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz#9a79ae6c9e9d8fe83d49e2712ecf4302db5bef5e" - integrity sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg== - -"@rollup/rollup-linux-riscv64-gnu@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz#67ac70eca4ace8e2942fabca95164e8874ab8128" - integrity sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA== - -"@rollup/rollup-linux-s390x-gnu@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz#9f883a7440f51a22ed7f99e1d070bd84ea5005fc" - integrity sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q== - -"@rollup/rollup-linux-x64-gnu@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz#70116ae6c577fe367f58559e2cffb5641a1dd9d0" - integrity sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg== - -"@rollup/rollup-linux-x64-musl@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz#f473f88219feb07b0b98b53a7923be716d1d182f" - integrity sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g== - -"@rollup/rollup-win32-arm64-msvc@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz#4349482d17f5d1c58604d1c8900540d676f420e0" - integrity sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw== - -"@rollup/rollup-win32-ia32-msvc@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz#a6fc39a15db618040ec3c2a24c1e26cb5f4d7422" - integrity sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g== - -"@rollup/rollup-win32-x64-msvc@4.22.4": - version "4.22.4" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz#3dd5d53e900df2a40841882c02e56f866c04d202" - integrity sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q== +"@rollup/rollup-android-arm-eabi@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.5.tgz#e0f5350845090ca09690fe4a472717f3b8aae225" + integrity sha512-SU5cvamg0Eyu/F+kLeMXS7GoahL+OoizlclVFX3l5Ql6yNlywJJ0OuqTzUx0v+aHhPHEB/56CT06GQrRrGNYww== + +"@rollup/rollup-android-arm64@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.5.tgz#08270faef6747e2716d3e978a8bbf479f75fb19a" + integrity sha512-S4pit5BP6E5R5C8S6tgU/drvgjtYW76FBuG6+ibG3tMvlD1h9LHVF9KmlmaUBQ8Obou7hEyS+0w+IR/VtxwNMQ== + +"@rollup/rollup-darwin-arm64@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.5.tgz#691671133b350661328d42c8dbdedd56dfb97dfd" + integrity sha512-250ZGg4ipTL0TGvLlfACkIxS9+KLtIbn7BCZjsZj88zSg2Lvu3Xdw6dhAhfe/FjjXPVNCtcSp+WZjVsD3a/Zlw== + +"@rollup/rollup-darwin-x64@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.5.tgz#b2ec52a1615f24b1cd40bc8906ae31af81e8a342" + integrity sha512-D8brJEFg5D+QxFcW6jYANu+Rr9SlKtTenmsX5hOSzNYVrK5oLAEMTUgKWYJP+wdKyCdeSwnapLsn+OVRFycuQg== + +"@rollup/rollup-linux-arm-gnueabihf@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.5.tgz#217f01f304808920680bd269002df38e25d9205f" + integrity sha512-PNqXYmdNFyWNg0ma5LdY8wP+eQfdvyaBAojAXgO7/gs0Q/6TQJVXAXe8gwW9URjbS0YAammur0fynYGiWsKlXw== + +"@rollup/rollup-linux-arm-musleabihf@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.5.tgz#93ac1c5a1e389f4482a2edaeec41fcffee54a930" + integrity sha512-kSSCZOKz3HqlrEuwKd9TYv7vxPYD77vHSUvM2y0YaTGnFc8AdI5TTQRrM1yIp3tXCKrSL9A7JLoILjtad5t8pQ== + +"@rollup/rollup-linux-arm64-gnu@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.5.tgz#a7f146787d6041fecc4ecdf1aa72234661ca94a4" + integrity sha512-oTXQeJHRbOnwRnRffb6bmqmUugz0glXaPyspp4gbQOPVApdpRrY/j7KP3lr7M8kTfQTyrBUzFjj5EuHAhqH4/w== + +"@rollup/rollup-linux-arm64-musl@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.5.tgz#6a37236189648e678bd564d6e8ca798f42cf42c5" + integrity sha512-qnOTIIs6tIGFKCHdhYitgC2XQ2X25InIbZFor5wh+mALH84qnFHvc+vmWUpyX97B0hNvwNUL4B+MB8vJvH65Fw== + +"@rollup/rollup-linux-powerpc64le-gnu@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.5.tgz#5661420dc463bec31ecb2d17d113de858cfcfe2d" + integrity sha512-TMYu+DUdNlgBXING13rHSfUc3Ky5nLPbWs4bFnT+R6Vu3OvXkTkixvvBKk8uO4MT5Ab6lC3U7x8S8El2q5o56w== + +"@rollup/rollup-linux-riscv64-gnu@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.5.tgz#cb00342b7432bdef723aa606281de2f522d6dcf7" + integrity sha512-PTQq1Kz22ZRvuhr3uURH+U/Q/a0pbxJoICGSprNLAoBEkyD3Sh9qP5I0Asn0y0wejXQBbsVMRZRxlbGFD9OK4A== + +"@rollup/rollup-linux-s390x-gnu@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.5.tgz#0708889674dccecccd28e2befccf791e0767fcb7" + integrity sha512-bR5nCojtpuMss6TDEmf/jnBnzlo+6n1UhgwqUvRoe4VIotC7FG1IKkyJbwsT7JDsF2jxR+NTnuOwiGv0hLyDoQ== + +"@rollup/rollup-linux-x64-gnu@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.5.tgz#a135b040b21582e91cfed2267ccfc7d589e1dbc6" + integrity sha512-N0jPPhHjGShcB9/XXZQWuWBKZQnC1F36Ce3sDqWpujsGjDz/CQtOL9LgTrJ+rJC8MJeesMWrMWVLKKNR/tMOCA== + +"@rollup/rollup-linux-x64-musl@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.5.tgz#88395a81a3ab7ee3dc8dc31a73ff62ed3185f34d" + integrity sha512-uBa2e28ohzNNwjr6Uxm4XyaA1M/8aTgfF2T7UIlElLaeXkgpmIJ2EitVNQxjO9xLLLy60YqAgKn/AqSpCUkE9g== + +"@rollup/rollup-win32-arm64-msvc@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.5.tgz#12ee49233b1125f2c1da38392f63b1dbb0c31bba" + integrity sha512-RXT8S1HP8AFN/Kr3tg4fuYrNxZ/pZf1HemC5Tsddc6HzgGnJm0+Lh5rAHJkDuW3StI0ynNXukidROMXYl6ew8w== + +"@rollup/rollup-win32-ia32-msvc@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.5.tgz#0f987b134c6b3123c22842b33ba0c2b6fb78cc3b" + integrity sha512-ElTYOh50InL8kzyUD6XsnPit7jYCKrphmddKAe1/Ytt74apOxDq5YEcbsiKs0fR3vff3jEneMM+3I7jbqaMyBg== + +"@rollup/rollup-win32-x64-msvc@4.22.5": + version "4.22.5" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.5.tgz#f2feb149235a5dc1deb5439758f8871255e5a161" + integrity sha512-+lvL/4mQxSV8MukpkKyyvfwhH266COcWlXE/1qxwN08ajovta3459zrjLghYMgDerlzNwLAcFpvU+WWE5y6nAQ== "@rushstack/node-core-library@5.7.0": version "5.7.0" @@ -998,12 +1003,12 @@ dependencies: "@types/ms" "*" -"@types/estree@1.0.5", "@types/estree@^1.0.0": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" - integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/estree@1.0.6", "@types/estree@^1.0.0", "@types/estree@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== -"@types/json-schema@^7.0.6": +"@types/json-schema@^7.0.15", "@types/json-schema@^7.0.6": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -1027,10 +1032,10 @@ dependencies: "@types/node" "*" -"@types/node@*": - version "22.5.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.0.tgz#10f01fe9465166b4cab72e75f60d8b99d019f958" - integrity sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg== +"@types/node@*", "@types/node@^22.5.5": + version "22.7.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc" + integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg== dependencies: undici-types "~6.19.2" @@ -1039,13 +1044,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.11.tgz#cbb15c12ca7c16c85a72b6bdc4d4b01151bb3cae" integrity sha512-3oJbGBUWuS6ahSnEq1eN2XrCyf4YsWI8OyCvo7c64zQJNplk3mO84t53o8lfTk+2ji59g5ycfc6qQ3fdHliHuA== -"@types/node@^22.5.5": - version "22.5.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44" - integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA== - dependencies: - undici-types "~6.19.2" - "@types/normalize-package-data@^2.4.0": version "2.4.4" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz#56e2cc26c397c038fab0e3a917a12d5c5909e901" @@ -1061,89 +1059,62 @@ resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.3.tgz#acaab0f919ce69cce629c2d4ed2eb4adc1b6c20c" integrity sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q== -"@typescript-eslint/eslint-plugin@^8.5.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.6.0.tgz#20049754ff9f6d3a09bf240297f029ce04290999" - integrity sha512-UOaz/wFowmoh2G6Mr9gw60B1mm0MzUtm6Ic8G2yM1Le6gyj5Loi/N+O5mocugRGY+8OeeKmkMmbxNqUCq3B4Sg== +"@typescript-eslint/eslint-plugin@^8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.7.0.tgz#d0070f206daad26253bf00ca5b80f9b54f9e2dd0" + integrity sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A== dependencies: "@eslint-community/regexpp" "^4.10.0" - "@typescript-eslint/scope-manager" "8.6.0" - "@typescript-eslint/type-utils" "8.6.0" - "@typescript-eslint/utils" "8.6.0" - "@typescript-eslint/visitor-keys" "8.6.0" + "@typescript-eslint/scope-manager" "8.7.0" + "@typescript-eslint/type-utils" "8.7.0" + "@typescript-eslint/utils" "8.7.0" + "@typescript-eslint/visitor-keys" "8.7.0" graphemer "^1.4.0" ignore "^5.3.1" natural-compare "^1.4.0" ts-api-utils "^1.3.0" -"@typescript-eslint/parser@^8.5.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.6.0.tgz#02e092b9dc8b4e319172af620d0d39b337d948f6" - integrity sha512-eQcbCuA2Vmw45iGfcyG4y6rS7BhWfz9MQuk409WD47qMM+bKCGQWXxvoOs1DUp+T7UBMTtRTVT+kXr7Sh4O9Ow== +"@typescript-eslint/parser@^8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.7.0.tgz#a567b0890d13db72c7348e1d88442ea8ab4e9173" + integrity sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ== dependencies: - "@typescript-eslint/scope-manager" "8.6.0" - "@typescript-eslint/types" "8.6.0" - "@typescript-eslint/typescript-estree" "8.6.0" - "@typescript-eslint/visitor-keys" "8.6.0" + "@typescript-eslint/scope-manager" "8.7.0" + "@typescript-eslint/types" "8.7.0" + "@typescript-eslint/typescript-estree" "8.7.0" + "@typescript-eslint/visitor-keys" "8.7.0" debug "^4.3.4" -"@typescript-eslint/scope-manager@8.2.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.2.0.tgz#4a4bd7e7df5522acc8795c3b6f21e8c41b951138" - integrity sha512-OFn80B38yD6WwpoHU2Tz/fTz7CgFqInllBoC3WP+/jLbTb4gGPTy9HBSTsbDWkMdN55XlVU0mMDYAtgvlUspGw== - dependencies: - "@typescript-eslint/types" "8.2.0" - "@typescript-eslint/visitor-keys" "8.2.0" - -"@typescript-eslint/scope-manager@8.6.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.6.0.tgz#28cc2fc26a84b75addf45091a2c6283e29e2c982" - integrity sha512-ZuoutoS5y9UOxKvpc/GkvF4cuEmpokda4wRg64JEia27wX+PysIE9q+lzDtlHHgblwUWwo5/Qn+/WyTUvDwBHw== +"@typescript-eslint/scope-manager@8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz#90ee7bf9bc982b9260b93347c01a8bc2b595e0b8" + integrity sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg== dependencies: - "@typescript-eslint/types" "8.6.0" - "@typescript-eslint/visitor-keys" "8.6.0" + "@typescript-eslint/types" "8.7.0" + "@typescript-eslint/visitor-keys" "8.7.0" -"@typescript-eslint/type-utils@8.6.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.6.0.tgz#d4347e637478bef88cee1db691fcfa20ade9b8a0" - integrity sha512-dtePl4gsuenXVwC7dVNlb4mGDcKjDT/Ropsk4za/ouMBPplCLyznIaR+W65mvCvsyS97dymoBRrioEXI7k0XIg== +"@typescript-eslint/type-utils@8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.7.0.tgz#d56b104183bdcffcc434a23d1ce26cde5e42df93" + integrity sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ== dependencies: - "@typescript-eslint/typescript-estree" "8.6.0" - "@typescript-eslint/utils" "8.6.0" + "@typescript-eslint/typescript-estree" "8.7.0" + "@typescript-eslint/utils" "8.7.0" debug "^4.3.4" ts-api-utils "^1.3.0" -"@typescript-eslint/types@8.2.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.2.0.tgz#dfe9895a2812f7c6bf7af863054c22a67060420c" - integrity sha512-6a9QSK396YqmiBKPkJtxsgZZZVjYQ6wQ/TlI0C65z7vInaETuC6HAHD98AGLC8DyIPqHytvNuS8bBVvNLKyqvQ== +"@typescript-eslint/types@8.7.0", "@typescript-eslint/types@^8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.7.0.tgz#21d987201c07b69ce7ddc03451d7196e5445ad19" + integrity sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w== -"@typescript-eslint/types@8.6.0", "@typescript-eslint/types@^8.5.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.6.0.tgz#cdc3a16f83f2f0663d6723e9fd032331cdd9f51c" - integrity sha512-rojqFZGd4MQxw33SrOy09qIDS8WEldM8JWtKQLAjf/X5mGSeEFh5ixQlxssMNyPslVIk9yzWqXCsV2eFhYrYUw== - -"@typescript-eslint/typescript-estree@8.2.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.2.0.tgz#fbdb93a1c7ac7f1f96ae2de4fc97cd64c60ae894" - integrity sha512-kiG4EDUT4dImplOsbh47B1QnNmXSoUqOjWDvCJw/o8LgfD0yr7k2uy54D5Wm0j4t71Ge1NkynGhpWdS0dEIAUA== +"@typescript-eslint/typescript-estree@8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz#6c7db6baa4380b937fa81466c546d052f362d0e8" + integrity sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg== dependencies: - "@typescript-eslint/types" "8.2.0" - "@typescript-eslint/visitor-keys" "8.2.0" - debug "^4.3.4" - globby "^11.1.0" - is-glob "^4.0.3" - minimatch "^9.0.4" - semver "^7.6.0" - ts-api-utils "^1.3.0" - -"@typescript-eslint/typescript-estree@8.6.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.6.0.tgz#f945506de42871f04868371cb5bf21e8f7266e01" - integrity sha512-MOVAzsKJIPIlLK239l5s06YXjNqpKTVhBVDnqUumQJja5+Y94V3+4VUFRA0G60y2jNnTVwRCkhyGQpavfsbq/g== - dependencies: - "@typescript-eslint/types" "8.6.0" - "@typescript-eslint/visitor-keys" "8.6.0" + "@typescript-eslint/types" "8.7.0" + "@typescript-eslint/visitor-keys" "8.7.0" debug "^4.3.4" fast-glob "^3.3.2" is-glob "^4.0.3" @@ -1151,40 +1122,22 @@ semver "^7.6.0" ts-api-utils "^1.3.0" -"@typescript-eslint/utils@8.6.0", "@typescript-eslint/utils@^8.4.0", "@typescript-eslint/utils@^8.5.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.6.0.tgz#175fe893f32804bed1e72b3364ea6bbe1044181c" - integrity sha512-eNp9cWnYf36NaOVjkEUznf6fEgVy1TWpE0o52e4wtojjBx7D1UV2WAWGzR+8Y5lVFtpMLPwNbC67T83DWSph4A== - dependencies: - "@eslint-community/eslint-utils" "^4.4.0" - "@typescript-eslint/scope-manager" "8.6.0" - "@typescript-eslint/types" "8.6.0" - "@typescript-eslint/typescript-estree" "8.6.0" - -"@typescript-eslint/utils@^8.1.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.2.0.tgz#02d442285925f28d520587185f295f932702e733" - integrity sha512-O46eaYKDlV3TvAVDNcoDzd5N550ckSe8G4phko++OCSC1dYIb9LTc3HDGYdWqWIAT5qDUKphO6sd9RrpIJJPfg== +"@typescript-eslint/utils@8.7.0", "@typescript-eslint/utils@^8.1.0", "@typescript-eslint/utils@^8.4.0", "@typescript-eslint/utils@^8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.7.0.tgz#cef3f70708b5b5fd7ed8672fc14714472bd8a011" + integrity sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw== dependencies: "@eslint-community/eslint-utils" "^4.4.0" - "@typescript-eslint/scope-manager" "8.2.0" - "@typescript-eslint/types" "8.2.0" - "@typescript-eslint/typescript-estree" "8.2.0" + "@typescript-eslint/scope-manager" "8.7.0" + "@typescript-eslint/types" "8.7.0" + "@typescript-eslint/typescript-estree" "8.7.0" -"@typescript-eslint/visitor-keys@8.2.0": - version "8.2.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.2.0.tgz#f6abb3b6508898a117175ddc11f9b9869cc96834" - integrity sha512-sbgsPMW9yLvS7IhCi8IpuK1oBmtbWUNP+hBdwl/I9nzqVsszGnNGti5r9dUtF5RLivHUFFIdRvLiTsPhzSyJ3Q== +"@typescript-eslint/visitor-keys@8.7.0": + version "8.7.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz#5e46f1777f9d69360a883c1a56ac3c511c9659a8" + integrity sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ== dependencies: - "@typescript-eslint/types" "8.2.0" - eslint-visitor-keys "^3.4.3" - -"@typescript-eslint/visitor-keys@8.6.0": - version "8.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.6.0.tgz#5432af4a1753f376f35ab5b891fc9db237aaf76f" - integrity sha512-wapVFfZg9H0qOYh4grNVQiMklJGluQrOUiOhYRrQWhx7BY/+I1IYb8BczWNbbUpO+pqy0rDciv3lQH5E1bCLrg== - dependencies: - "@typescript-eslint/types" "8.6.0" + "@typescript-eslint/types" "8.7.0" eslint-visitor-keys "^3.4.3" "@upstash/redis@^1.34.0": @@ -1194,10 +1147,10 @@ dependencies: crypto-js "^4.2.0" -"@vercel/build-utils@8.4.2": - version "8.4.2" - resolved "https://registry.yarnpkg.com/@vercel/build-utils/-/build-utils-8.4.2.tgz#f1afa3c9df53577cdbfdd69888faad17a552d8e1" - integrity sha512-Bern3FVvUgMu8YGuP+cYSTDaUA5Kn6HsMU75osWK6npS5Sw4K9zaY+cxONDMrzo/08Kvz5vgSRnwmq+P1MYq2g== +"@vercel/build-utils@8.4.5": + version "8.4.5" + resolved "https://registry.yarnpkg.com/@vercel/build-utils/-/build-utils-8.4.5.tgz#f530b4ec9a63a07b7b0a86ea26c5f73197434a1f" + integrity sha512-uqnc1OIA+CB4oIqsfQpn/7DCeUo9mO2TjoQLTdWEgYwb/PBkI25jJLB3oq4X6yKCnSFSTb1zoHdqkroWLCNsIw== "@vercel/error-utils@2.0.2": version "2.0.2" @@ -1223,15 +1176,15 @@ resolve-from "^5.0.0" "@vercel/node@^3.2.14": - version "3.2.14" - resolved "https://registry.yarnpkg.com/@vercel/node/-/node-3.2.14.tgz#bc44238c4a18aa43768b130b6e586ce0fbfb2ec2" - integrity sha512-aZFJgqem1YI3E7gvuVG/Jy4k8j19BjEQkexmnFv0nEieKuzHgTC8AzcgZQu8laEDVkpnOe+zlpmXZZBxTsvLuA== + version "3.2.17" + resolved "https://registry.yarnpkg.com/@vercel/node/-/node-3.2.17.tgz#8ebfea8750725bd57000ec459f2088a672237c91" + integrity sha512-TaT2ieOqq4dvi44g1S073MsP4+D+KRzdm2986WjmsldSp6Xpfhai/mowpBkSYGVToiQEnvdi+qb9b9lMnvr5jQ== dependencies: "@edge-runtime/node-utils" "2.3.0" "@edge-runtime/primitives" "4.1.0" "@edge-runtime/vm" "3.2.0" "@types/node" "16.18.11" - "@vercel/build-utils" "8.4.2" + "@vercel/build-utils" "8.4.5" "@vercel/error-utils" "2.0.2" "@vercel/nft" "0.27.3" "@vercel/static-config" "3.0.0" @@ -1283,24 +1236,24 @@ path-browserify "^1.0.1" vscode-uri "^3.0.8" -"@vue/compiler-core@3.4.38": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.4.38.tgz#326dfe3c92fa2b0f1dc9b39a948a231980253496" - integrity sha512-8IQOTCWnLFqfHzOGm9+P8OPSEDukgg3Huc92qSG49if/xI2SAwLHQO2qaPQbjCWPBcQoO1WYfXfTACUrWV3c5A== +"@vue/compiler-core@3.5.10": + version "3.5.10" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.5.10.tgz#dc382e4173c5ad6d309887f5cb02983dfd88cfee" + integrity sha512-iXWlk+Cg/ag7gLvY0SfVucU8Kh2CjysYZjhhP70w9qI4MvSox4frrP+vDGvtQuzIcgD8+sxM6lZvCtdxGunTAA== dependencies: - "@babel/parser" "^7.24.7" - "@vue/shared" "3.4.38" + "@babel/parser" "^7.25.3" + "@vue/shared" "3.5.10" entities "^4.5.0" estree-walker "^2.0.2" source-map-js "^1.2.0" "@vue/compiler-dom@^3.4.0": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.4.38.tgz#90348fac1130e0bbd408b650635cb626b3b9df06" - integrity sha512-Osc/c7ABsHXTsETLgykcOwIxFktHfGSUDkb05V61rocEfsFDcjDLH/IHJSNJP+/Sv9KeN2Lx1V6McZzlSb9EhQ== + version "3.5.10" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.5.10.tgz#233c660289ce289a48e8fe759b07b95f607cd98e" + integrity sha512-DyxHC6qPcktwYGKOIy3XqnHRrrXyWR2u91AjP+nLkADko380srsC2DC3s7Y1Rk6YfOlxOlvEQKa9XXmLI+W4ZA== dependencies: - "@vue/compiler-core" "3.4.38" - "@vue/shared" "3.4.38" + "@vue/compiler-core" "3.5.10" + "@vue/shared" "3.5.10" "@vue/compiler-vue2@^2.7.16": version "2.7.16" @@ -1324,10 +1277,10 @@ muggle-string "^0.4.1" path-browserify "^1.0.1" -"@vue/shared@3.4.38", "@vue/shared@^3.4.0": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.4.38.tgz#552a6770098bfd556fa3e2c686c9d3b4f4cd94c2" - integrity sha512-q0xCiLkuWWQLzVrecPb0RMsNWyxICOjPrcrwxTUEHb1fsnvni4dcuyG7RT/Ie7VPTvnjzIaWzRMUBsrqNj/hhw== +"@vue/shared@3.5.10", "@vue/shared@^3.4.0": + version "3.5.10" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.5.10.tgz#066f7dde31e09d700123e92e63eaa126cda21a17" + integrity sha512-VkkBhU97Ki+XJ0xvl4C9YJsIZ2uIlQ7HqPpZOS3m9VCvmROPaChZU6DexdMJqvz9tbgG+4EtFVrSuailUq5KGQ== abbrev@1: version "1.1.1" @@ -1345,9 +1298,9 @@ acorn-jsx@^5.3.2: integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== acorn-walk@^8.1.1, acorn-walk@^8.2.0: - version "8.3.3" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.3.tgz#9caeac29eefaa0c41e3d4c65137de4d6f34df43e" - integrity sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw== + version "8.3.4" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.4.tgz#794dd169c3977edf4ba4ea47583587c5866236b7" + integrity sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g== dependencies: acorn "^8.11.0" @@ -1517,11 +1470,6 @@ argparse@~1.0.9: dependencies: sprintf-js "~1.0.2" -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - as-table@^1.0.36: version "1.0.55" resolved "https://registry.yarnpkg.com/as-table/-/as-table-1.0.55.tgz#dc984da3937745de902cea1d45843c01bdbbec4f" @@ -1608,12 +1556,12 @@ braces@^3.0.3, braces@~3.0.2: fill-range "^7.1.1" browserslist@^4.23.3: - version "4.23.3" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.3.tgz#debb029d3c93ebc97ffbc8d9cbb03403e227c800" - integrity sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA== + version "4.24.0" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.0.tgz#a1325fe4bc80b64fda169629fc01b3d6cecd38d4" + integrity sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A== dependencies: - caniuse-lite "^1.0.30001646" - electron-to-chromium "^1.5.4" + caniuse-lite "^1.0.30001663" + electron-to-chromium "^1.5.28" node-releases "^2.0.18" update-browserslist-db "^1.1.0" @@ -1659,10 +1607,10 @@ callsites@^3.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -caniuse-lite@^1.0.30001646: - version "1.0.30001653" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001653.tgz#b8af452f8f33b1c77f122780a4aecebea0caca56" - integrity sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw== +caniuse-lite@^1.0.30001663: + version "1.0.30001664" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz#d588d75c9682d3301956b05a3749652a80677df4" + integrity sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g== capnp-ts@^0.7.0: version "0.7.0" @@ -1886,22 +1834,17 @@ data-uri-to-buffer@^2.0.0: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz#d296973d5a4897a5dbe31716d118211921f04770" integrity sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA== -date-fns@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf" - integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww== - de-indent@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d" integrity sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg== -debug@4, debug@^4.0.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.6: - version "4.3.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" - integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== +debug@4, debug@^4.0.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.6: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== dependencies: - ms "2.1.2" + ms "^2.1.3" debug@^3.2.7: version "3.2.7" @@ -1910,6 +1853,13 @@ debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.3: + version "4.3.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" + integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== + dependencies: + ms "2.1.2" + decode-named-character-reference@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz#daabac9690874c394c81e4162a0304b35d824f0e" @@ -1976,13 +1926,6 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -2005,10 +1948,10 @@ edge-runtime@2.5.9: signal-exit "4.0.2" time-span "4.0.0" -electron-to-chromium@^1.5.4: - version "1.5.13" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz#1abf0410c5344b2b829b7247e031f02810d442e6" - integrity sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q== +electron-to-chromium@^1.5.28: + version "1.5.29" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz#aa592a3caa95d07cc26a66563accf99fa573a1ee" + integrity sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw== emoji-regex@^8.0.0: version "8.0.0" @@ -2282,10 +2225,10 @@ esbuild@~0.23.0: "@esbuild/win32-ia32" "0.23.1" "@esbuild/win32-x64" "0.23.1" -escalade@^3.1.1, escalade@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" - integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== +escalade@^3.1.1, escalade@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== escape-string-regexp@^1.0.5: version "1.0.5" @@ -2350,17 +2293,17 @@ eslint-parser-plain@^0.1.0: resolved "https://registry.yarnpkg.com/eslint-parser-plain/-/eslint-parser-plain-0.1.0.tgz#8f7f0ac79fe4e4f47b33cf226b837ccff9d71ad6" integrity sha512-oOeA6FWU0UJT/Rxc3XF5Cq0nbIZbylm7j8+plqq0CZoE6m4u32OXJrR+9iy4srGMmF6v6pmgvP1zPxSRIGh3sg== -eslint-plugin-antfu@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-antfu/-/eslint-plugin-antfu-2.6.0.tgz#002d3391dae5bb974d80f3b6f400cb526200ce34" - integrity sha512-4dz0VgWGpZ6jUSEUPSI6OGFqBc+P8c7zFFXht5t+YwzIvBsruqVX7Hjl3I8KNNEyJmA4fL3+GIc+EWU1woTp1A== +eslint-plugin-antfu@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-antfu/-/eslint-plugin-antfu-2.7.0.tgz#63e6da511da21fabcd1774c10f7d8b5681b2e560" + integrity sha512-gZM3jq3ouqaoHmUNszb1Zo2Ux7RckSvkGksjLWz9ipBYGSv1EwwBETN6AdiUXn+RpVHXTbEMPAPlXJazcA6+iA== dependencies: "@antfu/utils" "^0.7.10" -eslint-plugin-command@^0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-command/-/eslint-plugin-command-0.2.5.tgz#c295bc557eafe9c4b28c3b6fcea1a7c171305011" - integrity sha512-mbCaSHD37MT8nVJnJUz2oeDfhz0wdOjfrqQVWkSpXuj3uU8m7/FK/niV2bL922af3M1js5x7Xcu3PwqWsrahfA== +eslint-plugin-command@^0.2.6: + version "0.2.6" + resolved "https://registry.yarnpkg.com/eslint-plugin-command/-/eslint-plugin-command-0.2.6.tgz#5eeed52da9fe19429a039374153ec115309e0c02" + integrity sha512-T0bHZ1oblW1xUHUVoBKZJR2osSNNGkfZuK4iqboNwuNS/M7tdp3pmURaJtTi/XDzitxaQ02lvOdFH0mUd5QLvQ== dependencies: "@es-joy/jsdoccomment" "^0.48.0" @@ -2386,10 +2329,10 @@ eslint-plugin-format@^0.1.2: prettier "^3.3.2" synckit "^0.9.0" -eslint-plugin-import-x@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-import-x/-/eslint-plugin-import-x-4.2.1.tgz#575f311d51d960f46609dfa3fea9f027cd0cf60b" - integrity sha512-WWi2GedccIJa0zXxx3WDnTgouGQTtdYK1nhXMwywbqqAgB0Ov+p1pYBsWh3VaB0bvBOwLse6OfVII7jZD9xo5Q== +eslint-plugin-import-x@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import-x/-/eslint-plugin-import-x-4.3.0.tgz#1b59ca3bda6a34d2eb0c09196ccd1f905fc30861" + integrity sha512-PxGzP7gAjF2DLeRnQtbYkkgZDg1intFyYr/XS1LgTYXUDrSXMHGkXx8++6i2eDv2jMs0jfeO6G6ykyeWxiFX7w== dependencies: "@typescript-eslint/utils" "^8.1.0" debug "^4.3.4" @@ -2402,10 +2345,10 @@ eslint-plugin-import-x@^4.2.1: stable-hash "^0.0.4" tslib "^2.6.3" -eslint-plugin-jsdoc@^50.2.3: - version "50.2.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.2.4.tgz#9abef68ea5869e87d8a4444bfef9e5a7787162e2" - integrity sha512-020jA+dXaXdb+TML3ZJBvpPmzwbNROjnYuTYi/g6A5QEmEjhptz4oPJDKkOGMIByNxsPpdTLzSU1HYVqebOX1w== +eslint-plugin-jsdoc@^50.3.0: + version "50.3.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.3.0.tgz#2a4d1ac7f45b2b62de42389ba8006fd00b7f08dd" + integrity sha512-P7qDB/RckdKETpBM4CtjHRQ5qXByPmFhRi86sN3E+J+tySchq+RSOGGhI2hDIefmmKFuTi/1ACjqsnDJDDDfzg== dependencies: "@es-joy/jsdoccomment" "~0.48.0" are-docs-informative "^0.0.2" @@ -2432,10 +2375,10 @@ eslint-plugin-jsonc@^2.16.0: natural-compare "^1.4.0" synckit "^0.6.0" -eslint-plugin-n@^17.10.2: - version "17.10.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.10.2.tgz#16d8d7d0b1dc076c03513bfea096f8ce1b0bcca8" - integrity sha512-e+s4eAf5NtJaxPhTNu3qMO0Iz40WANS93w9LQgYcvuljgvDmWi/a3rh+OrNyMHeng6aOWGJO0rCg5lH4zi8yTw== +eslint-plugin-n@^17.10.3: + version "17.10.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-17.10.3.tgz#6c8bae69b4d3354fe25c3c844afb3f83b83a3942" + integrity sha512-ySZBfKe49nQZWR1yFaA0v/GsH6Fgp8ah6XV0WDz6CN8WO0ek4McMzb7A2xnf4DCYV43frjCygvb9f/wx7UUxRw== dependencies: "@eslint-community/eslint-utils" "^4.4.0" enhanced-resolve "^5.17.0" @@ -2451,13 +2394,13 @@ eslint-plugin-no-only-tests@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-3.3.0.tgz#d9d42ccd4b5d099b4872fb5046cf95441188cfb5" integrity sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q== -eslint-plugin-perfectionist@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-3.6.0.tgz#3772b7cf8b642df222a2791364e097ad159ee476" - integrity sha512-sA6ljy6dL/9cM5ruZ/pMqRVt0FQ4Z7mbQWlBYpyX9941LVfm65d2jl2k1ZbWD3ud9Wm+/NKgOvRnAatsKhMJbA== +eslint-plugin-perfectionist@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-3.7.0.tgz#dac1253ee51e2653806cb681d2060e7195283ea0" + integrity sha512-pemhfcR3LDbYVWeveHok9u048yR7GpsnfyPvn6RsDkp/UV7iqBV0y5K0aGb9ZJMsemOyWok7akxGzPLsz+mHKQ== dependencies: - "@typescript-eslint/types" "^8.5.0" - "@typescript-eslint/utils" "^8.5.0" + "@typescript-eslint/types" "^8.7.0" + "@typescript-eslint/utils" "^8.7.0" minimatch "^9.0.5" natural-compare-lite "^1.4.0" @@ -2550,9 +2493,9 @@ eslint-scope@^7.1.1: estraverse "^5.2.0" eslint-scope@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.0.2.tgz#5cbb33d4384c9136083a71190d548158fe128f94" - integrity sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA== + version "8.1.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.1.0.tgz#70214a174d4cbffbc3e8a26911d8bf51b9ae9d30" + integrity sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" @@ -2562,25 +2505,28 @@ eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint-visitor-keys@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz#e3adc021aa038a2a8e0b2f8b0ce8f66b9483b1fb" - integrity sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw== +eslint-visitor-keys@^4.0.0, eslint-visitor-keys@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz#1f785cc5e81eb7534523d85922248232077d2f8c" + integrity sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg== eslint@^9.10.0: - version "9.10.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.10.0.tgz#0bd74d7fe4db77565d0e7f57c7df6d2b04756806" - integrity sha512-Y4D0IgtBZfOcOUAIQTSXBKoNGfY0REGqHJG6+Q81vNippW5YlKjHFj4soMxamKK1NXHUWuBZTLdU3Km+L/pcHw== + version "9.11.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.11.1.tgz#701e5fc528990153f9cef696d8427003b5206567" + integrity sha512-MobhYKIoAO1s1e4VUrgx1l1Sk2JBR/Gqjjgw8+mfgoLE2xwsHur4gdfTxyTgShrhvdVFTaJSgMiQBl1jv/AWxg== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.11.0" "@eslint/config-array" "^0.18.0" + "@eslint/core" "^0.6.0" "@eslint/eslintrc" "^3.1.0" - "@eslint/js" "9.10.0" - "@eslint/plugin-kit" "^0.1.0" + "@eslint/js" "9.11.1" + "@eslint/plugin-kit" "^0.2.0" "@humanwhocodes/module-importer" "^1.0.1" "@humanwhocodes/retry" "^0.3.0" "@nodelib/fs.walk" "^1.2.8" + "@types/estree" "^1.0.6" + "@types/json-schema" "^7.0.15" ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -2608,13 +2554,13 @@ eslint@^9.10.0: text-table "^0.2.0" espree@^10.0.1, espree@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-10.1.0.tgz#8788dae611574c0f070691f522e4116c5a11fc56" - integrity sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA== + version "10.2.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.2.0.tgz#f4bcead9e05b0615c968e85f83816bc386a45df6" + integrity sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g== dependencies: acorn "^8.12.0" acorn-jsx "^5.3.2" - eslint-visitor-keys "^4.0.0" + eslint-visitor-keys "^4.1.0" espree@^9.0.0, espree@^9.3.1, espree@^9.6.1: version "9.6.1" @@ -2684,7 +2630,7 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== -fast-glob@^3.2.7, fast-glob@^3.2.9, fast-glob@^3.3.2: +fast-glob@^3.2.7, fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== @@ -2706,9 +2652,9 @@ fast-levenshtein@^2.0.6: integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fast-uri@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.1.tgz#cddd2eecfc83a71c1be2cc2ef2061331be8a7134" - integrity sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw== + version "3.0.2" + resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.2.tgz#d78b298cf70fd3b752fd951175a3da6a7b48f024" + integrity sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row== fastq@^1.6.0: version "1.17.1" @@ -2857,7 +2803,14 @@ get-source@^2.0.12: data-uri-to-buffer "^2.0.0" source-map "^0.6.1" -get-tsconfig@^4.7.0, get-tsconfig@^4.7.3, get-tsconfig@^4.7.5: +get-tsconfig@^4.7.0, get-tsconfig@^4.7.3: + version "4.8.1" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.8.1.tgz#8995eb391ae6e1638d251118c7b56de7eb425471" + integrity sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg== + dependencies: + resolve-pkg-maps "^1.0.0" + +get-tsconfig@^4.7.5: version "4.7.6" resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.6.tgz#118fd5b7b9bae234cc7705a00cd771d7eb65d62a" integrity sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA== @@ -2917,18 +2870,6 @@ globals@^15.7.0, globals@^15.8.0, globals@^15.9.0: resolved "https://registry.yarnpkg.com/globals/-/globals-15.9.0.tgz#e9de01771091ffbc37db5714dab484f9f69ff399" integrity sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA== -globby@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" @@ -3149,6 +3090,11 @@ is-path-inside@^3.0.3: resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== +is-unicode-supported@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz#d824984b616c292a2e198207d4a609983842f714" + integrity sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -3513,7 +3459,7 @@ mdast-util-to-string@^4.0.0: dependencies: "@types/mdast" "^4.0.0" -merge2@^1.3.0, merge2@^1.4.1: +merge2@^1.3.0: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== @@ -3814,10 +3760,10 @@ min-indent@^1.0.0: resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== -miniflare@3.20240909.3: - version "3.20240909.3" - resolved "https://registry.yarnpkg.com/miniflare/-/miniflare-3.20240909.3.tgz#0ced51f0e62fb0a865ff5730f25ab8df5dfd60a5" - integrity sha512-HsWMexA4m0Ti8wTjqRdg50otufgoQ/I/rL3AHxf3dI/TN8zJC/5aMApqspW6I88Lzm24C+SRKnW0nm465PStIw== +miniflare@3.20240925.0: + version "3.20240925.0" + resolved "https://registry.yarnpkg.com/miniflare/-/miniflare-3.20240925.0.tgz#a291998dedf90bfb4bcfdad033ba030851ff9171" + integrity sha512-2LmQbKHf0n6ertUKhT+Iltixi53giqDH7P71+wCir3OnGyXIODqYwOECx1mSDNhYThpxM2dav8UdPn6SQiMoXw== dependencies: "@cspotcode/source-map-support" "0.8.1" acorn "^8.8.0" @@ -3827,7 +3773,7 @@ miniflare@3.20240909.3: glob-to-regexp "^0.4.1" stoppable "^1.1.0" undici "^5.28.4" - workerd "1.20240909.0" + workerd "1.20240925.0" ws "^8.17.1" youch "^3.2.2" zod "^3.22.3" @@ -3947,7 +3893,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.0.0, ms@^2.1.1: +ms@^2.0.0, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -4019,9 +3965,9 @@ node-forge@^1: integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== node-gyp-build@^4.2.2: - version "4.8.1" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.1.tgz#976d3ad905e71b76086f4f0b0d3637fe79b6cda5" - integrity sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw== + version "4.8.2" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.2.tgz#4f802b71c1ab2ca16af830e6c1ea7dd1ad9496fa" + integrity sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw== node-gyp@8.x: version "8.4.1" @@ -4105,10 +4051,10 @@ object-assign@^4.1.1: resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== -ohash@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/ohash/-/ohash-1.1.3.tgz#f12c3c50bfe7271ce3fd1097d42568122ccdcf07" - integrity sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw== +ohash@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/ohash/-/ohash-1.1.4.tgz#ae8d83014ab81157d2c285abf7792e2995fadd72" + integrity sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g== once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" @@ -4187,9 +4133,9 @@ parse-gitignore@^2.0.0: integrity sha512-RmVuCHWsfu0QPNW+mraxh/xjQVw/lhUCUru8Zni3Ctq3AoMhpDTq0OVdKS6iesd6Kqb7viCV3isAL43dciOSog== parse-imports@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/parse-imports/-/parse-imports-2.1.1.tgz#ce52141df24990065d72a446a364bffd595577f4" - integrity sha512-TDT4HqzUiTMO1wJRwg/t/hYk8Wdp3iF/ToMIlAoVQfL1Xs/sTxq1dKWSMjMbQmIarfWKymOyly40+zmPHXMqCA== + version "2.2.1" + resolved "https://registry.yarnpkg.com/parse-imports/-/parse-imports-2.2.1.tgz#0a6e8b5316beb5c9905f50eb2bbb8c64a4805642" + integrity sha512-OL/zLggRp8mFhKL0rNORUTR4yBYujK/uU+xZL+/0Rgm2QE4nLO9v8PzEweSJEbMGKmDRjJE4R3IMJlL2di4JeQ== dependencies: es-module-lexer "^1.5.3" slashes "^3.0.12" @@ -4244,11 +4190,6 @@ path-to-regexp@^6.3.0: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.3.0.tgz#2b6a26a337737a8e1416f9272ed0766b1c0389f4" integrity sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ== -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - pathe@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/pathe/-/pathe-1.1.2.tgz#6c4cb47a945692e48a1ddd6e4094d170516437ec" @@ -4264,12 +4205,7 @@ picocolors@1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picocolors@^1.0.0, picocolors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1" - integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew== - -picocolors@^1.1.0: +picocolors@^1.0.0, picocolors@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59" integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw== @@ -4307,13 +4243,13 @@ postcss-selector-parser@^6.0.15: util-deprecate "^1.0.2" postcss@^8.4.43: - version "8.4.44" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.44.tgz#d56834ef6508610ba224bb22b2457b2169ed0480" - integrity sha512-Aweb9unOEpQ3ezu4Q00DPvvM2ZTUitJdNKeP/+uQgr1IBIqu574IaZoURId7BKtWMREwzKa9OgzPzezWGPWFQw== + version "8.4.47" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.47.tgz#5bf6c9a010f3e724c503bf03ef7947dcb0fea365" + integrity sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ== dependencies: nanoid "^3.3.7" - picocolors "^1.0.1" - source-map-js "^1.2.0" + picocolors "^1.1.0" + source-map-js "^1.2.1" prebuild-install@^7.1.1: version "7.1.2" @@ -4570,28 +4506,28 @@ rollup-pluginutils@^2.8.1, rollup-pluginutils@^2.8.2: estree-walker "^0.6.1" rollup@^4.20.0: - version "4.22.4" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.22.4.tgz#4135a6446671cd2a2453e1ad42a45d5973ec3a0f" - integrity sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A== + version "4.22.5" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.22.5.tgz#d5108cc470249417e50492456253884d19f5d40f" + integrity sha512-WoinX7GeQOFMGznEcWA1WrTQCd/tpEbMkc3nuMs9BT0CPjMdSjPMTVClwWd4pgSQwJdP65SK9mTCNvItlr5o7w== dependencies: - "@types/estree" "1.0.5" + "@types/estree" "1.0.6" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.22.4" - "@rollup/rollup-android-arm64" "4.22.4" - "@rollup/rollup-darwin-arm64" "4.22.4" - "@rollup/rollup-darwin-x64" "4.22.4" - "@rollup/rollup-linux-arm-gnueabihf" "4.22.4" - "@rollup/rollup-linux-arm-musleabihf" "4.22.4" - "@rollup/rollup-linux-arm64-gnu" "4.22.4" - "@rollup/rollup-linux-arm64-musl" "4.22.4" - "@rollup/rollup-linux-powerpc64le-gnu" "4.22.4" - "@rollup/rollup-linux-riscv64-gnu" "4.22.4" - "@rollup/rollup-linux-s390x-gnu" "4.22.4" - "@rollup/rollup-linux-x64-gnu" "4.22.4" - "@rollup/rollup-linux-x64-musl" "4.22.4" - "@rollup/rollup-win32-arm64-msvc" "4.22.4" - "@rollup/rollup-win32-ia32-msvc" "4.22.4" - "@rollup/rollup-win32-x64-msvc" "4.22.4" + "@rollup/rollup-android-arm-eabi" "4.22.5" + "@rollup/rollup-android-arm64" "4.22.5" + "@rollup/rollup-darwin-arm64" "4.22.5" + "@rollup/rollup-darwin-x64" "4.22.5" + "@rollup/rollup-linux-arm-gnueabihf" "4.22.5" + "@rollup/rollup-linux-arm-musleabihf" "4.22.5" + "@rollup/rollup-linux-arm64-gnu" "4.22.5" + "@rollup/rollup-linux-arm64-musl" "4.22.5" + "@rollup/rollup-linux-powerpc64le-gnu" "4.22.5" + "@rollup/rollup-linux-riscv64-gnu" "4.22.5" + "@rollup/rollup-linux-s390x-gnu" "4.22.5" + "@rollup/rollup-linux-x64-gnu" "4.22.5" + "@rollup/rollup-linux-x64-musl" "4.22.5" + "@rollup/rollup-win32-arm64-msvc" "4.22.5" + "@rollup/rollup-win32-ia32-msvc" "4.22.5" + "@rollup/rollup-win32-x64-msvc" "4.22.5" fsevents "~2.3.2" run-parallel@^1.1.9: @@ -4701,11 +4637,6 @@ skip-regex@^1.0.2: resolved "https://registry.yarnpkg.com/skip-regex/-/skip-regex-1.0.2.tgz#ac655d77e7c771ac2b9f37585fea37bff56ad65b" integrity sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA== -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - slashes@^3.0.12: version "3.0.12" resolved "https://registry.yarnpkg.com/slashes/-/slashes-3.0.12.tgz#3d664c877ad542dc1509eaf2c50f38d483a6435a" @@ -4733,10 +4664,10 @@ socks@^2.6.2: ip-address "^9.0.5" smart-buffer "^4.2.0" -source-map-js@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" - integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== +source-map-js@^1.2.0, source-map-js@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" @@ -5137,13 +5068,13 @@ undici@^6.19.8: resolved "https://registry.yarnpkg.com/undici/-/undici-6.19.8.tgz#002d7c8a28f8cc3a44ff33c3d4be4d85e15d40e1" integrity sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g== -"unenv@npm:unenv-nightly@2.0.0-1726478054.1e87097": - version "2.0.0-1726478054.1e87097" - resolved "https://registry.yarnpkg.com/unenv-nightly/-/unenv-nightly-2.0.0-1726478054.1e87097.tgz#3dd65753f4a8d717be56f02ecbac9bdbfa8243eb" - integrity sha512-uZso8dCkGlJzWQqkyjOA5L4aUqNJl9E9oKRm03V/d+URrg6rFMJwBonlX9AAq538NxwJpPnCX0gAz0IfTxsbFQ== +"unenv@npm:unenv-nightly@2.0.0-20240919-125358-9a64854": + version "2.0.0-20240919-125358-9a64854" + resolved "https://registry.yarnpkg.com/unenv-nightly/-/unenv-nightly-2.0.0-20240919-125358-9a64854.tgz#13f6812c7b12b9521ea05c6d49259d136e093acd" + integrity sha512-XjsgUTrTHR7iw+k/SRTNjh6EQgwpC9voygnoCJo5kh4hKqsSDHUW84MhL9EsHTNfLctvVBHaSw8e2k3R2fKXsQ== dependencies: defu "^6.1.4" - ohash "^1.1.3" + ohash "^1.1.4" pathe "^1.1.2" ufo "^1.5.4" @@ -5203,12 +5134,12 @@ universalify@^2.0.0: integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== update-browserslist-db@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz#7ca61c0d8650766090728046e416a8cde682859e" - integrity sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ== + version "1.1.1" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" + integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== dependencies: - escalade "^3.1.2" - picocolors "^1.0.1" + escalade "^3.2.0" + picocolors "^1.1.0" uri-js@^4.2.2, uri-js@^4.4.1: version "4.4.1" @@ -5256,9 +5187,9 @@ vite-plugin-checker@^0.8.0: vscode-uri "^3.0.2" vite-plugin-dts@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.2.1.tgz#f8bee33b732929717ce13ef7a382696d51200c30" - integrity sha512-/QlYvgUMiv8+ZTEerhNCYnYaZMM07cdlX6hQCR/w/g/nTh0tUXPoYwbT6SitizLJ9BybT1lnrcZgqheI6wromQ== + version "4.2.2" + resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.2.2.tgz#96fd412827e545564a6dfe2de678feec5ddbed5c" + integrity sha512-USwTMReZFf8yXV+cKkm4WOMqmFjbReAvkyxON5xzdnZzJEBnFgax6BBDZIGGr9WMJYvhHdpaIHLrOjXDcla4OA== dependencies: "@microsoft/api-extractor" "7.47.7" "@rollup/pluginutils" "^5.1.0" @@ -5271,9 +5202,9 @@ vite-plugin-dts@^4.2.1: magic-string "^0.30.11" vite@^5.4.3: - version "5.4.6" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.6.tgz#85a93a1228a7fb5a723ca1743e337a2588ed008f" - integrity sha512-IeL5f8OO5nylsgzd9tq4qD2QqI0k2CQLGrWD0rCN0EQJZpBK5vJAx0I+GDkMOXxQX/OfFHMuLIx6ddAxGX/k+Q== + version "5.4.8" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.8.tgz#af548ce1c211b2785478d3ba3e8da51e39a287e8" + integrity sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ== dependencies: esbuild "^0.21.3" postcss "^8.4.43" @@ -5370,39 +5301,38 @@ word-wrap@^1.2.5: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -workerd@1.20240909.0: - version "1.20240909.0" - resolved "https://registry.yarnpkg.com/workerd/-/workerd-1.20240909.0.tgz#603bf89b51d4d1d442c172f6c556582e146654ab" - integrity sha512-NwuYh/Fgr/MK0H+Ht687sHl/f8tumwT5CWzYR0MZMHri8m3CIYu2IaY4tBFWoKE/tOU1Z5XjEXECa9zXY4+lwg== +workerd@1.20240925.0: + version "1.20240925.0" + resolved "https://registry.yarnpkg.com/workerd/-/workerd-1.20240925.0.tgz#0a2602eabfa7e1d01d89ff2b600ed359be9b515d" + integrity sha512-/Jj6+yLwfieZGEt3Kx4+5MoufuC3g/8iFaIh4MPBNGJOGYmdSKXvgCqz09m2+tVCYnysRfbq2zcbVxJRBfOCqQ== optionalDependencies: - "@cloudflare/workerd-darwin-64" "1.20240909.0" - "@cloudflare/workerd-darwin-arm64" "1.20240909.0" - "@cloudflare/workerd-linux-64" "1.20240909.0" - "@cloudflare/workerd-linux-arm64" "1.20240909.0" - "@cloudflare/workerd-windows-64" "1.20240909.0" + "@cloudflare/workerd-darwin-64" "1.20240925.0" + "@cloudflare/workerd-darwin-arm64" "1.20240925.0" + "@cloudflare/workerd-linux-64" "1.20240925.0" + "@cloudflare/workerd-linux-arm64" "1.20240925.0" + "@cloudflare/workerd-windows-64" "1.20240925.0" wrangler@^3.78.5: - version "3.78.5" - resolved "https://registry.yarnpkg.com/wrangler/-/wrangler-3.78.5.tgz#0727ed417bc05c498a1a593072b73360e00117fa" - integrity sha512-EqCQOuuxHCBHLSjWw7kWT/1PDSw38XUhSxPC3VnDcL7F6TukVBfHHyLFO4NYGTDDoH+G8KVK1bL1q8LXY2Rcbg== + version "3.78.12" + resolved "https://registry.yarnpkg.com/wrangler/-/wrangler-3.78.12.tgz#c3d7b605856b904ab7cce54afc223286b8454935" + integrity sha512-a/xk/N04IvOGk9J+BLkiFg42GDyPS+0BiJimbrHsbX+CDr8Iqq3HNMEyQld+6zbmq01u/gmc8S7GKVR9vDx4+g== dependencies: "@cloudflare/kv-asset-handler" "0.3.4" - "@cloudflare/workers-shared" "0.5.3" + "@cloudflare/workers-shared" "0.5.4" "@esbuild-plugins/node-globals-polyfill" "^0.2.3" "@esbuild-plugins/node-modules-polyfill" "^0.2.2" blake3-wasm "^2.1.5" chokidar "^3.5.3" - date-fns "^3.6.0" esbuild "0.17.19" - miniflare "3.20240909.3" + miniflare "3.20240925.0" nanoid "^3.3.3" path-to-regexp "^6.3.0" resolve "^1.22.8" resolve.exports "^2.0.2" selfsigned "^2.0.1" source-map "^0.6.1" - unenv "npm:unenv-nightly@2.0.0-1726478054.1e87097" - workerd "1.20240909.0" + unenv "npm:unenv-nightly@2.0.0-20240919-125358-9a64854" + workerd "1.20240925.0" xxhash-wasm "^1.0.1" optionalDependencies: fsevents "~2.3.2" @@ -5456,9 +5386,9 @@ yaml-eslint-parser@^1.2.1, yaml-eslint-parser@^1.2.3: yaml "^2.0.0" yaml@^2.0.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.5.0.tgz#c6165a721cf8000e91c36490a41d7be25176cf5d" - integrity sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw== + version "2.5.1" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.5.1.tgz#c9772aacf62cb7494a95b0c4f1fb065b563db130" + integrity sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q== yargs-parser@^21.1.1: version "21.1.1" From 73336e5478d6ee185f8240eca5c2f8ad19b8e461 Mon Sep 17 00:00:00 2001 From: tbxark Date: Wed, 9 Oct 2024 09:43:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86class=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0bind=20this?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/buildinfo.json | 2 +- dist/index.js | 25 +++++++++++++++++++++++-- dist/timestamp | 2 +- src/config/env.ts | 5 +++++ src/telegram/api/index.ts | 2 ++ src/telegram/utils/send.ts | 3 +++ src/utils/cache/index.ts | 2 ++ src/utils/router/index.ts | 10 ++++++++++ 8 files changed, 47 insertions(+), 4 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index 74bceb75..f8305268 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"db772d7","timestamp":1727589780} \ No newline at end of file +{"sha":"b876e24","timestamp":1728438149} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 0bf05ffb..fa5daf74 100644 --- a/dist/index.js +++ b/dist/index.js @@ -211,8 +211,8 @@ const ENV_KEY_MAPPER = { WORKERS_AI_MODEL: "WORKERS_CHAT_MODEL" }; class Environment extends EnvironmentConfig { - BUILD_TIMESTAMP = 1727589780 ; - BUILD_VERSION = "db772d7" ; + BUILD_TIMESTAMP = 1728438149 ; + BUILD_VERSION = "b876e24" ; I18N = loadI18n(); PLUGINS_ENV = {}; USER_CONFIG = createAgentUserConfig(); @@ -220,6 +220,10 @@ class Environment extends EnvironmentConfig { PLUGINS_COMMAND = {}; DATABASE = null; API_GUARD = null; + constructor() { + super(); + this.merge = this.merge.bind(this); + } merge(source) { this.DATABASE = source.DATABASE; this.API_GUARD = source.API_GUARD; @@ -309,6 +313,8 @@ class APIClientBase { while (this.baseURL.endsWith("/")) { this.baseURL = this.baseURL.slice(0, -1); } + this.request = this.request.bind(this); + this.requestJSON = this.requestJSON.bind(this); } uri(method) { return `${this.baseURL}/bot${this.token}/${method}`; @@ -593,6 +599,9 @@ class MessageSender { constructor(token, context) { this.api = createTelegramBotAPI(token); this.context = context; + this.sendRichText = this.sendRichText.bind(this); + this.sendPlainText = this.sendPlainText.bind(this); + this.sendPhoto = this.sendPhoto.bind(this); } static from(token, message) { return new MessageSender(token, new MessageContext(message)); @@ -758,6 +767,8 @@ class Cache { this.maxItems = 10; this.maxAge = 1e3 * 60 * 60; this.cache = {}; + this.set = this.set.bind(this); + this.get = this.get.bind(this); } set(key, value) { this.trim(); @@ -2702,6 +2713,16 @@ class Router { this.routes = routes; this.base = base; Object.assign(this, other); + this.fetch = this.fetch.bind(this); + this.route = this.route.bind(this); + this.get = this.get.bind(this); + this.post = this.post.bind(this); + this.put = this.put.bind(this); + this.delete = this.delete.bind(this); + this.patch = this.patch.bind(this); + this.head = this.head.bind(this); + this.options = this.options.bind(this); + this.all = this.all.bind(this); } parseQueryParams(searchParams) { const query = {}; diff --git a/dist/timestamp b/dist/timestamp index a4eee1dc..c7e21b99 100644 --- a/dist/timestamp +++ b/dist/timestamp @@ -1 +1 @@ -1727589780 \ No newline at end of file +1728438149 \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts index c77a28a3..0f3b2a56 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -71,6 +71,11 @@ class Environment extends EnvironmentConfig { DATABASE: KVNamespace = null as any; API_GUARD: APIGuard | null = null; + constructor() { + super(); + this.merge = this.merge.bind(this); + } + merge(source: any) { // 全局对象 this.DATABASE = source.DATABASE; diff --git a/src/telegram/api/index.ts b/src/telegram/api/index.ts index 4de7d69c..244886e2 100644 --- a/src/telegram/api/index.ts +++ b/src/telegram/api/index.ts @@ -13,6 +13,8 @@ class APIClientBase { while (this.baseURL.endsWith('/')) { this.baseURL = this.baseURL.slice(0, -1); } + this.request = this.request.bind(this); + this.requestJSON = this.requestJSON.bind(this); } private uri(method: Telegram.BotMethod): string { diff --git a/src/telegram/utils/send.ts b/src/telegram/utils/send.ts index d5cea9db..0a556c3d 100644 --- a/src/telegram/utils/send.ts +++ b/src/telegram/utils/send.ts @@ -30,6 +30,9 @@ export class MessageSender { constructor(token: string, context: MessageContext) { this.api = createTelegramBotAPI(token); this.context = context; + this.sendRichText = this.sendRichText.bind(this); + this.sendPlainText = this.sendPlainText.bind(this); + this.sendPhoto = this.sendPhoto.bind(this); } static from(token: string, message: Telegram.Message): MessageSender { diff --git a/src/utils/cache/index.ts b/src/utils/cache/index.ts index 3f99ee5b..399c3650 100644 --- a/src/utils/cache/index.ts +++ b/src/utils/cache/index.ts @@ -13,6 +13,8 @@ export class Cache { this.maxItems = 10; this.maxAge = 1000 * 60 * 60; this.cache = {}; + this.set = this.set.bind(this); + this.get = this.get.bind(this); } set(key: string, value: T) { diff --git a/src/utils/router/index.ts b/src/utils/router/index.ts index 2f9bdcb5..a6eccd10 100644 --- a/src/utils/router/index.ts +++ b/src/utils/router/index.ts @@ -18,6 +18,16 @@ export class Router { this.routes = routes; this.base = base; Object.assign(this, other); + this.fetch = this.fetch.bind(this); + this.route = this.route.bind(this); + this.get = this.get.bind(this); + this.post = this.post.bind(this); + this.put = this.put.bind(this); + this.delete = this.delete.bind(this); + this.patch = this.patch.bind(this); + this.head = this.head.bind(this); + this.options = this.options.bind(this); + this.all = this.all.bind(this); } private parseQueryParams(searchParams: URLSearchParams): QueryParams { From 49d9cb1f659ebeb445e59dc4c2583470040f3fd7 Mon Sep 17 00:00:00 2001 From: tbxark Date: Mon, 14 Oct 2024 16:38:52 +0800 Subject: [PATCH 5/5] =?UTF-8?q?perf:=20gemini=20=E6=94=AF=E6=8C=81cloudfla?= =?UTF-8?q?re=20ai=20gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/buildinfo.json | 2 +- dist/index.js | 11 ++++++----- dist/timestamp | 2 +- src/agent/gemini.ts | 10 ++++------ src/config/config.ts | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index f8305268..a7e1dd43 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"b876e24","timestamp":1728438149} \ No newline at end of file +{"sha":"e756436","timestamp":1728895080} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index fa5daf74..e758599c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -211,8 +211,8 @@ const ENV_KEY_MAPPER = { WORKERS_AI_MODEL: "WORKERS_CHAT_MODEL" }; class Environment extends EnvironmentConfig { - BUILD_TIMESTAMP = 1728438149 ; - BUILD_VERSION = "b876e24" ; + BUILD_TIMESTAMP = 1728895080 ; + BUILD_VERSION = "e756436" ; I18N = loadI18n(); PLUGINS_ENV = {}; USER_CONFIG = createAgentUserConfig(); @@ -1514,8 +1514,8 @@ class Gemini { if (onStream !== null) { console.warn("Stream mode is not supported"); } - const url = `${context.GOOGLE_COMPLETIONS_API}${context.GOOGLE_COMPLETIONS_MODEL}:${ - "generateContent"}?key=${context.GOOGLE_API_KEY}`; + const mode = "generateContent"; + const url = `${context.GOOGLE_COMPLETIONS_API}${context.GOOGLE_COMPLETIONS_MODEL}:${mode}`; const contentsTemp = [...history || [], { role: "user", content: message }]; if (prompt) { contentsTemp.unshift({ role: "assistant", content: prompt }); @@ -1532,7 +1532,8 @@ class Gemini { const resp = await fetch(url, { method: "POST", headers: { - "Content-Type": "application/json" + "Content-Type": "application/json", + "x-goog-api-key": context.GOOGLE_API_KEY }, body: JSON.stringify({ contents }) }); diff --git a/dist/timestamp b/dist/timestamp index c7e21b99..5087328b 100644 --- a/dist/timestamp +++ b/dist/timestamp @@ -1 +1 @@ -1728438149 \ No newline at end of file +1728895080 \ No newline at end of file diff --git a/src/agent/gemini.ts b/src/agent/gemini.ts index 6fdde704..0452e025 100644 --- a/src/agent/gemini.ts +++ b/src/agent/gemini.ts @@ -35,11 +35,8 @@ export class Gemini implements ChatAgent { if (onStream !== null) { console.warn('Stream mode is not supported'); } - const url = `${context.GOOGLE_COMPLETIONS_API}${context.GOOGLE_COMPLETIONS_MODEL}:${ - // 暂时不支持stream模式 - // onStream ? 'streamGenerateContent' : 'generateContent' - 'generateContent' - }?key=${context.GOOGLE_API_KEY}`; + const mode = 'generateContent'; // onStream ? 'streamGenerateContent' : 'generateContent' + const url = `${context.GOOGLE_COMPLETIONS_API}${context.GOOGLE_COMPLETIONS_MODEL}:${mode}`; const contentsTemp = [...history || [], { role: 'user', content: message }]; if (prompt) { @@ -62,7 +59,8 @@ export class Gemini implements ChatAgent { method: 'POST', headers: { 'Content-Type': 'application/json', - }, + 'x-goog-api-key': context.GOOGLE_API_KEY, + } as Record, body: JSON.stringify({ contents }), }); const data = await resp.json() as any; diff --git a/src/config/config.ts b/src/config/config.ts index 75710f06..7fc98f10 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -148,7 +148,7 @@ export class WorkersConfig { export class GeminiConfig { // Google Gemini API Key GOOGLE_API_KEY: string | null = null; - // Google Gemini API + // Google Gemini API: Cloudflare AI gateway: https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai-studio/v1/models GOOGLE_COMPLETIONS_API = 'https://generativelanguage.googleapis.com/v1beta/models/'; // Google Gemini Model GOOGLE_COMPLETIONS_MODEL = 'gemini-pro';