From 3914b4e8e3000526ffc9d98c681b768e38cbaecf Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 26 Mar 2025 23:24:05 -0700 Subject: [PATCH 01/10] Automatically generate .d.ts from zod schemas --- .eslintrc.json | 2 +- .husky/pre-commit | 11 +- package-lock.json | 530 +++++++++++++++++++++++++++++++++++++- package.json | 4 +- scripts/generate-types.ts | 19 ++ src/exports/types.d.ts | 266 +++++++++++++++++++ src/schemas/index.ts | 291 +++++++++++++++++++++ 7 files changed, 1116 insertions(+), 7 deletions(-) create mode 100644 scripts/generate-types.ts create mode 100644 src/exports/types.d.ts create mode 100644 src/schemas/index.ts diff --git a/.eslintrc.json b/.eslintrc.json index e967b58a03..500422ac4d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,5 +19,5 @@ "no-throw-literal": "warn", "semi": "off" }, - "ignorePatterns": ["out", "dist", "**/*.d.ts", "!roo-code.d.ts"] + "ignorePatterns": ["out", "dist", "**/*.d.ts", "!src/exports/roo-code.d.ts", "!src/exports/types.d.ts"] } diff --git a/.husky/pre-commit b/.husky/pre-commit index 8a87777657..19155fa3fc 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -12,4 +12,13 @@ else npx_cmd="npx" fi -"$npx_cmd" lint-staged \ No newline at end of file +"$npx_cmd" tsx scripts/generate-types.ts + +# Check if src/exports/types.d.ts has unstaged changes after running the script. +if [ -n "$(git diff --name-only src/exports/types.d.ts)" ]; then + echo "Error: There are unstaged changes to src/exports/types.d.ts after running generate-types.ts." + echo "Please review and stage the changes before committing." + exit 1 +fi + +"$npx_cmd" lint-staged diff --git a/package-lock.json b/package-lock.json index ceac6359d8..3844c11576 100644 --- a/package-lock.json +++ b/package-lock.json @@ -90,7 +90,9 @@ "prettier": "^3.4.2", "rimraf": "^6.0.1", "ts-jest": "^29.2.5", - "typescript": "^5.4.5" + "tsx": "^4.19.3", + "typescript": "^5.4.5", + "zod-to-ts": "^1.2.0" }, "engines": { "node": ">=20.18.1", @@ -7683,9 +7685,10 @@ } }, "node_modules/chokidar": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.1.tgz", - "integrity": "sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "license": "MIT", "dependencies": { "readdirp": "^4.0.1" }, @@ -9971,6 +9974,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.0.tgz", + "integrity": "sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/get-uri": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.4.tgz", @@ -14381,6 +14397,16 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/resolve.exports": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.3.tgz", @@ -15618,6 +15644,492 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, + "node_modules/tsx": { + "version": "4.19.3", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.3.tgz", + "integrity": "sha512-4H8vUNGNjQ4V2EOoGw005+c+dGuPSnhpPBPHBtsZdGZBk/iJb4kguGlPWaZTZ3q5nMtFOEsY0nRDlh9PJyd6SQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.1.tgz", + "integrity": "sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.1.tgz", + "integrity": "sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.1.tgz", + "integrity": "sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.1.tgz", + "integrity": "sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.1.tgz", + "integrity": "sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.1.tgz", + "integrity": "sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.1.tgz", + "integrity": "sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.1.tgz", + "integrity": "sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.1.tgz", + "integrity": "sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.1.tgz", + "integrity": "sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.1.tgz", + "integrity": "sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.1.tgz", + "integrity": "sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.1.tgz", + "integrity": "sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.1.tgz", + "integrity": "sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.1.tgz", + "integrity": "sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.1.tgz", + "integrity": "sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", + "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.1.tgz", + "integrity": "sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.1.tgz", + "integrity": "sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.1.tgz", + "integrity": "sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.1.tgz", + "integrity": "sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.1.tgz", + "integrity": "sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.1.tgz", + "integrity": "sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.1.tgz", + "integrity": "sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.1.tgz", + "integrity": "sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", + "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.1", + "@esbuild/android-arm": "0.25.1", + "@esbuild/android-arm64": "0.25.1", + "@esbuild/android-x64": "0.25.1", + "@esbuild/darwin-arm64": "0.25.1", + "@esbuild/darwin-x64": "0.25.1", + "@esbuild/freebsd-arm64": "0.25.1", + "@esbuild/freebsd-x64": "0.25.1", + "@esbuild/linux-arm": "0.25.1", + "@esbuild/linux-arm64": "0.25.1", + "@esbuild/linux-ia32": "0.25.1", + "@esbuild/linux-loong64": "0.25.1", + "@esbuild/linux-mips64el": "0.25.1", + "@esbuild/linux-ppc64": "0.25.1", + "@esbuild/linux-riscv64": "0.25.1", + "@esbuild/linux-s390x": "0.25.1", + "@esbuild/linux-x64": "0.25.1", + "@esbuild/netbsd-arm64": "0.25.1", + "@esbuild/netbsd-x64": "0.25.1", + "@esbuild/openbsd-arm64": "0.25.1", + "@esbuild/openbsd-x64": "0.25.1", + "@esbuild/sunos-x64": "0.25.1", + "@esbuild/win32-arm64": "0.25.1", + "@esbuild/win32-ia32": "0.25.1", + "@esbuild/win32-x64": "0.25.1" + } + }, "node_modules/turndown": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.0.tgz", @@ -16596,6 +17108,16 @@ "url": "https://github.com/sponsors/colinhacks" } }, + "node_modules/zod-to-ts": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/zod-to-ts/-/zod-to-ts-1.2.0.tgz", + "integrity": "sha512-x30XE43V+InwGpvTySRNz9kB7qFU8DlyEy7BsSTCHPH1R0QasMmHWZDCzYm6bVXtj/9NNJAZF3jW8rzFvH5OFA==", + "dev": true, + "peerDependencies": { + "typescript": "^4.9.4 || ^5.0.2", + "zod": "^3" + } + }, "node_modules/zod-validation-error": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-3.4.0.tgz", diff --git a/package.json b/package.json index c82c74d0bb..11abc99ed8 100644 --- a/package.json +++ b/package.json @@ -436,7 +436,9 @@ "prettier": "^3.4.2", "rimraf": "^6.0.1", "ts-jest": "^29.2.5", - "typescript": "^5.4.5" + "tsx": "^4.19.3", + "typescript": "^5.4.5", + "zod-to-ts": "^1.2.0" }, "lint-staged": { "*.{js,jsx,ts,tsx,json,css,md}": [ diff --git a/scripts/generate-types.ts b/scripts/generate-types.ts new file mode 100644 index 0000000000..a40afc43b3 --- /dev/null +++ b/scripts/generate-types.ts @@ -0,0 +1,19 @@ +import fs from "fs/promises" + +import { zodToTs, createTypeAlias, printNode } from "zod-to-ts" + +import { typeDefinitions } from "../src/schemas" + +async function main() { + const types: string[] = [ + "// This file is automatically generated by running `npx tsx scripts/generated-types.ts`\n// Do not edit it directly.", + ] + + for (const { schema, identifier } of typeDefinitions) { + types.push(printNode(createTypeAlias(zodToTs(schema, identifier).node, identifier))) + } + + await fs.writeFile("src/exports/types.d.ts", types.join("\n\n")) +} + +main() diff --git a/src/exports/types.d.ts b/src/exports/types.d.ts new file mode 100644 index 0000000000..c8a903ce58 --- /dev/null +++ b/src/exports/types.d.ts @@ -0,0 +1,266 @@ +// This file is automatically generated by running `npx tsx scripts/generated-types.ts` +// Do not edit it directly. + +type ProviderName = + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + +type ToolGroup = "read" | "edit" | "browser" | "command" | "mcp" | "modes" + +type CheckpointStorage = "task" | "workspace" + +type Language = + | "ca" + | "de" + | "en" + | "es" + | "fr" + | "hi" + | "it" + | "ja" + | "ko" + | "pl" + | "pt-BR" + | "tr" + | "vi" + | "zh-CN" + | "zh-TW" + +type TelemetrySetting = "unset" | "enabled" | "disabled" + +type ModelInfo = { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined +} + +type ApiConfigMeta = { + id: string + name: string + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined +} + +type HistoryItem = { + id: string + number: number + ts: number + task: string + tokensIn: number + tokensOut: number + cacheWrites?: number | undefined + cacheReads?: number | undefined + totalCost: number + size?: number | undefined +} + +type GroupEntry = ("read" | "edit" | "browser" | "command" | "mcp" | "modes") | any + +type ModeConfig = { + slug: string + name: string + roleDefinition: string + customInstructions?: string | undefined + groups: any + source?: ("global" | "project") | undefined +} + +type ExperimentId = { + experimentalDiffStrategy: boolean + search_and_replace: boolean + insert_content: boolean + powerSteering: boolean + multi_search_and_replace: boolean +} + +type GlobalSettings = { + currentApiConfigName?: string | undefined + listApiConfigMeta?: + | { + id: string + name: string + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined + }[] + | undefined + pinnedApiConfigs?: + | { + [x: string]: boolean + } + | undefined + lastShownAnnouncementId?: string | undefined + customInstructions?: string | undefined + taskHistory?: + | { + id: string + number: number + ts: number + task: string + tokensIn: number + tokensOut: number + cacheWrites?: number | undefined + cacheReads?: number | undefined + totalCost: number + size?: number | undefined + }[] + | undefined + autoApprovalEnabled?: boolean | undefined + alwaysAllowReadOnly?: boolean | undefined + alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined + alwaysAllowWrite?: boolean | undefined + alwaysAllowWriteOutsideWorkspace?: boolean | undefined + writeDelayMs?: number | undefined + alwaysAllowBrowser?: boolean | undefined + alwaysApproveResubmit?: boolean | undefined + requestDelaySeconds?: number | undefined + alwaysAllowMcp?: boolean | undefined + alwaysAllowModeSwitch?: boolean | undefined + alwaysAllowSubtasks?: boolean | undefined + alwaysAllowExecute?: boolean | undefined + allowedCommands?: string[] | undefined + browserToolEnabled?: boolean | undefined + browserViewportSize?: string | undefined + screenshotQuality?: number | undefined + remoteBrowserEnabled?: boolean | undefined + remoteBrowserHost?: string | undefined + enableCheckpoints?: boolean | undefined + checkpointStorage?: ("task" | "workspace") | undefined + ttsEnabled?: boolean | undefined + ttsSpeed?: number | undefined + soundEnabled?: boolean | undefined + soundVolume?: number | undefined + maxOpenTabsContext?: number | undefined + maxWorkspaceFiles?: number | undefined + showRooIgnoredFiles?: boolean | undefined + maxReadFileLine?: number | undefined + terminalOutputLineLimit?: number | undefined + terminalShellIntegrationTimeout?: number | undefined + rateLimitSeconds?: number | undefined + diffEnabled?: boolean | undefined + fuzzyMatchThreshold?: number | undefined + experiments?: + | { + experimentalDiffStrategy: boolean + search_and_replace: boolean + insert_content: boolean + powerSteering: boolean + multi_search_and_replace: boolean + } + | undefined + language?: + | ( + | "ca" + | "de" + | "en" + | "es" + | "fr" + | "hi" + | "it" + | "ja" + | "ko" + | "pl" + | "pt-BR" + | "tr" + | "vi" + | "zh-CN" + | "zh-TW" + ) + | undefined + telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined + mcpEnabled?: boolean | undefined + enableMcpServerCreation?: boolean | undefined + mode?: string | undefined + modeApiConfigs?: + | { + [x: string]: string + } + | undefined + customModes?: + | { + slug: string + name: string + roleDefinition: string + customInstructions?: string | undefined + groups: any + source?: ("global" | "project") | undefined + }[] + | undefined + customModePrompts?: + | { + [x: string]: + | { + roleDefinition?: string | undefined + customInstructions?: string | undefined + } + | undefined + } + | undefined + customSupportPrompts?: + | { + [x: string]: string | undefined + } + | undefined + enhancementApiConfigId?: string | undefined +} diff --git a/src/schemas/index.ts b/src/schemas/index.ts new file mode 100644 index 0000000000..661284a10e --- /dev/null +++ b/src/schemas/index.ts @@ -0,0 +1,291 @@ +// Update to this file will automatically propgate to src/exports/types.d.ts +// via a pre-commit hook. If you want to update the types before committing you +// can run `npx tsx scripts/generate-types.ts`. + +import { z } from "zod" + +/** + * ProviderName + */ + +export const providerNames = [ + "anthropic", + "glama", + "openrouter", + "bedrock", + "vertex", + "openai", + "ollama", + "vscode-lm", + "lmstudio", + "gemini", + "openai-native", + "mistral", + "deepseek", + "unbound", + "requesty", + "human-relay", + "fake-ai", +] as const + +export const providerNamesSchema = z.enum(providerNames) + +export type ProviderName = z.infer + +/** + * ToolGroup + */ + +export const toolGroups = ["read", "edit", "browser", "command", "mcp", "modes"] as const + +export const toolGroupsSchema = z.enum(toolGroups) + +export type ToolGroup = z.infer + +/** + * CheckpointStorage + */ + +export const checkpointStorages = ["task", "workspace"] as const + +export const checkpointStoragesSchema = z.enum(checkpointStorages) + +export type CheckpointStorage = z.infer + +/** + * Language + */ + +export const languages = [ + "ca", + "de", + "en", + "es", + "fr", + "hi", + "it", + "ja", + "ko", + "pl", + "pt-BR", + "tr", + "vi", + "zh-CN", + "zh-TW", +] as const + +export const languagesSchema = z.enum(languages) + +export type Language = z.infer + +/** + * TelemetrySetting + */ + +export const telemetrySettings = ["unset", "enabled", "disabled"] as const + +export const telemetrySettingsSchema = z.enum(telemetrySettings) + +export type TelemetrySetting = z.infer + +/** + * ModelInfo + */ + +export const modelInfoSchema = z.object({ + maxTokens: z.number().optional(), + contextWindow: z.number(), + supportsImages: z.boolean().optional(), + supportsComputerUse: z.boolean().optional(), + supportsPromptCache: z.boolean(), + inputPrice: z.number().optional(), + outputPrice: z.number().optional(), + cacheWritesPrice: z.number().optional(), + cacheReadsPrice: z.number().optional(), + description: z.string().optional(), + reasoningEffort: z.enum(["low", "medium", "high"]).optional(), + thinking: z.boolean().optional(), +}) + +export type ModelInfo = z.infer + +/** + * ApiConfigMeta + */ + +export const apiConfigMetaSchema = z.object({ + id: z.string(), + name: z.string(), + apiProvider: providerNamesSchema.optional(), +}) + +export type ApiConfigMeta = z.infer + +/** + * HistoryItem + */ + +export const historyItemSchema = z.object({ + id: z.string(), + number: z.number(), + ts: z.number(), + task: z.string(), + tokensIn: z.number(), + tokensOut: z.number(), + cacheWrites: z.number().optional(), + cacheReads: z.number().optional(), + totalCost: z.number(), + size: z.number().optional(), +}) + +export type HistoryItem = z.infer + +/** + * GroupEntry + */ + +export const groupEntrySchema = z.union([ + toolGroupsSchema, + z + .tuple([ + toolGroupsSchema, + z.object({ + fileRegex: z.string().optional(), + description: z.string().optional(), + }), + ]) + .readonly(), +]) + +export type GroupEntry = z.infer + +/** + * ModeConfig + */ + +export const modeConfigSchema = z.object({ + slug: z.string(), + name: z.string(), + roleDefinition: z.string(), + customInstructions: z.string().optional(), + groups: z.array(groupEntrySchema).readonly(), + source: z.enum(["global", "project"]).optional(), +}) + +export type ModeConfig = z.infer + +/** + * ExperimentId + */ + +export const experimentIdSchema = z.object({ + experimentalDiffStrategy: z.boolean(), + search_and_replace: z.boolean(), + insert_content: z.boolean(), + powerSteering: z.boolean(), + multi_search_and_replace: z.boolean(), +}) + +export type ExperimentId = z.infer + +/** + * GlobalSettings + */ + +export const globalSettingsSchema = z.object({ + currentApiConfigName: z.string().optional(), + listApiConfigMeta: z.array(apiConfigMetaSchema).optional(), + pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(), + + lastShownAnnouncementId: z.string().optional(), + customInstructions: z.string().optional(), + taskHistory: z.array(historyItemSchema).optional(), + + autoApprovalEnabled: z.boolean().optional(), + alwaysAllowReadOnly: z.boolean().optional(), + alwaysAllowReadOnlyOutsideWorkspace: z.boolean().optional(), + alwaysAllowWrite: z.boolean().optional(), + alwaysAllowWriteOutsideWorkspace: z.boolean().optional(), + writeDelayMs: z.number().optional(), + alwaysAllowBrowser: z.boolean().optional(), + alwaysApproveResubmit: z.boolean().optional(), + requestDelaySeconds: z.number().optional(), + alwaysAllowMcp: z.boolean().optional(), + alwaysAllowModeSwitch: z.boolean().optional(), + alwaysAllowSubtasks: z.boolean().optional(), + alwaysAllowExecute: z.boolean().optional(), + allowedCommands: z.array(z.string()).optional(), + + browserToolEnabled: z.boolean().optional(), + browserViewportSize: z.string().optional(), + screenshotQuality: z.number().optional(), + remoteBrowserEnabled: z.boolean().optional(), + remoteBrowserHost: z.string().optional(), + + enableCheckpoints: z.boolean().optional(), + checkpointStorage: checkpointStoragesSchema.optional(), + + ttsEnabled: z.boolean().optional(), + ttsSpeed: z.number().optional(), + soundEnabled: z.boolean().optional(), + soundVolume: z.number().optional(), + + maxOpenTabsContext: z.number().optional(), + maxWorkspaceFiles: z.number().optional(), + showRooIgnoredFiles: z.boolean().optional(), + maxReadFileLine: z.number().optional(), + + terminalOutputLineLimit: z.number().optional(), + terminalShellIntegrationTimeout: z.number().optional(), + + rateLimitSeconds: z.number().optional(), + diffEnabled: z.boolean().optional(), + fuzzyMatchThreshold: z.number().optional(), + experiments: experimentIdSchema.optional(), + + language: languagesSchema.optional(), + + telemetrySetting: telemetrySettingsSchema.optional(), + + mcpEnabled: z.boolean().optional(), + enableMcpServerCreation: z.boolean().optional(), + + mode: z.string().optional(), + modeApiConfigs: z.record(z.string(), z.string()).optional(), + customModes: z.array(modeConfigSchema).optional(), + customModePrompts: z + .record( + z.string(), + z + .object({ + roleDefinition: z.string().optional(), + customInstructions: z.string().optional(), + }) + .optional(), + ) + .optional(), + customSupportPrompts: z.record(z.string(), z.string().optional()).optional(), + enhancementApiConfigId: z.string().optional(), +}) + +export type GlobalSettings = z.infer + +type TypeDefinition = { + schema: z.ZodTypeAny + identifier: string +} + +export const typeDefinitions: TypeDefinition[] = [ + { schema: providerNamesSchema, identifier: "ProviderName" }, + { schema: toolGroupsSchema, identifier: "ToolGroup" }, + { schema: checkpointStoragesSchema, identifier: "CheckpointStorage" }, + { schema: languagesSchema, identifier: "Language" }, + { schema: telemetrySettingsSchema, identifier: "TelemetrySetting" }, + { schema: modelInfoSchema, identifier: "ModelInfo" }, + { schema: apiConfigMetaSchema, identifier: "ApiConfigMeta" }, + { schema: historyItemSchema, identifier: "HistoryItem" }, + { schema: groupEntrySchema, identifier: "GroupEntry" }, + { schema: modeConfigSchema, identifier: "ModeConfig" }, + { schema: experimentIdSchema, identifier: "ExperimentId" }, + { schema: globalSettingsSchema, identifier: "GlobalSettings" }, +] From 3f611f48744922499ad632d9b21dbb91d77d1c63 Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 01:16:41 -0700 Subject: [PATCH 02/10] Automatically generate .d.ts from zod schemas --- .eslintrc.json | 2 +- .husky/pre-commit | 8 +- package-lock.json | 365 ++++++++- package.json | 4 +- .../{generate-types.ts => generate-types.mts} | 5 +- src/core/__tests__/mode-validator.test.ts | 11 +- src/core/config/ContextProxy.ts | 34 +- src/core/config/ProviderSettingsManager.ts | 3 +- .../config/__tests__/ContextProxy.test.ts | 5 +- .../__tests__/ProviderSettingsManager.test.ts | 2 +- .../config/__tests__/importExport.test.ts | 2 +- src/core/config/importExport.ts | 2 +- src/core/mode-validator.ts | 2 +- src/core/prompts/__tests__/system.test.ts | 15 +- .../prompts/sections/custom-instructions.ts | 3 +- src/core/webview/ClineProvider.ts | 16 +- src/exports/roo-code.d.ts | 427 +---------- src/exports/types.d.ts | 266 ------- src/exports/types.ts | 523 +++++++++++++ src/schemas/__tests__/index.test.ts | 17 + src/schemas/index.ts | 425 ++++++++++- src/shared/ExtensionMessage.ts | 25 +- src/shared/HistoryItem.ts | 2 +- src/shared/api.ts | 2 +- src/shared/checkExistApiConfig.ts | 3 +- src/shared/checkpoints.ts | 8 +- src/shared/experiments.ts | 3 +- src/shared/globalState.ts | 695 ------------------ src/shared/language.ts | 5 +- src/shared/modes.ts | 2 +- src/shared/tool-groups.ts | 2 +- 31 files changed, 1356 insertions(+), 1528 deletions(-) rename scripts/{generate-types.ts => generate-types.mts} (71%) delete mode 100644 src/exports/types.d.ts create mode 100644 src/exports/types.ts create mode 100644 src/schemas/__tests__/index.test.ts delete mode 100644 src/shared/globalState.ts diff --git a/.eslintrc.json b/.eslintrc.json index 500422ac4d..e967b58a03 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,5 +19,5 @@ "no-throw-literal": "warn", "semi": "off" }, - "ignorePatterns": ["out", "dist", "**/*.d.ts", "!src/exports/roo-code.d.ts", "!src/exports/types.d.ts"] + "ignorePatterns": ["out", "dist", "**/*.d.ts", "!roo-code.d.ts"] } diff --git a/.husky/pre-commit b/.husky/pre-commit index 19155fa3fc..3c381f1ce5 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -12,11 +12,11 @@ else npx_cmd="npx" fi -"$npx_cmd" tsx scripts/generate-types.ts +npm run generate-types -# Check if src/exports/types.d.ts has unstaged changes after running the script. -if [ -n "$(git diff --name-only src/exports/types.d.ts)" ]; then - echo "Error: There are unstaged changes to src/exports/types.d.ts after running generate-types.ts." +# Check if src/exports/types.ts has unstaged changes after running the script. +if [ -n "$(git diff --name-only src/exports/types.ts)" ]; then + echo "Error: There are unstaged changes to src/exports/types.ts after running 'npm run generate-types'." echo "Please review and stage the changes before committing." exit 1 fi diff --git a/package-lock.json b/package-lock.json index 3844c11576..c04ec0dff2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,6 +79,7 @@ "@typescript-eslint/parser": "^7.11.0", "esbuild": "^0.24.0", "eslint": "^8.57.0", + "execa": "^9.5.2", "glob": "^11.0.1", "husky": "^9.1.7", "jest": "^29.7.0", @@ -3109,6 +3110,30 @@ "node": ">=16" } }, + "node_modules/@dotenvx/dotenvx/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, "node_modules/@dotenvx/dotenvx/node_modules/fdir": { "version": "6.4.3", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz", @@ -3124,6 +3149,29 @@ } } }, + "node_modules/@dotenvx/dotenvx/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@dotenvx/dotenvx/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, "node_modules/@dotenvx/dotenvx/node_modules/isexe": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", @@ -3134,6 +3182,19 @@ "node": ">=16" } }, + "node_modules/@dotenvx/dotenvx/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@dotenvx/dotenvx/node_modules/picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", @@ -3147,6 +3208,23 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/@dotenvx/dotenvx/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/@dotenvx/dotenvx/node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/@dotenvx/dotenvx/node_modules/which": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", @@ -4657,6 +4735,13 @@ "node": ">=18" } }, + "node_modules/@sec-ant/readable-stream": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", + "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==", + "dev": true, + "license": "MIT" + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -9123,33 +9208,57 @@ } }, "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "version": "9.5.2", + "resolved": "https://registry.npmjs.org/execa/-/execa-9.5.2.tgz", + "integrity": "sha512-EHlpxMCpHWSAh1dgS6bVeoLAXGnJNdR93aabr4QCGbzOM73o5XmRfM/e5FUqsw3aagP8S8XEWUWFAxnRBnAF0Q==", "dev": true, + "license": "MIT", "dependencies": { + "@sindresorhus/merge-streams": "^4.0.0", "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" + "figures": "^6.1.0", + "get-stream": "^9.0.0", + "human-signals": "^8.0.0", + "is-plain-obj": "^4.1.0", + "is-stream": "^4.0.1", + "npm-run-path": "^6.0.0", + "pretty-ms": "^9.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^4.0.0", + "yoctocolors": "^2.0.0" }, "engines": { - "node": ">=10" + "node": "^18.19.0 || >=20.5.0" }, "funding": { "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/execa/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true + "node_modules/execa/node_modules/@sindresorhus/merge-streams": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", + "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/is-stream": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", + "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/exit": { "version": "0.1.2", @@ -9454,6 +9563,22 @@ "pend": "~1.2.0" } }, + "node_modules/figures": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz", + "integrity": "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-unicode-supported": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -9946,12 +10071,30 @@ } }, "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", + "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", "dev": true, + "license": "MIT", + "dependencies": { + "@sec-ant/readable-stream": "^0.4.1", + "is-stream": "^4.0.1" + }, "engines": { - "node": ">=10" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-stream/node_modules/is-stream": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", + "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -10315,12 +10458,13 @@ "dev": true }, "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.0.tgz", + "integrity": "sha512-/1/GPCpDUCCYwlERiYjxoczfP0zfvZMU/OWgQPMya9AbAE24vseigFdhAMObpc8Q4lc/kjutPfUddDYyAmejnA==", "dev": true, + "license": "Apache-2.0", "engines": { - "node": ">=10.17.0" + "node": ">=18.18.0" } }, "node_modules/humanize-ms": { @@ -10771,6 +10915,19 @@ "node": ">=8" } }, + "node_modules/is-plain-obj": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -10904,6 +11061,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-unicode-supported": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", + "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-weakmap": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", @@ -11156,6 +11326,83 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-changed-files/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/jest-changed-files/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-changed-files/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/jest-changed-files/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-changed-files/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/jest-changed-files/node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/jest-circus": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", @@ -12817,6 +13064,7 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -13222,15 +13470,46 @@ } }, "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-6.0.0.tgz", + "integrity": "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA==", "dev": true, + "license": "MIT", "dependencies": { - "path-key": "^3.0.0" + "path-key": "^4.0.0", + "unicorn-magic": "^0.3.0" }, "engines": { - "node": ">=8" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/unicorn-magic": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz", + "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/nth-check": { @@ -13331,6 +13610,7 @@ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, + "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" }, @@ -15368,12 +15648,16 @@ } }, "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-4.0.0.tgz", + "integrity": "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==", "dev": true, + "license": "MIT", "engines": { - "node": ">=6" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/strip-json-comments": { @@ -17100,6 +17384,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/yoctocolors": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.1.tgz", + "integrity": "sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/zod": { "version": "3.23.8", "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", diff --git a/package.json b/package.json index 11abc99ed8..30df090654 100644 --- a/package.json +++ b/package.json @@ -351,7 +351,8 @@ "clean:webview": "cd webview-ui && npm run clean", "clean:e2e": "cd e2e && npm run clean", "clean:benchmark": "cd benchmark && npm run clean", - "update-contributors": "node scripts/update-contributors.js" + "update-contributors": "node scripts/update-contributors.js", + "generate-types": "tsx scripts/generate-types.mts" }, "dependencies": { "@anthropic-ai/bedrock-sdk": "^0.10.2", @@ -425,6 +426,7 @@ "@typescript-eslint/parser": "^7.11.0", "esbuild": "^0.24.0", "eslint": "^8.57.0", + "execa": "^9.5.2", "glob": "^11.0.1", "husky": "^9.1.7", "jest": "^29.7.0", diff --git a/scripts/generate-types.ts b/scripts/generate-types.mts similarity index 71% rename from scripts/generate-types.ts rename to scripts/generate-types.mts index a40afc43b3..e6bf40b134 100644 --- a/scripts/generate-types.ts +++ b/scripts/generate-types.mts @@ -1,6 +1,7 @@ import fs from "fs/promises" import { zodToTs, createTypeAlias, printNode } from "zod-to-ts" +import { $ } from "execa" import { typeDefinitions } from "../src/schemas" @@ -11,9 +12,11 @@ async function main() { for (const { schema, identifier } of typeDefinitions) { types.push(printNode(createTypeAlias(zodToTs(schema, identifier).node, identifier))) + types.push(`export type { ${identifier} }`) } - await fs.writeFile("src/exports/types.d.ts", types.join("\n\n")) + await fs.writeFile("src/exports/types.ts", types.join("\n\n")) + await $`npx prettier --write src/exports/types.ts` } main() diff --git a/src/core/__tests__/mode-validator.test.ts b/src/core/__tests__/mode-validator.test.ts index 632ca8a8ab..fee41971c6 100644 --- a/src/core/__tests__/mode-validator.test.ts +++ b/src/core/__tests__/mode-validator.test.ts @@ -1,6 +1,7 @@ -import { Mode, isToolAllowedForMode, getModeConfig, modes } from "../../shared/modes" -import { validateToolUse } from "../mode-validator" +import { isToolAllowedForMode, getModeConfig, modes, ModeConfig } from "../../shared/modes" import { TOOL_GROUPS } from "../../shared/tool-groups" +import { validateToolUse } from "../mode-validator" + const [codeMode, architectMode, askMode] = modes.map((mode) => mode.slug) describe("mode-validator", () => { @@ -49,7 +50,7 @@ describe("mode-validator", () => { describe("custom modes", () => { it("allows tools from custom mode configuration", () => { - const customModes = [ + const customModes: ModeConfig[] = [ { slug: "custom-mode", name: "Custom Mode", @@ -65,7 +66,7 @@ describe("mode-validator", () => { }) it("allows custom mode to override built-in mode", () => { - const customModes = [ + const customModes: ModeConfig[] = [ { slug: codeMode, name: "Custom Code Mode", @@ -80,7 +81,7 @@ describe("mode-validator", () => { }) it("respects tool requirements in custom modes", () => { - const customModes = [ + const customModes: ModeConfig[] = [ { slug: "custom-mode", name: "Custom Mode", diff --git a/src/core/config/ContextProxy.ts b/src/core/config/ContextProxy.ts index f4a8c56a8d..48c9846856 100644 --- a/src/core/config/ContextProxy.ts +++ b/src/core/config/ContextProxy.ts @@ -1,25 +1,27 @@ import * as vscode from "vscode" -import { logger } from "../../utils/logging" -import type { - ProviderSettings, - RooCodeSettings, - RooCodeSettingsKey, - GlobalStateKey, - GlobalState, - SecretStateKey, - SecretState, - GlobalSettings, -} from "../../exports/roo-code" import { PROVIDER_SETTINGS_KEYS, - GLOBAL_STATE_KEYS, + ProviderSettings, + providerSettingsSchema, + GlobalSettings, + globalSettingsSchema, + RooCodeSettings, SECRET_STATE_KEYS, + SecretState, isSecretStateKey, - isPassThroughStateKey, - globalSettingsSchema, - providerSettingsSchema, -} from "../../shared/globalState" + GLOBAL_STATE_KEYS, + GlobalState, +} from "../../schemas" +import { logger } from "../../utils/logging" + +type GlobalStateKey = keyof GlobalState +type SecretStateKey = keyof SecretState +type RooCodeSettingsKey = keyof RooCodeSettings + +const PASS_THROUGH_STATE_KEYS = ["taskHistory"] + +export const isPassThroughStateKey = (key: string) => PASS_THROUGH_STATE_KEYS.includes(key) const globalSettingsExportSchema = globalSettingsSchema.omit({ taskHistory: true, diff --git a/src/core/config/ProviderSettingsManager.ts b/src/core/config/ProviderSettingsManager.ts index 5a25f4dfdb..471abe7e18 100644 --- a/src/core/config/ProviderSettingsManager.ts +++ b/src/core/config/ProviderSettingsManager.ts @@ -1,9 +1,8 @@ import { ExtensionContext } from "vscode" import { z } from "zod" -import { providerSettingsSchema } from "../../shared/globalState" +import { providerSettingsSchema, ApiConfigMeta } from "../../schemas" import { Mode } from "../../shared/modes" -import { ApiConfigMeta } from "../../shared/ExtensionMessage" const providerSettingsWithIdSchema = providerSettingsSchema.extend({ id: z.string().optional() }) diff --git a/src/core/config/__tests__/ContextProxy.test.ts b/src/core/config/__tests__/ContextProxy.test.ts index 85b72c8a32..bdd3d5ddc5 100644 --- a/src/core/config/__tests__/ContextProxy.test.ts +++ b/src/core/config/__tests__/ContextProxy.test.ts @@ -1,12 +1,9 @@ // npx jest src/core/config/__tests__/ContextProxy.test.ts -import fs from "fs/promises" - import * as vscode from "vscode" import { ContextProxy } from "../ContextProxy" -import { logger } from "../../../utils/logging" -import { GLOBAL_STATE_KEYS, SECRET_STATE_KEYS } from "../../../shared/globalState" +import { GLOBAL_STATE_KEYS, SECRET_STATE_KEYS } from "../../../schemas" jest.mock("vscode", () => ({ Uri: { diff --git a/src/core/config/__tests__/ProviderSettingsManager.test.ts b/src/core/config/__tests__/ProviderSettingsManager.test.ts index 43cc789beb..c72abdab65 100644 --- a/src/core/config/__tests__/ProviderSettingsManager.test.ts +++ b/src/core/config/__tests__/ProviderSettingsManager.test.ts @@ -2,7 +2,7 @@ import { ExtensionContext } from "vscode" -import { ProviderSettings } from "../../../exports/roo-code" +import { ProviderSettings } from "../../../schemas" import { ProviderSettingsManager, ProviderProfiles } from "../ProviderSettingsManager" // Mock VSCode ExtensionContext diff --git a/src/core/config/__tests__/importExport.test.ts b/src/core/config/__tests__/importExport.test.ts index f5d370605b..8df619f3bf 100644 --- a/src/core/config/__tests__/importExport.test.ts +++ b/src/core/config/__tests__/importExport.test.ts @@ -6,10 +6,10 @@ import os from "os" import * as vscode from "vscode" +import { ProviderName } from "../../../schemas" import { importSettings, exportSettings } from "../importExport" import { ProviderSettingsManager } from "../ProviderSettingsManager" import { ContextProxy } from "../ContextProxy" -import { ProviderName } from "../../../exports/roo-code" // Mock VSCode modules jest.mock("vscode", () => ({ diff --git a/src/core/config/importExport.ts b/src/core/config/importExport.ts index 35782b5fed..3bd2c2ede8 100644 --- a/src/core/config/importExport.ts +++ b/src/core/config/importExport.ts @@ -5,7 +5,7 @@ import fs from "fs/promises" import * as vscode from "vscode" import { z } from "zod" -import { globalSettingsSchema } from "../../shared/globalState" +import { globalSettingsSchema } from "../../schemas" import { ProviderSettingsManager, providerProfilesSchema } from "./ProviderSettingsManager" import { ContextProxy } from "./ContextProxy" diff --git a/src/core/mode-validator.ts b/src/core/mode-validator.ts index 509496fa36..415c06cc36 100644 --- a/src/core/mode-validator.ts +++ b/src/core/mode-validator.ts @@ -1,4 +1,4 @@ -import { Mode, isToolAllowedForMode, getModeConfig, ModeConfig, FileRestrictionError } from "../shared/modes" +import { Mode, isToolAllowedForMode, ModeConfig } from "../shared/modes" import { ToolName } from "../shared/tool-groups" export { isToolAllowedForMode } diff --git a/src/core/prompts/__tests__/system.test.ts b/src/core/prompts/__tests__/system.test.ts index 9750d13b3c..0e9d643923 100644 --- a/src/core/prompts/__tests__/system.test.ts +++ b/src/core/prompts/__tests__/system.test.ts @@ -1,16 +1,12 @@ +import * as vscode from "vscode" + import { SYSTEM_PROMPT } from "../system" import { McpHub } from "../../../services/mcp/McpHub" -import { McpServer } from "../../../shared/mcp" import { ClineProvider } from "../../../core/webview/ClineProvider" import { SearchReplaceDiffStrategy } from "../../../core/diff/strategies/search-replace" -import * as vscode from "vscode" -import fs from "fs/promises" -import os from "os" -import { defaultModeSlug, modes, Mode, isToolAllowedForMode } from "../../../shared/modes" -// Import path utils to get access to toPosix string extension -import "../../../utils/path" +import { defaultModeSlug, modes, Mode, ModeConfig } from "../../../shared/modes" +import "../../../utils/path" // Import path utils to get access to toPosix string extension. import { addCustomInstructions } from "../sections/custom-instructions" -import * as modesSection from "../sections/modes" import { EXPERIMENT_IDS } from "../../../shared/experiments" // Mock the sections @@ -386,7 +382,8 @@ describe("SYSTEM_PROMPT", () => { it("should include custom mode role definition at top and instructions at bottom", async () => { const modeCustomInstructions = "Custom mode instructions" - const customModes = [ + + const customModes: ModeConfig[] = [ { slug: "custom-mode", name: "Custom Mode", diff --git a/src/core/prompts/sections/custom-instructions.ts b/src/core/prompts/sections/custom-instructions.ts index 8aeb958917..bf5b009bc2 100644 --- a/src/core/prompts/sections/custom-instructions.ts +++ b/src/core/prompts/sections/custom-instructions.ts @@ -1,8 +1,7 @@ import fs from "fs/promises" import path from "path" -import { LANGUAGES } from "../../../shared/language" -import { isLanguage } from "../../../shared/globalState" +import { LANGUAGES, isLanguage } from "../../../shared/language" async function safeReadFile(filePath: string): Promise { try { diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 5f51b3f9e9..baa10b24a5 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -12,12 +12,12 @@ import * as vscode from "vscode" import { CheckpointStorage, GlobalState, + SecretState, Language, ProviderSettings, RooCodeSettings, - GlobalStateKey, - SecretStateKey, -} from "../../exports/roo-code" + ApiConfigMeta, +} from "../../schemas" import { changeLanguage, t } from "../../i18n" import { setPanel } from "../../activate/registerCommands" import { @@ -35,7 +35,7 @@ import { findLast } from "../../shared/array" import { supportPrompt } from "../../shared/support-prompt" import { GlobalFileNames } from "../../shared/globalFileNames" import { HistoryItem } from "../../shared/HistoryItem" -import { ApiConfigMeta, ExtensionMessage } from "../../shared/ExtensionMessage" +import { ExtensionMessage } from "../../shared/ExtensionMessage" import { checkoutDiffPayloadSchema, checkoutRestorePayloadSchema, WebviewMessage } from "../../shared/WebviewMessage" import { Mode, PromptComponent, defaultModeSlug, getModeBySlug, getGroupName } from "../../shared/modes" import { checkExistKey } from "../../shared/checkExistApiConfig" @@ -2804,21 +2804,21 @@ export class ClineProvider extends EventEmitter implements // global - public async updateGlobalState(key: K, value: GlobalState[K]) { + public async updateGlobalState(key: K, value: GlobalState[K]) { await this.contextProxy.setValue(key, value) } - public getGlobalState(key: K) { + public getGlobalState(key: K) { return this.contextProxy.getValue(key) } // secrets - public async storeSecret(key: SecretStateKey, value?: string) { + public async storeSecret(key: keyof SecretState, value?: string) { await this.contextProxy.setValue(key, value) } - private getSecret(key: SecretStateKey) { + private getSecret(key: keyof SecretState) { return this.contextProxy.getValue(key) } diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 4af32695fd..8def29c870 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -2,6 +2,10 @@ import * as vscode from "vscode" import { EventEmitter } from "events" +import type { ProviderSettings, GlobalSettings } from "./types" + +export type RooCodeSettings = GlobalSettings & ProviderSettings + export interface TokenUsage { totalTokensIn: number totalTokensOut: number @@ -70,7 +74,7 @@ export interface RooCodeAPI extends EventEmitter { * Sets the configuration for the current task. * @param values An object containing key-value pairs to set. */ - setConfiguration(values: Partial): Promise + setConfiguration(values: RooCodeSettings): Promise /** * Returns true if the API is ready to use. @@ -138,6 +142,11 @@ export type ClineSay = | "checkpoint_saved" | "rooignore_error" +export type ToolProgressStatus = { + icon?: string + text?: string +} + export interface ClineMessage { ts: number type: "ask" | "say" @@ -151,419 +160,3 @@ export interface ClineMessage { checkpoint?: Record progressStatus?: ToolProgressStatus } - -export interface ModelInfo { - maxTokens?: number - contextWindow: number - supportsImages?: boolean - supportsComputerUse?: boolean - supportsPromptCache: boolean // This value is hardcoded for now. - inputPrice?: number - outputPrice?: number - cacheWritesPrice?: number - cacheReadsPrice?: number - description?: string - reasoningEffort?: "low" | "medium" | "high" - thinking?: boolean -} - -export interface ApiConfigMeta { - id: string - name: string - apiProvider?: ProviderName -} - -export type HistoryItem = { - id: string - number: number - ts: number - task: string - tokensIn: number - tokensOut: number - cacheWrites?: number - cacheReads?: number - totalCost: number - size?: number -} - -export type ExperimentId = - | "experimentalDiffStrategy" - | "search_and_replace" - | "insert_content" - | "powerSteering" - | "multi_search_and_replace" - -export type CheckpointStorage = "task" | "workspace" - -export type GroupOptions = { - fileRegex?: string // Regular expression pattern. - description?: string // Human-readable description of the pattern. -} - -export type ToolGroup = "read" | "edit" | "browser" | "command" | "mcp" | "modes" - -export type GroupEntry = ToolGroup | readonly [ToolGroup, GroupOptions] - -export type ModeConfig = { - slug: string - name: string - roleDefinition: string - customInstructions?: string - groups: readonly GroupEntry[] // Now supports both simple strings and tuples with options - source?: "global" | "project" // Where this mode was loaded from -} - -export type PromptComponent = { - roleDefinition?: string - customInstructions?: string -} - -export type CustomModePrompts = { - [key: string]: PromptComponent | undefined -} - -export type CustomSupportPrompts = { - [key: string]: string | undefined -} - -export type TelemetrySetting = "unset" | "enabled" | "disabled" - -export type Language = - | "ca" - | "de" - | "en" - | "es" - | "fr" - | "hi" - | "it" - | "ja" - | "ko" - | "pl" - | "pt-BR" - | "tr" - | "vi" - | "zh-CN" - | "zh-TW" - -/** - * GlobalSettings - * - * These are settings that apply globally. - * They are all stored in the global state. - */ - -export interface GlobalSettings { - currentApiConfigName?: string - listApiConfigMeta?: ApiConfigMeta[] - pinnedApiConfigs?: Record - - lastShownAnnouncementId?: string - customInstructions?: string - taskHistory?: HistoryItem[] - - autoApprovalEnabled?: boolean - alwaysAllowReadOnly?: boolean - alwaysAllowReadOnlyOutsideWorkspace?: boolean - alwaysAllowWrite?: boolean - alwaysAllowWriteOutsideWorkspace?: boolean - writeDelayMs?: number - alwaysAllowBrowser?: boolean - alwaysApproveResubmit?: boolean - requestDelaySeconds?: number - alwaysAllowMcp?: boolean - alwaysAllowModeSwitch?: boolean - alwaysAllowSubtasks?: boolean - alwaysAllowExecute?: boolean - allowedCommands?: string[] - - browserToolEnabled?: boolean - browserViewportSize?: string - screenshotQuality?: number - remoteBrowserEnabled?: boolean - remoteBrowserHost?: string - - enableCheckpoints?: boolean - checkpointStorage?: CheckpointStorage - - ttsEnabled?: boolean - ttsSpeed?: number - soundEnabled?: boolean - soundVolume?: number - - maxOpenTabsContext?: number - maxWorkspaceFiles?: number - showRooIgnoredFiles?: boolean - maxReadFileLine?: number - - terminalOutputLineLimit?: number - terminalShellIntegrationTimeout?: number - - rateLimitSeconds?: number - diffEnabled?: boolean - fuzzyMatchThreshold?: number - experiments?: Record // Map of experiment IDs to their enabled state. - - language?: Language - - telemetrySetting?: TelemetrySetting - - mcpEnabled?: boolean - enableMcpServerCreation?: boolean - - mode?: string - modeApiConfigs?: Record - customModes?: ModeConfig[] - customModePrompts?: CustomModePrompts - customSupportPrompts?: CustomSupportPrompts - enhancementApiConfigId?: string -} - -export type GlobalSettingsKey = keyof GlobalSettings - -/** - * ProviderSettings - * - * These are settings that apply on a per-provider basis. - * Non-sensitive values are stored in the global state. - * Sensitive values are stored in VSCode secrets. - */ - -/** - * DiscriminatedProviderSettings - * - * NOTE: This is actually how our provider settings should be typed, but it - * will take a little elbow grease to move to this shape. For now we're just - * using it to generate the `ProviderName`. - */ - -export type DiscriminatedProviderSettings = - | { - apiProvider: "anthropic" - apiKey?: string - anthropicBaseUrl?: string - apiModelId?: string - } - | { - apiProvider: "glama" - glamaApiKey?: string - glamaModelId?: string - } - | { - apiProvider: "openrouter" - openRouterApiKey?: string - openRouterModelId?: string - openRouterBaseUrl?: string - openRouterSpecificProvider?: string - openRouterUseMiddleOutTransform?: boolean - } - | { - apiProvider: "bedrock" - awsAccessKey?: string - awsSecretKey?: string - awsSessionToken?: string - awsRegion?: string - awsUseCrossRegionInference?: boolean - awsUsePromptCache?: boolean - awspromptCacheId?: string - awsProfile?: string - awsUseProfile?: boolean - awsCustomArn?: string - } - | { - apiProvider: "vertex" - vertexKeyFile?: string - vertexJsonCredentials?: string - vertexProjectId?: string - vertexRegion?: string - } - | { - apiProvider: "openai" - openAiApiKey?: string - openAiBaseUrl?: string - openAiR1FormatEnabled?: boolean - openAiModelId?: string - openAiUseAzure?: boolean - azureApiVersion?: string - openAiStreamingEnabled?: boolean - } - | { - apiProvider: "ollama" - ollamaModelId?: string - ollamaBaseUrl?: string - } - | { - apiProvider: "vscode-lm" - vsCodeLmModelSelector?: vscode.LanguageModelChatSelector - } - | { - apiProvider: "lmstudio" - lmStudioModelId?: string - lmStudioBaseUrl?: string - lmStudioDraftModelId?: string - lmStudioSpeculativeDecodingEnabled?: boolean - } - | { - apiProvider: "gemini" - googleGeminiBaseUrl?: string - } - | { - apiProvider: "openai-native" - openAiNativeApiKey?: string - } - | { - apiProvider: "mistral" - mistralApiKey?: string - mistralCodestralUrl?: string - } - | { - apiProvider: "deepseek" - deepSeekApiKey?: string - deepSeekBaseUrl?: string - } - | { - apiProvider: "unbound" - unboundApiKey?: string - unboundModelId?: string - } - | { - apiProvider: "requesty" - requestyApiKey?: string - requestyModelId?: string - } - | { - apiProvider: "human-relay" - } - | { - apiProvider: "fake-ai" - fakeAi?: unknown - } - -export type ProviderName = DiscriminatedProviderSettings["apiProvider"] - -export interface ProviderSettings { - apiProvider?: ProviderName - apiModelId?: string - // Anthropic - apiKey?: string // secret - anthropicBaseUrl?: string - // Glama - glamaApiKey?: string // secret - glamaModelId?: string - glamaModelInfo?: ModelInfo - // OpenRouter - openRouterApiKey?: string // secret - openRouterModelId?: string - openRouterModelInfo?: ModelInfo - openRouterBaseUrl?: string - openRouterSpecificProvider?: string - openRouterUseMiddleOutTransform?: boolean - // AWS Bedrock - awsAccessKey?: string // secret - awsSecretKey?: string // secret - awsSessionToken?: string // secret - awsRegion?: string - awsUseCrossRegionInference?: boolean - awsUsePromptCache?: boolean - awspromptCacheId?: string - awsProfile?: string - awsUseProfile?: boolean - awsCustomArn?: string - // Google Vertex - vertexKeyFile?: string - vertexJsonCredentials?: string - vertexProjectId?: string - vertexRegion?: string - // OpenAI - openAiApiKey?: string // secret - openAiBaseUrl?: string - openAiR1FormatEnabled?: boolean - openAiModelId?: string - openAiCustomModelInfo?: ModelInfo - openAiUseAzure?: boolean - azureApiVersion?: string - openAiStreamingEnabled?: boolean - // Ollama - ollamaModelId?: string - ollamaBaseUrl?: string - // VS Code LM - vsCodeLmModelSelector?: vscode.LanguageModelChatSelector - // LM Studio - lmStudioModelId?: string - lmStudioBaseUrl?: string - lmStudioDraftModelId?: string - lmStudioSpeculativeDecodingEnabled?: boolean - // Gemini - geminiApiKey?: string // secret - googleGeminiBaseUrl?: string - // OpenAI Native - openAiNativeApiKey?: string // secret - // Mistral - mistralApiKey?: string // secret - mistralCodestralUrl?: string // New option for Codestral URL. - // DeepSeek - deepSeekApiKey?: string // secret - deepSeekBaseUrl?: string - // Unbound - unboundApiKey?: string // secret - unboundModelId?: string - unboundModelInfo?: ModelInfo - // Requesty - requestyApiKey?: string - requestyModelId?: string - requestyModelInfo?: ModelInfo - // Claude 3.7 Sonnet Thinking - modelTemperature?: number | null - modelMaxTokens?: number - modelMaxThinkingTokens?: number - // Generic (For now though, OpenAI, DeekSeek, Mistral, and Requesty make reference to it.) - includeMaxTokens?: boolean - // Fake AI - fakeAi?: unknown -} - -export type ProviderSettingsKey = keyof ProviderSettings - -/** - * RooCodeSettings - * - * All settings, irrespective of scope and storage. - */ - -export type RooCodeSettings = GlobalSettings & ProviderSettings - -export type RooCodeSettingsKey = keyof RooCodeSettings - -/** - * SecretState - * - * All settings that are stored in VSCode secrets. - */ - -export type SecretState = Pick< - RooCodeSettings, - | "apiKey" - | "glamaApiKey" - | "openRouterApiKey" - | "awsAccessKey" - | "awsSecretKey" - | "awsSessionToken" - | "openAiApiKey" - | "geminiApiKey" - | "openAiNativeApiKey" - | "deepSeekApiKey" - | "mistralApiKey" - | "unboundApiKey" - | "requestyApiKey" -> - -export type SecretStateKey = keyof SecretState - -/** - * GlobalState - * - * All settings that are stored in the global state. - */ - -export type GlobalState = Omit - -export type GlobalStateKey = keyof GlobalState diff --git a/src/exports/types.d.ts b/src/exports/types.d.ts deleted file mode 100644 index c8a903ce58..0000000000 --- a/src/exports/types.d.ts +++ /dev/null @@ -1,266 +0,0 @@ -// This file is automatically generated by running `npx tsx scripts/generated-types.ts` -// Do not edit it directly. - -type ProviderName = - | "anthropic" - | "glama" - | "openrouter" - | "bedrock" - | "vertex" - | "openai" - | "ollama" - | "vscode-lm" - | "lmstudio" - | "gemini" - | "openai-native" - | "mistral" - | "deepseek" - | "unbound" - | "requesty" - | "human-relay" - | "fake-ai" - -type ToolGroup = "read" | "edit" | "browser" | "command" | "mcp" | "modes" - -type CheckpointStorage = "task" | "workspace" - -type Language = - | "ca" - | "de" - | "en" - | "es" - | "fr" - | "hi" - | "it" - | "ja" - | "ko" - | "pl" - | "pt-BR" - | "tr" - | "vi" - | "zh-CN" - | "zh-TW" - -type TelemetrySetting = "unset" | "enabled" | "disabled" - -type ModelInfo = { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined -} - -type ApiConfigMeta = { - id: string - name: string - apiProvider?: - | ( - | "anthropic" - | "glama" - | "openrouter" - | "bedrock" - | "vertex" - | "openai" - | "ollama" - | "vscode-lm" - | "lmstudio" - | "gemini" - | "openai-native" - | "mistral" - | "deepseek" - | "unbound" - | "requesty" - | "human-relay" - | "fake-ai" - ) - | undefined -} - -type HistoryItem = { - id: string - number: number - ts: number - task: string - tokensIn: number - tokensOut: number - cacheWrites?: number | undefined - cacheReads?: number | undefined - totalCost: number - size?: number | undefined -} - -type GroupEntry = ("read" | "edit" | "browser" | "command" | "mcp" | "modes") | any - -type ModeConfig = { - slug: string - name: string - roleDefinition: string - customInstructions?: string | undefined - groups: any - source?: ("global" | "project") | undefined -} - -type ExperimentId = { - experimentalDiffStrategy: boolean - search_and_replace: boolean - insert_content: boolean - powerSteering: boolean - multi_search_and_replace: boolean -} - -type GlobalSettings = { - currentApiConfigName?: string | undefined - listApiConfigMeta?: - | { - id: string - name: string - apiProvider?: - | ( - | "anthropic" - | "glama" - | "openrouter" - | "bedrock" - | "vertex" - | "openai" - | "ollama" - | "vscode-lm" - | "lmstudio" - | "gemini" - | "openai-native" - | "mistral" - | "deepseek" - | "unbound" - | "requesty" - | "human-relay" - | "fake-ai" - ) - | undefined - }[] - | undefined - pinnedApiConfigs?: - | { - [x: string]: boolean - } - | undefined - lastShownAnnouncementId?: string | undefined - customInstructions?: string | undefined - taskHistory?: - | { - id: string - number: number - ts: number - task: string - tokensIn: number - tokensOut: number - cacheWrites?: number | undefined - cacheReads?: number | undefined - totalCost: number - size?: number | undefined - }[] - | undefined - autoApprovalEnabled?: boolean | undefined - alwaysAllowReadOnly?: boolean | undefined - alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined - alwaysAllowWrite?: boolean | undefined - alwaysAllowWriteOutsideWorkspace?: boolean | undefined - writeDelayMs?: number | undefined - alwaysAllowBrowser?: boolean | undefined - alwaysApproveResubmit?: boolean | undefined - requestDelaySeconds?: number | undefined - alwaysAllowMcp?: boolean | undefined - alwaysAllowModeSwitch?: boolean | undefined - alwaysAllowSubtasks?: boolean | undefined - alwaysAllowExecute?: boolean | undefined - allowedCommands?: string[] | undefined - browserToolEnabled?: boolean | undefined - browserViewportSize?: string | undefined - screenshotQuality?: number | undefined - remoteBrowserEnabled?: boolean | undefined - remoteBrowserHost?: string | undefined - enableCheckpoints?: boolean | undefined - checkpointStorage?: ("task" | "workspace") | undefined - ttsEnabled?: boolean | undefined - ttsSpeed?: number | undefined - soundEnabled?: boolean | undefined - soundVolume?: number | undefined - maxOpenTabsContext?: number | undefined - maxWorkspaceFiles?: number | undefined - showRooIgnoredFiles?: boolean | undefined - maxReadFileLine?: number | undefined - terminalOutputLineLimit?: number | undefined - terminalShellIntegrationTimeout?: number | undefined - rateLimitSeconds?: number | undefined - diffEnabled?: boolean | undefined - fuzzyMatchThreshold?: number | undefined - experiments?: - | { - experimentalDiffStrategy: boolean - search_and_replace: boolean - insert_content: boolean - powerSteering: boolean - multi_search_and_replace: boolean - } - | undefined - language?: - | ( - | "ca" - | "de" - | "en" - | "es" - | "fr" - | "hi" - | "it" - | "ja" - | "ko" - | "pl" - | "pt-BR" - | "tr" - | "vi" - | "zh-CN" - | "zh-TW" - ) - | undefined - telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined - mcpEnabled?: boolean | undefined - enableMcpServerCreation?: boolean | undefined - mode?: string | undefined - modeApiConfigs?: - | { - [x: string]: string - } - | undefined - customModes?: - | { - slug: string - name: string - roleDefinition: string - customInstructions?: string | undefined - groups: any - source?: ("global" | "project") | undefined - }[] - | undefined - customModePrompts?: - | { - [x: string]: - | { - roleDefinition?: string | undefined - customInstructions?: string | undefined - } - | undefined - } - | undefined - customSupportPrompts?: - | { - [x: string]: string | undefined - } - | undefined - enhancementApiConfigId?: string | undefined -} diff --git a/src/exports/types.ts b/src/exports/types.ts new file mode 100644 index 0000000000..434db4d2dd --- /dev/null +++ b/src/exports/types.ts @@ -0,0 +1,523 @@ +// This file is automatically generated by running `npx tsx scripts/generated-types.ts` +// Do not edit it directly. + +type ProviderName = + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + +export type { ProviderName } + +type ToolGroup = "read" | "edit" | "browser" | "command" | "mcp" | "modes" + +export type { ToolGroup } + +type CheckpointStorage = "task" | "workspace" + +export type { CheckpointStorage } + +type Language = + | "ca" + | "de" + | "en" + | "es" + | "fr" + | "hi" + | "it" + | "ja" + | "ko" + | "pl" + | "pt-BR" + | "tr" + | "vi" + | "zh-CN" + | "zh-TW" + +export type { Language } + +type TelemetrySetting = "unset" | "enabled" | "disabled" + +export type { TelemetrySetting } + +type ModelInfo = { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined +} + +export type { ModelInfo } + +type ApiConfigMeta = { + id: string + name: string + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined +} + +export type { ApiConfigMeta } + +type HistoryItem = { + id: string + number: number + ts: number + task: string + tokensIn: number + tokensOut: number + cacheWrites?: number | undefined + cacheReads?: number | undefined + totalCost: number + size?: number | undefined +} + +export type { HistoryItem } + +type GroupOptions = { + fileRegex?: string | undefined + description?: string | undefined +} + +export type { GroupOptions } + +type GroupEntry = + | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") + | [ + "read" | "edit" | "browser" | "command" | "mcp" | "modes", + { + fileRegex?: string | undefined + description?: string | undefined + }, + ] + +export type { GroupEntry } + +type ModeConfig = { + slug: string + name: string + roleDefinition: string + customInstructions?: string | undefined + groups: ( + | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") + | [ + "read" | "edit" | "browser" | "command" | "mcp" | "modes", + { + fileRegex?: string | undefined + description?: string | undefined + }, + ] + )[] + source?: ("global" | "project") | undefined +} + +export type { ModeConfig } + +type PromptComponent = { + roleDefinition?: string | undefined + customInstructions?: string | undefined +} + +export type { PromptComponent } + +type CustomModePrompts = { + [x: string]: + | { + roleDefinition?: string | undefined + customInstructions?: string | undefined + } + | undefined +} + +export type { CustomModePrompts } + +type CustomSupportPrompts = { + [x: string]: string | undefined +} + +export type { CustomSupportPrompts } + +type ExperimentId = + | "experimentalDiffStrategy" + | "search_and_replace" + | "insert_content" + | "powerSteering" + | "multi_search_and_replace" + +export type { ExperimentId } + +type Experiments = { + experimentalDiffStrategy: boolean + search_and_replace: boolean + insert_content: boolean + powerSteering: boolean + multi_search_and_replace: boolean +} + +export type { Experiments } + +type GlobalSettings = { + currentApiConfigName?: string | undefined + listApiConfigMeta?: + | { + id: string + name: string + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined + }[] + | undefined + pinnedApiConfigs?: + | { + [x: string]: boolean + } + | undefined + lastShownAnnouncementId?: string | undefined + customInstructions?: string | undefined + taskHistory?: + | { + id: string + number: number + ts: number + task: string + tokensIn: number + tokensOut: number + cacheWrites?: number | undefined + cacheReads?: number | undefined + totalCost: number + size?: number | undefined + }[] + | undefined + autoApprovalEnabled?: boolean | undefined + alwaysAllowReadOnly?: boolean | undefined + alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined + alwaysAllowWrite?: boolean | undefined + alwaysAllowWriteOutsideWorkspace?: boolean | undefined + writeDelayMs?: number | undefined + alwaysAllowBrowser?: boolean | undefined + alwaysApproveResubmit?: boolean | undefined + requestDelaySeconds?: number | undefined + alwaysAllowMcp?: boolean | undefined + alwaysAllowModeSwitch?: boolean | undefined + alwaysAllowSubtasks?: boolean | undefined + alwaysAllowExecute?: boolean | undefined + allowedCommands?: string[] | undefined + browserToolEnabled?: boolean | undefined + browserViewportSize?: string | undefined + screenshotQuality?: number | undefined + remoteBrowserEnabled?: boolean | undefined + remoteBrowserHost?: string | undefined + enableCheckpoints?: boolean | undefined + checkpointStorage?: ("task" | "workspace") | undefined + ttsEnabled?: boolean | undefined + ttsSpeed?: number | undefined + soundEnabled?: boolean | undefined + soundVolume?: number | undefined + maxOpenTabsContext?: number | undefined + maxWorkspaceFiles?: number | undefined + showRooIgnoredFiles?: boolean | undefined + maxReadFileLine?: number | undefined + terminalOutputLineLimit?: number | undefined + terminalShellIntegrationTimeout?: number | undefined + rateLimitSeconds?: number | undefined + diffEnabled?: boolean | undefined + fuzzyMatchThreshold?: number | undefined + experiments?: + | { + experimentalDiffStrategy: boolean + search_and_replace: boolean + insert_content: boolean + powerSteering: boolean + multi_search_and_replace: boolean + } + | undefined + language?: + | ( + | "ca" + | "de" + | "en" + | "es" + | "fr" + | "hi" + | "it" + | "ja" + | "ko" + | "pl" + | "pt-BR" + | "tr" + | "vi" + | "zh-CN" + | "zh-TW" + ) + | undefined + telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined + mcpEnabled?: boolean | undefined + enableMcpServerCreation?: boolean | undefined + mode?: string | undefined + modeApiConfigs?: + | { + [x: string]: string + } + | undefined + customModes?: + | { + slug: string + name: string + roleDefinition: string + customInstructions?: string | undefined + groups: ( + | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") + | [ + "read" | "edit" | "browser" | "command" | "mcp" | "modes", + { + fileRegex?: string | undefined + description?: string | undefined + }, + ] + )[] + source?: ("global" | "project") | undefined + }[] + | undefined + customModePrompts?: + | { + [x: string]: + | { + roleDefinition?: string | undefined + customInstructions?: string | undefined + } + | undefined + } + | undefined + customSupportPrompts?: + | { + [x: string]: string | undefined + } + | undefined + enhancementApiConfigId?: string | undefined +} + +export type { GlobalSettings } + +type ProviderSettings = { + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined + apiModelId?: string | undefined + apiKey?: string | undefined + anthropicBaseUrl?: string | undefined + glamaModelId?: string | undefined + glamaModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + glamaApiKey?: string | undefined + openRouterApiKey?: string | undefined + openRouterModelId?: string | undefined + openRouterModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + openRouterBaseUrl?: string | undefined + openRouterSpecificProvider?: string | undefined + openRouterUseMiddleOutTransform?: boolean | undefined + awsAccessKey?: string | undefined + awsSecretKey?: string | undefined + awsSessionToken?: string | undefined + awsRegion?: string | undefined + awsUseCrossRegionInference?: boolean | undefined + awsUsePromptCache?: boolean | undefined + awspromptCacheId?: string | undefined + awsProfile?: string | undefined + awsUseProfile?: boolean | undefined + awsCustomArn?: string | undefined + vertexKeyFile?: string | undefined + vertexJsonCredentials?: string | undefined + vertexProjectId?: string | undefined + vertexRegion?: string | undefined + openAiBaseUrl?: string | undefined + openAiApiKey?: string | undefined + openAiR1FormatEnabled?: boolean | undefined + openAiModelId?: string | undefined + openAiCustomModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + openAiUseAzure?: boolean | undefined + azureApiVersion?: string | undefined + openAiStreamingEnabled?: boolean | undefined + ollamaModelId?: string | undefined + ollamaBaseUrl?: string | undefined + vsCodeLmModelSelector?: + | { + vendor?: string | undefined + family?: string | undefined + version?: string | undefined + id?: string | undefined + } + | undefined + lmStudioModelId?: string | undefined + lmStudioBaseUrl?: string | undefined + lmStudioDraftModelId?: string | undefined + lmStudioSpeculativeDecodingEnabled?: boolean | undefined + geminiApiKey?: string | undefined + googleGeminiBaseUrl?: string | undefined + openAiNativeApiKey?: string | undefined + mistralApiKey?: string | undefined + mistralCodestralUrl?: string | undefined + deepSeekBaseUrl?: string | undefined + deepSeekApiKey?: string | undefined + unboundApiKey?: string | undefined + unboundModelId?: string | undefined + unboundModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + requestyApiKey?: string | undefined + requestyModelId?: string | undefined + requestyModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + modelTemperature?: (number | null) | undefined + modelMaxTokens?: number | undefined + modelMaxThinkingTokens?: number | undefined + includeMaxTokens?: boolean | undefined + fakeAi?: unknown | undefined +} + +export type { ProviderSettings } diff --git a/src/schemas/__tests__/index.test.ts b/src/schemas/__tests__/index.test.ts new file mode 100644 index 0000000000..3db992bbd3 --- /dev/null +++ b/src/schemas/__tests__/index.test.ts @@ -0,0 +1,17 @@ +// npx jest src/schemas/__tests__/index.test.ts + +import { GLOBAL_STATE_KEYS } from "../index" + +describe("GLOBAL_SETTINGS_KEYS", () => { + it("should contain provider settings keys", () => { + expect(GLOBAL_STATE_KEYS).toContain("autoApprovalEnabled") + }) + + it("should contain provider settings keys", () => { + expect(GLOBAL_STATE_KEYS).toContain("anthropicBaseUrl") + }) + + it("should not contain secret state keys", () => { + expect(GLOBAL_STATE_KEYS).not.toContain("openRouterApiKey") + }) +}) diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 661284a10e..1fe7b15922 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -1,9 +1,11 @@ -// Update to this file will automatically propgate to src/exports/types.d.ts +// Updates to this file will automatically propgate to src/exports/types.ts // via a pre-commit hook. If you want to update the types before committing you -// can run `npx tsx scripts/generate-types.ts`. +// can run `npm run generate-types`. import { z } from "zod" +import { Equals, Keys, AssertEqual } from "../utils/type-fu" + /** * ProviderName */ @@ -52,6 +54,9 @@ export const checkpointStoragesSchema = z.enum(checkpointStorages) export type CheckpointStorage = z.infer +export const isCheckpointStorage = (value: string): value is CheckpointStorage => + checkpointStorages.includes(value as CheckpointStorage) + /** * Language */ @@ -78,6 +83,8 @@ export const languagesSchema = z.enum(languages) export type Language = z.infer +export const isLanguage = (value: string): value is Language => languages.includes(value as Language) + /** * TelemetrySetting */ @@ -140,22 +147,22 @@ export const historyItemSchema = z.object({ export type HistoryItem = z.infer +/** + * GroupOptions + */ + +export const groupOptionsSchema = z.object({ + fileRegex: z.string().optional(), + description: z.string().optional(), +}) + +export type GroupOptions = z.infer + /** * GroupEntry */ -export const groupEntrySchema = z.union([ - toolGroupsSchema, - z - .tuple([ - toolGroupsSchema, - z.object({ - fileRegex: z.string().optional(), - description: z.string().optional(), - }), - ]) - .readonly(), -]) +export const groupEntrySchema = z.union([toolGroupsSchema, z.tuple([toolGroupsSchema, groupOptionsSchema])]) export type GroupEntry = z.infer @@ -168,17 +175,60 @@ export const modeConfigSchema = z.object({ name: z.string(), roleDefinition: z.string(), customInstructions: z.string().optional(), - groups: z.array(groupEntrySchema).readonly(), + groups: z.array(groupEntrySchema), source: z.enum(["global", "project"]).optional(), }) export type ModeConfig = z.infer +/** + * PromptComponent + */ + +export const promptComponentSchema = z.object({ + roleDefinition: z.string().optional(), + customInstructions: z.string().optional(), +}) + +export type PromptComponent = z.infer + +/** + * CustomModePrompts + */ + +export const customModePromptsSchema = z.record(z.string(), promptComponentSchema.optional()) + +export type CustomModePrompts = z.infer + +/** + * CustomSupportPrompts + */ + +export const customSupportPromptsSchema = z.record(z.string(), z.string().optional()) + +export type CustomSupportPrompts = z.infer + /** * ExperimentId */ -export const experimentIdSchema = z.object({ +export const experimentIds = [ + "experimentalDiffStrategy", + "search_and_replace", + "insert_content", + "powerSteering", + "multi_search_and_replace", +] as const + +export const experimentIdsSchema = z.enum(experimentIds) + +export type ExperimentId = z.infer + +/** + * Experiments + */ + +const experimentsSchema = z.object({ experimentalDiffStrategy: z.boolean(), search_and_replace: z.boolean(), insert_content: z.boolean(), @@ -186,7 +236,187 @@ export const experimentIdSchema = z.object({ multi_search_and_replace: z.boolean(), }) -export type ExperimentId = z.infer +export type Experiments = z.infer + +type _AssertExperiments = AssertEqual>> + +/** + * ProviderSettings + */ + +export const providerSettingsSchema = z.object({ + apiProvider: providerNamesSchema.optional(), + // Anthropic + apiModelId: z.string().optional(), + apiKey: z.string().optional(), + anthropicBaseUrl: z.string().optional(), + // Glama + glamaModelId: z.string().optional(), + glamaModelInfo: modelInfoSchema.optional(), + glamaApiKey: z.string().optional(), + // OpenRouter + openRouterApiKey: z.string().optional(), + openRouterModelId: z.string().optional(), + openRouterModelInfo: modelInfoSchema.optional(), + openRouterBaseUrl: z.string().optional(), + openRouterSpecificProvider: z.string().optional(), + openRouterUseMiddleOutTransform: z.boolean().optional(), + // AWS Bedrock + awsAccessKey: z.string().optional(), + awsSecretKey: z.string().optional(), + awsSessionToken: z.string().optional(), + awsRegion: z.string().optional(), + awsUseCrossRegionInference: z.boolean().optional(), + awsUsePromptCache: z.boolean().optional(), + awspromptCacheId: z.string().optional(), + awsProfile: z.string().optional(), + awsUseProfile: z.boolean().optional(), + awsCustomArn: z.string().optional(), + // Google Vertex + vertexKeyFile: z.string().optional(), + vertexJsonCredentials: z.string().optional(), + vertexProjectId: z.string().optional(), + vertexRegion: z.string().optional(), + // OpenAI + openAiBaseUrl: z.string().optional(), + openAiApiKey: z.string().optional(), + openAiR1FormatEnabled: z.boolean().optional(), + openAiModelId: z.string().optional(), + openAiCustomModelInfo: modelInfoSchema.optional(), + openAiUseAzure: z.boolean().optional(), + azureApiVersion: z.string().optional(), + openAiStreamingEnabled: z.boolean().optional(), + // Ollama + ollamaModelId: z.string().optional(), + ollamaBaseUrl: z.string().optional(), + // VS Code LM + vsCodeLmModelSelector: z + .object({ + vendor: z.string().optional(), + family: z.string().optional(), + version: z.string().optional(), + id: z.string().optional(), + }) + .optional(), + // LM Studio + lmStudioModelId: z.string().optional(), + lmStudioBaseUrl: z.string().optional(), + lmStudioDraftModelId: z.string().optional(), + lmStudioSpeculativeDecodingEnabled: z.boolean().optional(), + // Gemini + geminiApiKey: z.string().optional(), + googleGeminiBaseUrl: z.string().optional(), + // OpenAI Native + openAiNativeApiKey: z.string().optional(), + // Mistral + mistralApiKey: z.string().optional(), + mistralCodestralUrl: z.string().optional(), + // DeepSeek + deepSeekBaseUrl: z.string().optional(), + deepSeekApiKey: z.string().optional(), + // Unbound + unboundApiKey: z.string().optional(), + unboundModelId: z.string().optional(), + unboundModelInfo: modelInfoSchema.optional(), + // Requesty + requestyApiKey: z.string().optional(), + requestyModelId: z.string().optional(), + requestyModelInfo: modelInfoSchema.optional(), + // Claude 3.7 Sonnet Thinking + modelTemperature: z.number().nullish(), + modelMaxTokens: z.number().optional(), + modelMaxThinkingTokens: z.number().optional(), + // Generic + includeMaxTokens: z.boolean().optional(), + // Fake AI + fakeAi: z.unknown().optional(), +}) + +export type ProviderSettings = z.infer + +type ProviderSettingsRecord = Record, undefined> + +const providerSettingsRecord: ProviderSettingsRecord = { + apiProvider: undefined, + // Anthropic + apiModelId: undefined, + apiKey: undefined, + anthropicBaseUrl: undefined, + // Glama + glamaModelId: undefined, + glamaModelInfo: undefined, + glamaApiKey: undefined, + // OpenRouter + openRouterApiKey: undefined, + openRouterModelId: undefined, + openRouterModelInfo: undefined, + openRouterBaseUrl: undefined, + openRouterSpecificProvider: undefined, + openRouterUseMiddleOutTransform: undefined, + // AWS Bedrock + awsAccessKey: undefined, + awsSecretKey: undefined, + awsSessionToken: undefined, + awsRegion: undefined, + awsUseCrossRegionInference: undefined, + awsUsePromptCache: undefined, + awspromptCacheId: undefined, + awsProfile: undefined, + awsUseProfile: undefined, + awsCustomArn: undefined, + // Google Vertex + vertexKeyFile: undefined, + vertexJsonCredentials: undefined, + vertexProjectId: undefined, + vertexRegion: undefined, + // OpenAI + openAiBaseUrl: undefined, + openAiApiKey: undefined, + openAiR1FormatEnabled: undefined, + openAiModelId: undefined, + openAiCustomModelInfo: undefined, + openAiUseAzure: undefined, + azureApiVersion: undefined, + openAiStreamingEnabled: undefined, + // Ollama + ollamaModelId: undefined, + ollamaBaseUrl: undefined, + // VS Code LM + vsCodeLmModelSelector: undefined, + lmStudioModelId: undefined, + lmStudioBaseUrl: undefined, + lmStudioDraftModelId: undefined, + lmStudioSpeculativeDecodingEnabled: undefined, + // Gemini + geminiApiKey: undefined, + googleGeminiBaseUrl: undefined, + // OpenAI Native + openAiNativeApiKey: undefined, + // Mistral + mistralApiKey: undefined, + mistralCodestralUrl: undefined, + // DeepSeek + deepSeekBaseUrl: undefined, + deepSeekApiKey: undefined, + // Unbound + unboundApiKey: undefined, + unboundModelId: undefined, + unboundModelInfo: undefined, + // Requesty + requestyApiKey: undefined, + requestyModelId: undefined, + requestyModelInfo: undefined, + // Claude 3.7 Sonnet Thinking + modelTemperature: undefined, + modelMaxTokens: undefined, + modelMaxThinkingTokens: undefined, + // Generic + includeMaxTokens: undefined, + // Fake AI + fakeAi: undefined, +} + +export const PROVIDER_SETTINGS_KEYS = Object.keys(providerSettingsRecord) as Keys[] /** * GlobalSettings @@ -241,7 +471,7 @@ export const globalSettingsSchema = z.object({ rateLimitSeconds: z.number().optional(), diffEnabled: z.boolean().optional(), fuzzyMatchThreshold: z.number().optional(), - experiments: experimentIdSchema.optional(), + experiments: experimentsSchema.optional(), language: languagesSchema.optional(), @@ -253,23 +483,150 @@ export const globalSettingsSchema = z.object({ mode: z.string().optional(), modeApiConfigs: z.record(z.string(), z.string()).optional(), customModes: z.array(modeConfigSchema).optional(), - customModePrompts: z - .record( - z.string(), - z - .object({ - roleDefinition: z.string().optional(), - customInstructions: z.string().optional(), - }) - .optional(), - ) - .optional(), - customSupportPrompts: z.record(z.string(), z.string().optional()).optional(), + customModePrompts: customModePromptsSchema.optional(), + customSupportPrompts: customSupportPromptsSchema.optional(), enhancementApiConfigId: z.string().optional(), }) export type GlobalSettings = z.infer +type GlobalSettingsRecord = Record, undefined> + +const globalSettingsRecord: GlobalSettingsRecord = { + currentApiConfigName: undefined, + listApiConfigMeta: undefined, + pinnedApiConfigs: undefined, + + lastShownAnnouncementId: undefined, + customInstructions: undefined, + taskHistory: undefined, + + autoApprovalEnabled: undefined, + alwaysAllowReadOnly: undefined, + alwaysAllowReadOnlyOutsideWorkspace: undefined, + alwaysAllowWrite: undefined, + alwaysAllowWriteOutsideWorkspace: undefined, + writeDelayMs: undefined, + alwaysAllowBrowser: undefined, + alwaysApproveResubmit: undefined, + requestDelaySeconds: undefined, + alwaysAllowMcp: undefined, + alwaysAllowModeSwitch: undefined, + alwaysAllowSubtasks: undefined, + alwaysAllowExecute: undefined, + allowedCommands: undefined, + + browserToolEnabled: undefined, + browserViewportSize: undefined, + screenshotQuality: undefined, + remoteBrowserEnabled: undefined, + remoteBrowserHost: undefined, + + enableCheckpoints: undefined, + checkpointStorage: undefined, + + ttsEnabled: undefined, + ttsSpeed: undefined, + soundEnabled: undefined, + soundVolume: undefined, + + maxOpenTabsContext: undefined, + maxWorkspaceFiles: undefined, + showRooIgnoredFiles: undefined, + maxReadFileLine: undefined, + + terminalOutputLineLimit: undefined, + terminalShellIntegrationTimeout: undefined, + + rateLimitSeconds: undefined, + diffEnabled: undefined, + fuzzyMatchThreshold: undefined, + experiments: undefined, + + language: undefined, + + telemetrySetting: undefined, + + mcpEnabled: undefined, + enableMcpServerCreation: undefined, + + mode: undefined, + modeApiConfigs: undefined, + customModes: undefined, + customModePrompts: undefined, + customSupportPrompts: undefined, + enhancementApiConfigId: undefined, +} + +export const GLOBAL_SETTINGS_KEYS = Object.keys(globalSettingsRecord) as Keys[] + +/** + * RooCodeSettings + */ + +export type RooCodeSettings = GlobalSettings & ProviderSettings + +/** + * SecretState + */ + +export type SecretState = Pick< + ProviderSettings, + | "apiKey" + | "glamaApiKey" + | "openRouterApiKey" + | "awsAccessKey" + | "awsSecretKey" + | "awsSessionToken" + | "openAiApiKey" + | "geminiApiKey" + | "openAiNativeApiKey" + | "deepSeekApiKey" + | "mistralApiKey" + | "unboundApiKey" + | "requestyApiKey" +> + +type SecretStateRecord = Record, undefined> + +const secretStateRecord: SecretStateRecord = { + apiKey: undefined, + glamaApiKey: undefined, + openRouterApiKey: undefined, + awsAccessKey: undefined, + awsSecretKey: undefined, + awsSessionToken: undefined, + openAiApiKey: undefined, + geminiApiKey: undefined, + openAiNativeApiKey: undefined, + deepSeekApiKey: undefined, + mistralApiKey: undefined, + unboundApiKey: undefined, + requestyApiKey: undefined, +} + +export const SECRET_STATE_KEYS = Object.keys(secretStateRecord) as Keys[] + +export const isSecretStateKey = (key: string): key is Keys => + SECRET_STATE_KEYS.includes(key as Keys) + +/** + * GlobalState + */ + +export type GlobalState = Omit> + +export const GLOBAL_STATE_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_KEYS].filter( + (key: Keys) => !SECRET_STATE_KEYS.includes(key as Keys), +) as Keys[] + +export const isGlobalStateKey = (key: string): key is Keys => + GLOBAL_STATE_KEYS.includes(key as Keys) + +/** + * TypeDefinition + */ + type TypeDefinition = { schema: z.ZodTypeAny identifier: string @@ -284,8 +641,14 @@ export const typeDefinitions: TypeDefinition[] = [ { schema: modelInfoSchema, identifier: "ModelInfo" }, { schema: apiConfigMetaSchema, identifier: "ApiConfigMeta" }, { schema: historyItemSchema, identifier: "HistoryItem" }, + { schema: groupOptionsSchema, identifier: "GroupOptions" }, { schema: groupEntrySchema, identifier: "GroupEntry" }, { schema: modeConfigSchema, identifier: "ModeConfig" }, - { schema: experimentIdSchema, identifier: "ExperimentId" }, + { schema: promptComponentSchema, identifier: "PromptComponent" }, + { schema: customModePromptsSchema, identifier: "CustomModePrompts" }, + { schema: customSupportPromptsSchema, identifier: "CustomSupportPrompts" }, + { schema: experimentIdsSchema, identifier: "ExperimentId" }, + { schema: experimentsSchema, identifier: "Experiments" }, { schema: globalSettingsSchema, identifier: "GlobalSettings" }, + { schema: providerSettingsSchema, identifier: "ProviderSettings" }, ] diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index b4918e8eb2..398077e353 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -1,12 +1,18 @@ -import { ApiConfiguration, ModelInfo } from "./api" -import { HistoryItem } from "./HistoryItem" +import { + ModelInfo, + GlobalSettings, + ApiConfigMeta, + ProviderSettings as ApiConfiguration, + HistoryItem, + ModeConfig, + CheckpointStorage, + TelemetrySetting, + ExperimentId, +} from "../schemas" import { McpServer } from "./mcp" import { GitCommit } from "../utils/git" -import { Mode, ModeConfig } from "./modes" -import { ExperimentId } from "./experiments" -import { CheckpointStorage } from "./checkpoints" -import { TelemetrySetting } from "./TelemetrySetting" -import type { GlobalSettings, ApiConfigMeta, ClineMessage, ClineAsk, ClineSay } from "../exports/roo-code" +import { Mode } from "./modes" +import type { ClineMessage, ClineAsk, ClineSay } from "../exports/roo-code" export type { ApiConfigMeta } @@ -262,7 +268,4 @@ export interface ClineApiReqInfo { export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled" -export type ToolProgressStatus = { - icon?: string - text?: string -} +export type { ToolProgressStatus } from "../exports/roo-code" diff --git a/src/shared/HistoryItem.ts b/src/shared/HistoryItem.ts index 8a72ee3906..0bc5528302 100644 --- a/src/shared/HistoryItem.ts +++ b/src/shared/HistoryItem.ts @@ -1,3 +1,3 @@ -import type { HistoryItem } from "../exports/roo-code" +import type { HistoryItem } from "../schemas" export type { HistoryItem } diff --git a/src/shared/api.ts b/src/shared/api.ts index b254cdd92d..d90dec6ad8 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -1,4 +1,4 @@ -import { ModelInfo, ProviderName, ProviderSettings } from "../exports/roo-code" +import { ModelInfo, ProviderName, ProviderSettings } from "../schemas" export type { ModelInfo, ProviderName as ApiProvider } diff --git a/src/shared/checkExistApiConfig.ts b/src/shared/checkExistApiConfig.ts index 6d928e6d35..05dcb6e678 100644 --- a/src/shared/checkExistApiConfig.ts +++ b/src/shared/checkExistApiConfig.ts @@ -1,5 +1,4 @@ -import { ProviderSettings } from "../exports/roo-code" -import { SECRET_STATE_KEYS } from "./globalState" +import { SECRET_STATE_KEYS, ProviderSettings } from "../schemas" export function checkExistKey(config: ProviderSettings | undefined) { if (!config) { diff --git a/src/shared/checkpoints.ts b/src/shared/checkpoints.ts index 04f909fca8..2776e12b32 100644 --- a/src/shared/checkpoints.ts +++ b/src/shared/checkpoints.ts @@ -1,7 +1,3 @@ -import { CheckpointStorage } from "../exports/roo-code" +import { CheckpointStorage, isCheckpointStorage } from "../schemas" -export type { CheckpointStorage } - -export const isCheckpointStorage = (value: string): value is CheckpointStorage => { - return value === "task" || value === "workspace" -} +export { type CheckpointStorage, isCheckpointStorage } diff --git a/src/shared/experiments.ts b/src/shared/experiments.ts index b563b1372a..b731863e0b 100644 --- a/src/shared/experiments.ts +++ b/src/shared/experiments.ts @@ -1,5 +1,4 @@ -import { ExperimentId } from "../exports/roo-code" - +import { ExperimentId } from "../schemas" import { AssertEqual, Equals, Keys, Values } from "../utils/type-fu" export type { ExperimentId } diff --git a/src/shared/globalState.ts b/src/shared/globalState.ts deleted file mode 100644 index b0931031a2..0000000000 --- a/src/shared/globalState.ts +++ /dev/null @@ -1,695 +0,0 @@ -import { z } from "zod" - -import type { - ProviderName, - CheckpointStorage, - ToolGroup, - Language, - TelemetrySetting, - ProviderSettingsKey, - SecretStateKey, - GlobalStateKey, - ModelInfo, - ApiConfigMeta, - HistoryItem, - GroupEntry, - ModeConfig, - ExperimentId, - ProviderSettings, - GlobalSettings, -} from "../exports/roo-code" - -import { Keys, AssertEqual, Equals } from "../utils/type-fu" - -/** - * ProviderName - */ - -const providerNames: Record = { - anthropic: true, - glama: true, - openrouter: true, - bedrock: true, - vertex: true, - openai: true, - ollama: true, - lmstudio: true, - gemini: true, - "openai-native": true, - deepseek: true, - "vscode-lm": true, - mistral: true, - unbound: true, - requesty: true, - "human-relay": true, - "fake-ai": true, -} - -const PROVIDER_NAMES = Object.keys(providerNames) as ProviderName[] - -const providerNamesEnum: [ProviderName, ...ProviderName[]] = [ - PROVIDER_NAMES[0], - ...PROVIDER_NAMES.slice(1).map((p) => p), -] - -/** - * CheckpointStorage - */ - -const checkpointStorages: Record = { - task: true, - workspace: true, -} - -const CHECKPOINT_STORAGES = Object.keys(checkpointStorages) as CheckpointStorage[] - -const checkpointStoragesEnum: [CheckpointStorage, ...CheckpointStorage[]] = [ - CHECKPOINT_STORAGES[0], - ...CHECKPOINT_STORAGES.slice(1).map((p) => p), -] - -/** - * ToolGroup - */ - -const toolGroups: Record = { - read: true, - edit: true, - browser: true, - command: true, - mcp: true, - modes: true, -} - -const TOOL_GROUPS = Object.keys(toolGroups) as ToolGroup[] - -const toolGroupsEnum: [ToolGroup, ...ToolGroup[]] = [TOOL_GROUPS[0], ...TOOL_GROUPS.slice(1).map((p) => p)] - -/** - * Language - */ - -const languages: Record = { - ca: true, - de: true, - en: true, - es: true, - fr: true, - hi: true, - it: true, - ja: true, - ko: true, - pl: true, - "pt-BR": true, - tr: true, - vi: true, - "zh-CN": true, - "zh-TW": true, -} - -const LANGUAGES = Object.keys(languages) as Language[] - -const languagesEnum: [Language, ...Language[]] = [LANGUAGES[0], ...LANGUAGES.slice(1).map((p) => p)] - -export const isLanguage = (key: string): key is Language => LANGUAGES.includes(key as Language) - -/** - * TelemetrySetting - */ - -const telemetrySettings: Record = { - unset: true, - enabled: true, - disabled: true, -} - -const TELEMETRY_SETTINGS = Object.keys(telemetrySettings) as TelemetrySetting[] - -const telemetrySettingsEnum: [TelemetrySetting, ...TelemetrySetting[]] = [ - TELEMETRY_SETTINGS[0], - ...TELEMETRY_SETTINGS.slice(1).map((p) => p), -] - -/** - * ProviderSettingsKey - */ - -const providerSettingsKeys: Record = { - apiProvider: true, - apiModelId: true, - // Anthropic - apiKey: true, - anthropicBaseUrl: true, - // Glama - glamaApiKey: true, - glamaModelId: true, - glamaModelInfo: true, - // OpenRouter - openRouterApiKey: true, - openRouterModelId: true, - openRouterModelInfo: true, - openRouterBaseUrl: true, - openRouterSpecificProvider: true, - openRouterUseMiddleOutTransform: true, - // AWS Bedrock - awsAccessKey: true, - awsSecretKey: true, - awsSessionToken: true, - awsRegion: true, - awsUseCrossRegionInference: true, - awsUsePromptCache: true, - awspromptCacheId: true, - awsProfile: true, - awsUseProfile: true, - awsCustomArn: true, - // Google Vertex - vertexKeyFile: true, - vertexJsonCredentials: true, - vertexProjectId: true, - vertexRegion: true, - // OpenAI - openAiApiKey: true, - openAiBaseUrl: true, - openAiR1FormatEnabled: true, - openAiModelId: true, - openAiCustomModelInfo: true, - openAiUseAzure: true, - azureApiVersion: true, - openAiStreamingEnabled: true, - // Ollama - ollamaModelId: true, - ollamaBaseUrl: true, - // VS Code LM - vsCodeLmModelSelector: true, - // LM Studio - lmStudioModelId: true, - lmStudioBaseUrl: true, - lmStudioDraftModelId: true, - lmStudioSpeculativeDecodingEnabled: true, - // Gemini - geminiApiKey: true, - googleGeminiBaseUrl: true, - // OpenAI Native - openAiNativeApiKey: true, - // Mistral - mistralApiKey: true, - mistralCodestralUrl: true, - // DeepSeek - deepSeekApiKey: true, - deepSeekBaseUrl: true, - includeMaxTokens: true, - // Unbound - unboundApiKey: true, - unboundModelId: true, - unboundModelInfo: true, - // Requesty - requestyApiKey: true, - requestyModelId: true, - requestyModelInfo: true, - // Claude 3.7 Sonnet Thinking - modelTemperature: true, - modelMaxTokens: true, - modelMaxThinkingTokens: true, - // Fake AI - fakeAi: true, -} - -export const PROVIDER_SETTINGS_KEYS = Object.keys(providerSettingsKeys) as ProviderSettingsKey[] - -/** - * SecretStateKey - */ - -const secretStateKeys: Record = { - apiKey: true, - glamaApiKey: true, - openRouterApiKey: true, - awsAccessKey: true, - awsSecretKey: true, - awsSessionToken: true, - openAiApiKey: true, - geminiApiKey: true, - openAiNativeApiKey: true, - deepSeekApiKey: true, - mistralApiKey: true, - unboundApiKey: true, - requestyApiKey: true, -} - -export const SECRET_STATE_KEYS = Object.keys(secretStateKeys) as SecretStateKey[] - -export const isSecretStateKey = (key: string): key is SecretStateKey => - SECRET_STATE_KEYS.includes(key as SecretStateKey) - -/** - * GlobalStateKey - */ - -const globalStateKeys: Record = { - apiProvider: true, - apiModelId: true, - // Anthropic - // apiKey: true, - anthropicBaseUrl: true, - // Glama - // glamaApiKey: true, - glamaModelId: true, - glamaModelInfo: true, - // OpenRouter - // openRouterApiKey: true, - openRouterModelId: true, - openRouterModelInfo: true, - openRouterBaseUrl: true, - openRouterSpecificProvider: true, - openRouterUseMiddleOutTransform: true, - // AWS Bedrock - // awsAccessKey: true, - // awsSecretKey: true, - // awsSessionToken: true, - awsRegion: true, - awsUseCrossRegionInference: true, - awsUsePromptCache: true, - awspromptCacheId: true, - awsProfile: true, - awsUseProfile: true, - awsCustomArn: true, - // Google Vertex - vertexKeyFile: true, - vertexJsonCredentials: true, - vertexProjectId: true, - vertexRegion: true, - // OpenAI - // openAiApiKey: true, - openAiBaseUrl: true, - openAiR1FormatEnabled: true, - openAiModelId: true, - openAiCustomModelInfo: true, - openAiUseAzure: true, - azureApiVersion: true, - openAiStreamingEnabled: true, - // Ollama - ollamaModelId: true, - ollamaBaseUrl: true, - // VS Code LM - vsCodeLmModelSelector: true, - // LM Studio - lmStudioModelId: true, - lmStudioBaseUrl: true, - lmStudioDraftModelId: true, - lmStudioSpeculativeDecodingEnabled: true, - // Gemini - // geminiApiKey: true, - googleGeminiBaseUrl: true, - // OpenAI Native - // openAiNativeApiKey: true, - // Mistral - // mistralApiKey: true, - mistralCodestralUrl: true, - // DeepSeek - // deepSeekApiKey: true, - deepSeekBaseUrl: true, - includeMaxTokens: true, - // Unbound - // unboundApiKey: true, - unboundModelId: true, - unboundModelInfo: true, - // Requesty - // requestyApiKey: true, - requestyModelId: true, - requestyModelInfo: true, - // Claude 3.7 Sonnet Thinking - modelTemperature: true, - modelMaxTokens: true, - modelMaxThinkingTokens: true, - // Fake AI - fakeAi: true, - - currentApiConfigName: true, - listApiConfigMeta: true, - pinnedApiConfigs: true, - - lastShownAnnouncementId: true, - customInstructions: true, - taskHistory: true, - - autoApprovalEnabled: true, - alwaysAllowReadOnly: true, - alwaysAllowReadOnlyOutsideWorkspace: true, - alwaysAllowWrite: true, - alwaysAllowWriteOutsideWorkspace: true, - writeDelayMs: true, - alwaysAllowBrowser: true, - alwaysApproveResubmit: true, - requestDelaySeconds: true, - alwaysAllowMcp: true, - alwaysAllowModeSwitch: true, - alwaysAllowSubtasks: true, - alwaysAllowExecute: true, - allowedCommands: true, - - browserToolEnabled: true, - browserViewportSize: true, - screenshotQuality: true, - remoteBrowserEnabled: true, - remoteBrowserHost: true, - - enableCheckpoints: true, - checkpointStorage: true, - - ttsEnabled: true, - ttsSpeed: true, - soundEnabled: true, - soundVolume: true, - - maxOpenTabsContext: true, - maxWorkspaceFiles: true, - showRooIgnoredFiles: true, - maxReadFileLine: true, - - terminalOutputLineLimit: true, - terminalShellIntegrationTimeout: true, - - rateLimitSeconds: true, - diffEnabled: true, - fuzzyMatchThreshold: true, - experiments: true, - - language: true, - - telemetrySetting: true, - - mcpEnabled: true, - enableMcpServerCreation: true, - - mode: true, - modeApiConfigs: true, - customModes: true, - customModePrompts: true, - customSupportPrompts: true, - enhancementApiConfigId: true, -} - -export const GLOBAL_STATE_KEYS = Object.keys(globalStateKeys) as GlobalStateKey[] - -/** - * PassThroughStateKey - * - * TODO: Why is this necessary? - */ - -const PASS_THROUGH_STATE_KEYS = ["taskHistory"] as const - -type PassThroughStateKey = (typeof PASS_THROUGH_STATE_KEYS)[number] - -export const isPassThroughStateKey = (key: string): key is PassThroughStateKey => - PASS_THROUGH_STATE_KEYS.includes(key as PassThroughStateKey) - -/** - * Schemas - */ - -/** - * ModelInfo - */ - -const modelInfoSchema = z.object({ - maxTokens: z.number().optional(), - contextWindow: z.number(), - supportsImages: z.boolean().optional(), - supportsComputerUse: z.boolean().optional(), - supportsPromptCache: z.boolean(), - inputPrice: z.number().optional(), - outputPrice: z.number().optional(), - cacheWritesPrice: z.number().optional(), - cacheReadsPrice: z.number().optional(), - description: z.string().optional(), - reasoningEffort: z.enum(["low", "medium", "high"]).optional(), - thinking: z.boolean().optional(), -}) - -// Throws a type error if the inferred type of the modelInfoSchema is not equal -// to ModelInfo. -type _AssertModelInfo = AssertEqual>> - -/** - * ApiConfigMeta - */ - -const apiConfigMetaSchema = z.object({ - id: z.string(), - name: z.string(), - apiProvider: z.enum(providerNamesEnum).optional(), -}) - -type _AssertApiConfigMeta = AssertEqual>> - -/** - * HistoryItem - */ - -const historyItemSchema = z.object({ - id: z.string(), - number: z.number(), - ts: z.number(), - task: z.string(), - tokensIn: z.number(), - tokensOut: z.number(), - cacheWrites: z.number().optional(), - cacheReads: z.number().optional(), - totalCost: z.number(), - size: z.number().optional(), -}) - -type _AssertHistoryItem = AssertEqual>> - -/** - * GroupEntry - */ - -const groupEntrySchema = z.union([ - z.enum(toolGroupsEnum), - z - .tuple([ - z.enum(toolGroupsEnum), - z.object({ - fileRegex: z.string().optional(), - description: z.string().optional(), - }), - ]) - .readonly(), -]) - -type _AssertGroupEntry = AssertEqual>> - -/** - * ModeConfig - */ - -const modeConfigSchema = z.object({ - slug: z.string(), - name: z.string(), - roleDefinition: z.string(), - customInstructions: z.string().optional(), - groups: z.array(groupEntrySchema).readonly(), - source: z.enum(["global", "project"]).optional(), -}) - -type _AssertModeConfig = AssertEqual>> - -/** - * ExperimentId - */ - -const experimentsSchema = z.object({ - experimentalDiffStrategy: z.boolean(), - search_and_replace: z.boolean(), - insert_content: z.boolean(), - powerSteering: z.boolean(), - multi_search_and_replace: z.boolean(), -}) - -// Throws a type error if the inferred type of the experimentsSchema is not -// equal to ExperimentId. -type _AssertExperiments = AssertEqual>>> - -/** - * GlobalSettings - */ - -export const globalSettingsSchema = z.object({ - currentApiConfigName: z.string().optional(), - listApiConfigMeta: z.array(apiConfigMetaSchema).optional(), - pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(), - - lastShownAnnouncementId: z.string().optional(), - customInstructions: z.string().optional(), - taskHistory: z.array(historyItemSchema).optional(), - - autoApprovalEnabled: z.boolean().optional(), - alwaysAllowReadOnly: z.boolean().optional(), - alwaysAllowReadOnlyOutsideWorkspace: z.boolean().optional(), - alwaysAllowWrite: z.boolean().optional(), - alwaysAllowWriteOutsideWorkspace: z.boolean().optional(), - writeDelayMs: z.number().optional(), - alwaysAllowBrowser: z.boolean().optional(), - alwaysApproveResubmit: z.boolean().optional(), - requestDelaySeconds: z.number().optional(), - alwaysAllowMcp: z.boolean().optional(), - alwaysAllowModeSwitch: z.boolean().optional(), - alwaysAllowSubtasks: z.boolean().optional(), - alwaysAllowExecute: z.boolean().optional(), - allowedCommands: z.array(z.string()).optional(), - - browserToolEnabled: z.boolean().optional(), - browserViewportSize: z.string().optional(), - screenshotQuality: z.number().optional(), - remoteBrowserEnabled: z.boolean().optional(), - remoteBrowserHost: z.string().optional(), - - enableCheckpoints: z.boolean().optional(), - checkpointStorage: z.enum(checkpointStoragesEnum).optional(), - - ttsEnabled: z.boolean().optional(), - ttsSpeed: z.number().optional(), - soundEnabled: z.boolean().optional(), - soundVolume: z.number().optional(), - - maxOpenTabsContext: z.number().optional(), - maxWorkspaceFiles: z.number().optional(), - showRooIgnoredFiles: z.boolean().optional(), - maxReadFileLine: z.number().optional(), - - terminalOutputLineLimit: z.number().optional(), - terminalShellIntegrationTimeout: z.number().optional(), - - rateLimitSeconds: z.number().optional(), - diffEnabled: z.boolean().optional(), - fuzzyMatchThreshold: z.number().optional(), - experiments: experimentsSchema.optional(), - - language: z.enum(languagesEnum).optional(), - - telemetrySetting: z.enum(telemetrySettingsEnum).optional(), - - mcpEnabled: z.boolean().optional(), - enableMcpServerCreation: z.boolean().optional(), - - mode: z.string().optional(), - modeApiConfigs: z.record(z.string(), z.string()).optional(), - customModes: z.array(modeConfigSchema).optional(), - customModePrompts: z - .record( - z.string(), - z - .object({ - roleDefinition: z.string().optional(), - customInstructions: z.string().optional(), - }) - .optional(), - ) - .optional(), - customSupportPrompts: z.record(z.string(), z.string().optional()).optional(), - enhancementApiConfigId: z.string().optional(), -}) - -// Throws a type error if the inferred type of the globalSettingsSchema is not -// equal to GlobalSettings. -type _AssertGlobalSettings = AssertEqual>> - -/** - * ProviderSettings - */ - -export const providerSettingsSchema = z.object({ - apiProvider: z.enum(providerNamesEnum).optional(), - // Anthropic - apiModelId: z.string().optional(), - apiKey: z.string().optional(), - anthropicBaseUrl: z.string().optional(), - // Glama - glamaModelId: z.string().optional(), - glamaModelInfo: modelInfoSchema.optional(), - glamaApiKey: z.string().optional(), - // OpenRouter - openRouterApiKey: z.string().optional(), - openRouterModelId: z.string().optional(), - openRouterModelInfo: modelInfoSchema.optional(), - openRouterBaseUrl: z.string().optional(), - openRouterSpecificProvider: z.string().optional(), - // AWS Bedrock - awsAccessKey: z.string().optional(), - awsSecretKey: z.string().optional(), - awsSessionToken: z.string().optional(), - awsRegion: z.string().optional(), - awsUseCrossRegionInference: z.boolean().optional(), - awsUsePromptCache: z.boolean().optional(), - awspromptCacheId: z.string().optional(), - awsProfile: z.string().optional(), - awsUseProfile: z.boolean().optional(), - awsCustomArn: z.string().optional(), - // Google Vertex - vertexKeyFile: z.string().optional(), - vertexJsonCredentials: z.string().optional(), - vertexProjectId: z.string().optional(), - vertexRegion: z.string().optional(), - // OpenAI - openAiBaseUrl: z.string().optional(), - openAiApiKey: z.string().optional(), - openAiR1FormatEnabled: z.boolean().optional(), - openAiModelId: z.string().optional(), - openAiCustomModelInfo: modelInfoSchema.optional(), - openAiUseAzure: z.boolean().optional(), - // Ollama - ollamaModelId: z.string().optional(), - ollamaBaseUrl: z.string().optional(), - // VS Code LM - vsCodeLmModelSelector: z - .object({ - vendor: z.string().optional(), - family: z.string().optional(), - version: z.string().optional(), - id: z.string().optional(), - }) - .optional(), - // LM Studio - lmStudioModelId: z.string().optional(), - lmStudioBaseUrl: z.string().optional(), - lmStudioDraftModelId: z.string().optional(), - lmStudioSpeculativeDecodingEnabled: z.boolean().optional(), - // Gemini - geminiApiKey: z.string().optional(), - googleGeminiBaseUrl: z.string().optional(), - // OpenAI Native - openAiNativeApiKey: z.string().optional(), - // Mistral - mistralApiKey: z.string().optional(), - mistralCodestralUrl: z.string().optional(), - // Azure - azureApiVersion: z.string().optional(), - // OpenRouter - openRouterUseMiddleOutTransform: z.boolean().optional(), - openAiStreamingEnabled: z.boolean().optional(), - // DeepSeek - deepSeekBaseUrl: z.string().optional(), - deepSeekApiKey: z.string().optional(), - // Unbound - unboundApiKey: z.string().optional(), - unboundModelId: z.string().optional(), - unboundModelInfo: modelInfoSchema.optional(), - // Requesty - requestyApiKey: z.string().optional(), - requestyModelId: z.string().optional(), - requestyModelInfo: modelInfoSchema.optional(), - // Claude 3.7 Sonnet Thinking - modelTemperature: z.number().nullish(), - modelMaxTokens: z.number().optional(), - modelMaxThinkingTokens: z.number().optional(), - // Generic - includeMaxTokens: z.boolean().optional(), - // Fake AI - fakeAi: z.unknown().optional(), -}) - -// Throws a type error if the inferred type of the providerSettingsSchema is not -// equal to ProviderSettings. -type _AssertProviderSettings = AssertEqual>> diff --git a/src/shared/language.ts b/src/shared/language.ts index 99830177eb..f6a06b9d56 100644 --- a/src/shared/language.ts +++ b/src/shared/language.ts @@ -1,7 +1,6 @@ -import { type Language } from "../exports/roo-code" -import { isLanguage } from "./globalState" +import { type Language, isLanguage } from "../schemas" -export type { Language } +export { type Language, isLanguage } /** * Language name mapping from ISO codes to full language names diff --git a/src/shared/modes.ts b/src/shared/modes.ts index cb295df6ae..0f51b4e50f 100644 --- a/src/shared/modes.ts +++ b/src/shared/modes.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode" -import { GroupOptions, GroupEntry, ModeConfig, PromptComponent, CustomModePrompts } from "../exports/roo-code" +import { GroupOptions, GroupEntry, ModeConfig, PromptComponent, CustomModePrompts } from "../schemas" import { TOOL_GROUPS, ToolGroup, ALWAYS_AVAILABLE_TOOLS } from "./tool-groups" import { addCustomInstructions } from "../core/prompts/sections/custom-instructions" diff --git a/src/shared/tool-groups.ts b/src/shared/tool-groups.ts index 8b5f033584..8340a8e542 100644 --- a/src/shared/tool-groups.ts +++ b/src/shared/tool-groups.ts @@ -1,4 +1,4 @@ -import type { ToolGroup } from "../exports/roo-code" +import type { ToolGroup } from "../schemas" // Define tool group configuration export type ToolGroupConfig = { From dabae0159313e942adf599349f44de07babcdc1c Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 01:17:01 -0700 Subject: [PATCH 03/10] Add changeset --- .changeset/sweet-bugs-glow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sweet-bugs-glow.md diff --git a/.changeset/sweet-bugs-glow.md b/.changeset/sweet-bugs-glow.md new file mode 100644 index 0000000000..5c4854d996 --- /dev/null +++ b/.changeset/sweet-bugs-glow.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Automatically generate .d.ts from zod schemas From 069fcc39a6b9749606bfafa714d43105b6cae544 Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Thu, 27 Mar 2025 01:28:34 -0700 Subject: [PATCH 04/10] Update scripts/generate-types.mts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- scripts/generate-types.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-types.mts b/scripts/generate-types.mts index e6bf40b134..cef672e9bf 100644 --- a/scripts/generate-types.mts +++ b/scripts/generate-types.mts @@ -7,7 +7,7 @@ import { typeDefinitions } from "../src/schemas" async function main() { const types: string[] = [ - "// This file is automatically generated by running `npx tsx scripts/generated-types.ts`\n// Do not edit it directly.", + "// This file is automatically generated by running `npx tsx scripts/generate-types.mts`\n// Do not edit it directly.", ] for (const { schema, identifier } of typeDefinitions) { From 67243d15c4e1ccf3a5d47902f46ebcf3f3e918f5 Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Thu, 27 Mar 2025 01:30:55 -0700 Subject: [PATCH 05/10] Update src/schemas/__tests__/index.test.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- src/schemas/__tests__/index.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schemas/__tests__/index.test.ts b/src/schemas/__tests__/index.test.ts index 3db992bbd3..a4a59e826c 100644 --- a/src/schemas/__tests__/index.test.ts +++ b/src/schemas/__tests__/index.test.ts @@ -2,7 +2,7 @@ import { GLOBAL_STATE_KEYS } from "../index" -describe("GLOBAL_SETTINGS_KEYS", () => { +describe("GLOBAL_STATE_KEYS", () => { it("should contain provider settings keys", () => { expect(GLOBAL_STATE_KEYS).toContain("autoApprovalEnabled") }) From f5e85a7da9a7e7d8a23f98b9577cf4cd73ab0f55 Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 01:55:19 -0700 Subject: [PATCH 06/10] More type cleanup --- src/core/Cline.ts | 4 +- src/exports/roo-code.d.ts | 76 +---- src/exports/types.ts | 524 +++++++++++++-------------------- src/schemas/index.ts | 122 ++++++-- src/shared/ExtensionMessage.ts | 9 +- src/shared/getApiMetrics.ts | 2 +- 6 files changed, 322 insertions(+), 415 deletions(-) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index 14cd2bbb00..f81931baf1 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -11,9 +11,8 @@ import pWaitFor from "p-wait-for" import getFolderSize from "get-folder-size" import { serializeError } from "serialize-error" import * as vscode from "vscode" -import { isPathOutsideWorkspace } from "../utils/pathUtils" -import { TokenUsage } from "../exports/roo-code" +import { TokenUsage } from "../schemas" import { ApiHandler, buildApiHandler } from "../api" import { ApiStream } from "../api/transform/stream" import { DIFF_VIEW_URI_SCHEME, DiffViewProvider } from "../integrations/editor/DiffViewProvider" @@ -65,6 +64,7 @@ import { defaultModeSlug, getModeBySlug, getFullModeDetails } from "../shared/mo import { EXPERIMENT_IDS, experiments as Experiments, ExperimentId } from "../shared/experiments" import { calculateApiCostAnthropic } from "../utils/cost" import { fileExistsAtPath } from "../utils/fs" +import { isPathOutsideWorkspace } from "../utils/pathUtils" import { arePathsEqual, getReadablePath } from "../utils/path" import { parseMentions } from "./mentions" import { RooIgnoreController } from "./ignore/RooIgnoreController" diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 8def29c870..837a21fae3 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -1,19 +1,12 @@ -import * as vscode from "vscode" - import { EventEmitter } from "events" -import type { ProviderSettings, GlobalSettings } from "./types" +import * as vscode from "vscode" -export type RooCodeSettings = GlobalSettings & ProviderSettings +import type { ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } from "./types" -export interface TokenUsage { - totalTokensIn: number - totalTokensOut: number - totalCacheWrites?: number - totalCacheReads?: number - totalCost: number - contextTokens: number -} +type RooCodeSettings = GlobalSettings & ProviderSettings + +export type { RooCodeSettings, ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } export interface RooCodeEvents { message: [{ taskId: string; action: "created" | "updated"; message: ClineMessage }] @@ -101,62 +94,3 @@ export interface RooCodeAPI extends EventEmitter { */ log(message: string): void } - -export type ClineAsk = - | "followup" - | "command" - | "command_output" - | "completion_result" - | "tool" - | "api_req_failed" - | "resume_task" - | "resume_completed_task" - | "mistake_limit_reached" - | "browser_action_launch" - | "use_mcp_server" - | "finishTask" - -export type ClineSay = - | "task" - | "error" - | "api_req_started" - | "api_req_finished" - | "api_req_retried" - | "api_req_retry_delayed" - | "api_req_deleted" - | "text" - | "reasoning" - | "completion_result" - | "user_feedback" - | "user_feedback_diff" - | "command_output" - | "tool" - | "shell_integration_warning" - | "browser_action" - | "browser_action_result" - | "command" - | "mcp_server_request_started" - | "mcp_server_response" - | "new_task_started" - | "new_task" - | "checkpoint_saved" - | "rooignore_error" - -export type ToolProgressStatus = { - icon?: string - text?: string -} - -export interface ClineMessage { - ts: number - type: "ask" | "say" - ask?: ClineAsk - say?: ClineSay - text?: string - images?: string[] - partial?: boolean - reasoning?: string - conversationHistoryIndex?: number - checkpoint?: Record - progressStatus?: ToolProgressStatus -} diff --git a/src/exports/types.ts b/src/exports/types.ts index 434db4d2dd..0da9469321 100644 --- a/src/exports/types.ts +++ b/src/exports/types.ts @@ -1,78 +1,7 @@ // This file is automatically generated by running `npx tsx scripts/generated-types.ts` // Do not edit it directly. -type ProviderName = - | "anthropic" - | "glama" - | "openrouter" - | "bedrock" - | "vertex" - | "openai" - | "ollama" - | "vscode-lm" - | "lmstudio" - | "gemini" - | "openai-native" - | "mistral" - | "deepseek" - | "unbound" - | "requesty" - | "human-relay" - | "fake-ai" - -export type { ProviderName } - -type ToolGroup = "read" | "edit" | "browser" | "command" | "mcp" | "modes" - -export type { ToolGroup } - -type CheckpointStorage = "task" | "workspace" - -export type { CheckpointStorage } - -type Language = - | "ca" - | "de" - | "en" - | "es" - | "fr" - | "hi" - | "it" - | "ja" - | "ko" - | "pl" - | "pt-BR" - | "tr" - | "vi" - | "zh-CN" - | "zh-TW" - -export type { Language } - -type TelemetrySetting = "unset" | "enabled" | "disabled" - -export type { TelemetrySetting } - -type ModelInfo = { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined -} - -export type { ModelInfo } - -type ApiConfigMeta = { - id: string - name: string +type ProviderSettings = { apiProvider?: | ( | "anthropic" @@ -94,106 +23,150 @@ type ApiConfigMeta = { | "fake-ai" ) | undefined -} - -export type { ApiConfigMeta } - -type HistoryItem = { - id: string - number: number - ts: number - task: string - tokensIn: number - tokensOut: number - cacheWrites?: number | undefined - cacheReads?: number | undefined - totalCost: number - size?: number | undefined -} - -export type { HistoryItem } - -type GroupOptions = { - fileRegex?: string | undefined - description?: string | undefined -} - -export type { GroupOptions } - -type GroupEntry = - | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") - | [ - "read" | "edit" | "browser" | "command" | "mcp" | "modes", - { - fileRegex?: string | undefined + apiModelId?: string | undefined + apiKey?: string | undefined + anthropicBaseUrl?: string | undefined + glamaModelId?: string | undefined + glamaModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined description?: string | undefined - }, - ] - -export type { GroupEntry } - -type ModeConfig = { - slug: string - name: string - roleDefinition: string - customInstructions?: string | undefined - groups: ( - | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") - | [ - "read" | "edit" | "browser" | "command" | "mcp" | "modes", - { - fileRegex?: string | undefined - description?: string | undefined - }, - ] - )[] - source?: ("global" | "project") | undefined -} - -export type { ModeConfig } - -type PromptComponent = { - roleDefinition?: string | undefined - customInstructions?: string | undefined -} - -export type { PromptComponent } - -type CustomModePrompts = { - [x: string]: + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + glamaApiKey?: string | undefined + openRouterApiKey?: string | undefined + openRouterModelId?: string | undefined + openRouterModelInfo?: | { - roleDefinition?: string | undefined - customInstructions?: string | undefined + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined } | undefined + openRouterBaseUrl?: string | undefined + openRouterSpecificProvider?: string | undefined + openRouterUseMiddleOutTransform?: boolean | undefined + awsAccessKey?: string | undefined + awsSecretKey?: string | undefined + awsSessionToken?: string | undefined + awsRegion?: string | undefined + awsUseCrossRegionInference?: boolean | undefined + awsUsePromptCache?: boolean | undefined + awspromptCacheId?: string | undefined + awsProfile?: string | undefined + awsUseProfile?: boolean | undefined + awsCustomArn?: string | undefined + vertexKeyFile?: string | undefined + vertexJsonCredentials?: string | undefined + vertexProjectId?: string | undefined + vertexRegion?: string | undefined + openAiBaseUrl?: string | undefined + openAiApiKey?: string | undefined + openAiR1FormatEnabled?: boolean | undefined + openAiModelId?: string | undefined + openAiCustomModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + openAiUseAzure?: boolean | undefined + azureApiVersion?: string | undefined + openAiStreamingEnabled?: boolean | undefined + ollamaModelId?: string | undefined + ollamaBaseUrl?: string | undefined + vsCodeLmModelSelector?: + | { + vendor?: string | undefined + family?: string | undefined + version?: string | undefined + id?: string | undefined + } + | undefined + lmStudioModelId?: string | undefined + lmStudioBaseUrl?: string | undefined + lmStudioDraftModelId?: string | undefined + lmStudioSpeculativeDecodingEnabled?: boolean | undefined + geminiApiKey?: string | undefined + googleGeminiBaseUrl?: string | undefined + openAiNativeApiKey?: string | undefined + mistralApiKey?: string | undefined + mistralCodestralUrl?: string | undefined + deepSeekBaseUrl?: string | undefined + deepSeekApiKey?: string | undefined + unboundApiKey?: string | undefined + unboundModelId?: string | undefined + unboundModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + requestyApiKey?: string | undefined + requestyModelId?: string | undefined + requestyModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + modelTemperature?: (number | null) | undefined + modelMaxTokens?: number | undefined + modelMaxThinkingTokens?: number | undefined + includeMaxTokens?: boolean | undefined + fakeAi?: unknown | undefined } -export type { CustomModePrompts } - -type CustomSupportPrompts = { - [x: string]: string | undefined -} - -export type { CustomSupportPrompts } - -type ExperimentId = - | "experimentalDiffStrategy" - | "search_and_replace" - | "insert_content" - | "powerSteering" - | "multi_search_and_replace" - -export type { ExperimentId } - -type Experiments = { - experimentalDiffStrategy: boolean - search_and_replace: boolean - insert_content: boolean - powerSteering: boolean - multi_search_and_replace: boolean -} - -export type { Experiments } +export type { ProviderSettings } type GlobalSettings = { currentApiConfigName?: string | undefined @@ -355,169 +328,80 @@ type GlobalSettings = { export type { GlobalSettings } -type ProviderSettings = { - apiProvider?: +type ClineMessage = { + ts: number + type: "ask" | "say" + ask?: | ( - | "anthropic" - | "glama" - | "openrouter" - | "bedrock" - | "vertex" - | "openai" - | "ollama" - | "vscode-lm" - | "lmstudio" - | "gemini" - | "openai-native" - | "mistral" - | "deepseek" - | "unbound" - | "requesty" - | "human-relay" - | "fake-ai" + | "followup" + | "command" + | "command_output" + | "completion_result" + | "tool" + | "api_req_failed" + | "resume_task" + | "resume_completed_task" + | "mistake_limit_reached" + | "browser_action_launch" + | "use_mcp_server" + | "finishTask" ) | undefined - apiModelId?: string | undefined - apiKey?: string | undefined - anthropicBaseUrl?: string | undefined - glamaModelId?: string | undefined - glamaModelInfo?: - | { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined - } - | undefined - glamaApiKey?: string | undefined - openRouterApiKey?: string | undefined - openRouterModelId?: string | undefined - openRouterModelInfo?: - | { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined - } - | undefined - openRouterBaseUrl?: string | undefined - openRouterSpecificProvider?: string | undefined - openRouterUseMiddleOutTransform?: boolean | undefined - awsAccessKey?: string | undefined - awsSecretKey?: string | undefined - awsSessionToken?: string | undefined - awsRegion?: string | undefined - awsUseCrossRegionInference?: boolean | undefined - awsUsePromptCache?: boolean | undefined - awspromptCacheId?: string | undefined - awsProfile?: string | undefined - awsUseProfile?: boolean | undefined - awsCustomArn?: string | undefined - vertexKeyFile?: string | undefined - vertexJsonCredentials?: string | undefined - vertexProjectId?: string | undefined - vertexRegion?: string | undefined - openAiBaseUrl?: string | undefined - openAiApiKey?: string | undefined - openAiR1FormatEnabled?: boolean | undefined - openAiModelId?: string | undefined - openAiCustomModelInfo?: - | { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined - } + say?: + | ( + | "task" + | "error" + | "api_req_started" + | "api_req_finished" + | "api_req_retried" + | "api_req_retry_delayed" + | "api_req_deleted" + | "text" + | "reasoning" + | "completion_result" + | "user_feedback" + | "user_feedback_diff" + | "command_output" + | "tool" + | "shell_integration_warning" + | "browser_action" + | "browser_action_result" + | "command" + | "mcp_server_request_started" + | "mcp_server_response" + | "new_task_started" + | "new_task" + | "checkpoint_saved" + | "rooignore_error" + ) | undefined - openAiUseAzure?: boolean | undefined - azureApiVersion?: string | undefined - openAiStreamingEnabled?: boolean | undefined - ollamaModelId?: string | undefined - ollamaBaseUrl?: string | undefined - vsCodeLmModelSelector?: + text?: string | undefined + images?: string[] | undefined + partial?: boolean | undefined + reasoning?: string | undefined + conversationHistoryIndex?: number | undefined + checkpoint?: | { - vendor?: string | undefined - family?: string | undefined - version?: string | undefined - id?: string | undefined + [x: string]: unknown } | undefined - lmStudioModelId?: string | undefined - lmStudioBaseUrl?: string | undefined - lmStudioDraftModelId?: string | undefined - lmStudioSpeculativeDecodingEnabled?: boolean | undefined - geminiApiKey?: string | undefined - googleGeminiBaseUrl?: string | undefined - openAiNativeApiKey?: string | undefined - mistralApiKey?: string | undefined - mistralCodestralUrl?: string | undefined - deepSeekBaseUrl?: string | undefined - deepSeekApiKey?: string | undefined - unboundApiKey?: string | undefined - unboundModelId?: string | undefined - unboundModelInfo?: + progressStatus?: | { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined - } - | undefined - requestyApiKey?: string | undefined - requestyModelId?: string | undefined - requestyModelInfo?: - | { - maxTokens?: number | undefined - contextWindow: number - supportsImages?: boolean | undefined - supportsComputerUse?: boolean | undefined - supportsPromptCache: boolean - inputPrice?: number | undefined - outputPrice?: number | undefined - cacheWritesPrice?: number | undefined - cacheReadsPrice?: number | undefined - description?: string | undefined - reasoningEffort?: ("low" | "medium" | "high") | undefined - thinking?: boolean | undefined + icon?: string | undefined + text?: string | undefined } | undefined - modelTemperature?: (number | null) | undefined - modelMaxTokens?: number | undefined - modelMaxThinkingTokens?: number | undefined - includeMaxTokens?: boolean | undefined - fakeAi?: unknown | undefined } -export type { ProviderSettings } +export type { ClineMessage } + +type TokenUsage = { + totalTokensIn: number + totalTokensOut: number + totalCacheWrites?: number | undefined + totalCacheReads?: number | undefined + totalCost: number + contextTokens: number +} + +export type { TokenUsage } diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 1fe7b15922..68390d795f 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -623,6 +623,108 @@ export const GLOBAL_STATE_KEYS = [...GLOBAL_SETTINGS_KEYS, ...PROVIDER_SETTINGS_ export const isGlobalStateKey = (key: string): key is Keys => GLOBAL_STATE_KEYS.includes(key as Keys) +/** + * ClineAsk + */ + +export const clineAsks = [ + "followup", + "command", + "command_output", + "completion_result", + "tool", + "api_req_failed", + "resume_task", + "resume_completed_task", + "mistake_limit_reached", + "browser_action_launch", + "use_mcp_server", + "finishTask", +] as const + +export const clineAskSchema = z.enum(clineAsks) + +export type ClineAsk = z.infer + +// ClineSay + +export const clineSays = [ + "task", + "error", + "api_req_started", + "api_req_finished", + "api_req_retried", + "api_req_retry_delayed", + "api_req_deleted", + "text", + "reasoning", + "completion_result", + "user_feedback", + "user_feedback_diff", + "command_output", + "tool", + "shell_integration_warning", + "browser_action", + "browser_action_result", + "command", + "mcp_server_request_started", + "mcp_server_response", + "new_task_started", + "new_task", + "checkpoint_saved", + "rooignore_error", +] as const + +export const clineSaySchema = z.enum(clineSays) + +export type ClineSay = z.infer + +/** + * ToolProgressStatus + */ + +export const toolProgressStatusSchema = z.object({ + icon: z.string().optional(), + text: z.string().optional(), +}) + +export type ToolProgressStatus = z.infer + +/** + * ClineMessage + */ + +export const clineMessageSchema = z.object({ + ts: z.number(), + type: z.union([z.literal("ask"), z.literal("say")]), + ask: clineAskSchema.optional(), + say: clineSaySchema.optional(), + text: z.string().optional(), + images: z.array(z.string()).optional(), + partial: z.boolean().optional(), + reasoning: z.string().optional(), + conversationHistoryIndex: z.number().optional(), + checkpoint: z.record(z.string(), z.unknown()).optional(), + progressStatus: toolProgressStatusSchema.optional(), +}) + +export type ClineMessage = z.infer + +/** + * TokenUsage + */ + +export const tokenUsageSchema = z.object({ + totalTokensIn: z.number(), + totalTokensOut: z.number(), + totalCacheWrites: z.number().optional(), + totalCacheReads: z.number().optional(), + totalCost: z.number(), + contextTokens: z.number(), +}) + +export type TokenUsage = z.infer + /** * TypeDefinition */ @@ -633,22 +735,8 @@ type TypeDefinition = { } export const typeDefinitions: TypeDefinition[] = [ - { schema: providerNamesSchema, identifier: "ProviderName" }, - { schema: toolGroupsSchema, identifier: "ToolGroup" }, - { schema: checkpointStoragesSchema, identifier: "CheckpointStorage" }, - { schema: languagesSchema, identifier: "Language" }, - { schema: telemetrySettingsSchema, identifier: "TelemetrySetting" }, - { schema: modelInfoSchema, identifier: "ModelInfo" }, - { schema: apiConfigMetaSchema, identifier: "ApiConfigMeta" }, - { schema: historyItemSchema, identifier: "HistoryItem" }, - { schema: groupOptionsSchema, identifier: "GroupOptions" }, - { schema: groupEntrySchema, identifier: "GroupEntry" }, - { schema: modeConfigSchema, identifier: "ModeConfig" }, - { schema: promptComponentSchema, identifier: "PromptComponent" }, - { schema: customModePromptsSchema, identifier: "CustomModePrompts" }, - { schema: customSupportPromptsSchema, identifier: "CustomSupportPrompts" }, - { schema: experimentIdsSchema, identifier: "ExperimentId" }, - { schema: experimentsSchema, identifier: "Experiments" }, - { schema: globalSettingsSchema, identifier: "GlobalSettings" }, { schema: providerSettingsSchema, identifier: "ProviderSettings" }, + { schema: globalSettingsSchema, identifier: "GlobalSettings" }, + { schema: clineMessageSchema, identifier: "ClineMessage" }, + { schema: tokenUsageSchema, identifier: "TokenUsage" }, ] diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index 398077e353..eb5e89a2b4 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -8,13 +8,16 @@ import { CheckpointStorage, TelemetrySetting, ExperimentId, + ClineAsk, + ClineSay, + ToolProgressStatus, + ClineMessage, } from "../schemas" import { McpServer } from "./mcp" import { GitCommit } from "../utils/git" import { Mode } from "./modes" -import type { ClineMessage, ClineAsk, ClineSay } from "../exports/roo-code" -export type { ApiConfigMeta } +export type { ApiConfigMeta, ToolProgressStatus } export interface LanguageModelChatSelector { vendor?: string @@ -267,5 +270,3 @@ export interface ClineApiReqInfo { } export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled" - -export type { ToolProgressStatus } from "../exports/roo-code" diff --git a/src/shared/getApiMetrics.ts b/src/shared/getApiMetrics.ts index bb4927edef..55100d643a 100644 --- a/src/shared/getApiMetrics.ts +++ b/src/shared/getApiMetrics.ts @@ -1,4 +1,4 @@ -import { TokenUsage } from "../exports/roo-code" +import { TokenUsage } from "../schemas" import { ClineMessage } from "./ExtensionMessage" From 76ffcc77033e0ca8b8297354e6277bcbd7ca6c52 Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 02:33:11 -0700 Subject: [PATCH 07/10] Use tsup --- .husky/pre-commit | 4 +- package-lock.json | 1222 +++++++++++++++++++++++++++++++++++- package.json | 1 + scripts/generate-types.mts | 8 +- src/exports/interface.ts | 94 +++ src/exports/roo-code.d.ts | 425 ++++++++++++- src/exports/types.ts | 2 +- 7 files changed, 1731 insertions(+), 25 deletions(-) create mode 100644 src/exports/interface.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 3c381f1ce5..e434854b2d 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -15,8 +15,8 @@ fi npm run generate-types # Check if src/exports/types.ts has unstaged changes after running the script. -if [ -n "$(git diff --name-only src/exports/types.ts)" ]; then - echo "Error: There are unstaged changes to src/exports/types.ts after running 'npm run generate-types'." +if [ -n "$(git diff --name-only src/exports/roo-code.d.ts)" ]; then + echo "Error: There are unstaged changes to roo-code.d.ts after running 'npm run generate-types'." echo "Please review and stage the changes before committing." exit 1 fi diff --git a/package-lock.json b/package-lock.json index c04ec0dff2..2dce74320f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,6 +91,7 @@ "prettier": "^3.4.2", "rimraf": "^6.0.1", "ts-jest": "^29.2.5", + "tsup": "^8.4.0", "tsx": "^4.19.3", "typescript": "^5.4.5", "zod-to-ts": "^1.2.0" @@ -4714,6 +4715,17 @@ "node": ">= 8" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@puppeteer/browsers": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.5.0.tgz", @@ -4735,6 +4747,286 @@ "node": ">=18" } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.37.0.tgz", + "integrity": "sha512-l7StVw6WAa8l3vA1ov80jyetOAEo1FtHvZDbzXDO/02Sq/QVvqlHkYoFwDJPIMj0GKiistsBudfx5tGFnwYWDQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.37.0.tgz", + "integrity": "sha512-6U3SlVyMxezt8Y+/iEBcbp945uZjJwjZimu76xoG7tO1av9VO691z8PkhzQ85ith2I8R2RddEPeSfcbyPfD4hA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.37.0.tgz", + "integrity": "sha512-+iTQ5YHuGmPt10NTzEyMPbayiNTcOZDWsbxZYR1ZnmLnZxG17ivrPSWFO9j6GalY0+gV3Jtwrrs12DBscxnlYA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.37.0.tgz", + "integrity": "sha512-m8W2UbxLDcmRKVjgl5J/k4B8d7qX2EcJve3Sut7YGrQoPtCIQGPH5AMzuFvYRWZi0FVS0zEY4c8uttPfX6bwYQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.37.0.tgz", + "integrity": "sha512-FOMXGmH15OmtQWEt174v9P1JqqhlgYge/bUjIbiVD1nI1NeJ30HYT9SJlZMqdo1uQFyt9cz748F1BHghWaDnVA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.37.0.tgz", + "integrity": "sha512-SZMxNttjPKvV14Hjck5t70xS3l63sbVwl98g3FlVVx2YIDmfUIy29jQrsw06ewEYQ8lQSuY9mpAPlmgRD2iSsA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.37.0.tgz", + "integrity": "sha512-hhAALKJPidCwZcj+g+iN+38SIOkhK2a9bqtJR+EtyxrKKSt1ynCBeqrQy31z0oWU6thRZzdx53hVgEbRkuI19w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.37.0.tgz", + "integrity": "sha512-jUb/kmn/Gd8epbHKEqkRAxq5c2EwRt0DqhSGWjPFxLeFvldFdHQs/n8lQ9x85oAeVb6bHcS8irhTJX2FCOd8Ag==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.37.0.tgz", + "integrity": "sha512-oNrJxcQT9IcbcmKlkF+Yz2tmOxZgG9D9GRq+1OE6XCQwCVwxixYAa38Z8qqPzQvzt1FCfmrHX03E0pWoXm1DqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.37.0.tgz", + "integrity": "sha512-pfxLBMls+28Ey2enpX3JvjEjaJMBX5XlPCZNGxj4kdJyHduPBXtxYeb8alo0a7bqOoWZW2uKynhHxF/MWoHaGQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.37.0.tgz", + "integrity": "sha512-yCE0NnutTC/7IGUq/PUHmoeZbIwq3KRh02e9SfFh7Vmc1Z7atuJRYWhRME5fKgT8aS20mwi1RyChA23qSyRGpA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.37.0.tgz", + "integrity": "sha512-NxcICptHk06E2Lh3a4Pu+2PEdZ6ahNHuK7o6Np9zcWkrBMuv21j10SQDJW3C9Yf/A/P7cutWoC/DptNLVsZ0VQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.37.0.tgz", + "integrity": "sha512-PpWwHMPCVpFZLTfLq7EWJWvrmEuLdGn1GMYcm5MV7PaRgwCEYJAwiN94uBuZev0/J/hFIIJCsYw4nLmXA9J7Pw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.37.0.tgz", + "integrity": "sha512-DTNwl6a3CfhGTAOYZ4KtYbdS8b+275LSLqJVJIrPa5/JuIufWWZ/QFvkxp52gpmguN95eujrM68ZG+zVxa8zHA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.37.0.tgz", + "integrity": "sha512-hZDDU5fgWvDdHFuExN1gBOhCuzo/8TMpidfOR+1cPZJflcEzXdCy1LjnklQdW8/Et9sryOPJAKAQRw8Jq7Tg+A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.37.0.tgz", + "integrity": "sha512-pKivGpgJM5g8dwj0ywBwe/HeVAUSuVVJhUTa/URXjxvoyTT/AxsLTAbkHkDHG7qQxLoW2s3apEIl26uUe08LVQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.37.0.tgz", + "integrity": "sha512-E2lPrLKE8sQbY/2bEkVTGDEk4/49UYRVWgj90MY8yPjpnGBQ+Xi1Qnr7b7UIWw1NOggdFQFOLZ8+5CzCiz143w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.37.0.tgz", + "integrity": "sha512-Jm7biMazjNzTU4PrQtr7VS8ibeys9Pn29/1bm4ph7CP2kf21950LgN+BaE2mJ1QujnvOc6p54eWWiVvn05SOBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.37.0.tgz", + "integrity": "sha512-e3/1SFm1OjefWICB2Ucstg2dxYDkDTZGDYgwufcbsxTHyqQps1UQf33dFEChBNmeSsTOyrjw2JJq0zbG5GF6RA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.37.0.tgz", + "integrity": "sha512-LWbXUBwn/bcLx2sSsqy7pK5o+Nr+VCoRoAohfJ5C/aBio9nfJmGQqHAhU6pwxV/RmyTk5AqdySma7uwWGlmeuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@sec-ant/readable-stream": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", @@ -6528,6 +6820,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", @@ -7087,6 +7386,13 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -7592,6 +7898,22 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/bundle-require": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz", + "integrity": "sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "load-tsconfig": "^0.2.3" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "peerDependencies": { + "esbuild": ">=0.18" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -7601,6 +7923,16 @@ "node": ">= 0.8" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", @@ -8026,6 +8358,16 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/consola": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, "node_modules/console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -12074,6 +12416,16 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/js-tiktoken": { "version": "1.0.19", "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.19.tgz", @@ -12675,6 +13027,16 @@ "node": ">=4" } }, + "node_modules/load-tsconfig": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz", + "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -12702,6 +13064,13 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.startcase": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz", @@ -13170,7 +13539,19 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/natural-compare": { + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", @@ -14161,6 +14542,49 @@ "node": ">= 0.4" } }, + "node_modules/postcss-load-config": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz", + "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "jiti": ">=1.21.0", + "postcss": ">=8.0.9", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + }, + "postcss": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, "node_modules/posthog-node": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/posthog-node/-/posthog-node-4.7.0.tgz", @@ -14808,6 +15232,46 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup": { + "version": "4.37.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.37.0.tgz", + "integrity": "sha512-iAtQy/L4QFU+rTJ1YUjXqJOJzuwEghqWzCEYD2FEghT7Gsy1VdABntrO4CLopA5IkflTyqNiLNwPcOJ3S7UKLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.37.0", + "@rollup/rollup-android-arm64": "4.37.0", + "@rollup/rollup-darwin-arm64": "4.37.0", + "@rollup/rollup-darwin-x64": "4.37.0", + "@rollup/rollup-freebsd-arm64": "4.37.0", + "@rollup/rollup-freebsd-x64": "4.37.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.37.0", + "@rollup/rollup-linux-arm-musleabihf": "4.37.0", + "@rollup/rollup-linux-arm64-gnu": "4.37.0", + "@rollup/rollup-linux-arm64-musl": "4.37.0", + "@rollup/rollup-linux-loongarch64-gnu": "4.37.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.37.0", + "@rollup/rollup-linux-riscv64-gnu": "4.37.0", + "@rollup/rollup-linux-riscv64-musl": "4.37.0", + "@rollup/rollup-linux-s390x-gnu": "4.37.0", + "@rollup/rollup-linux-x64-gnu": "4.37.0", + "@rollup/rollup-linux-x64-musl": "4.37.0", + "@rollup/rollup-win32-arm64-msvc": "4.37.0", + "@rollup/rollup-win32-ia32-msvc": "4.37.0", + "@rollup/rollup-win32-x64-msvc": "4.37.0", + "fsevents": "~2.3.2" + } + }, "node_modules/router": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/router/-/router-2.1.0.tgz", @@ -15677,6 +16141,100 @@ "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==" }, + "node_modules/sucrase": { + "version": "3.35.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", + "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "glob": "^10.3.10", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/sucrase/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/sucrase/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sucrase/node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/sucrase/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/sucrase/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/summary": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/summary/-/summary-2.1.0.tgz", @@ -15810,11 +16368,86 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.12.tgz", + "integrity": "sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.4.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz", + "integrity": "sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", @@ -15855,6 +16488,16 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/tree-sitter-wasms": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/tree-sitter-wasms/-/tree-sitter-wasms-0.1.12.tgz", @@ -15875,6 +16518,13 @@ "typescript": ">=4.2.0" } }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/ts-jest": { "version": "29.2.5", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz", @@ -15928,6 +16578,576 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, + "node_modules/tsup": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.4.0.tgz", + "integrity": "sha512-b+eZbPCjz10fRryaAA7C8xlIHnf8VnsaRqydheLIqwG/Mcpfk8Z5zp3HayX7GaTygkigHl5cBUs+IhcySiIexQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "bundle-require": "^5.1.0", + "cac": "^6.7.14", + "chokidar": "^4.0.3", + "consola": "^3.4.0", + "debug": "^4.4.0", + "esbuild": "^0.25.0", + "joycon": "^3.1.1", + "picocolors": "^1.1.1", + "postcss-load-config": "^6.0.1", + "resolve-from": "^5.0.0", + "rollup": "^4.34.8", + "source-map": "0.8.0-beta.0", + "sucrase": "^3.35.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.11", + "tree-kill": "^1.2.2" + }, + "bin": { + "tsup": "dist/cli-default.js", + "tsup-node": "dist/cli-node.js" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@microsoft/api-extractor": "^7.36.0", + "@swc/core": "^1", + "postcss": "^8.4.12", + "typescript": ">=4.5.0" + }, + "peerDependenciesMeta": { + "@microsoft/api-extractor": { + "optional": true + }, + "@swc/core": { + "optional": true + }, + "postcss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/tsup/node_modules/@esbuild/aix-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.1.tgz", + "integrity": "sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/android-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.1.tgz", + "integrity": "sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/android-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.1.tgz", + "integrity": "sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/android-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.1.tgz", + "integrity": "sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/darwin-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.1.tgz", + "integrity": "sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/darwin-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.1.tgz", + "integrity": "sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.1.tgz", + "integrity": "sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/freebsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.1.tgz", + "integrity": "sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-arm": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.1.tgz", + "integrity": "sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.1.tgz", + "integrity": "sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.1.tgz", + "integrity": "sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-loong64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.1.tgz", + "integrity": "sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-mips64el": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.1.tgz", + "integrity": "sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-ppc64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.1.tgz", + "integrity": "sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-riscv64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.1.tgz", + "integrity": "sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-s390x": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.1.tgz", + "integrity": "sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.1.tgz", + "integrity": "sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.1.tgz", + "integrity": "sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/netbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.1.tgz", + "integrity": "sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.1.tgz", + "integrity": "sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/openbsd-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.1.tgz", + "integrity": "sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/sunos-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.1.tgz", + "integrity": "sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-arm64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.1.tgz", + "integrity": "sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-ia32": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.1.tgz", + "integrity": "sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-x64": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.1.tgz", + "integrity": "sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/esbuild": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.1.tgz", + "integrity": "sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.1", + "@esbuild/android-arm": "0.25.1", + "@esbuild/android-arm64": "0.25.1", + "@esbuild/android-x64": "0.25.1", + "@esbuild/darwin-arm64": "0.25.1", + "@esbuild/darwin-x64": "0.25.1", + "@esbuild/freebsd-arm64": "0.25.1", + "@esbuild/freebsd-x64": "0.25.1", + "@esbuild/linux-arm": "0.25.1", + "@esbuild/linux-arm64": "0.25.1", + "@esbuild/linux-ia32": "0.25.1", + "@esbuild/linux-loong64": "0.25.1", + "@esbuild/linux-mips64el": "0.25.1", + "@esbuild/linux-ppc64": "0.25.1", + "@esbuild/linux-riscv64": "0.25.1", + "@esbuild/linux-s390x": "0.25.1", + "@esbuild/linux-x64": "0.25.1", + "@esbuild/netbsd-arm64": "0.25.1", + "@esbuild/netbsd-x64": "0.25.1", + "@esbuild/openbsd-arm64": "0.25.1", + "@esbuild/openbsd-x64": "0.25.1", + "@esbuild/sunos-x64": "0.25.1", + "@esbuild/win32-arm64": "0.25.1", + "@esbuild/win32-ia32": "0.25.1", + "@esbuild/win32-x64": "0.25.1" + } + }, + "node_modules/tsup/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/tsup/node_modules/source-map": { + "version": "0.8.0-beta.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", + "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "whatwg-url": "^7.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/tsup/node_modules/tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/tsup/node_modules/webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/tsup/node_modules/whatwg-url": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, "node_modules/tsx": { "version": "4.19.3", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.3.tgz", diff --git a/package.json b/package.json index 30df090654..830b77d2ca 100644 --- a/package.json +++ b/package.json @@ -438,6 +438,7 @@ "prettier": "^3.4.2", "rimraf": "^6.0.1", "ts-jest": "^29.2.5", + "tsup": "^8.4.0", "tsx": "^4.19.3", "typescript": "^5.4.5", "zod-to-ts": "^1.2.0" diff --git a/scripts/generate-types.mts b/scripts/generate-types.mts index cef672e9bf..3c68391ccd 100644 --- a/scripts/generate-types.mts +++ b/scripts/generate-types.mts @@ -7,7 +7,7 @@ import { typeDefinitions } from "../src/schemas" async function main() { const types: string[] = [ - "// This file is automatically generated by running `npx tsx scripts/generate-types.mts`\n// Do not edit it directly.", + "// This file is automatically generated by running `npm run generate-types`\n// Do not edit it directly.", ] for (const { schema, identifier } of typeDefinitions) { @@ -16,7 +16,11 @@ async function main() { } await fs.writeFile("src/exports/types.ts", types.join("\n\n")) - await $`npx prettier --write src/exports/types.ts` + + await $`npx tsup src/exports/interface.ts --dts-only -d out` + await $`cp out/interface.d.ts src/exports/roo-code.d.ts` + + await $`npx prettier --write src/exports/types.ts src/exports/roo-code.d.ts` } main() diff --git a/src/exports/interface.ts b/src/exports/interface.ts new file mode 100644 index 0000000000..e8abe8e379 --- /dev/null +++ b/src/exports/interface.ts @@ -0,0 +1,94 @@ +import { EventEmitter } from "events" + +import type { ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } from "./types" + +type RooCodeSettings = GlobalSettings & ProviderSettings + +export type { RooCodeSettings, ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } + +export interface RooCodeEvents { + message: [{ taskId: string; action: "created" | "updated"; message: ClineMessage }] + taskCreated: [taskId: string] + taskStarted: [taskId: string] + taskPaused: [taskId: string] + taskUnpaused: [taskId: string] + taskAskResponded: [taskId: string] + taskAborted: [taskId: string] + taskSpawned: [taskId: string, childTaskId: string] + taskCompleted: [taskId: string, usage: TokenUsage] + taskTokenUsageUpdated: [taskId: string, usage: TokenUsage] +} + +export interface RooCodeAPI extends EventEmitter { + /** + * Starts a new task with an optional initial message and images. + * @param task Optional initial task message. + * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,..."). + * @returns The ID of the new task. + */ + startNewTask(task?: string, images?: string[]): Promise + + /** + * Returns the current task stack. + * @returns An array of task IDs. + */ + getCurrentTaskStack(): string[] + + /** + * Clears the current task. + */ + clearCurrentTask(lastMessage?: string): Promise + + /** + * Cancels the current task. + */ + cancelCurrentTask(): Promise + + /** + * Sends a message to the current task. + * @param message Optional message to send. + * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,..."). + */ + sendMessage(message?: string, images?: string[]): Promise + + /** + * Simulates pressing the primary button in the chat interface. + */ + pressPrimaryButton(): Promise + + /** + * Simulates pressing the secondary button in the chat interface. + */ + pressSecondaryButton(): Promise + + /** + * Sets the configuration for the current task. + * @param values An object containing key-value pairs to set. + */ + setConfiguration(values: RooCodeSettings): Promise + + /** + * Returns true if the API is ready to use. + */ + isReady(): boolean + + /** + * Returns the messages for a given task. + * @param taskId The ID of the task. + * @returns An array of ClineMessage objects. + */ + getMessages(taskId: string): ClineMessage[] + + /** + * Returns the token usage for a given task. + * @param taskId The ID of the task. + * @returns A TokenUsage object. + */ + getTokenUsage(taskId: string): TokenUsage + + /** + * Logs a message to the output channel. + * @param message The message to log. + */ + log(message: string): void +} diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 837a21fae3..5508d30160 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -1,15 +1,412 @@ import { EventEmitter } from "events" -import * as vscode from "vscode" +type ProviderSettings = { + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined + apiModelId?: string | undefined + apiKey?: string | undefined + anthropicBaseUrl?: string | undefined + glamaModelId?: string | undefined + glamaModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + glamaApiKey?: string | undefined + openRouterApiKey?: string | undefined + openRouterModelId?: string | undefined + openRouterModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + openRouterBaseUrl?: string | undefined + openRouterSpecificProvider?: string | undefined + openRouterUseMiddleOutTransform?: boolean | undefined + awsAccessKey?: string | undefined + awsSecretKey?: string | undefined + awsSessionToken?: string | undefined + awsRegion?: string | undefined + awsUseCrossRegionInference?: boolean | undefined + awsUsePromptCache?: boolean | undefined + awspromptCacheId?: string | undefined + awsProfile?: string | undefined + awsUseProfile?: boolean | undefined + awsCustomArn?: string | undefined + vertexKeyFile?: string | undefined + vertexJsonCredentials?: string | undefined + vertexProjectId?: string | undefined + vertexRegion?: string | undefined + openAiBaseUrl?: string | undefined + openAiApiKey?: string | undefined + openAiR1FormatEnabled?: boolean | undefined + openAiModelId?: string | undefined + openAiCustomModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + openAiUseAzure?: boolean | undefined + azureApiVersion?: string | undefined + openAiStreamingEnabled?: boolean | undefined + ollamaModelId?: string | undefined + ollamaBaseUrl?: string | undefined + vsCodeLmModelSelector?: + | { + vendor?: string | undefined + family?: string | undefined + version?: string | undefined + id?: string | undefined + } + | undefined + lmStudioModelId?: string | undefined + lmStudioBaseUrl?: string | undefined + lmStudioDraftModelId?: string | undefined + lmStudioSpeculativeDecodingEnabled?: boolean | undefined + geminiApiKey?: string | undefined + googleGeminiBaseUrl?: string | undefined + openAiNativeApiKey?: string | undefined + mistralApiKey?: string | undefined + mistralCodestralUrl?: string | undefined + deepSeekBaseUrl?: string | undefined + deepSeekApiKey?: string | undefined + unboundApiKey?: string | undefined + unboundModelId?: string | undefined + unboundModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + requestyApiKey?: string | undefined + requestyModelId?: string | undefined + requestyModelInfo?: + | { + maxTokens?: number | undefined + contextWindow: number + supportsImages?: boolean | undefined + supportsComputerUse?: boolean | undefined + supportsPromptCache: boolean + inputPrice?: number | undefined + outputPrice?: number | undefined + cacheWritesPrice?: number | undefined + cacheReadsPrice?: number | undefined + description?: string | undefined + reasoningEffort?: ("low" | "medium" | "high") | undefined + thinking?: boolean | undefined + } + | undefined + modelTemperature?: (number | null) | undefined + modelMaxTokens?: number | undefined + modelMaxThinkingTokens?: number | undefined + includeMaxTokens?: boolean | undefined + fakeAi?: unknown | undefined +} -import type { ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } from "./types" +type GlobalSettings = { + currentApiConfigName?: string | undefined + listApiConfigMeta?: + | { + id: string + name: string + apiProvider?: + | ( + | "anthropic" + | "glama" + | "openrouter" + | "bedrock" + | "vertex" + | "openai" + | "ollama" + | "vscode-lm" + | "lmstudio" + | "gemini" + | "openai-native" + | "mistral" + | "deepseek" + | "unbound" + | "requesty" + | "human-relay" + | "fake-ai" + ) + | undefined + }[] + | undefined + pinnedApiConfigs?: + | { + [x: string]: boolean + } + | undefined + lastShownAnnouncementId?: string | undefined + customInstructions?: string | undefined + taskHistory?: + | { + id: string + number: number + ts: number + task: string + tokensIn: number + tokensOut: number + cacheWrites?: number | undefined + cacheReads?: number | undefined + totalCost: number + size?: number | undefined + }[] + | undefined + autoApprovalEnabled?: boolean | undefined + alwaysAllowReadOnly?: boolean | undefined + alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined + alwaysAllowWrite?: boolean | undefined + alwaysAllowWriteOutsideWorkspace?: boolean | undefined + writeDelayMs?: number | undefined + alwaysAllowBrowser?: boolean | undefined + alwaysApproveResubmit?: boolean | undefined + requestDelaySeconds?: number | undefined + alwaysAllowMcp?: boolean | undefined + alwaysAllowModeSwitch?: boolean | undefined + alwaysAllowSubtasks?: boolean | undefined + alwaysAllowExecute?: boolean | undefined + allowedCommands?: string[] | undefined + browserToolEnabled?: boolean | undefined + browserViewportSize?: string | undefined + screenshotQuality?: number | undefined + remoteBrowserEnabled?: boolean | undefined + remoteBrowserHost?: string | undefined + enableCheckpoints?: boolean | undefined + checkpointStorage?: ("task" | "workspace") | undefined + ttsEnabled?: boolean | undefined + ttsSpeed?: number | undefined + soundEnabled?: boolean | undefined + soundVolume?: number | undefined + maxOpenTabsContext?: number | undefined + maxWorkspaceFiles?: number | undefined + showRooIgnoredFiles?: boolean | undefined + maxReadFileLine?: number | undefined + terminalOutputLineLimit?: number | undefined + terminalShellIntegrationTimeout?: number | undefined + rateLimitSeconds?: number | undefined + diffEnabled?: boolean | undefined + fuzzyMatchThreshold?: number | undefined + experiments?: + | { + experimentalDiffStrategy: boolean + search_and_replace: boolean + insert_content: boolean + powerSteering: boolean + multi_search_and_replace: boolean + } + | undefined + language?: + | ( + | "ca" + | "de" + | "en" + | "es" + | "fr" + | "hi" + | "it" + | "ja" + | "ko" + | "pl" + | "pt-BR" + | "tr" + | "vi" + | "zh-CN" + | "zh-TW" + ) + | undefined + telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined + mcpEnabled?: boolean | undefined + enableMcpServerCreation?: boolean | undefined + mode?: string | undefined + modeApiConfigs?: + | { + [x: string]: string + } + | undefined + customModes?: + | { + slug: string + name: string + roleDefinition: string + customInstructions?: string | undefined + groups: ( + | ("read" | "edit" | "browser" | "command" | "mcp" | "modes") + | [ + "read" | "edit" | "browser" | "command" | "mcp" | "modes", + { + fileRegex?: string | undefined + description?: string | undefined + }, + ] + )[] + source?: ("global" | "project") | undefined + }[] + | undefined + customModePrompts?: + | { + [x: string]: + | { + roleDefinition?: string | undefined + customInstructions?: string | undefined + } + | undefined + } + | undefined + customSupportPrompts?: + | { + [x: string]: string | undefined + } + | undefined + enhancementApiConfigId?: string | undefined +} -type RooCodeSettings = GlobalSettings & ProviderSettings +type ClineMessage = { + ts: number + type: "ask" | "say" + ask?: + | ( + | "followup" + | "command" + | "command_output" + | "completion_result" + | "tool" + | "api_req_failed" + | "resume_task" + | "resume_completed_task" + | "mistake_limit_reached" + | "browser_action_launch" + | "use_mcp_server" + | "finishTask" + ) + | undefined + say?: + | ( + | "task" + | "error" + | "api_req_started" + | "api_req_finished" + | "api_req_retried" + | "api_req_retry_delayed" + | "api_req_deleted" + | "text" + | "reasoning" + | "completion_result" + | "user_feedback" + | "user_feedback_diff" + | "command_output" + | "tool" + | "shell_integration_warning" + | "browser_action" + | "browser_action_result" + | "command" + | "mcp_server_request_started" + | "mcp_server_response" + | "new_task_started" + | "new_task" + | "checkpoint_saved" + | "rooignore_error" + ) + | undefined + text?: string | undefined + images?: string[] | undefined + partial?: boolean | undefined + reasoning?: string | undefined + conversationHistoryIndex?: number | undefined + checkpoint?: + | { + [x: string]: unknown + } + | undefined + progressStatus?: + | { + icon?: string | undefined + text?: string | undefined + } + | undefined +} + +type TokenUsage = { + totalTokensIn: number + totalTokensOut: number + totalCacheWrites?: number | undefined + totalCacheReads?: number | undefined + totalCost: number + contextTokens: number +} -export type { RooCodeSettings, ProviderSettings, GlobalSettings, ClineMessage, TokenUsage } +type RooCodeSettings = GlobalSettings & ProviderSettings -export interface RooCodeEvents { - message: [{ taskId: string; action: "created" | "updated"; message: ClineMessage }] +interface RooCodeEvents { + message: [ + { + taskId: string + action: "created" | "updated" + message: ClineMessage + }, + ] taskCreated: [taskId: string] taskStarted: [taskId: string] taskPaused: [taskId: string] @@ -20,8 +417,7 @@ export interface RooCodeEvents { taskCompleted: [taskId: string, usage: TokenUsage] taskTokenUsageUpdated: [taskId: string, usage: TokenUsage] } - -export interface RooCodeAPI extends EventEmitter { +interface RooCodeAPI extends EventEmitter { /** * Starts a new task with an optional initial message and images. * @param task Optional initial task message. @@ -29,68 +425,59 @@ export interface RooCodeAPI extends EventEmitter { * @returns The ID of the new task. */ startNewTask(task?: string, images?: string[]): Promise - /** * Returns the current task stack. * @returns An array of task IDs. */ getCurrentTaskStack(): string[] - /** * Clears the current task. */ clearCurrentTask(lastMessage?: string): Promise - /** * Cancels the current task. */ cancelCurrentTask(): Promise - /** * Sends a message to the current task. * @param message Optional message to send. * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,..."). */ sendMessage(message?: string, images?: string[]): Promise - /** * Simulates pressing the primary button in the chat interface. */ pressPrimaryButton(): Promise - /** * Simulates pressing the secondary button in the chat interface. */ pressSecondaryButton(): Promise - /** * Sets the configuration for the current task. * @param values An object containing key-value pairs to set. */ setConfiguration(values: RooCodeSettings): Promise - /** * Returns true if the API is ready to use. */ isReady(): boolean - /** * Returns the messages for a given task. * @param taskId The ID of the task. * @returns An array of ClineMessage objects. */ getMessages(taskId: string): ClineMessage[] - /** * Returns the token usage for a given task. * @param taskId The ID of the task. * @returns A TokenUsage object. */ getTokenUsage(taskId: string): TokenUsage - /** * Logs a message to the output channel. * @param message The message to log. */ log(message: string): void } + +export type { ClineMessage, GlobalSettings, ProviderSettings, RooCodeAPI, RooCodeEvents, RooCodeSettings, TokenUsage } diff --git a/src/exports/types.ts b/src/exports/types.ts index 0da9469321..9432537718 100644 --- a/src/exports/types.ts +++ b/src/exports/types.ts @@ -1,4 +1,4 @@ -// This file is automatically generated by running `npx tsx scripts/generated-types.ts` +// This file is automatically generated by running `npm run generate-types` // Do not edit it directly. type ProviderSettings = { From 1e33070cc4f4fecc183ffb3013d7583d8c4af31b Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 02:37:42 -0700 Subject: [PATCH 08/10] Remove comment --- .husky/pre-commit | 1 - 1 file changed, 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index e434854b2d..96623f1005 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -14,7 +14,6 @@ fi npm run generate-types -# Check if src/exports/types.ts has unstaged changes after running the script. if [ -n "$(git diff --name-only src/exports/roo-code.d.ts)" ]; then echo "Error: There are unstaged changes to roo-code.d.ts after running 'npm run generate-types'." echo "Please review and stage the changes before committing." From 84f24289e25d88bbe76c13084ba787c8f0d03944 Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Thu, 27 Mar 2025 02:42:18 -0700 Subject: [PATCH 09/10] Update scripts/generate-types.mts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- scripts/generate-types.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-types.mts b/scripts/generate-types.mts index 3c68391ccd..c9bed9a003 100644 --- a/scripts/generate-types.mts +++ b/scripts/generate-types.mts @@ -18,7 +18,7 @@ async function main() { await fs.writeFile("src/exports/types.ts", types.join("\n\n")) await $`npx tsup src/exports/interface.ts --dts-only -d out` - await $`cp out/interface.d.ts src/exports/roo-code.d.ts` + await fs.copyFile('out/interface.d.ts', 'src/exports/roo-code.d.ts') await $`npx prettier --write src/exports/types.ts src/exports/roo-code.d.ts` } From 47f1e60af8eacf8c3bfaf0bd71742dc9d1040002 Mon Sep 17 00:00:00 2001 From: cte Date: Thu, 27 Mar 2025 02:44:50 -0700 Subject: [PATCH 10/10] Increase timeout for e2e tests --- e2e/src/suite/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/src/suite/utils.ts b/e2e/src/suite/utils.ts index a84ddd814f..e816315633 100644 --- a/e2e/src/suite/utils.ts +++ b/e2e/src/suite/utils.ts @@ -9,7 +9,7 @@ type WaitForOptions = { export const waitFor = ( condition: (() => Promise) | (() => boolean), - { timeout = 30_000, interval = 250 }: WaitForOptions = {}, + { timeout = 60_000, interval = 250 }: WaitForOptions = {}, ) => { let timeoutId: NodeJS.Timeout | undefined = undefined