diff --git a/.opencode/node_modules/.package-lock.json b/.opencode/node_modules/.package-lock.json index 8f272b983d581d9aaf71795c837ffcc30e95bc3f..9619dc5128eff5fba65d41f56ac5069199d9e79b 100644 --- a/.opencode/node_modules/.package-lock.json +++ b/.opencode/node_modules/.package-lock.json @@ -4,33 +4,43 @@ "lockfileVersion": 3, "requires": true, "packages": { - "../../../data/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz", - "integrity": "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==", + "node_modules/@ai-sdk/provider": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@ai-sdk/provider/-/provider-3.0.8.tgz", + "integrity": "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ==", + "dependencies": { + "json-schema": "^0.4.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.4.tgz", + "integrity": "sha512-8TNXMEjJc3QEy7R/x1INhgiU+XakDAFUzBhaz7+Rbrs8NH5UQeHQxxmzsSBJGyV6I1jW79undiQm8tOI+D+8FQ==", "cpu": [ "x64" ], - "license": "MIT", "optional": true, "os": [ "linux" ] }, - "../../../data/.opencode/node_modules/@opencode-ai/plugin": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.15.5.tgz", - "integrity": "sha512-QvhrDLlQuLeFGET1zB2crMWPvou6PpAzYtKrbun9akWvaskyAcXIAVn3lNYX/InMcut5VzL6ERbPgvM7ucHfLA==", - "license": "MIT", + "node_modules/@opencode-ai/plugin": { + "version": "1.18.21", + "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.18.21.tgz", + "integrity": "sha512-wQXMbSvg3pG75F8fYAiJxYuyr6Cl9Hd74lSCY2yznZnejpwa+ksd2kMphmgSo+/UgLhb2AId9KAI6dsRhprzTg==", "dependencies": { - "@opencode-ai/sdk": "1.15.5", - "effect": "4.0.0-beta.65", + "@ai-sdk/provider": "3.0.8", + "@opencode-ai/sdk": "1.18.21", + "effect": "4.0.0-beta.83", "zod": "4.1.8" }, "peerDependencies": { - "@opentui/core": ">=0.2.14", - "@opentui/keymap": ">=0.2.14", - "@opentui/solid": ">=0.2.14" + "@opentui/core": ">=0.4.5", + "@opentui/keymap": ">=0.4.5", + "@opentui/solid": ">=0.4.5" }, "peerDependenciesMeta": { "@opentui/core": { @@ -44,26 +54,23 @@ } } }, - "../../../data/.opencode/node_modules/@opencode-ai/sdk": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.15.5.tgz", - "integrity": "sha512-ozJuEmXzrOvia5n0L1KAuvpyf9ESGmTk1FiPhn0RK5X1whbzjlTXL0NAxqNCEkqETxL35jS1KHArEiTpvtJ6FQ==", - "license": "MIT", + "node_modules/@opencode-ai/sdk": { + "version": "1.18.21", + "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.18.21.tgz", + "integrity": "sha512-k6iHQ5C8wOPglk+LgFyYnst168cGMQYumgpbVoeXJ+iC1AtvwD5zmjuF8CxMze/y9G1K2bOeO6p9yRvA7eHZLA==", "dependencies": { "cross-spawn": "7.0.6" } }, - "../../../data/.opencode/node_modules/@standard-schema/spec": { + "node_modules/@standard-schema/spec": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "license": "MIT" + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==" }, - "../../../data/.opencode/node_modules/cross-spawn": { + "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -73,38 +80,36 @@ "node": ">= 8" } }, - "../../../data/.opencode/node_modules/detect-libc": { + "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "license": "Apache-2.0", "optional": true, "engines": { "node": ">=8" } }, - "../../../data/.opencode/node_modules/effect": { - "version": "4.0.0-beta.65", - "resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.65.tgz", - "integrity": "sha512-QYKvQPAj3CmtsvWkHQww15wX4KG2gNsszDWEcOO5sZCMknp66u6Si/Opmt3wwWCwsyvRmDAdIg+JIz5qzbbFIw==", - "license": "MIT", + "node_modules/effect": { + "version": "4.0.0-beta.83", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.83.tgz", + "integrity": "sha512-0wsak8RtgGAr9UWSbVDgJHZcUqMSvicHcvaZv1MbMM7MCGgW4Rn/137J1MHQbwYPcwYGxT/IqehFd+UbYuj78w==", "dependencies": { "@standard-schema/spec": "^1.1.0", - "fast-check": "^4.6.0", + "fast-check": "^4.8.0", "find-my-way-ts": "^0.1.6", - "ini": "^6.0.0", + "ini": "^7.0.0", "kubernetes-types": "^1.30.0", - "msgpackr": "^1.11.9", + "msgpackr": "^2.0.1", "multipasta": "^0.2.7", "toml": "^4.1.1", - "uuid": "^13.0.0", - "yaml": "^2.8.3" + "uuid": "^14.0.0", + "yaml": "^2.9.0" } }, - "../../../data/.opencode/node_modules/fast-check": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.8.0.tgz", - "integrity": "sha512-GOJ158CUMnN6cSahsv4+ExARvIDuzzinFjkp0E9WtiBa5zcVeLozVkWaE4IzFcc+Y48Wp1EDlUZsXRyAztQcSg==", + "node_modules/fast-check": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.9.0.tgz", + "integrity": "sha512-7ms6T7SybUev/PQITciI0yLM2pOSFy5zpG8Ty7tQofcVaQUvrMXp6CBwqF6fThLCLOrfBtuHAtwq6Yu4XPCllg==", "funding": [ { "type": "individual", @@ -115,7 +120,6 @@ "url": "https://opencollective.com/fast-check" } ], - "license": "MIT", "dependencies": { "pure-rand": "^8.0.0" }, @@ -123,48 +127,47 @@ "node": ">=12.17.0" } }, - "../../../data/.opencode/node_modules/find-my-way-ts": { + "node_modules/find-my-way-ts": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/find-my-way-ts/-/find-my-way-ts-0.1.6.tgz", - "integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==", - "license": "MIT" + "integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==" }, - "../../../data/.opencode/node_modules/ini": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ini/-/ini-6.0.0.tgz", - "integrity": "sha512-IBTdIkzZNOpqm7q3dRqJvMaldXjDHWkEDfrwGEQTs5eaQMWV+djAhR+wahyNNMAa+qpbDUhBMVt4ZKNwpPm7xQ==", - "license": "ISC", + "node_modules/ini": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-7.0.0.tgz", + "integrity": "sha512-ifK0CgjALofS5bkrcTy4RaQ9Vx2Knf/eLeIO+NaswQEpH1UblrtTSCIvN71qQDMq0PeQ/SSPojvEJp9vvvfr+w==", "engines": { - "node": "^20.17.0 || >=22.9.0" + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" } }, - "../../../data/.opencode/node_modules/isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "license": "ISC" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, - "../../../data/.opencode/node_modules/kubernetes-types": { + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" + }, + "node_modules/kubernetes-types": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/kubernetes-types/-/kubernetes-types-1.30.0.tgz", - "integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==", - "license": "Apache-2.0" + "integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==" }, - "../../../data/.opencode/node_modules/msgpackr": { - "version": "1.11.12", - "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.11.12.tgz", - "integrity": "sha512-RBdJ1Un7yGlXWajrkxcSa93nvQ0w4zBf60c0yYv7YtBelP8H2FA7XsfBbMHtXKXUMUxH7zV3Zuozh+kUQWhHvg==", - "license": "MIT", + "node_modules/msgpackr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-2.0.5.tgz", + "integrity": "sha512-cef05H/dSYpLpqp3sj/qyZh5vhUYCalnaLO7j1yOmpsR0y/XwLVtK7r5gn+U/F7CTEfMowcGhlUQJDLcLf7jcA==", "optionalDependencies": { - "msgpackr-extract": "^3.0.2" + "msgpackr-extract": "^3.0.4" } }, - "../../../data/.opencode/node_modules/msgpackr-extract": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz", - "integrity": "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==", + "node_modules/msgpackr-extract": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.4.tgz", + "integrity": "sha512-4kmO/MdyUIkLIvTPr8VHLil4AtoKIoniWPIEk5+CDy0xnWC84azhSFmuJ7PxZdsYtiP5kEeQsORAVIeMgxT+Hw==", "hasInstallScript": true, - "license": "MIT", "optional": true, "dependencies": { "node-gyp-build-optional-packages": "5.2.2" @@ -173,25 +176,23 @@ "download-msgpackr-prebuilds": "bin/download-prebuilds.js" }, "optionalDependencies": { - "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3", - "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3", - "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3", - "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3", - "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3", - "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3" + "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.4", + "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.4", + "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.4", + "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.4", + "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.4", + "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.4" } }, - "../../../data/.opencode/node_modules/multipasta": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.7.tgz", - "integrity": "sha512-KPA58d68KgGil15oDqXjkUBEBYc00XvbPj5/X+dyzeo/lWm9Nc25pQRlf1D+gv4OpK7NM0J1odrbu9JNNGvynA==", - "license": "MIT" + "node_modules/multipasta": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.8.tgz", + "integrity": "sha512-ZPWuMKyv0cSO29f7hozp+k6+crZbQijV8ipMvxNxRf2SwtYGTX1ZX89Kd20VV4H9Znonx+EQn+iy1wGQsJ+b+Q==" }, - "../../../data/.opencode/node_modules/node-gyp-build-optional-packages": { + "node_modules/node-gyp-build-optional-packages": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz", "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==", - "license": "MIT", "optional": true, "dependencies": { "detect-libc": "^2.0.1" @@ -202,19 +203,18 @@ "node-gyp-build-optional-packages-test": "build-test.js" } }, - "../../../data/.opencode/node_modules/path-key": { + "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "license": "MIT", "engines": { "node": ">=8" } }, - "../../../data/.opencode/node_modules/pure-rand": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.0.tgz", - "integrity": "sha512-IoM8YF/jY0hiugFo/wOWqfmarlE6J0wc6fDK1PhftMk7MGhVZl88sZimmqBBFomLOCSmcCCpsfj7wXASCpvK9A==", + "node_modules/pure-rand": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.2.tgz", + "integrity": "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng==", "funding": [ { "type": "individual", @@ -224,14 +224,12 @@ "type": "opencollective", "url": "https://opencollective.com/fast-check" } - ], - "license": "MIT" + ] }, - "../../../data/.opencode/node_modules/shebang-command": { + "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" }, @@ -239,42 +237,38 @@ "node": ">=8" } }, - "../../../data/.opencode/node_modules/shebang-regex": { + "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "license": "MIT", "engines": { "node": ">=8" } }, - "../../../data/.opencode/node_modules/toml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/toml/-/toml-4.1.1.tgz", - "integrity": "sha512-EBJnVBr3dTXdA89WVFoAIPUqkBjxPMwRqsfuo1r240tKFHXv3zgca4+NJib/h6TyvGF7vOawz0jGuryJCdNHrw==", - "license": "MIT", + "node_modules/toml": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-4.3.0.tgz", + "integrity": "sha512-lVb8X9BsPVuH0M4BKeS91tXAmJvCjQ5UIyAbQFaxkKGyUFK2RPkhwaFSQH8vbpl1d23eu/IBH+dwVMHWaq9A5A==", "engines": { "node": ">=20" } }, - "../../../data/.opencode/node_modules/uuid": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.2.tgz", - "integrity": "sha512-vzi9uRZ926x4XV73S/4qQaTwPXM2JBj6/6lI/byHH1jOpCzb0zDbfytgA9LcN/hzb2l7WQSQnxITOVx5un/wGw==", + "node_modules/uuid": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.2.tgz", + "integrity": "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], - "license": "MIT", "bin": { "uuid": "dist-node/bin/uuid" } }, - "../../../data/.opencode/node_modules/which": { + "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "license": "ISC", "dependencies": { "isexe": "^2.0.0" }, @@ -285,11 +279,10 @@ "node": ">= 8" } }, - "../../../data/.opencode/node_modules/yaml": { + "node_modules/yaml": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", - "license": "ISC", "bin": { "yaml": "bin.mjs" }, @@ -300,7 +293,7 @@ "url": "https://github.com/sponsors/eemeli" } }, - "../../../data/.opencode/node_modules/zod": { + "node_modules/zod": { "version": "4.1.8", "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", diff --git a/.opencode/node_modules/@ai-sdk/provider/CHANGELOG.md b/.opencode/node_modules/@ai-sdk/provider/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..d8779066ee47b4bdcab864e7289e4398288ec78e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/CHANGELOG.md @@ -0,0 +1,979 @@ +# @ai-sdk/provider + +## 3.0.8 + +### Patch Changes + +- 7168375: feat (ai, provider): default global provider video model resolution + +## 3.0.7 + +### Patch Changes + +- 53f6731: feat (ai, provider): experimental generate video support + +## 3.0.6 + +### Patch Changes + +- 2810850: fix(ai): improve type validation error messages with field paths and entity identifiers + +## 3.0.5 + +### Patch Changes + +- 4de5a1d: chore: excluded tests from src folder in npm package + +## 3.0.4 + +### Patch Changes + +- 5c090e7: fix(ai): fix LanguageModelV2ProviderTool type + +## 3.0.3 + +### Patch Changes + +- 1b11dcb: chore(ai): include sources in npm package + +## 3.0.2 + +### Patch Changes + +- d937c8f: Add Image model middleware support via `wrapImageModel` and `ImageModelV3Middleware`. + +## 3.0.1 + +### Patch Changes + +- 863d34f: fix: trigger release to update `@latest` + +## 3.0.0 + +### Major Changes + +- dee8b05: ai SDK 6 beta + +### Minor Changes + +- 78928cb: release: start 5.1 beta + +### Patch Changes + +- 0c3b58b: fix(provider): add specificationVersion to ProviderV3 +- 0adc679: feat(provider): shared spec v3 +- d1bdadb: Added reranking model +- 046aa3b: feat(provider): speech model v3 spec +- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3 + + Before + + ```ts + model.textEmbeddingModel('my-model-id'); + ``` + + After + + ```ts + model.embeddingModel('my-model-id'); + ``` + +- dce03c4: feat: tool input examples +- 2625a04: feat(openai); update spec for mcp approval +- 37c58a0: This release introduces `wrapEmbeddingModel`, a new helper that brings embedding model customization capabilities similar to `wrapLanguageModel`. +- 2b0caef: feat(provider): add preliminary provider executed tool results to language model specification +- 954c356: feat(openai): allow custom names for provider-defined tools +- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool +- 0c4822d: feat: `EmbeddingModelV3` +- 4c44a5b: fix(spec): allow `undefined` values in `JSONObject` type +- e8109d3: feat: tool execution approval +- ed329cb: feat: `Provider-V3` +- 53f3368: feat(provider): support embedding model call warnings in specification +- 3bd2689: feat: extended token usage +- bb36798: fix(spec): `LanguageModelV3ToolResult["result"]` change from `unknown` to `NonNullable` +- 8dac895: feat: `LanguageModelV3` +- a755db5: feat(provider): Add SharedV3Warning type +- 475189e: chore(specification): rename EmbeddingModelCallOptions +- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings +- b681d7d: feat: expose usage tokens for 'generateImage' function +- db913bd: fix(google): add thought signature to gemini 3 pro image parts +- 9061dc0: feat: image editing +- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases +- 81d4308: feat: provider-executed dynamic tools +- 9549c9e: chore(specification): extract types +- af3780b: chore(provider): remove providerExecuted from LanguageModelV3ToolResult +- 522f6b8: feat: `ImageModelV3` +- 10d819b: fix(packages/provider): fix CallWarning and allow strings as type +- 3794514: feat: flexible tool output content support +- cbf52cd: feat: expose raw finish reason +- 1bd7d32: feat: tool-specific strict mode + +## 3.0.0-beta.32 + +### Patch Changes + +- 475189e: chore(specification): rename EmbeddingModelCallOptions + +## 3.0.0-beta.31 + +### Patch Changes + +- 2625a04: feat(openai); update spec for mcp approval + +## 3.0.0-beta.30 + +### Patch Changes + +- cbf52cd: feat: expose raw finish reason + +## 3.0.0-beta.29 + +### Patch Changes + +- 9549c9e: chore(specification): extract types + +## 3.0.0-beta.28 + +### Patch Changes + +- 9061dc0: feat: image editing + +## 3.0.0-beta.27 + +### Patch Changes + +- 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases + +## 3.0.0-beta.26 + +### Patch Changes + +- 3bd2689: feat: extended token usage + +## 3.0.0-beta.25 + +### Patch Changes + +- 53f3368: feat(provider): support embedding model call warnings in specification + +## 3.0.0-beta.24 + +### Patch Changes + +- dce03c4: feat: tool input examples + +## 3.0.0-beta.23 + +### Patch Changes + +- 1bd7d32: feat: tool-specific strict mode + +## 3.0.0-beta.22 + +### Patch Changes + +- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool + +## 3.0.0-beta.21 + +### Patch Changes + +- 954c356: feat(openai): allow custom names for provider-defined tools + +## 3.0.0-beta.20 + +### Patch Changes + +- 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings + +## 3.0.0-beta.19 + +### Patch Changes + +- 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3 + + Before + + ```ts + model.textEmbeddingModel('my-model-id'); + ``` + + After + + ```ts + model.embeddingModel('my-model-id'); + ``` + +## 3.0.0-beta.18 + +### Patch Changes + +- 10d819b: fix(packages/provider): fix CallWarning and allow strings as type + +## 3.0.0-beta.17 + +### Patch Changes + +- db913bd: fix(google): add thought signature to gemini 3 pro image parts + +## 3.0.0-beta.16 + +### Patch Changes + +- b681d7d: feat: expose usage tokens for 'generateImage' function + +## 3.0.0-beta.15 + +### Patch Changes + +- bb36798: fix(spec): `LanguageModelV3ToolResult["result"]` change from `unknown` to `NonNullable` + +## 3.0.0-beta.14 + +### Patch Changes + +- af3780b: chore(provider): remove providerExecuted from LanguageModelV3ToolResult + +## 3.0.0-beta.13 + +### Patch Changes + +- 37c58a0: This release introduces `wrapEmbeddingModel`, a new helper that brings embedding model customization capabilities similar to `wrapLanguageModel`. + +## 3.0.0-beta.12 + +### Patch Changes + +- d1bdadb: Added reranking model + +## 3.0.0-beta.11 + +### Patch Changes + +- 4c44a5b: fix(spec): allow `undefined` values in `JSONObject` type + +## 3.0.0-beta.10 + +### Patch Changes + +- 0c3b58b: fix(provider): add specificationVersion to ProviderV3 + +## 3.0.0-beta.9 + +### Patch Changes + +- a755db5: feat(provider): Add SharedV3Warning type + +## 3.0.0-beta.8 + +### Patch Changes + +- 3794514: feat: flexible tool output content support + +## 3.0.0-beta.7 + +### Patch Changes + +- 81d4308: feat: provider-executed dynamic tools + +## 3.0.0-beta.6 + +### Major Changes + +- dee8b05: ai SDK 6 beta + +## 2.1.0-beta.5 + +### Patch Changes + +- 046aa3b: feat(provider): speech model v3 spec +- e8109d3: feat: tool execution approval + +## 2.1.0-beta.4 + +### Patch Changes + +- 0adc679: feat(provider): shared spec v3 +- 2b0caef: feat(provider): add preliminary provider executed tool results to language model specification + +## 2.1.0-beta.3 + +### Patch Changes + +- 8dac895: feat: `LanguageModelV3` + +## 2.1.0-beta.2 + +### Patch Changes + +- ed329cb: feat: `Provider-V3` +- 522f6b8: feat: `ImageModelV3` + +## 2.1.0-beta.1 + +### Patch Changes + +- 0c4822d: feat: `EmbeddingModelV3` + +## 2.1.0-beta.0 + +### Minor Changes + +- 78928cb: release: start 5.1 beta + +## 2.0.0 + +### Major Changes + +- 742b7be: feat: forward id, streaming start, streaming end of content blocks +- 7cddb72: refactoring (provider): collapse provider defined tools into single definition +- ccce59b: feat (provider): support changing provider, model, supportedUrls in middleware +- e2b9e4b: feat (provider): add name for provider defined tools for future validation +- 95857aa: chore: restructure language model supported urls +- 6f6bb89: chore (provider): cleanup request and rawRequest (language model v2) +- d1a1aa1: chore (provider): merge rawRequest into request (language model v2) +- 63f9e9b: chore (provider,ai): tools have input/output instead of args,result +- d5f588f: AI SDK 5 +- b6b43c7: chore: move warnings into stream-start part (spec) +- 411e483: chore (provider): refactor usage (language model v2) +- abf9a79: chore: rename mimeType to mediaType +- 14c9410: chore: refactor file towards source pattern (spec) +- e86be6f: chore: remove logprobs +- 0d06df6: chore (ai): remove v1 providers +- d9c98f4: chore: refactor reasoning parts (spec) +- a3f768e: chore: restructure reasoning support +- 7435eb5: feat: upgrade speech models to v2 specification +- 0054544: chore: refactor source parts (spec) +- 9e9c809: chore: refactor tool call and tool call delta parts (spec) +- 32831c6: chore: refactor text parts (spec) +- 6dc848c: chore (provider): remove image parts +- d0f9495: chore: refactor file parts (spec) +- 7979f7f: feat (provider): support reasoning tokens, cached input tokens, total token in usage information +- 44f4aba: feat: upgrade transcription models to v2 specification +- 7ea4132: chore: remove object generation mode +- 023ba40: feat (provider): support arbitrary media types in tool results +- e030615: chore (provider): remove prompt type from language model v2 spec +- 5e57fae: refactoring (provider): restructure tool result output +- c57e248: chore (provider): remove mode +- 3795467: chore: return content array from doGenerate (spec) +- 1766ede: chore: rename maxTokens to maxOutputTokens +- 33f4a6a: chore (provider): rename providerMetadata inputs to providerOptions + +### Patch Changes + +- dc714f3: release alpha.4 +- b5da06a: update to LanguageModelV2ProviderDefinedClientTool to add server side tool later on +- 48d257a: release alpha.15 +- 0d2c085: chore (provider): tweak provider definition +- 9222aeb: release alpha.8 +- e2aceaf: feat: add raw chunk support +- 7b3ae3f: chore (provider): change getSupportedUrls to supportedUrls (language model v2) +- a166433: feat: add transcription with experimental_transcribe +- 26735b5: chore(embedding-model): add v2 interface +- 443d8ec: feat(embedding-model-v2): add response body field +- a8c8bd5: feat(embed-many): respect supportsParallelCalls & concurrency +- 9bf7291: chore(providers/openai): enable structuredOutputs by default & switch to provider option +- 2e13791: feat(anthropic): add server-side web search support +- 472524a: spec (ai): add provider options to tools +- dd3ff01: chore: add language setting to speechv2 +- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2` +- 0a87932: core (ai): change transcription model mimeType to mediaType +- c4a2fec: chore (provider): extract shared provider options and metadata (spec) +- 79457bd: chore (provider): extract LanguageModelV2File +- 8aa9e20: feat: add speech with experimental_generateSpeech +- 4617fab: chore(embedding-models): remove remaining settings +- cb68df0: feat: add transcription and speech model support to provider registry +- ad80501: chore (provider): allow both binary and base64 file content (spec) + + Before + + ```ts + import { convertUint8ArrayToBase64 } from '@ai-sdk/provider-utils'; + + // Had to manually convert binary data to base64 + const fileData = new Uint8Array([0, 1, 2, 3]); + const filePart = { + type: 'file', + mediaType: 'application/pdf', + data: convertUint8ArrayToBase64(fileData), // Required conversion + }; + ``` + + After + + ```ts + // Can use binary data directly + const fileData = new Uint8Array([0, 1, 2, 3]); + const filePart = { + type: 'file', + mediaType: 'application/pdf', + data: fileData, // Direct Uint8Array support + }; + ``` + +- 68ecf2f: release alpha.13 +- 6b98118: release alpha.3 +- 3f2f00c: feat: `ImageModelV2#maxImagesPerCall` can be set to a function that returns a `number` or `undefined`, optionally as a promise + + pull request: https://github.com/vercel/ai/pull/6343 + +- 9bd5ab5: feat (provider): add providerMetadata to ImageModelV2 interface (#5977) + + The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models. + + ```js + const prompt = 'Santa Claus driving a Cadillac'; + + const { providerMetadata } = await experimental_generateImage({ + model: openai.image('dall-e-3'), + prompt, + }); + + const revisedPrompt = providerMetadata.openai.images[0]?.revisedPrompt; + + console.log({ + prompt, + revisedPrompt, + }); + ``` + +- 5c56081: release alpha.7 +- fd65bc6: chore(embedding-model-v2): rename rawResponse to response +- 26535e0: release alpha.2 +- 393138b: feat(embedding-model-v2): add providerOptions +- 7182d14: Remove `Experimental_LanguageModelV2Middleware` type +- c1e6647: release alpha.11 +- 811dff3: release alpha.9 +- f10304b: feat(tool-calling): don't require the user to have to pass parameters +- 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response +- c4df419: release alpha.10 + +## 2.0.0-beta.2 + +### Patch Changes + +- 27deb4d: feat (provider/gateway): Add providerMetadata to embeddings response + +## 2.0.0-beta.1 + +### Major Changes + +- 742b7be: feat: forward id, streaming start, streaming end of content blocks +- 7cddb72: refactoring (provider): collapse provider defined tools into single definition +- ccce59b: feat (provider): support changing provider, model, supportedUrls in middleware +- e2b9e4b: feat (provider): add name for provider defined tools for future validation +- 0d06df6: chore (ai): remove v1 providers +- 7435eb5: feat: upgrade speech models to v2 specification +- 44f4aba: feat: upgrade transcription models to v2 specification +- 023ba40: feat (provider): support arbitrary media types in tool results +- 5e57fae: refactoring (provider): restructure tool result output + +### Patch Changes + +- 472524a: spec (ai): add provider options to tools +- dd3ff01: chore: add language setting to speechv2 +- cb68df0: feat: add transcription and speech model support to provider registry + +## 2.0.0-alpha.15 + +### Patch Changes + +- 48d257a: release alpha.15 + +## 2.0.0-alpha.14 + +### Major Changes + +- 63f9e9b: chore (provider,ai): tools have input/output instead of args,result + +### Patch Changes + +- b5da06a: update to LanguageModelV2ProviderDefinedClientTool to add server side tool later on +- 2e13791: feat(anthropic): add server-side web search support + +## 2.0.0-alpha.13 + +### Patch Changes + +- 68ecf2f: release alpha.13 + +## 2.0.0-alpha.12 + +### Patch Changes + +- e2aceaf: feat: add raw chunk support + +## 2.0.0-alpha.11 + +### Patch Changes + +- c1e6647: release alpha.11 + +## 2.0.0-alpha.10 + +### Patch Changes + +- c4df419: release alpha.10 + +## 2.0.0-alpha.9 + +### Patch Changes + +- 811dff3: release alpha.9 + +## 2.0.0-alpha.8 + +### Patch Changes + +- 9222aeb: release alpha.8 + +## 2.0.0-alpha.7 + +### Patch Changes + +- 5c56081: release alpha.7 + +## 2.0.0-alpha.6 + +### Patch Changes + +- 0d2c085: chore (provider): tweak provider definition + +## 2.0.0-alpha.4 + +### Patch Changes + +- dc714f3: release alpha.4 + +## 2.0.0-alpha.3 + +### Patch Changes + +- 6b98118: release alpha.3 + +## 2.0.0-alpha.2 + +### Patch Changes + +- 26535e0: release alpha.2 + +## 2.0.0-alpha.1 + +### Patch Changes + +- 3f2f00c: feat: `ImageModelV2#maxImagesPerCall` can be set to a function that returns a `number` or `undefined`, optionally as a promise + + pull request: https://github.com/vercel/ai/pull/6343 + +## 2.0.0-canary.14 + +### Major Changes + +- 7979f7f: feat (provider): support reasoning tokens, cached input tokens, total token in usage information + +### Patch Changes + +- a8c8bd5: feat(embed-many): respect supportsParallelCalls & concurrency + +## 2.0.0-canary.13 + +### Patch Changes + +- 9bd5ab5: feat (provider): add providerMetadata to ImageModelV2 interface (#5977) + + The `experimental_generateImage` method from the `ai` package now returnes revised prompts for OpenAI's image models. + + ```js + const prompt = 'Santa Claus driving a Cadillac'; + + const { providerMetadata } = await experimental_generateImage({ + model: openai.image('dall-e-3'), + prompt, + }); + + const revisedPrompt = providerMetadata.openai.images[0]?.revisedPrompt; + + console.log({ + prompt, + revisedPrompt, + }); + ``` + +## 2.0.0-canary.12 + +### Patch Changes + +- 7b3ae3f: chore (provider): change getSupportedUrls to supportedUrls (language model v2) + +## 2.0.0-canary.11 + +### Major Changes + +- e030615: chore (provider): remove prompt type from language model v2 spec + +### Patch Changes + +- 9bf7291: chore(providers/openai): enable structuredOutputs by default & switch to provider option +- 4617fab: chore(embedding-models): remove remaining settings + +## 2.0.0-canary.10 + +### Major Changes + +- a3f768e: chore: restructure reasoning support + +### Patch Changes + +- 9301f86: refactor (image-model): rename `ImageModelV1` to `ImageModelV2` + +## 2.0.0-canary.9 + +### Major Changes + +- e86be6f: chore: remove logprobs + +## 2.0.0-canary.8 + +### Major Changes + +- 95857aa: chore: restructure language model supported urls +- 7ea4132: chore: remove object generation mode + +## 2.0.0-canary.7 + +### Major Changes + +- b6b43c7: chore: move warnings into stream-start part (spec) +- 3795467: chore: return content array from doGenerate (spec) + +### Patch Changes + +- 8aa9e20: feat: add speech with experimental_generateSpeech + +## 2.0.0-canary.6 + +### Major Changes + +- 14c9410: chore: refactor file towards source pattern (spec) +- d9c98f4: chore: refactor reasoning parts (spec) +- 0054544: chore: refactor source parts (spec) +- 9e9c809: chore: refactor tool call and tool call delta parts (spec) +- 32831c6: chore: refactor text parts (spec) +- d0f9495: chore: refactor file parts (spec) + +### Patch Changes + +- 26735b5: chore(embedding-model): add v2 interface +- 443d8ec: feat(embedding-model-v2): add response body field +- c4a2fec: chore (provider): extract shared provider options and metadata (spec) +- fd65bc6: chore(embedding-model-v2): rename rawResponse to response +- 393138b: feat(embedding-model-v2): add providerOptions +- 7182d14: Remove `Experimental_LanguageModelV2Middleware` type + +## 2.0.0-canary.5 + +### Major Changes + +- 411e483: chore (provider): refactor usage (language model v2) +- ad80501: chore (provider): allow both binary and base64 file content (spec) +- 1766ede: chore: rename maxTokens to maxOutputTokens + +### Patch Changes + +- 79457bd: chore (provider): extract LanguageModelV2File +- f10304b: feat(tool-calling): don't require the user to have to pass parameters + +## 2.0.0-canary.4 + +### Major Changes + +- 6f6bb89: chore (provider): cleanup request and rawRequest (language model v2) + +## 2.0.0-canary.3 + +### Major Changes + +- d1a1aa1: chore (provider): merge rawRequest into request (language model v2) + +## 2.0.0-canary.2 + +### Major Changes + +- abf9a79: chore: rename mimeType to mediaType +- 6dc848c: chore (provider): remove image parts + +### Patch Changes + +- a166433: feat: add transcription with experimental_transcribe +- 0a87932: core (ai): change transcription model mimeType to mediaType + +## 2.0.0-canary.1 + +### Major Changes + +- c57e248: chore (provider): remove mode +- 33f4a6a: chore (provider): rename providerMetadata inputs to providerOptions + +## 2.0.0-canary.0 + +### Major Changes + +- d5f588f: AI SDK 5 + +## 1.1.0 + +### Minor Changes + +- 5bc638d: AI SDK 4.2 + +## 1.0.12 + +### Patch Changes + +- 0bd5bc6: feat (ai): support model-generated files + +## 1.0.11 + +### Patch Changes + +- 2e1101a: feat (provider/openai): pdf input support + +## 1.0.10 + +### Patch Changes + +- e1d3d42: feat (ai): expose raw response body in generateText and generateObject + +## 1.0.9 + +### Patch Changes + +- ddf9740: feat (ai): add anthropic reasoning + +## 1.0.8 + +### Patch Changes + +- 2761f06: fix (ai/provider): publish with LanguageModelV1Source + +## 1.0.7 + +### Patch Changes + +- d89c3b9: feat (provider): add image model support to provider specification + +## 1.0.6 + +### Patch Changes + +- 3a58a2e: feat (ai/core): throw NoImageGeneratedError from generateImage when no predictions are returned. + +## 1.0.5 + +### Patch Changes + +- 0a699f1: feat: add reasoning token support + +## 1.0.4 + +### Patch Changes + +- 19a2ce7: feat (provider): add message option to UnsupportedFunctionalityError +- 6337688: feat: change image generation errors to warnings + +## 1.0.3 + +### Patch Changes + +- 5ed5e45: chore (config): Use ts-library.json tsconfig for no-UI libs. + +## 1.0.2 + +### Patch Changes + +- 09a9cab: feat (ai/core): add experimental generateImage function + +## 1.0.1 + +### Patch Changes + +- b446ae5: feat (provider): Define type for ObjectGenerationMode. + +## 1.0.0 + +### Major Changes + +- b469a7e: chore: remove isXXXError methods +- c0ddc24: chore (ai): remove toJSON method from AI SDK errors + +## 1.0.0-canary.0 + +### Major Changes + +- b469a7e: chore: remove isXXXError methods +- c0ddc24: chore (ai): remove toJSON method from AI SDK errors + +## 0.0.26 + +### Patch Changes + +- aa98cdb: chore: more flexible dependency versioning +- 1486128: feat: add supportsUrl to language model specification +- 7b937c5: feat (provider-utils): improve id generator robustness +- 3b1b69a: feat: provider-defined tools +- 811a317: feat (ai/core): multi-part tool results (incl. images) + +## 0.0.25 + +### Patch Changes + +- b9b0d7b: feat (ai): access raw request body + +## 0.0.24 + +### Patch Changes + +- d595d0d: feat (ai/core): file content parts + +## 0.0.23 + +### Patch Changes + +- 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api +- 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages + +## 0.0.22 + +### Patch Changes + +- 26515cb: feat (ai/provider): introduce ProviderV1 specification + +## 0.0.21 + +### Patch Changes + +- f2c025e: feat (ai/core): prompt validation + +## 0.0.20 + +### Patch Changes + +- 6ac355e: feat (provider/anthropic): add cache control support + +## 0.0.19 + +### Patch Changes + +- dd4a0f5: fix (ai/provider): remove invalid check in isJSONParseError + +## 0.0.18 + +### Patch Changes + +- 4bd27a9: chore (ai/provider): refactor type validation + +## 0.0.17 + +### Patch Changes + +- 029af4c: feat (ai/core): support schema name & description in generateObject & streamObject + +## 0.0.16 + +### Patch Changes + +- d58517b: feat (ai/openai): structured outputs + +## 0.0.15 + +### Patch Changes + +- 96aed25: fix (ai/provider): release new version + +## 0.0.14 + +### Patch Changes + +- a8d1c9e9: feat (ai/core): parallel image download + +## 0.0.13 + +### Patch Changes + +- 2b9da0f0: feat (core): support stopSequences setting. +- a5b58845: feat (core): support topK setting +- 4aa8deb3: feat (provider): support responseFormat setting in provider api +- 13b27ec6: chore (ai/core): remove grammar mode + +## 0.0.12 + +### Patch Changes + +- b7290943: feat (ai/core): add token usage to embed and embedMany + +## 0.0.11 + +### Patch Changes + +- 5edc6110: feat (provider): add headers support to language and embedding model spec + +## 0.0.10 + +### Patch Changes + +- 102ca22f: fix (@ai-sdk/provider): fix TypeValidationError.isTypeValidationError + +## 0.0.9 + +### Patch Changes + +- 09295e2e: feat (@ai-sdk/provider): add DownloadError + +## 0.0.8 + +### Patch Changes + +- f39c0dd2: feat (provider): add toolChoice to language model specification + +## 0.0.7 + +### Patch Changes + +- 8e780288: feat (ai/provider): add "unknown" finish reason (for models that don't provide a finish reason) + +## 0.0.6 + +### Patch Changes + +- 6a50ac4: feat (provider): add additional error types + +## 0.0.5 + +### Patch Changes + +- 0f6bc4e: feat (ai/core): add embed function + +## 0.0.4 + +### Patch Changes + +- 325ca55: feat (ai/core): improve image content part error message + +## 0.0.3 + +### Patch Changes + +- 41d5736: ai/core: re-expose language model types. + +## 0.0.2 + +### Patch Changes + +- d6431ae: ai/core: add logprobs support (thanks @SamStenner for the contribution) +- 25f3350: ai/core: add support for getting raw response headers. + +## 0.0.1 + +### Patch Changes + +- eb150a6: ai/core: remove scaling of setting values (breaking change). If you were using the temperature, frequency penalty, or presence penalty settings, you need to update the providers and adjust the setting values. diff --git a/.opencode/node_modules/@ai-sdk/provider/LICENSE b/.opencode/node_modules/@ai-sdk/provider/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6c16c29f41168411dbf6e3ba3a063ce789c27334 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/LICENSE @@ -0,0 +1,13 @@ +Copyright 2023 Vercel, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/README.md b/.opencode/node_modules/@ai-sdk/provider/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0e858d8757f716fb5c0a9444ebf2defd9f41dc13 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/README.md @@ -0,0 +1 @@ +# AI SDK - Provider Language Model Specification diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.d.mts b/.opencode/node_modules/@ai-sdk/provider/dist/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..fe0d47ccc4d9673b7a97278d90242424b08c1219 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.d.mts @@ -0,0 +1,4030 @@ +import { JSONSchema7 } from 'json-schema'; +export { JSONSchema7, JSONSchema7Definition } from 'json-schema'; + +type SharedV3Headers = Record; + +/** + * A JSON value can be a string, number, boolean, object, array, or null. + * JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods. + */ +type JSONValue = null | string | number | boolean | JSONObject | JSONArray; +type JSONObject = { + [key: string]: JSONValue | undefined; +}; +type JSONArray = JSONValue[]; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV3ProviderMetadata = Record; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV3ProviderOptions = Record; + +/** + * Warning from the model. + * + * For example, that certain features are unsupported or compatibility + * functionality is used (which might lead to suboptimal results). + */ +type SharedV3Warning = { + /** + * A feature is not supported by the model. + */ + type: 'unsupported'; + /** + * The feature that is not supported. + */ + feature: string; + /** + * Additional details about the warning. + */ + details?: string; +} | { + /** + * A compatibility feature is used that might lead to suboptimal results. + */ + type: 'compatibility'; + /** + * The feature that is used in a compatibility mode. + */ + feature: string; + /** + * Additional details about the warning. + */ + details?: string; +} | { + /** + * Other warning. + */ + type: 'other'; + /** + * The message of the warning. + */ + message: string; +}; + +type SharedV2Headers = Record; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV2ProviderMetadata = Record>; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV2ProviderOptions = Record>; + +type EmbeddingModelV3CallOptions = { + /** + * List of text values to generate embeddings for. + */ + values: Array; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; + +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +type EmbeddingModelV3Embedding = Array; + +/** + * The result of a embedding model doEmbed call. + */ +type EmbeddingModelV3Result = { + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { + tokens: number; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * The response body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 3. + * + * It is specific to text embeddings. + */ +type EmbeddingModelV3 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: PromiseLike | number | undefined; + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed(options: EmbeddingModelV3CallOptions): PromiseLike; +}; + +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +type EmbeddingModelV2Embedding = Array; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 2. + * + * VALUE is the type of the values that the model can embed. + * This will allow us to go beyond text embeddings in the future, + * e.g. to support image embeddings + */ +type EmbeddingModelV2 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: PromiseLike | number | undefined; + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed(options: { + /** + * List of values to embed. + */ + values: Array; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + }): PromiseLike<{ + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { + tokens: number; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * The response body. + */ + body?: unknown; + }; + }>; +}; + +declare const symbol$d: unique symbol; +/** + * Custom error class for AI SDK related errors. + * @extends Error + */ +declare class AISDKError extends Error { + private readonly [symbol$d]; + /** + * The underlying cause of the error, if any. + */ + readonly cause?: unknown; + /** + * Creates an AI SDK Error. + * + * @param {Object} params - The parameters for creating the error. + * @param {string} params.name - The name of the error. + * @param {string} params.message - The error message. + * @param {unknown} [params.cause] - The underlying cause of the error. + */ + constructor({ name, message, cause, }: { + name: string; + message: string; + cause?: unknown; + }); + /** + * Checks if the given error is an AI SDK Error. + * @param {unknown} error - The error to check. + * @returns {boolean} True if the error is an AI SDK Error, false otherwise. + */ + static isInstance(error: unknown): error is AISDKError; + protected static hasMarker(error: unknown, marker: string): boolean; +} + +declare const symbol$c: unique symbol; +declare class APICallError extends AISDKError { + private readonly [symbol$c]; + readonly url: string; + readonly requestBodyValues: unknown; + readonly statusCode?: number; + readonly responseHeaders?: Record; + readonly responseBody?: string; + readonly isRetryable: boolean; + readonly data?: unknown; + constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable, // server error + data, }: { + message: string; + url: string; + requestBodyValues: unknown; + statusCode?: number; + responseHeaders?: Record; + responseBody?: string; + cause?: unknown; + isRetryable?: boolean; + data?: unknown; + }); + static isInstance(error: unknown): error is APICallError; +} + +declare const symbol$b: unique symbol; +declare class EmptyResponseBodyError extends AISDKError { + private readonly [symbol$b]; + constructor({ message }?: { + message?: string; + }); + static isInstance(error: unknown): error is EmptyResponseBodyError; +} + +declare function getErrorMessage(error: unknown | undefined): string; + +declare const symbol$a: unique symbol; +/** + * A function argument is invalid. + */ +declare class InvalidArgumentError extends AISDKError { + private readonly [symbol$a]; + readonly argument: string; + constructor({ message, cause, argument, }: { + argument: string; + message: string; + cause?: unknown; + }); + static isInstance(error: unknown): error is InvalidArgumentError; +} + +declare const symbol$9: unique symbol; +/** + * A prompt is invalid. This error should be thrown by providers when they cannot + * process a prompt. + */ +declare class InvalidPromptError extends AISDKError { + private readonly [symbol$9]; + readonly prompt: unknown; + constructor({ prompt, message, cause, }: { + prompt: unknown; + message: string; + cause?: unknown; + }); + static isInstance(error: unknown): error is InvalidPromptError; +} + +declare const symbol$8: unique symbol; +/** + * Server returned a response with invalid data content. + * This should be thrown by providers when they cannot parse the response from the API. + */ +declare class InvalidResponseDataError extends AISDKError { + private readonly [symbol$8]; + readonly data: unknown; + constructor({ data, message, }: { + data: unknown; + message?: string; + }); + static isInstance(error: unknown): error is InvalidResponseDataError; +} + +declare const symbol$7: unique symbol; +declare class JSONParseError extends AISDKError { + private readonly [symbol$7]; + readonly text: string; + constructor({ text, cause }: { + text: string; + cause: unknown; + }); + static isInstance(error: unknown): error is JSONParseError; +} + +declare const symbol$6: unique symbol; +declare class LoadAPIKeyError extends AISDKError { + private readonly [symbol$6]; + constructor({ message }: { + message: string; + }); + static isInstance(error: unknown): error is LoadAPIKeyError; +} + +declare const symbol$5: unique symbol; +declare class LoadSettingError extends AISDKError { + private readonly [symbol$5]; + constructor({ message }: { + message: string; + }); + static isInstance(error: unknown): error is LoadSettingError; +} + +declare const symbol$4: unique symbol; +/** + * Thrown when the AI provider fails to generate any content. + */ +declare class NoContentGeneratedError extends AISDKError { + private readonly [symbol$4]; + constructor({ message, }?: { + message?: string; + }); + static isInstance(error: unknown): error is NoContentGeneratedError; +} + +declare const symbol$3: unique symbol; +declare class NoSuchModelError extends AISDKError { + private readonly [symbol$3]; + readonly modelId: string; + readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel'; + constructor({ errorName, modelId, modelType, message, }: { + errorName?: string; + modelId: string; + modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel'; + message?: string; + }); + static isInstance(error: unknown): error is NoSuchModelError; +} + +declare const symbol$2: unique symbol; +declare class TooManyEmbeddingValuesForCallError extends AISDKError { + private readonly [symbol$2]; + readonly provider: string; + readonly modelId: string; + readonly maxEmbeddingsPerCall: number; + readonly values: Array; + constructor(options: { + provider: string; + modelId: string; + maxEmbeddingsPerCall: number; + values: Array; + }); + static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError; +} + +declare const symbol$1: unique symbol; +interface TypeValidationContext { + /** + * Field path in dot notation (e.g., "message.metadata", "message.parts[3].data") + */ + field?: string; + /** + * Entity name (e.g., tool name, data type name) + */ + entityName?: string; + /** + * Entity identifier (e.g., message ID, tool call ID) + */ + entityId?: string; +} +declare class TypeValidationError extends AISDKError { + private readonly [symbol$1]; + readonly value: unknown; + readonly context?: TypeValidationContext; + constructor({ value, cause, context, }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }); + static isInstance(error: unknown): error is TypeValidationError; + /** + * Wraps an error into a TypeValidationError. + * If the cause is already a TypeValidationError with the same value and context, it returns the cause. + * Otherwise, it creates a new TypeValidationError. + * + * @param {Object} params - The parameters for wrapping the error. + * @param {unknown} params.value - The value that failed validation. + * @param {unknown} params.cause - The original error or cause of the validation failure. + * @param {TypeValidationContext} params.context - Optional context about what is being validated. + * @returns {TypeValidationError} A TypeValidationError instance. + */ + static wrap({ value, cause, context, }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }): TypeValidationError; +} + +declare const symbol: unique symbol; +declare class UnsupportedFunctionalityError extends AISDKError { + private readonly [symbol]; + readonly functionality: string; + constructor({ functionality, message, }: { + functionality: string; + message?: string; + }); + static isInstance(error: unknown): error is UnsupportedFunctionalityError; +} + +declare function isJSONValue(value: unknown): value is JSONValue; +declare function isJSONArray(value: unknown): value is JSONArray; +declare function isJSONObject(value: unknown): value is JSONObject; + +/** + * Usage information for an image model call. + */ +type ImageModelV3Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + /** + * The number of output tokens used, if reported by the provider. + */ + outputTokens: number | undefined; + /** + * The total number of tokens as reported by the provider. + */ + totalTokens: number | undefined; +}; + +/** + * An image file that can be used for image editing or variation generation. + */ +type ImageModelV3File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png`. Any string is supported. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +} | { + type: 'url'; + /** + * The URL of the image file. + */ + url: string; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +}; + +type ImageModelV3CallOptions = { + /** + * Prompt for the image generation. Some operations, like upscaling, may not require a prompt. + */ + prompt: string | undefined; + /** + * Number of images to generate. + */ + n: number; + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + /** + * Array of images for image editing or variation generation. + * The images should be provided as base64 encoded strings or binary data. + */ + files: ImageModelV3File[] | undefined; + /** + * Mask image for inpainting operations. + * The mask should be provided as base64 encoded strings or binary data. + */ + mask: ImageModelV3File | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +type ImageModelV3ProviderMetadata = Record; +type GetMaxImagesPerCallFunction$1 = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Image generation model specification version 3. + */ +type ImageModelV3 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$1; + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV3CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV3ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + /** + * Optional token usage for the image generation call (if the provider reports it). + */ + usage?: ImageModelV3Usage; + }>; +}; + +type ImageModelV2CallOptions = { + /** + * Prompt for the image generation. + */ + prompt: string; + /** + * Number of images to generate. + */ + n: number; + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type ImageModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof ImageModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +type ImageModelV2ProviderMetadata = Record; +type GetMaxImagesPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Image generation model specification version 2. + */ +type ImageModelV2 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction; + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV2CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV2ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; + +/** + * Middleware for ImageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of ImageModelV3 operations. + */ +type ImageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The image model instance. + */ + overrideProvider?: (options: { + model: ImageModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The image model instance. + */ + overrideModelId?: (options: { + model: ImageModelV3; + }) => string; + /** + * Override the limit of how many images can be generated in a single API call if desired. + * @param options.model - The image model instance. + */ + overrideMaxImagesPerCall?: (options: { + model: ImageModelV3; + }) => ImageModelV3['maxImagesPerCall']; + /** + * Transforms the parameters before they are passed to the image model. + * @param options - Object containing the parameters. + * @param options.params - The original parameters for the image model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => PromiseLike; + /** + * Wraps the generate operation of the image model. + * + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The image model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => Promise>>; +}; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +type LanguageModelV3FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + /** + * An optional list of input examples that show the language + * model what the input should look like. + */ + inputExamples?: Array<{ + input: JSONObject; + }>; + /** + * Strict mode setting for the tool. + * + * Providers that support strict mode will use this setting to determine + * how the input should be generated. Strict mode will always produce + * valid inputs, but it might limit what input schemas are supported. + */ + strict?: boolean; + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV3ProviderOptions; +}; + +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +type LanguageModelV3DataContent = Uint8Array | string | URL; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +type LanguageModelV3Prompt = Array; +type LanguageModelV3Message = ({ + role: 'system'; + content: string; +} | { + role: 'user'; + content: Array; +} | { + role: 'assistant'; + content: Array; +} | { + role: 'tool'; + content: Array; +}) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +}; +/** + * Text content part of a prompt. It contains a string of text. + */ +interface LanguageModelV3TextPart { + type: 'text'; + /** + * The text content. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +interface LanguageModelV3ReasoningPart { + type: 'reasoning'; + /** + * The reasoning text. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * File content part of a prompt. It contains a file. + */ +interface LanguageModelV3FilePart { + type: 'file'; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV3DataContent; + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +interface LanguageModelV3ToolCallPart { + type: 'tool-call'; + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + /** + * Name of the tool that is being called. + */ + toolName: string; + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +interface LanguageModelV3ToolResultPart { + type: 'tool-result'; + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. + */ + output: LanguageModelV3ToolResultOutput; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool approval response content part of a prompt. It contains the user's + * decision to approve or deny a provider-executed tool call. + */ +interface LanguageModelV3ToolApprovalResponsePart { + type: 'tool-approval-response'; + /** + * ID of the approval request that this response refers to. + */ + approvalId: string; + /** + * Whether the approval was granted (true) or denied (false). + */ + approved: boolean; + /** + * Optional reason for approval or denial. + */ + reason?: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Result of a tool call. + */ +type LanguageModelV3ToolResultOutput = { + /** + * Text tool output that should be directly sent to the API. + */ + type: 'text'; + value: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'json'; + value: JSONValue; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + /** + * Type when the user has denied the execution of the tool call. + */ + type: 'execution-denied'; + /** + * Optional reason for the execution denial. + */ + reason?: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'error-text'; + value: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'error-json'; + value: JSONValue; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'content'; + value: Array<{ + type: 'text'; + /** + * Text content. + */ + text: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-data'; + /** + * Base-64 encoded media data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-url'; + /** + * URL of the file. + */ + url: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-id'; + /** + * ID of the file. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using base64 encoded data. + */ + type: 'image-data'; + /** + * Base-64 encoded image data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using a URL. + */ + type: 'image-url'; + /** + * URL of the image. + */ + url: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using a provider file id. + */ + type: 'image-file-id'; + /** + * Image that is referenced using a provider file id. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Custom content part. This can be used to implement + * provider-specific content parts. + */ + type: 'custom'; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + }>; +}; + +/** + * The configuration of a provider tool. + * + * Provider tools are tools that are specific to a certain provider. + * The input and output schemas are defined be the provider, and + * some of the tools are also executed on the provider systems. + */ +type LanguageModelV3ProviderTool = { + /** + * The type of the tool (always 'provider'). + */ + type: 'provider'; + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; + +type LanguageModelV3ToolChoice = { + type: 'auto'; +} | { + type: 'none'; +} | { + type: 'required'; +} | { + type: 'tool'; + toolName: string; +}; + +type LanguageModelV3CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV3Prompt; + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + /** + * Nucleus sampling. + */ + topP?: number; + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: { + type: 'text'; + } | { + type: 'json'; + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + /** + * The tools that are available for the model. + */ + tools?: Array; + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV3ToolChoice; + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +}; + +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +type LanguageModelV3File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Reasoning that the model has generated. + */ +type LanguageModelV3Reasoning = { + type: 'reasoning'; + text: string; + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * A source that has been used as input to generate the response. + */ +type LanguageModelV3Source = { + type: 'source'; + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + /** + * The ID of the source. + */ + id: string; + /** + * The URL of the source. + */ + url: string; + /** + * The title of the source. + */ + title?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'source'; + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + /** + * The ID of the source. + */ + id: string; + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + /** + * The title of the document. + */ + title: string; + /** + * Optional filename of the document. + */ + filename?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Text that the model has generated. + */ +type LanguageModelV3Text = { + type: 'text'; + /** + * The text content. + */ + text: string; + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Tool approval request emitted by a provider for a provider-executed tool call. + * + * This is used for flows where the provider executes the tool (e.g. MCP tools) + * but requires an explicit user approval before continuing. + */ +type LanguageModelV3ToolApprovalRequest = { + type: 'tool-approval-request'; + /** + * ID of the approval request. This ID is referenced by the subsequent + * tool-approval-response (tool message) to approve or deny execution. + */ + approvalId: string; + /** + * The tool call ID that this approval request is for. + */ + toolCallId: string; + /** + * Additional provider-specific metadata for the approval request. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Tool calls that the model has generated. + */ +type LanguageModelV3ToolCall = { + type: 'tool-call'; + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + /** + * The name of the tool that should be called. + */ + toolName: string; + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Result of a tool call that has been executed by the provider. + */ +type LanguageModelV3ToolResult = { + type: 'tool-result'; + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: NonNullable; + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + /** + * Whether the tool result is preliminary. + * + * Preliminary tool results replace each other, e.g. image previews. + * There always has to be a final, non-preliminary tool result. + * + * If this flag is set to true, the tool result is preliminary. + * If this flag is not set or is false, the tool result is not preliminary. + */ + preliminary?: boolean; + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult; + +/** + * Reason why a language model finished generating a response. + * + * Contains both a unified finish reason and a raw finish reason from the provider. + * The unified finish reason is used to provide a consistent finish reason across different providers. + * The raw finish reason is used to provide the original finish reason from the provider. + */ +type LanguageModelV3FinishReason = { + /** + * Unified finish reason. This enables using the same finish reason across different providers. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + */ + unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other'; + /** + * Raw finish reason from the provider. + * This is the original finish reason from the provider. + */ + raw: string | undefined; +}; + +interface LanguageModelV3ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} + +/** + * Usage information for a language model call. + */ +type LanguageModelV3Usage = { + /** + * Information about the input tokens. + */ + inputTokens: { + /** + * The total number of input (prompt) tokens used. + */ + total: number | undefined; + /** + * The number of non-cached input (prompt) tokens used. + */ + noCache: number | undefined; + /** + * The number of cached input (prompt) tokens read. + */ + cacheRead: number | undefined; + /** + * The number of cached input (prompt) tokens written. + */ + cacheWrite: number | undefined; + }; + /** + * Information about the output tokens. + */ + outputTokens: { + /** + * The total number of output (completion) tokens used. + */ + total: number | undefined; + /** + * The number of text tokens used. + */ + text: number | undefined; + /** + * The number of reasoning tokens used. + */ + reasoning: number | undefined; + }; + /** + * Raw usage information from the provider. + * + * This is the usage information in the shape that the provider returns. + * It can include additional information that is not part of the standard usage information. + */ + raw?: JSONObject; +}; + +/** + * The result of a language model doGenerate call. + */ +type LanguageModelV3GenerateResult = { + /** + * Ordered content that the model has generated. + */ + content: Array; + /** + * The finish reason. + */ + finishReason: LanguageModelV3FinishReason; + /** + * The usage information. + */ + usage: LanguageModelV3Usage; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV3ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response HTTP body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; + +type LanguageModelV3StreamPart = { + type: 'text-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; +} | { + type: 'text-end'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'reasoning-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; +} | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV3ProviderMetadata; + providerExecuted?: boolean; + dynamic?: boolean; + title?: string; +} | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; +} | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | { + type: 'stream-start'; + warnings: Array; +} | ({ + type: 'response-metadata'; +} & LanguageModelV3ResponseMetadata) | { + type: 'finish'; + usage: LanguageModelV3Usage; + finishReason: LanguageModelV3FinishReason; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'raw'; + rawValue: unknown; +} | { + type: 'error'; + error: unknown; +}; + +/** + * The result of a language model doStream call. + */ +type LanguageModelV3StreamResult = { + /** + * The stream. + */ + stream: ReadableStream; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + }; +}; + +/** + * Specification for a language model that implements the language model interface version 3. + */ +type LanguageModelV3 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v3'; + /** + * Provider ID. + */ + readonly provider: string; + /** + * Provider-specific model ID. + */ + readonly modelId: string; + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: PromiseLike> | Record; + /** + * Generates a language model output (non-streaming). + + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate(options: LanguageModelV3CallOptions): PromiseLike; + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream(options: LanguageModelV3CallOptions): PromiseLike; +}; + +/** + * Experimental middleware for LanguageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV3 operations. + */ +type LanguageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { + model: LanguageModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { + model: LanguageModelV3; + }) => string; + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV3; + }) => PromiseLike> | Record; + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; +}; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +type LanguageModelV2FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV2ProviderOptions; +}; + +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +type LanguageModelV2DataContent = Uint8Array | string | URL; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +type LanguageModelV2Prompt = Array; +type LanguageModelV2Message = ({ + role: 'system'; + content: string; +} | { + role: 'user'; + content: Array; +} | { + role: 'assistant'; + content: Array; +} | { + role: 'tool'; + content: Array; +}) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +}; +/** + * Text content part of a prompt. It contains a string of text. + */ +interface LanguageModelV2TextPart { + type: 'text'; + /** + * The text content. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +interface LanguageModelV2ReasoningPart { + type: 'reasoning'; + /** + * The reasoning text. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * File content part of a prompt. It contains a file. + */ +interface LanguageModelV2FilePart { + type: 'file'; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV2DataContent; + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +interface LanguageModelV2ToolCallPart { + type: 'tool-call'; + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + /** + * Name of the tool that is being called. + */ + toolName: string; + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +interface LanguageModelV2ToolResultPart { + type: 'tool-result'; + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. + */ + output: LanguageModelV2ToolResultOutput; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +type LanguageModelV2ToolResultOutput = { + type: 'text'; + value: string; +} | { + type: 'json'; + value: JSONValue; +} | { + type: 'error-text'; + value: string; +} | { + type: 'error-json'; + value: JSONValue; +} | { + type: 'content'; + value: Array<{ + type: 'text'; + /** + * Text content. + */ + text: string; + } | { + type: 'media'; + /** + * Base-64 encoded media data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + }>; +}; + +/** + * The configuration of a tool that is defined by the provider. + */ +type LanguageModelV2ProviderDefinedTool = { + /** + * The type of the tool (always 'provider-defined'). + */ + type: 'provider-defined'; + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + /** + * The name of the tool that the user must use in the tool set. + */ + name: string; + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; + +type LanguageModelV2ToolChoice = { + type: 'auto'; +} | { + type: 'none'; +} | { + type: 'required'; +} | { + type: 'tool'; + toolName: string; +}; + +type LanguageModelV2CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV2Prompt; + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + /** + * Nucleus sampling. + */ + topP?: number; + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: { + type: 'text'; + } | { + type: 'json'; + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + /** + * The tools that are available for the model. + */ + tools?: Array; + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV2ToolChoice; + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type LanguageModelV2CallWarning = { + type: 'unsupported-setting'; + setting: Omit; + details?: string; +} | { + type: 'unsupported-tool'; + tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +type LanguageModelV2File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; +}; + +/** + * Reasoning that the model has generated. + */ +type LanguageModelV2Reasoning = { + type: 'reasoning'; + text: string; + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * A source that has been used as input to generate the response. + */ +type LanguageModelV2Source = { + type: 'source'; + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + /** + * The ID of the source. + */ + id: string; + /** + * The URL of the source. + */ + url: string; + /** + * The title of the source. + */ + title?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'source'; + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + /** + * The ID of the source. + */ + id: string; + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + /** + * The title of the document. + */ + title: string; + /** + * Optional filename of the document. + */ + filename?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Text that the model has generated. + */ +type LanguageModelV2Text = { + type: 'text'; + /** + * The text content. + */ + text: string; + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Tool calls that the model has generated. + */ +type LanguageModelV2ToolCall = { + type: 'tool-call'; + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + /** + * The name of the tool that should be called. + */ + toolName: string; + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Result of a tool call that has been executed by the provider. + */ +type LanguageModelV2ToolResult = { + type: 'tool-result'; + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: unknown; + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + /** + * Whether the tool result was generated by the provider. + * If this flag is set to true, the tool result was generated by the provider. + * If this flag is not set or is false, the tool result was generated by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult; + +/** + * Reason why a language model finished generating a response. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + * - `unknown`: the model has not transmitted a finish reason + */ +type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown'; + +interface LanguageModelV2ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} + +/** + * Usage information for a language model call. + * + * If your API return additional usage information, you can add it to the + * provider metadata under your provider's key. + */ +type LanguageModelV2Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + /** + * The number of output (completion) tokens used. + */ + outputTokens: number | undefined; + /** + * The total number of tokens as reported by the provider. + * This number might be different from the sum of `inputTokens` and `outputTokens` + * and e.g. include reasoning tokens or other overhead. + */ + totalTokens: number | undefined; + /** + * The number of reasoning tokens used. + */ + reasoningTokens?: number | undefined; + /** + * The number of cached input tokens. + */ + cachedInputTokens?: number | undefined; +}; + +type LanguageModelV2StreamPart = { + type: 'text-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; +} | { + type: 'text-end'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'reasoning-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; +} | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV2ProviderMetadata; + providerExecuted?: boolean; +} | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; +} | LanguageModelV2ToolCall | LanguageModelV2ToolResult | LanguageModelV2File | LanguageModelV2Source | { + type: 'stream-start'; + warnings: Array; +} | ({ + type: 'response-metadata'; +} & LanguageModelV2ResponseMetadata) | { + type: 'finish'; + usage: LanguageModelV2Usage; + finishReason: LanguageModelV2FinishReason; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'raw'; + rawValue: unknown; +} | { + type: 'error'; + error: unknown; +}; + +/** + * Specification for a language model that implements the language model interface version 2. + */ +type LanguageModelV2 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: PromiseLike> | Record; + /** + * Generates a language model output (non-streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{ + /** + * Ordered content that the model has generated. + */ + content: Array; + /** + * Finish reason. + */ + finishReason: LanguageModelV2FinishReason; + /** + * Usage information. + */ + usage: LanguageModelV2Usage; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV2ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response HTTP body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + }>; + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream(options: LanguageModelV2CallOptions): PromiseLike<{ + stream: ReadableStream; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + }; + }>; +}; + +/** + * Experimental middleware for LanguageModelV2. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV2 operations. + */ +type LanguageModelV2Middleware = { + /** + * Middleware specification version. Use `v2` for the current version. + */ + middlewareVersion?: 'v2' | undefined; + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { + model: LanguageModelV2; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { + model: LanguageModelV2; + }) => string; + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV2; + }) => PromiseLike> | Record; + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike; + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => Promise>>; + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike>>; +}; + +/** + * Middleware for EmbeddingModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of EmbeddingModelV3 operations. + */ +type EmbeddingModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The embedding model instance. + */ + overrideProvider?: (options: { + model: EmbeddingModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The embedding model instance. + */ + overrideModelId?: (options: { + model: EmbeddingModelV3; + }) => string; + /** + * Override the limit of how many embeddings can be generated in a single API call if desired. + * @param options.model - The embedding model instance. + */ + overrideMaxEmbeddingsPerCall?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | number | undefined; + /** + * Override support for handling multiple embedding calls in parallel, if desired.. + * @param options.model - The embedding model instance. + */ + overrideSupportsParallelCalls?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | boolean; + /** + * Transforms the parameters before they are passed to the embed model. + * @param options - Object containing the type of operation and the parameters. + * @param options.params - The original parameters for the embedding model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => PromiseLike; + /** + * Wraps the embed operation of the embedding model. + * + * @param options - Object containing the embed function, parameters, and model. + * @param options.doEmbed - The original embed function. + * @param options.params - The parameters for the embed call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The embedding model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapEmbed?: (options: { + doEmbed: () => ReturnType; + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => Promise>>; +}; + +type RerankingModelV3CallOptions = { + /** + * Documents to rerank. + * Either a list of texts or a list of JSON objects. + */ + documents: { + type: 'text'; + values: string[]; + } | { + type: 'object'; + values: JSONObject[]; + }; + /** + * The query is a string that represents the query to rerank the documents against. + */ + query: string; + /** + * Optional limit returned documents to the top n documents. + */ + topN?: number; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; + +/** + * Specification for a reranking model that implements the reranking model interface version 3. + */ +type RerankingModelV3 = { + /** + * The reranking model must specify which reranking model interface version it implements. + */ + readonly specificationVersion: 'v3'; + /** + * Provider ID. + */ + readonly provider: string; + /** + * Provider-specific model ID. + */ + readonly modelId: string; + /** + * Reranking a list of documents using the query. + */ + doRerank(options: RerankingModelV3CallOptions): PromiseLike<{ + /** + * Ordered list of reranked documents (via index before reranking). + * The documents are sorted by the descending order of relevance scores. + */ + ranking: Array<{ + /** + * The index of the document in the original list of documents before reranking. + */ + index: number; + /** + * The relevance score of the document after reranking. + */ + relevanceScore: number; + }>; + /** + * Additional provider-specific metadata. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings?: Array; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response body. + */ + body?: unknown; + }; + }>; +}; + +type SpeechModelV3ProviderOptions = Record; +type SpeechModelV3CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + /** + * The speed of the speech generation. + */ + speed?: number; + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Speech model specification version 3. + */ +type SpeechModelV3 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV3CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; + +type TranscriptionModelV3ProviderOptions = Record; +type TranscriptionModelV3CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Transcription model specification version 3. + */ +type TranscriptionModelV3 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV3CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; + +/** + * Provider for language, text embedding, and image generation models. + */ +interface ProviderV3 { + readonly specificationVersion: 'v3'; + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV3; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + embeddingModel(modelId: string): EmbeddingModelV3; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {EmbeddingModel} The embedding model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + * + * @deprecated Use `embeddingModel` instead. + */ + textEmbeddingModel?(modelId: string): EmbeddingModelV3; + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV3; + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV3; + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV3; + /** + * Returns the reranking model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {RerankingModel} The reranking model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + rerankingModel?(modelId: string): RerankingModelV3; +} + +type SpeechModelV2ProviderOptions = Record>; +type SpeechModelV2CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + /** + * The speed of the speech generation. + */ + speed?: number; + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type SpeechModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof SpeechModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * Speech model specification version 2. + */ +type SpeechModelV2 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV2CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; + +type TranscriptionModelV2ProviderOptions = Record>; +type TranscriptionModelV2CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type TranscriptionModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof TranscriptionModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * Transcription model specification version 2. + */ +type TranscriptionModelV2 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV2CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; + +/** + * Provider for language, text embedding, and image generation models. + */ +interface ProviderV2 { + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV2; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + textEmbeddingModel(modelId: string): EmbeddingModelV2; + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV2; + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV2; + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV2; +} + +/** + * A video or image file that can be used for video editing or image-to-video generation. + * Supports both image inputs (for image-to-video) and video inputs (for editing). + */ +type VideoModelV3File = { + type: 'file'; + /** + * The IANA media type of the file. + * Video types: 'video/mp4', 'video/webm', 'video/quicktime' + * Image types: 'image/png', 'image/jpeg', 'image/webp' + */ + mediaType: string; + /** + * File data as base64 encoded string or binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +} | { + type: 'url'; + /** + * The URL of the video or image file. + */ + url: string; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +}; + +type VideoModelV3CallOptions = { + /** + * Text prompt for the video generation. + */ + prompt: string | undefined; + /** + * Number of videos to generate. Default: 1. + * Most video models only support n=1 due to computational cost. + */ + n: number; + /** + * Aspect ratio of the videos to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + * Common values: '16:9', '9:16', '1:1', '21:9', '4:3' + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Resolution of the video to generate. + * Format: `{width}x{height}` (e.g., '1280x720', '1920x1080') + * `undefined` will use the provider's default resolution. + */ + resolution: `${number}x${number}` | undefined; + /** + * Duration of the video in seconds. + * `undefined` will use the provider's default duration. + * Typically 3-10 seconds for most models. + */ + duration: number | undefined; + /** + * Frames per second (FPS) for the video. + * `undefined` will use the provider's default FPS. + * Common values: 24, 30, 60 + */ + fps: number | undefined; + /** + * Seed for deterministic video generation. + * `undefined` will use a random seed. + */ + seed: number | undefined; + /** + * Input image for image-to-video generation. + * The image serves as the starting frame that the model will animate. + */ + image: VideoModelV3File | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * Example: + * { + * "fal": { + * "loop": true, + * "motionStrength": 0.8 + * } + * } + */ + providerOptions: SharedV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +type GetMaxVideosPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Generated video data. Can be a URL, base64-encoded string, or binary data. + */ +type VideoModelV3VideoData = { + /** + * Video available as a URL (most common for video providers). + */ + type: 'url'; + url: string; + mediaType: string; +} | { + /** + * Video as base64-encoded string. + */ + type: 'base64'; + data: string; + mediaType: string; +} | { + /** + * Video as binary data. + */ + type: 'binary'; + data: Uint8Array; + mediaType: string; +}; +/** + * Video generation model specification version 3. + */ +type VideoModelV3 = { + /** + * The video model must specify which video model interface + * version it implements. This will allow us to evolve the video + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many videos can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + * + * Most video models only support generating 1 video at a time due to + * computational cost. Default is typically 1. + */ + readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction; + /** + * Generates an array of videos. + */ + doGenerate(options: VideoModelV3CallOptions): PromiseLike<{ + /** + * Generated videos as URLs, base64 strings, or binary data. + * + * Most providers return URLs to video files (MP4, WebM) due to large file sizes. + * Use the discriminated union to indicate the type of video data being returned. + */ + videos: Array; + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. + * + * ```ts + * { + * "fal": { + * "videos": [{ + * "duration": 5.0, + * "fps": 24, + * "width": 1280, + * "height": 720 + * }] + * } + * } + * ``` + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; + +export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue }; diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.d.ts b/.opencode/node_modules/@ai-sdk/provider/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fe0d47ccc4d9673b7a97278d90242424b08c1219 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.d.ts @@ -0,0 +1,4030 @@ +import { JSONSchema7 } from 'json-schema'; +export { JSONSchema7, JSONSchema7Definition } from 'json-schema'; + +type SharedV3Headers = Record; + +/** + * A JSON value can be a string, number, boolean, object, array, or null. + * JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods. + */ +type JSONValue = null | string | number | boolean | JSONObject | JSONArray; +type JSONObject = { + [key: string]: JSONValue | undefined; +}; +type JSONArray = JSONValue[]; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV3ProviderMetadata = Record; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV3ProviderOptions = Record; + +/** + * Warning from the model. + * + * For example, that certain features are unsupported or compatibility + * functionality is used (which might lead to suboptimal results). + */ +type SharedV3Warning = { + /** + * A feature is not supported by the model. + */ + type: 'unsupported'; + /** + * The feature that is not supported. + */ + feature: string; + /** + * Additional details about the warning. + */ + details?: string; +} | { + /** + * A compatibility feature is used that might lead to suboptimal results. + */ + type: 'compatibility'; + /** + * The feature that is used in a compatibility mode. + */ + feature: string; + /** + * Additional details about the warning. + */ + details?: string; +} | { + /** + * Other warning. + */ + type: 'other'; + /** + * The message of the warning. + */ + message: string; +}; + +type SharedV2Headers = Record; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV2ProviderMetadata = Record>; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +type SharedV2ProviderOptions = Record>; + +type EmbeddingModelV3CallOptions = { + /** + * List of text values to generate embeddings for. + */ + values: Array; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; + +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +type EmbeddingModelV3Embedding = Array; + +/** + * The result of a embedding model doEmbed call. + */ +type EmbeddingModelV3Result = { + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { + tokens: number; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * The response body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 3. + * + * It is specific to text embeddings. + */ +type EmbeddingModelV3 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: PromiseLike | number | undefined; + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed(options: EmbeddingModelV3CallOptions): PromiseLike; +}; + +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +type EmbeddingModelV2Embedding = Array; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 2. + * + * VALUE is the type of the values that the model can embed. + * This will allow us to go beyond text embeddings in the future, + * e.g. to support image embeddings + */ +type EmbeddingModelV2 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: PromiseLike | number | undefined; + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed(options: { + /** + * List of values to embed. + */ + values: Array; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + }): PromiseLike<{ + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { + tokens: number; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * The response body. + */ + body?: unknown; + }; + }>; +}; + +declare const symbol$d: unique symbol; +/** + * Custom error class for AI SDK related errors. + * @extends Error + */ +declare class AISDKError extends Error { + private readonly [symbol$d]; + /** + * The underlying cause of the error, if any. + */ + readonly cause?: unknown; + /** + * Creates an AI SDK Error. + * + * @param {Object} params - The parameters for creating the error. + * @param {string} params.name - The name of the error. + * @param {string} params.message - The error message. + * @param {unknown} [params.cause] - The underlying cause of the error. + */ + constructor({ name, message, cause, }: { + name: string; + message: string; + cause?: unknown; + }); + /** + * Checks if the given error is an AI SDK Error. + * @param {unknown} error - The error to check. + * @returns {boolean} True if the error is an AI SDK Error, false otherwise. + */ + static isInstance(error: unknown): error is AISDKError; + protected static hasMarker(error: unknown, marker: string): boolean; +} + +declare const symbol$c: unique symbol; +declare class APICallError extends AISDKError { + private readonly [symbol$c]; + readonly url: string; + readonly requestBodyValues: unknown; + readonly statusCode?: number; + readonly responseHeaders?: Record; + readonly responseBody?: string; + readonly isRetryable: boolean; + readonly data?: unknown; + constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable, // server error + data, }: { + message: string; + url: string; + requestBodyValues: unknown; + statusCode?: number; + responseHeaders?: Record; + responseBody?: string; + cause?: unknown; + isRetryable?: boolean; + data?: unknown; + }); + static isInstance(error: unknown): error is APICallError; +} + +declare const symbol$b: unique symbol; +declare class EmptyResponseBodyError extends AISDKError { + private readonly [symbol$b]; + constructor({ message }?: { + message?: string; + }); + static isInstance(error: unknown): error is EmptyResponseBodyError; +} + +declare function getErrorMessage(error: unknown | undefined): string; + +declare const symbol$a: unique symbol; +/** + * A function argument is invalid. + */ +declare class InvalidArgumentError extends AISDKError { + private readonly [symbol$a]; + readonly argument: string; + constructor({ message, cause, argument, }: { + argument: string; + message: string; + cause?: unknown; + }); + static isInstance(error: unknown): error is InvalidArgumentError; +} + +declare const symbol$9: unique symbol; +/** + * A prompt is invalid. This error should be thrown by providers when they cannot + * process a prompt. + */ +declare class InvalidPromptError extends AISDKError { + private readonly [symbol$9]; + readonly prompt: unknown; + constructor({ prompt, message, cause, }: { + prompt: unknown; + message: string; + cause?: unknown; + }); + static isInstance(error: unknown): error is InvalidPromptError; +} + +declare const symbol$8: unique symbol; +/** + * Server returned a response with invalid data content. + * This should be thrown by providers when they cannot parse the response from the API. + */ +declare class InvalidResponseDataError extends AISDKError { + private readonly [symbol$8]; + readonly data: unknown; + constructor({ data, message, }: { + data: unknown; + message?: string; + }); + static isInstance(error: unknown): error is InvalidResponseDataError; +} + +declare const symbol$7: unique symbol; +declare class JSONParseError extends AISDKError { + private readonly [symbol$7]; + readonly text: string; + constructor({ text, cause }: { + text: string; + cause: unknown; + }); + static isInstance(error: unknown): error is JSONParseError; +} + +declare const symbol$6: unique symbol; +declare class LoadAPIKeyError extends AISDKError { + private readonly [symbol$6]; + constructor({ message }: { + message: string; + }); + static isInstance(error: unknown): error is LoadAPIKeyError; +} + +declare const symbol$5: unique symbol; +declare class LoadSettingError extends AISDKError { + private readonly [symbol$5]; + constructor({ message }: { + message: string; + }); + static isInstance(error: unknown): error is LoadSettingError; +} + +declare const symbol$4: unique symbol; +/** + * Thrown when the AI provider fails to generate any content. + */ +declare class NoContentGeneratedError extends AISDKError { + private readonly [symbol$4]; + constructor({ message, }?: { + message?: string; + }); + static isInstance(error: unknown): error is NoContentGeneratedError; +} + +declare const symbol$3: unique symbol; +declare class NoSuchModelError extends AISDKError { + private readonly [symbol$3]; + readonly modelId: string; + readonly modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel'; + constructor({ errorName, modelId, modelType, message, }: { + errorName?: string; + modelId: string; + modelType: 'languageModel' | 'embeddingModel' | 'imageModel' | 'transcriptionModel' | 'speechModel' | 'rerankingModel' | 'videoModel'; + message?: string; + }); + static isInstance(error: unknown): error is NoSuchModelError; +} + +declare const symbol$2: unique symbol; +declare class TooManyEmbeddingValuesForCallError extends AISDKError { + private readonly [symbol$2]; + readonly provider: string; + readonly modelId: string; + readonly maxEmbeddingsPerCall: number; + readonly values: Array; + constructor(options: { + provider: string; + modelId: string; + maxEmbeddingsPerCall: number; + values: Array; + }); + static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError; +} + +declare const symbol$1: unique symbol; +interface TypeValidationContext { + /** + * Field path in dot notation (e.g., "message.metadata", "message.parts[3].data") + */ + field?: string; + /** + * Entity name (e.g., tool name, data type name) + */ + entityName?: string; + /** + * Entity identifier (e.g., message ID, tool call ID) + */ + entityId?: string; +} +declare class TypeValidationError extends AISDKError { + private readonly [symbol$1]; + readonly value: unknown; + readonly context?: TypeValidationContext; + constructor({ value, cause, context, }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }); + static isInstance(error: unknown): error is TypeValidationError; + /** + * Wraps an error into a TypeValidationError. + * If the cause is already a TypeValidationError with the same value and context, it returns the cause. + * Otherwise, it creates a new TypeValidationError. + * + * @param {Object} params - The parameters for wrapping the error. + * @param {unknown} params.value - The value that failed validation. + * @param {unknown} params.cause - The original error or cause of the validation failure. + * @param {TypeValidationContext} params.context - Optional context about what is being validated. + * @returns {TypeValidationError} A TypeValidationError instance. + */ + static wrap({ value, cause, context, }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }): TypeValidationError; +} + +declare const symbol: unique symbol; +declare class UnsupportedFunctionalityError extends AISDKError { + private readonly [symbol]; + readonly functionality: string; + constructor({ functionality, message, }: { + functionality: string; + message?: string; + }); + static isInstance(error: unknown): error is UnsupportedFunctionalityError; +} + +declare function isJSONValue(value: unknown): value is JSONValue; +declare function isJSONArray(value: unknown): value is JSONArray; +declare function isJSONObject(value: unknown): value is JSONObject; + +/** + * Usage information for an image model call. + */ +type ImageModelV3Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + /** + * The number of output tokens used, if reported by the provider. + */ + outputTokens: number | undefined; + /** + * The total number of tokens as reported by the provider. + */ + totalTokens: number | undefined; +}; + +/** + * An image file that can be used for image editing or variation generation. + */ +type ImageModelV3File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png`. Any string is supported. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +} | { + type: 'url'; + /** + * The URL of the image file. + */ + url: string; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +}; + +type ImageModelV3CallOptions = { + /** + * Prompt for the image generation. Some operations, like upscaling, may not require a prompt. + */ + prompt: string | undefined; + /** + * Number of images to generate. + */ + n: number; + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + /** + * Array of images for image editing or variation generation. + * The images should be provided as base64 encoded strings or binary data. + */ + files: ImageModelV3File[] | undefined; + /** + * Mask image for inpainting operations. + * The mask should be provided as base64 encoded strings or binary data. + */ + mask: ImageModelV3File | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +type ImageModelV3ProviderMetadata = Record; +type GetMaxImagesPerCallFunction$1 = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Image generation model specification version 3. + */ +type ImageModelV3 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction$1; + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV3CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV3ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + /** + * Optional token usage for the image generation call (if the provider reports it). + */ + usage?: ImageModelV3Usage; + }>; +}; + +type ImageModelV2CallOptions = { + /** + * Prompt for the image generation. + */ + prompt: string; + /** + * Number of images to generate. + */ + n: number; + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type ImageModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof ImageModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +type ImageModelV2ProviderMetadata = Record; +type GetMaxImagesPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Image generation model specification version 2. + */ +type ImageModelV2 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction; + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV2CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV2ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; + +/** + * Middleware for ImageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of ImageModelV3 operations. + */ +type ImageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The image model instance. + */ + overrideProvider?: (options: { + model: ImageModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The image model instance. + */ + overrideModelId?: (options: { + model: ImageModelV3; + }) => string; + /** + * Override the limit of how many images can be generated in a single API call if desired. + * @param options.model - The image model instance. + */ + overrideMaxImagesPerCall?: (options: { + model: ImageModelV3; + }) => ImageModelV3['maxImagesPerCall']; + /** + * Transforms the parameters before they are passed to the image model. + * @param options - Object containing the parameters. + * @param options.params - The original parameters for the image model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => PromiseLike; + /** + * Wraps the generate operation of the image model. + * + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The image model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => Promise>>; +}; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +type LanguageModelV3FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + /** + * An optional list of input examples that show the language + * model what the input should look like. + */ + inputExamples?: Array<{ + input: JSONObject; + }>; + /** + * Strict mode setting for the tool. + * + * Providers that support strict mode will use this setting to determine + * how the input should be generated. Strict mode will always produce + * valid inputs, but it might limit what input schemas are supported. + */ + strict?: boolean; + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV3ProviderOptions; +}; + +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +type LanguageModelV3DataContent = Uint8Array | string | URL; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +type LanguageModelV3Prompt = Array; +type LanguageModelV3Message = ({ + role: 'system'; + content: string; +} | { + role: 'user'; + content: Array; +} | { + role: 'assistant'; + content: Array; +} | { + role: 'tool'; + content: Array; +}) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +}; +/** + * Text content part of a prompt. It contains a string of text. + */ +interface LanguageModelV3TextPart { + type: 'text'; + /** + * The text content. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +interface LanguageModelV3ReasoningPart { + type: 'reasoning'; + /** + * The reasoning text. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * File content part of a prompt. It contains a file. + */ +interface LanguageModelV3FilePart { + type: 'file'; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV3DataContent; + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +interface LanguageModelV3ToolCallPart { + type: 'tool-call'; + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + /** + * Name of the tool that is being called. + */ + toolName: string; + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +interface LanguageModelV3ToolResultPart { + type: 'tool-result'; + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. + */ + output: LanguageModelV3ToolResultOutput; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Tool approval response content part of a prompt. It contains the user's + * decision to approve or deny a provider-executed tool call. + */ +interface LanguageModelV3ToolApprovalResponsePart { + type: 'tool-approval-response'; + /** + * ID of the approval request that this response refers to. + */ + approvalId: string; + /** + * Whether the approval was granted (true) or denied (false). + */ + approved: boolean; + /** + * Optional reason for approval or denial. + */ + reason?: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} +/** + * Result of a tool call. + */ +type LanguageModelV3ToolResultOutput = { + /** + * Text tool output that should be directly sent to the API. + */ + type: 'text'; + value: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'json'; + value: JSONValue; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + /** + * Type when the user has denied the execution of the tool call. + */ + type: 'execution-denied'; + /** + * Optional reason for the execution denial. + */ + reason?: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'error-text'; + value: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'error-json'; + value: JSONValue; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; +} | { + type: 'content'; + value: Array<{ + type: 'text'; + /** + * Text content. + */ + text: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-data'; + /** + * Base-64 encoded media data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-url'; + /** + * URL of the file. + */ + url: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + type: 'file-id'; + /** + * ID of the file. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using base64 encoded data. + */ + type: 'image-data'; + /** + * Base-64 encoded image data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using a URL. + */ + type: 'image-url'; + /** + * URL of the image. + */ + url: string; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Images that are referenced using a provider file id. + */ + type: 'image-file-id'; + /** + * Image that is referenced using a provider file id. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } | { + /** + * Custom content part. This can be used to implement + * provider-specific content parts. + */ + type: 'custom'; + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + }>; +}; + +/** + * The configuration of a provider tool. + * + * Provider tools are tools that are specific to a certain provider. + * The input and output schemas are defined be the provider, and + * some of the tools are also executed on the provider systems. + */ +type LanguageModelV3ProviderTool = { + /** + * The type of the tool (always 'provider'). + */ + type: 'provider'; + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; + +type LanguageModelV3ToolChoice = { + type: 'auto'; +} | { + type: 'none'; +} | { + type: 'required'; +} | { + type: 'tool'; + toolName: string; +}; + +type LanguageModelV3CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV3Prompt; + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + /** + * Nucleus sampling. + */ + topP?: number; + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: { + type: 'text'; + } | { + type: 'json'; + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + /** + * The tools that are available for the model. + */ + tools?: Array; + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV3ToolChoice; + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +}; + +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +type LanguageModelV3File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Reasoning that the model has generated. + */ +type LanguageModelV3Reasoning = { + type: 'reasoning'; + text: string; + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * A source that has been used as input to generate the response. + */ +type LanguageModelV3Source = { + type: 'source'; + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + /** + * The ID of the source. + */ + id: string; + /** + * The URL of the source. + */ + url: string; + /** + * The title of the source. + */ + title?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'source'; + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + /** + * The ID of the source. + */ + id: string; + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + /** + * The title of the document. + */ + title: string; + /** + * Optional filename of the document. + */ + filename?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Text that the model has generated. + */ +type LanguageModelV3Text = { + type: 'text'; + /** + * The text content. + */ + text: string; + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Tool approval request emitted by a provider for a provider-executed tool call. + * + * This is used for flows where the provider executes the tool (e.g. MCP tools) + * but requires an explicit user approval before continuing. + */ +type LanguageModelV3ToolApprovalRequest = { + type: 'tool-approval-request'; + /** + * ID of the approval request. This ID is referenced by the subsequent + * tool-approval-response (tool message) to approve or deny execution. + */ + approvalId: string; + /** + * The tool call ID that this approval request is for. + */ + toolCallId: string; + /** + * Additional provider-specific metadata for the approval request. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Tool calls that the model has generated. + */ +type LanguageModelV3ToolCall = { + type: 'tool-call'; + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + /** + * The name of the tool that should be called. + */ + toolName: string; + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +/** + * Result of a tool call that has been executed by the provider. + */ +type LanguageModelV3ToolResult = { + type: 'tool-result'; + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: NonNullable; + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + /** + * Whether the tool result is preliminary. + * + * Preliminary tool results replace each other, e.g. image previews. + * There always has to be a final, non-preliminary tool result. + * + * If this flag is set to true, the tool result is preliminary. + * If this flag is not set or is false, the tool result is not preliminary. + */ + preliminary?: boolean; + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; + +type LanguageModelV3Content = LanguageModelV3Text | LanguageModelV3Reasoning | LanguageModelV3File | LanguageModelV3ToolApprovalRequest | LanguageModelV3Source | LanguageModelV3ToolCall | LanguageModelV3ToolResult; + +/** + * Reason why a language model finished generating a response. + * + * Contains both a unified finish reason and a raw finish reason from the provider. + * The unified finish reason is used to provide a consistent finish reason across different providers. + * The raw finish reason is used to provide the original finish reason from the provider. + */ +type LanguageModelV3FinishReason = { + /** + * Unified finish reason. This enables using the same finish reason across different providers. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + */ + unified: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other'; + /** + * Raw finish reason from the provider. + * This is the original finish reason from the provider. + */ + raw: string | undefined; +}; + +interface LanguageModelV3ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} + +/** + * Usage information for a language model call. + */ +type LanguageModelV3Usage = { + /** + * Information about the input tokens. + */ + inputTokens: { + /** + * The total number of input (prompt) tokens used. + */ + total: number | undefined; + /** + * The number of non-cached input (prompt) tokens used. + */ + noCache: number | undefined; + /** + * The number of cached input (prompt) tokens read. + */ + cacheRead: number | undefined; + /** + * The number of cached input (prompt) tokens written. + */ + cacheWrite: number | undefined; + }; + /** + * Information about the output tokens. + */ + outputTokens: { + /** + * The total number of output (completion) tokens used. + */ + total: number | undefined; + /** + * The number of text tokens used. + */ + text: number | undefined; + /** + * The number of reasoning tokens used. + */ + reasoning: number | undefined; + }; + /** + * Raw usage information from the provider. + * + * This is the usage information in the shape that the provider returns. + * It can include additional information that is not part of the standard usage information. + */ + raw?: JSONObject; +}; + +/** + * The result of a language model doGenerate call. + */ +type LanguageModelV3GenerateResult = { + /** + * Ordered content that the model has generated. + */ + content: Array; + /** + * The finish reason. + */ + finishReason: LanguageModelV3FinishReason; + /** + * The usage information. + */ + usage: LanguageModelV3Usage; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV3ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response HTTP body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; + +type LanguageModelV3StreamPart = { + type: 'text-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; +} | { + type: 'text-end'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'reasoning-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; +} | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; +} | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV3ProviderMetadata; + providerExecuted?: boolean; + dynamic?: boolean; + title?: string; +} | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; +} | LanguageModelV3ToolApprovalRequest | LanguageModelV3ToolCall | LanguageModelV3ToolResult | LanguageModelV3File | LanguageModelV3Source | { + type: 'stream-start'; + warnings: Array; +} | ({ + type: 'response-metadata'; +} & LanguageModelV3ResponseMetadata) | { + type: 'finish'; + usage: LanguageModelV3Usage; + finishReason: LanguageModelV3FinishReason; + providerMetadata?: SharedV3ProviderMetadata; +} | { + type: 'raw'; + rawValue: unknown; +} | { + type: 'error'; + error: unknown; +}; + +/** + * The result of a language model doStream call. + */ +type LanguageModelV3StreamResult = { + /** + * The stream. + */ + stream: ReadableStream; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + }; +}; + +/** + * Specification for a language model that implements the language model interface version 3. + */ +type LanguageModelV3 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v3'; + /** + * Provider ID. + */ + readonly provider: string; + /** + * Provider-specific model ID. + */ + readonly modelId: string; + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: PromiseLike> | Record; + /** + * Generates a language model output (non-streaming). + + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate(options: LanguageModelV3CallOptions): PromiseLike; + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream(options: LanguageModelV3CallOptions): PromiseLike; +}; + +/** + * Experimental middleware for LanguageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV3 operations. + */ +type LanguageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { + model: LanguageModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { + model: LanguageModelV3; + }) => string; + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV3; + }) => PromiseLike> | Record; + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; +}; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +type LanguageModelV2FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + /** + * The name of the tool. Unique within this model call. + */ + name: string; + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV2ProviderOptions; +}; + +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +type LanguageModelV2DataContent = Uint8Array | string | URL; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +type LanguageModelV2Prompt = Array; +type LanguageModelV2Message = ({ + role: 'system'; + content: string; +} | { + role: 'user'; + content: Array; +} | { + role: 'assistant'; + content: Array; +} | { + role: 'tool'; + content: Array; +}) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +}; +/** + * Text content part of a prompt. It contains a string of text. + */ +interface LanguageModelV2TextPart { + type: 'text'; + /** + * The text content. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +interface LanguageModelV2ReasoningPart { + type: 'reasoning'; + /** + * The reasoning text. + */ + text: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * File content part of a prompt. It contains a file. + */ +interface LanguageModelV2FilePart { + type: 'file'; + /** + * Optional filename of the file. + */ + filename?: string; + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV2DataContent; + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +interface LanguageModelV2ToolCallPart { + type: 'tool-call'; + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + /** + * Name of the tool that is being called. + */ + toolName: string; + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +interface LanguageModelV2ToolResultPart { + type: 'tool-result'; + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. + */ + output: LanguageModelV2ToolResultOutput; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} +type LanguageModelV2ToolResultOutput = { + type: 'text'; + value: string; +} | { + type: 'json'; + value: JSONValue; +} | { + type: 'error-text'; + value: string; +} | { + type: 'error-json'; + value: JSONValue; +} | { + type: 'content'; + value: Array<{ + type: 'text'; + /** + * Text content. + */ + text: string; + } | { + type: 'media'; + /** + * Base-64 encoded media data. + */ + data: string; + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + }>; +}; + +/** + * The configuration of a tool that is defined by the provider. + */ +type LanguageModelV2ProviderDefinedTool = { + /** + * The type of the tool (always 'provider-defined'). + */ + type: 'provider-defined'; + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + /** + * The name of the tool that the user must use in the tool set. + */ + name: string; + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; + +type LanguageModelV2ToolChoice = { + type: 'auto'; +} | { + type: 'none'; +} | { + type: 'required'; +} | { + type: 'tool'; + toolName: string; +}; + +type LanguageModelV2CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV2Prompt; + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + /** + * Nucleus sampling. + */ + topP?: number; + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: { + type: 'text'; + } | { + type: 'json'; + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + /** + * The tools that are available for the model. + */ + tools?: Array; + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV2ToolChoice; + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type LanguageModelV2CallWarning = { + type: 'unsupported-setting'; + setting: Omit; + details?: string; +} | { + type: 'unsupported-tool'; + tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +type LanguageModelV2File = { + type: 'file'; + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; +}; + +/** + * Reasoning that the model has generated. + */ +type LanguageModelV2Reasoning = { + type: 'reasoning'; + text: string; + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * A source that has been used as input to generate the response. + */ +type LanguageModelV2Source = { + type: 'source'; + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + /** + * The ID of the source. + */ + id: string; + /** + * The URL of the source. + */ + url: string; + /** + * The title of the source. + */ + title?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'source'; + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + /** + * The ID of the source. + */ + id: string; + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + /** + * The title of the document. + */ + title: string; + /** + * Optional filename of the document. + */ + filename?: string; + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Text that the model has generated. + */ +type LanguageModelV2Text = { + type: 'text'; + /** + * The text content. + */ + text: string; + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Tool calls that the model has generated. + */ +type LanguageModelV2ToolCall = { + type: 'tool-call'; + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + /** + * The name of the tool that should be called. + */ + toolName: string; + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +/** + * Result of a tool call that has been executed by the provider. + */ +type LanguageModelV2ToolResult = { + type: 'tool-result'; + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + /** + * Name of the tool that generated this result. + */ + toolName: string; + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: unknown; + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + /** + * Whether the tool result was generated by the provider. + * If this flag is set to true, the tool result was generated by the provider. + * If this flag is not set or is false, the tool result was generated by the client. + */ + providerExecuted?: boolean; + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; + +type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult; + +/** + * Reason why a language model finished generating a response. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + * - `unknown`: the model has not transmitted a finish reason + */ +type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown'; + +interface LanguageModelV2ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} + +/** + * Usage information for a language model call. + * + * If your API return additional usage information, you can add it to the + * provider metadata under your provider's key. + */ +type LanguageModelV2Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + /** + * The number of output (completion) tokens used. + */ + outputTokens: number | undefined; + /** + * The total number of tokens as reported by the provider. + * This number might be different from the sum of `inputTokens` and `outputTokens` + * and e.g. include reasoning tokens or other overhead. + */ + totalTokens: number | undefined; + /** + * The number of reasoning tokens used. + */ + reasoningTokens?: number | undefined; + /** + * The number of cached input tokens. + */ + cachedInputTokens?: number | undefined; +}; + +type LanguageModelV2StreamPart = { + type: 'text-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; +} | { + type: 'text-end'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'reasoning-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; +} | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; +} | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV2ProviderMetadata; + providerExecuted?: boolean; +} | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; +} | LanguageModelV2ToolCall | LanguageModelV2ToolResult | LanguageModelV2File | LanguageModelV2Source | { + type: 'stream-start'; + warnings: Array; +} | ({ + type: 'response-metadata'; +} & LanguageModelV2ResponseMetadata) | { + type: 'finish'; + usage: LanguageModelV2Usage; + finishReason: LanguageModelV2FinishReason; + providerMetadata?: SharedV2ProviderMetadata; +} | { + type: 'raw'; + rawValue: unknown; +} | { + type: 'error'; + error: unknown; +}; + +/** + * Specification for a language model that implements the language model interface version 2. + */ +type LanguageModelV2 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: PromiseLike> | Record; + /** + * Generates a language model output (non-streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{ + /** + * Ordered content that the model has generated. + */ + content: Array; + /** + * Finish reason. + */ + finishReason: LanguageModelV2FinishReason; + /** + * Usage information. + */ + usage: LanguageModelV2Usage; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV2ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response HTTP body. + */ + body?: unknown; + }; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + }>; + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream(options: LanguageModelV2CallOptions): PromiseLike<{ + stream: ReadableStream; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + }; + }>; +}; + +/** + * Experimental middleware for LanguageModelV2. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV2 operations. + */ +type LanguageModelV2Middleware = { + /** + * Middleware specification version. Use `v2` for the current version. + */ + middlewareVersion?: 'v2' | undefined; + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { + model: LanguageModelV2; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { + model: LanguageModelV2; + }) => string; + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV2; + }) => PromiseLike> | Record; + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike; + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => Promise>>; + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike>>; +}; + +/** + * Middleware for EmbeddingModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of EmbeddingModelV3 operations. + */ +type EmbeddingModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + /** + * Override the provider name if desired. + * @param options.model - The embedding model instance. + */ + overrideProvider?: (options: { + model: EmbeddingModelV3; + }) => string; + /** + * Override the model ID if desired. + * @param options.model - The embedding model instance. + */ + overrideModelId?: (options: { + model: EmbeddingModelV3; + }) => string; + /** + * Override the limit of how many embeddings can be generated in a single API call if desired. + * @param options.model - The embedding model instance. + */ + overrideMaxEmbeddingsPerCall?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | number | undefined; + /** + * Override support for handling multiple embedding calls in parallel, if desired.. + * @param options.model - The embedding model instance. + */ + overrideSupportsParallelCalls?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | boolean; + /** + * Transforms the parameters before they are passed to the embed model. + * @param options - Object containing the type of operation and the parameters. + * @param options.params - The original parameters for the embedding model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => PromiseLike; + /** + * Wraps the embed operation of the embedding model. + * + * @param options - Object containing the embed function, parameters, and model. + * @param options.doEmbed - The original embed function. + * @param options.params - The parameters for the embed call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The embedding model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapEmbed?: (options: { + doEmbed: () => ReturnType; + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => Promise>>; +}; + +type RerankingModelV3CallOptions = { + /** + * Documents to rerank. + * Either a list of texts or a list of JSON objects. + */ + documents: { + type: 'text'; + values: string[]; + } | { + type: 'object'; + values: JSONObject[]; + }; + /** + * The query is a string that represents the query to rerank the documents against. + */ + query: string; + /** + * Optional limit returned documents to the top n documents. + */ + topN?: number; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; + +/** + * Specification for a reranking model that implements the reranking model interface version 3. + */ +type RerankingModelV3 = { + /** + * The reranking model must specify which reranking model interface version it implements. + */ + readonly specificationVersion: 'v3'; + /** + * Provider ID. + */ + readonly provider: string; + /** + * Provider-specific model ID. + */ + readonly modelId: string; + /** + * Reranking a list of documents using the query. + */ + doRerank(options: RerankingModelV3CallOptions): PromiseLike<{ + /** + * Ordered list of reranked documents (via index before reranking). + * The documents are sorted by the descending order of relevance scores. + */ + ranking: Array<{ + /** + * The index of the document in the original list of documents before reranking. + */ + index: number; + /** + * The relevance score of the document after reranking. + */ + relevanceScore: number; + }>; + /** + * Additional provider-specific metadata. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings?: Array; + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response body. + */ + body?: unknown; + }; + }>; +}; + +type SpeechModelV3ProviderOptions = Record; +type SpeechModelV3CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + /** + * The speed of the speech generation. + */ + speed?: number; + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Speech model specification version 3. + */ +type SpeechModelV3 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV3CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; + +type TranscriptionModelV3ProviderOptions = Record; +type TranscriptionModelV3CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Transcription model specification version 3. + */ +type TranscriptionModelV3 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV3CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV3Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; + +/** + * Provider for language, text embedding, and image generation models. + */ +interface ProviderV3 { + readonly specificationVersion: 'v3'; + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV3; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + embeddingModel(modelId: string): EmbeddingModelV3; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {EmbeddingModel} The embedding model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + * + * @deprecated Use `embeddingModel` instead. + */ + textEmbeddingModel?(modelId: string): EmbeddingModelV3; + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV3; + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV3; + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV3; + /** + * Returns the reranking model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {RerankingModel} The reranking model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + rerankingModel?(modelId: string): RerankingModelV3; +} + +type SpeechModelV2ProviderOptions = Record>; +type SpeechModelV2CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + /** + * The speed of the speech generation. + */ + speed?: number; + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type SpeechModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof SpeechModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * Speech model specification version 2. + */ +type SpeechModelV2 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV2CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; + +type TranscriptionModelV2ProviderOptions = Record>; +type TranscriptionModelV2CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV2ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +type TranscriptionModelV2CallWarning = { + type: 'unsupported-setting'; + setting: keyof TranscriptionModelV2CallOptions; + details?: string; +} | { + type: 'other'; + message: string; +}; + +/** + * Transcription model specification version 2. + */ +type TranscriptionModelV2 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV2CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers?: SharedV2Headers; + /** + * Response body. + */ + body?: unknown; + }; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; + +/** + * Provider for language, text embedding, and image generation models. + */ +interface ProviderV2 { + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV2; + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + textEmbeddingModel(modelId: string): EmbeddingModelV2; + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV2; + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV2; + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV2; +} + +/** + * A video or image file that can be used for video editing or image-to-video generation. + * Supports both image inputs (for image-to-video) and video inputs (for editing). + */ +type VideoModelV3File = { + type: 'file'; + /** + * The IANA media type of the file. + * Video types: 'video/mp4', 'video/webm', 'video/quicktime' + * Image types: 'image/png', 'image/jpeg', 'image/webp' + */ + mediaType: string; + /** + * File data as base64 encoded string or binary data. + */ + data: string | Uint8Array; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +} | { + type: 'url'; + /** + * The URL of the video or image file. + */ + url: string; + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; +}; + +type VideoModelV3CallOptions = { + /** + * Text prompt for the video generation. + */ + prompt: string | undefined; + /** + * Number of videos to generate. Default: 1. + * Most video models only support n=1 due to computational cost. + */ + n: number; + /** + * Aspect ratio of the videos to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + * Common values: '16:9', '9:16', '1:1', '21:9', '4:3' + */ + aspectRatio: `${number}:${number}` | undefined; + /** + * Resolution of the video to generate. + * Format: `{width}x{height}` (e.g., '1280x720', '1920x1080') + * `undefined` will use the provider's default resolution. + */ + resolution: `${number}x${number}` | undefined; + /** + * Duration of the video in seconds. + * `undefined` will use the provider's default duration. + * Typically 3-10 seconds for most models. + */ + duration: number | undefined; + /** + * Frames per second (FPS) for the video. + * `undefined` will use the provider's default FPS. + * Common values: 24, 30, 60 + */ + fps: number | undefined; + /** + * Seed for deterministic video generation. + * `undefined` will use a random seed. + */ + seed: number | undefined; + /** + * Input image for image-to-video generation. + * The image serves as the starting frame that the model will animate. + */ + image: VideoModelV3File | undefined; + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * Example: + * { + * "fal": { + * "loop": true, + * "motionStrength": 0.8 + * } + * } + */ + providerOptions: SharedV3ProviderOptions; + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; + +type GetMaxVideosPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; +/** + * Generated video data. Can be a URL, base64-encoded string, or binary data. + */ +type VideoModelV3VideoData = { + /** + * Video available as a URL (most common for video providers). + */ + type: 'url'; + url: string; + mediaType: string; +} | { + /** + * Video as base64-encoded string. + */ + type: 'base64'; + data: string; + mediaType: string; +} | { + /** + * Video as binary data. + */ + type: 'binary'; + data: Uint8Array; + mediaType: string; +}; +/** + * Video generation model specification version 3. + */ +type VideoModelV3 = { + /** + * The video model must specify which video model interface + * version it implements. This will allow us to evolve the video + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + /** + * Limit of how many videos can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + * + * Most video models only support generating 1 video at a time due to + * computational cost. Default is typically 1. + */ + readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction; + /** + * Generates an array of videos. + */ + doGenerate(options: VideoModelV3CallOptions): PromiseLike<{ + /** + * Generated videos as URLs, base64 strings, or binary data. + * + * Most providers return URLs to video files (MP4, WebM) due to large file sizes. + * Use the discriminated union to indicate the type of video data being returned. + */ + videos: Array; + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. + * + * ```ts + * { + * "fal": { + * "videos": [{ + * "duration": 5.0, + * "fps": 24, + * "width": 1280, + * "height": 720 + * }] + * } + * } + * ``` + */ + providerMetadata?: SharedV3ProviderMetadata; + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; + +export { AISDKError, APICallError, type EmbeddingModelV2, type EmbeddingModelV2Embedding, type EmbeddingModelV3, type EmbeddingModelV3CallOptions, type EmbeddingModelV3Embedding, type EmbeddingModelV3Middleware, type EmbeddingModelV3Result, EmptyResponseBodyError, type VideoModelV3 as Experimental_VideoModelV3, type VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions, type VideoModelV3File as Experimental_VideoModelV3File, type VideoModelV3VideoData as Experimental_VideoModelV3VideoData, type ImageModelV2, type ImageModelV2CallOptions, type ImageModelV2CallWarning, type ImageModelV2ProviderMetadata, type ImageModelV3, type ImageModelV3CallOptions, type ImageModelV3File, type ImageModelV3Middleware, type ImageModelV3ProviderMetadata, type ImageModelV3Usage, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV2, type LanguageModelV2CallOptions, type LanguageModelV2CallWarning, type LanguageModelV2Content, type LanguageModelV2DataContent, type LanguageModelV2File, type LanguageModelV2FilePart, type LanguageModelV2FinishReason, type LanguageModelV2FunctionTool, type LanguageModelV2Message, type LanguageModelV2Middleware, type LanguageModelV2Prompt, type LanguageModelV2ProviderDefinedTool, type LanguageModelV2Reasoning, type LanguageModelV2ReasoningPart, type LanguageModelV2ResponseMetadata, type LanguageModelV2Source, type LanguageModelV2StreamPart, type LanguageModelV2Text, type LanguageModelV2TextPart, type LanguageModelV2ToolCall, type LanguageModelV2ToolCallPart, type LanguageModelV2ToolChoice, type LanguageModelV2ToolResultOutput, type LanguageModelV2ToolResultPart, type LanguageModelV2Usage, type LanguageModelV3, type LanguageModelV3CallOptions, type LanguageModelV3Content, type LanguageModelV3DataContent, type LanguageModelV3File, type LanguageModelV3FilePart, type LanguageModelV3FinishReason, type LanguageModelV3FunctionTool, type LanguageModelV3GenerateResult, type LanguageModelV3Message, type LanguageModelV3Middleware, type LanguageModelV3Prompt, type LanguageModelV3ProviderTool, type LanguageModelV3Reasoning, type LanguageModelV3ReasoningPart, type LanguageModelV3ResponseMetadata, type LanguageModelV3Source, type LanguageModelV3StreamPart, type LanguageModelV3StreamResult, type LanguageModelV3Text, type LanguageModelV3TextPart, type LanguageModelV3ToolApprovalRequest, type LanguageModelV3ToolApprovalResponsePart, type LanguageModelV3ToolCall, type LanguageModelV3ToolCallPart, type LanguageModelV3ToolChoice, type LanguageModelV3ToolResult, type LanguageModelV3ToolResultOutput, type LanguageModelV3ToolResultPart, type LanguageModelV3Usage, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV2, type ProviderV3, type RerankingModelV3, type RerankingModelV3CallOptions, type SharedV2Headers, type SharedV2ProviderMetadata, type SharedV2ProviderOptions, type SharedV3Headers, type SharedV3ProviderMetadata, type SharedV3ProviderOptions, type SharedV3Warning, type SpeechModelV2, type SpeechModelV2CallOptions, type SpeechModelV2CallWarning, type SpeechModelV3, type SpeechModelV3CallOptions, TooManyEmbeddingValuesForCallError, type TranscriptionModelV2, type TranscriptionModelV2CallOptions, type TranscriptionModelV2CallWarning, type TranscriptionModelV3, type TranscriptionModelV3CallOptions, type TypeValidationContext, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue }; diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.js b/.opencode/node_modules/@ai-sdk/provider/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..fe12e875b7080b1c72604f7d15056c59a288bec3 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.js @@ -0,0 +1,448 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name14 in all) + __defProp(target, name14, { get: all[name14], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + AISDKError: () => AISDKError, + APICallError: () => APICallError, + EmptyResponseBodyError: () => EmptyResponseBodyError, + InvalidArgumentError: () => InvalidArgumentError, + InvalidPromptError: () => InvalidPromptError, + InvalidResponseDataError: () => InvalidResponseDataError, + JSONParseError: () => JSONParseError, + LoadAPIKeyError: () => LoadAPIKeyError, + LoadSettingError: () => LoadSettingError, + NoContentGeneratedError: () => NoContentGeneratedError, + NoSuchModelError: () => NoSuchModelError, + TooManyEmbeddingValuesForCallError: () => TooManyEmbeddingValuesForCallError, + TypeValidationError: () => TypeValidationError, + UnsupportedFunctionalityError: () => UnsupportedFunctionalityError, + getErrorMessage: () => getErrorMessage, + isJSONArray: () => isJSONArray, + isJSONObject: () => isJSONObject, + isJSONValue: () => isJSONValue +}); +module.exports = __toCommonJS(src_exports); + +// src/errors/ai-sdk-error.ts +var marker = "vercel.ai.error"; +var symbol = Symbol.for(marker); +var _a, _b; +var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) { + /** + * Creates an AI SDK Error. + * + * @param {Object} params - The parameters for creating the error. + * @param {string} params.name - The name of the error. + * @param {string} params.message - The error message. + * @param {unknown} [params.cause] - The underlying cause of the error. + */ + constructor({ + name: name14, + message, + cause + }) { + super(message); + this[_a] = true; + this.name = name14; + this.cause = cause; + } + /** + * Checks if the given error is an AI SDK Error. + * @param {unknown} error - The error to check. + * @returns {boolean} True if the error is an AI SDK Error, false otherwise. + */ + static isInstance(error) { + return _AISDKError.hasMarker(error, marker); + } + static hasMarker(error, marker15) { + const markerSymbol = Symbol.for(marker15); + return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true; + } +}; + +// src/errors/api-call-error.ts +var name = "AI_APICallError"; +var marker2 = `vercel.ai.error.${name}`; +var symbol2 = Symbol.for(marker2); +var _a2, _b2; +var APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) { + constructor({ + message, + url, + requestBodyValues, + statusCode, + responseHeaders, + responseBody, + cause, + isRetryable = statusCode != null && (statusCode === 408 || // request timeout + statusCode === 409 || // conflict + statusCode === 429 || // too many requests + statusCode >= 500), + // server error + data + }) { + super({ name, message, cause }); + this[_a2] = true; + this.url = url; + this.requestBodyValues = requestBodyValues; + this.statusCode = statusCode; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + this.isRetryable = isRetryable; + this.data = data; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker2); + } +}; + +// src/errors/empty-response-body-error.ts +var name2 = "AI_EmptyResponseBodyError"; +var marker3 = `vercel.ai.error.${name2}`; +var symbol3 = Symbol.for(marker3); +var _a3, _b3; +var EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) { + // used in isInstance + constructor({ message = "Empty response body" } = {}) { + super({ name: name2, message }); + this[_a3] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker3); + } +}; + +// src/errors/get-error-message.ts +function getErrorMessage(error) { + if (error == null) { + return "unknown error"; + } + if (typeof error === "string") { + return error; + } + if (error instanceof Error) { + return error.message; + } + return JSON.stringify(error); +} + +// src/errors/invalid-argument-error.ts +var name3 = "AI_InvalidArgumentError"; +var marker4 = `vercel.ai.error.${name3}`; +var symbol4 = Symbol.for(marker4); +var _a4, _b4; +var InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) { + constructor({ + message, + cause, + argument + }) { + super({ name: name3, message, cause }); + this[_a4] = true; + this.argument = argument; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker4); + } +}; + +// src/errors/invalid-prompt-error.ts +var name4 = "AI_InvalidPromptError"; +var marker5 = `vercel.ai.error.${name4}`; +var symbol5 = Symbol.for(marker5); +var _a5, _b5; +var InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) { + constructor({ + prompt, + message, + cause + }) { + super({ name: name4, message: `Invalid prompt: ${message}`, cause }); + this[_a5] = true; + this.prompt = prompt; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker5); + } +}; + +// src/errors/invalid-response-data-error.ts +var name5 = "AI_InvalidResponseDataError"; +var marker6 = `vercel.ai.error.${name5}`; +var symbol6 = Symbol.for(marker6); +var _a6, _b6; +var InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) { + constructor({ + data, + message = `Invalid response data: ${JSON.stringify(data)}.` + }) { + super({ name: name5, message }); + this[_a6] = true; + this.data = data; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker6); + } +}; + +// src/errors/json-parse-error.ts +var name6 = "AI_JSONParseError"; +var marker7 = `vercel.ai.error.${name6}`; +var symbol7 = Symbol.for(marker7); +var _a7, _b7; +var JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) { + constructor({ text, cause }) { + super({ + name: name6, + message: `JSON parsing failed: Text: ${text}. +Error message: ${getErrorMessage(cause)}`, + cause + }); + this[_a7] = true; + this.text = text; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker7); + } +}; + +// src/errors/load-api-key-error.ts +var name7 = "AI_LoadAPIKeyError"; +var marker8 = `vercel.ai.error.${name7}`; +var symbol8 = Symbol.for(marker8); +var _a8, _b8; +var LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) { + // used in isInstance + constructor({ message }) { + super({ name: name7, message }); + this[_a8] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker8); + } +}; + +// src/errors/load-setting-error.ts +var name8 = "AI_LoadSettingError"; +var marker9 = `vercel.ai.error.${name8}`; +var symbol9 = Symbol.for(marker9); +var _a9, _b9; +var LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) { + // used in isInstance + constructor({ message }) { + super({ name: name8, message }); + this[_a9] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker9); + } +}; + +// src/errors/no-content-generated-error.ts +var name9 = "AI_NoContentGeneratedError"; +var marker10 = `vercel.ai.error.${name9}`; +var symbol10 = Symbol.for(marker10); +var _a10, _b10; +var NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) { + // used in isInstance + constructor({ + message = "No content generated." + } = {}) { + super({ name: name9, message }); + this[_a10] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker10); + } +}; + +// src/errors/no-such-model-error.ts +var name10 = "AI_NoSuchModelError"; +var marker11 = `vercel.ai.error.${name10}`; +var symbol11 = Symbol.for(marker11); +var _a11, _b11; +var NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) { + constructor({ + errorName = name10, + modelId, + modelType, + message = `No such ${modelType}: ${modelId}` + }) { + super({ name: errorName, message }); + this[_a11] = true; + this.modelId = modelId; + this.modelType = modelType; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker11); + } +}; + +// src/errors/too-many-embedding-values-for-call-error.ts +var name11 = "AI_TooManyEmbeddingValuesForCallError"; +var marker12 = `vercel.ai.error.${name11}`; +var symbol12 = Symbol.for(marker12); +var _a12, _b12; +var TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) { + constructor(options) { + super({ + name: name11, + message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.` + }); + this[_a12] = true; + this.provider = options.provider; + this.modelId = options.modelId; + this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall; + this.values = options.values; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker12); + } +}; + +// src/errors/type-validation-error.ts +var name12 = "AI_TypeValidationError"; +var marker13 = `vercel.ai.error.${name12}`; +var symbol13 = Symbol.for(marker13); +var _a13, _b13; +var TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) { + constructor({ + value, + cause, + context + }) { + let contextPrefix = "Type validation failed"; + if (context == null ? void 0 : context.field) { + contextPrefix += ` for ${context.field}`; + } + if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) { + contextPrefix += " ("; + const parts = []; + if (context.entityName) { + parts.push(context.entityName); + } + if (context.entityId) { + parts.push(`id: "${context.entityId}"`); + } + contextPrefix += parts.join(", "); + contextPrefix += ")"; + } + super({ + name: name12, + message: `${contextPrefix}: Value: ${JSON.stringify(value)}. +Error message: ${getErrorMessage(cause)}`, + cause + }); + this[_a13] = true; + this.value = value; + this.context = context; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker13); + } + /** + * Wraps an error into a TypeValidationError. + * If the cause is already a TypeValidationError with the same value and context, it returns the cause. + * Otherwise, it creates a new TypeValidationError. + * + * @param {Object} params - The parameters for wrapping the error. + * @param {unknown} params.value - The value that failed validation. + * @param {unknown} params.cause - The original error or cause of the validation failure. + * @param {TypeValidationContext} params.context - Optional context about what is being validated. + * @returns {TypeValidationError} A TypeValidationError instance. + */ + static wrap({ + value, + cause, + context + }) { + var _a15, _b15, _c; + if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) { + return cause; + } + return new _TypeValidationError({ value, cause, context }); + } +}; + +// src/errors/unsupported-functionality-error.ts +var name13 = "AI_UnsupportedFunctionalityError"; +var marker14 = `vercel.ai.error.${name13}`; +var symbol14 = Symbol.for(marker14); +var _a14, _b14; +var UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) { + constructor({ + functionality, + message = `'${functionality}' functionality not supported.` + }) { + super({ name: name13, message }); + this[_a14] = true; + this.functionality = functionality; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker14); + } +}; + +// src/json-value/is-json.ts +function isJSONValue(value) { + if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") { + return true; + } + if (Array.isArray(value)) { + return value.every(isJSONValue); + } + if (typeof value === "object") { + return Object.entries(value).every( + ([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val)) + ); + } + return false; +} +function isJSONArray(value) { + return Array.isArray(value) && value.every(isJSONValue); +} +function isJSONObject(value) { + return value != null && typeof value === "object" && Object.entries(value).every( + ([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val)) + ); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + AISDKError, + APICallError, + EmptyResponseBodyError, + InvalidArgumentError, + InvalidPromptError, + InvalidResponseDataError, + JSONParseError, + LoadAPIKeyError, + LoadSettingError, + NoContentGeneratedError, + NoSuchModelError, + TooManyEmbeddingValuesForCallError, + TypeValidationError, + UnsupportedFunctionalityError, + getErrorMessage, + isJSONArray, + isJSONObject, + isJSONValue +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.js.map b/.opencode/node_modules/@ai-sdk/provider/dist/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..1d1603c666788800ea67aaaddfb8b201a400de47 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts","../src/errors/ai-sdk-error.ts","../src/errors/api-call-error.ts","../src/errors/empty-response-body-error.ts","../src/errors/get-error-message.ts","../src/errors/invalid-argument-error.ts","../src/errors/invalid-prompt-error.ts","../src/errors/invalid-response-data-error.ts","../src/errors/json-parse-error.ts","../src/errors/load-api-key-error.ts","../src/errors/load-setting-error.ts","../src/errors/no-content-generated-error.ts","../src/errors/no-such-model-error.ts","../src/errors/too-many-embedding-values-for-call-error.ts","../src/errors/type-validation-error.ts","../src/errors/unsupported-functionality-error.ts","../src/json-value/is-json.ts"],"sourcesContent":["export * from './embedding-model/index';\nexport * from './errors/index';\nexport * from './image-model/index';\nexport * from './image-model-middleware/index';\nexport * from './json-value/index';\nexport * from './language-model-middleware/index';\nexport * from './embedding-model-middleware/index';\nexport * from './language-model/index';\nexport * from './provider/index';\nexport * from './reranking-model/index';\nexport * from './shared/index';\nexport * from './speech-model/index';\nexport * from './transcription-model/index';\nexport * from './video-model/index';\n\nexport type { JSONSchema7, JSONSchema7Definition } from 'json-schema';\n","/**\n * Symbol used for identifying AI SDK Error instances.\n * Enables checking if an error is an instance of AISDKError across package versions.\n */\nconst marker = 'vercel.ai.error';\nconst symbol = Symbol.for(marker);\n\n/**\n * Custom error class for AI SDK related errors.\n * @extends Error\n */\nexport class AISDKError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n /**\n * The underlying cause of the error, if any.\n */\n readonly cause?: unknown;\n\n /**\n * Creates an AI SDK Error.\n *\n * @param {Object} params - The parameters for creating the error.\n * @param {string} params.name - The name of the error.\n * @param {string} params.message - The error message.\n * @param {unknown} [params.cause] - The underlying cause of the error.\n */\n constructor({\n name,\n message,\n cause,\n }: {\n name: string;\n message: string;\n cause?: unknown;\n }) {\n super(message);\n\n this.name = name;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is an AI SDK Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n */\n static isInstance(error: unknown): error is AISDKError {\n return AISDKError.hasMarker(error, marker);\n }\n\n protected static hasMarker(error: unknown, marker: string): boolean {\n const markerSymbol = Symbol.for(marker);\n return (\n error != null &&\n typeof error === 'object' &&\n markerSymbol in error &&\n typeof error[markerSymbol] === 'boolean' &&\n error[markerSymbol] === true\n );\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_APICallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class APICallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly url: string;\n readonly requestBodyValues: unknown;\n readonly statusCode?: number;\n\n readonly responseHeaders?: Record;\n readonly responseBody?: string;\n\n readonly isRetryable: boolean;\n readonly data?: unknown;\n\n constructor({\n message,\n url,\n requestBodyValues,\n statusCode,\n responseHeaders,\n responseBody,\n cause,\n isRetryable = statusCode != null &&\n (statusCode === 408 || // request timeout\n statusCode === 409 || // conflict\n statusCode === 429 || // too many requests\n statusCode >= 500), // server error\n data,\n }: {\n message: string;\n url: string;\n requestBodyValues: unknown;\n statusCode?: number;\n responseHeaders?: Record;\n responseBody?: string;\n cause?: unknown;\n isRetryable?: boolean;\n data?: unknown;\n }) {\n super({ name, message, cause });\n\n this.url = url;\n this.requestBodyValues = requestBodyValues;\n this.statusCode = statusCode;\n this.responseHeaders = responseHeaders;\n this.responseBody = responseBody;\n this.isRetryable = isRetryable;\n this.data = data;\n }\n\n static isInstance(error: unknown): error is APICallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_EmptyResponseBodyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class EmptyResponseBodyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message = 'Empty response body' }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is EmptyResponseBodyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","export function getErrorMessage(error: unknown | undefined) {\n if (error == null) {\n return 'unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return JSON.stringify(error);\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidArgumentError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A function argument is invalid.\n */\nexport class InvalidArgumentError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly argument: string;\n\n constructor({\n message,\n cause,\n argument,\n }: {\n argument: string;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message, cause });\n\n this.argument = argument;\n }\n\n static isInstance(error: unknown): error is InvalidArgumentError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidPromptError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A prompt is invalid. This error should be thrown by providers when they cannot\n * process a prompt.\n */\nexport class InvalidPromptError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly prompt: unknown;\n\n constructor({\n prompt,\n message,\n cause,\n }: {\n prompt: unknown;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message: `Invalid prompt: ${message}`, cause });\n\n this.prompt = prompt;\n }\n\n static isInstance(error: unknown): error is InvalidPromptError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidResponseDataError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Server returned a response with invalid data content.\n * This should be thrown by providers when they cannot parse the response from the API.\n */\nexport class InvalidResponseDataError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly data: unknown;\n\n constructor({\n data,\n message = `Invalid response data: ${JSON.stringify(data)}.`,\n }: {\n data: unknown;\n message?: string;\n }) {\n super({ name, message });\n\n this.data = data;\n }\n\n static isInstance(error: unknown): error is InvalidResponseDataError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_JSONParseError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class JSONParseError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly text: string;\n\n constructor({ text, cause }: { text: string; cause: unknown }) {\n super({\n name,\n message:\n `JSON parsing failed: ` +\n `Text: ${text}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.text = text;\n }\n\n static isInstance(error: unknown): error is JSONParseError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadAPIKeyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadAPIKeyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadAPIKeyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadSettingError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadSettingError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadSettingError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoContentGeneratedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when the AI provider fails to generate any content.\n */\nexport class NoContentGeneratedError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({\n message = 'No content generated.',\n }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is NoContentGeneratedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoSuchModelError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class NoSuchModelError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly modelId: string;\n readonly modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel'\n | 'videoModel';\n\n constructor({\n errorName = name,\n modelId,\n modelType,\n message = `No such ${modelType}: ${modelId}`,\n }: {\n errorName?: string;\n modelId: string;\n modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel'\n | 'videoModel';\n message?: string;\n }) {\n super({ name: errorName, message });\n\n this.modelId = modelId;\n this.modelType = modelType;\n }\n\n static isInstance(error: unknown): error is NoSuchModelError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_TooManyEmbeddingValuesForCallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TooManyEmbeddingValuesForCallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly provider: string;\n readonly modelId: string;\n readonly maxEmbeddingsPerCall: number;\n readonly values: Array;\n\n constructor(options: {\n provider: string;\n modelId: string;\n maxEmbeddingsPerCall: number;\n values: Array;\n }) {\n super({\n name,\n message:\n `Too many values for a single embedding call. ` +\n `The ${options.provider} model \"${options.modelId}\" can only embed up to ` +\n `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,\n });\n\n this.provider = options.provider;\n this.modelId = options.modelId;\n this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n this.values = options.values;\n }\n\n static isInstance(\n error: unknown,\n ): error is TooManyEmbeddingValuesForCallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_TypeValidationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport interface TypeValidationContext {\n /**\n * Field path in dot notation (e.g., \"message.metadata\", \"message.parts[3].data\")\n */\n field?: string;\n\n /**\n * Entity name (e.g., tool name, data type name)\n */\n entityName?: string;\n\n /**\n * Entity identifier (e.g., message ID, tool call ID)\n */\n entityId?: string;\n}\n\nexport class TypeValidationError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly value: unknown;\n readonly context?: TypeValidationContext;\n\n constructor({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }) {\n let contextPrefix = 'Type validation failed';\n\n if (context?.field) {\n contextPrefix += ` for ${context.field}`;\n }\n\n if (context?.entityName || context?.entityId) {\n contextPrefix += ' (';\n const parts: string[] = [];\n if (context.entityName) {\n parts.push(context.entityName);\n }\n if (context.entityId) {\n parts.push(`id: \"${context.entityId}\"`);\n }\n contextPrefix += parts.join(', ');\n contextPrefix += ')';\n }\n\n super({\n name,\n message:\n `${contextPrefix}: ` +\n `Value: ${JSON.stringify(value)}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.value = value;\n this.context = context;\n }\n\n static isInstance(error: unknown): error is TypeValidationError {\n return AISDKError.hasMarker(error, marker);\n }\n\n /**\n * Wraps an error into a TypeValidationError.\n * If the cause is already a TypeValidationError with the same value and context, it returns the cause.\n * Otherwise, it creates a new TypeValidationError.\n *\n * @param {Object} params - The parameters for wrapping the error.\n * @param {unknown} params.value - The value that failed validation.\n * @param {unknown} params.cause - The original error or cause of the validation failure.\n * @param {TypeValidationContext} params.context - Optional context about what is being validated.\n * @returns {TypeValidationError} A TypeValidationError instance.\n */\n static wrap({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }): TypeValidationError {\n if (\n TypeValidationError.isInstance(cause) &&\n cause.value === value &&\n cause.context?.field === context?.field &&\n cause.context?.entityName === context?.entityName &&\n cause.context?.entityId === context?.entityId\n ) {\n return cause;\n }\n\n return new TypeValidationError({ value, cause, context });\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_UnsupportedFunctionalityError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class UnsupportedFunctionalityError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly functionality: string;\n\n constructor({\n functionality,\n message = `'${functionality}' functionality not supported.`,\n }: {\n functionality: string;\n message?: string;\n }) {\n super({ name, message });\n this.functionality = functionality;\n }\n\n static isInstance(error: unknown): error is UnsupportedFunctionalityError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { JSONArray, JSONObject, JSONValue } from './json-value';\n\nexport function isJSONValue(value: unknown): value is JSONValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.every(isJSONValue);\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is JSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is JSONObject {\n return (\n value != null &&\n typeof value === 'object' &&\n Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AALhC;AAWO,IAAM,aAAN,MAAM,qBAAmB,YACZ,aADY,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBpC,YAAY;AAAA,IACV,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,OAAO;AAxBf,SAAkB,MAAU;AA0B1B,SAAK,OAAOA;AACZ,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,OAAqC;AACrD,WAAO,YAAW,UAAU,OAAO,MAAM;AAAA,EAC3C;AAAA,EAEA,OAAiB,UAAU,OAAgBC,UAAyB;AAClE,UAAM,eAAe,OAAO,IAAIA,QAAM;AACtC,WACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,OAAO,MAAM,YAAY,MAAM,aAC/B,MAAM,YAAY,MAAM;AAAA,EAE5B;AACF;;;AC3DA,IAAM,OAAO;AACb,IAAMC,UAAS,mBAAmB,IAAI;AACtC,IAAMC,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,eAAN,eAA2BA,MAAA,YACdD,MAAAD,SADcE,KAAW;AAAA,EAa3C,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,cAAc,SACzB,eAAe;AAAA,IACd,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA;AAAA,IAClB;AAAA,EACF,GAUG;AACD,UAAM,EAAE,MAAM,SAAS,MAAM,CAAC;AArChC,SAAkBD,OAAU;AAuC1B,SAAK,MAAM;AACX,SAAK,oBAAoB;AACzB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,eAAe;AACpB,SAAK,cAAc;AACnB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAuC;AACvD,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACxDA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,yBAAN,eAAqCA,MAAA,YACxBD,MAAAD,SADwBE,KAAW;AAAA;AAAA,EAGrD,YAAY,EAAE,UAAU,sBAAsB,IAA0B,CAAC,GAAG;AAC1E,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAAiD;AACjE,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AChBO,SAAS,gBAAgB,OAA4B;AAC1D,MAAI,SAAS,MAAM;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,OAAO;AAC1B,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,KAAK,UAAU,KAAK;AAC7B;;;ACZA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AASO,IAAM,uBAAN,eAAmCA,MAAA,YACtBD,MAAAD,SADsBE,KAAW;AAAA,EAKnD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,MAAAJ,OAAM,SAAS,MAAM,CAAC;AAbhC,SAAkBG,OAAU;AAe1B,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,OAAO,WAAW,OAA+C;AAC/D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC7BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAUO,IAAM,qBAAN,eAAiCA,MAAA,YACpBD,MAAAD,SADoBE,KAAW;AAAA,EAKjD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,MAAAJ,OAAM,SAAS,mBAAmB,OAAO,IAAI,MAAM,CAAC;AAb9D,SAAkBG,OAAU;AAe1B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,WAAW,OAA6C;AAC7D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC9BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAUO,IAAM,2BAAN,eAAuCA,MAAA,YAC1BD,MAAAD,SAD0BE,KAAW;AAAA,EAKvD,YAAY;AAAA,IACV;AAAA,IACA,UAAU,0BAA0B,KAAK,UAAU,IAAI,CAAC;AAAA,EAC1D,GAGG;AACD,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAXzB,SAAkBG,OAAU;AAa1B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAmD;AACnE,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC3BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AALhC,IAAAE,KAAAC;AAOO,IAAM,iBAAN,eAA6BA,MAAA,YAChBD,MAAAD,SADgBE,KAAW;AAAA,EAK7C,YAAY,EAAE,MAAM,MAAM,GAAqC;AAC7D,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,8BACS,IAAI;AAAA,iBACK,gBAAgB,KAAK,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAZH,SAAkBG,OAAU;AAc1B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAyC;AACzD,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC1BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,kBAAN,eAA8BA,MAAA,YACjBD,MAAAD,SADiBE,KAAW;AAAA;AAAA,EAG9C,YAAY,EAAE,QAAQ,GAAwB;AAC5C,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAA0C;AAC1D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACdA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,mBAAN,eAA+BA,MAAA,YAClBD,MAAAD,SADkBE,KAAW;AAAA;AAAA,EAG/C,YAAY,EAAE,QAAQ,GAAwB;AAC5C,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAA2C;AAC3D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACdA,IAAMI,QAAO;AACb,IAAMC,WAAS,mBAAmBD,KAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AASO,IAAM,0BAAN,eAAsCA,OAAA,YACzBD,OAAAD,UADyBE,MAAW;AAAA;AAAA,EAGtD,YAAY;AAAA,IACV,UAAU;AAAA,EACZ,IAA0B,CAAC,GAAG;AAC5B,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AALzB,SAAkBG,QAAU;AAAA,EAM5B;AAAA,EAEA,OAAO,WAAW,OAAkD;AAClE,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACnBA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,mBAAN,eAA+BA,OAAA,YAClBD,OAAAD,UADkBE,MAAW;AAAA,EAa/C,YAAY;AAAA,IACV,YAAYJ;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,WAAW,SAAS,KAAK,OAAO;AAAA,EAC5C,GAYG;AACD,UAAM,EAAE,MAAM,WAAW,QAAQ,CAAC;AA9BpC,SAAkBG,QAAU;AAgC1B,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,OAAO,WAAW,OAA2C;AAC3D,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;AC5CA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,qCAAN,eAAiDA,OAAA,YACpCD,OAAAD,UADoCE,MAAW;AAAA,EAQjE,YAAY,SAKT;AACD,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,oDACO,QAAQ,QAAQ,WAAW,QAAQ,OAAO,0BAC9C,QAAQ,oBAAoB,yBAAyB,QAAQ,OAAO,MAAM;AAAA,IACjF,CAAC;AAnBH,SAAkBG,QAAU;AAqB1B,SAAK,WAAW,QAAQ;AACxB,SAAK,UAAU,QAAQ;AACvB,SAAK,uBAAuB,QAAQ;AACpC,SAAK,SAAS,QAAQ;AAAA,EACxB;AAAA,EAEA,OAAO,WACL,OAC6C;AAC7C,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACpCA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AALhC,IAAAE,MAAAC;AAwBO,IAAM,sBAAN,MAAM,8BAA4BA,OAAA,YACrBD,OAAAD,UADqBE,MAAW;AAAA,EAMlD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,QAAI,gBAAgB;AAEpB,QAAI,mCAAS,OAAO;AAClB,uBAAiB,QAAQ,QAAQ,KAAK;AAAA,IACxC;AAEA,SAAI,mCAAS,gBAAc,mCAAS,WAAU;AAC5C,uBAAiB;AACjB,YAAM,QAAkB,CAAC;AACzB,UAAI,QAAQ,YAAY;AACtB,cAAM,KAAK,QAAQ,UAAU;AAAA,MAC/B;AACA,UAAI,QAAQ,UAAU;AACpB,cAAM,KAAK,QAAQ,QAAQ,QAAQ,GAAG;AAAA,MACxC;AACA,uBAAiB,MAAM,KAAK,IAAI;AAChC,uBAAiB;AAAA,IACnB;AAEA,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,GAAG,aAAa,YACN,KAAK,UAAU,KAAK,CAAC;AAAA,iBACb,gBAAgB,KAAK,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAxCH,SAAkBG,QAAU;AA0C1B,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAA8C;AAC9D,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,OAAO,KAAK;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIwB;AA9F1B,QAAAE,MAAAC,MAAA;AA+FI,QACE,qBAAoB,WAAW,KAAK,KACpC,MAAM,UAAU,WAChBD,OAAA,MAAM,YAAN,gBAAAA,KAAe,YAAU,mCAAS,YAClCC,OAAA,MAAM,YAAN,gBAAAA,KAAe,iBAAe,mCAAS,iBACvC,WAAM,YAAN,mBAAe,eAAa,mCAAS,WACrC;AACA,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,qBAAoB,EAAE,OAAO,OAAO,QAAQ,CAAC;AAAA,EAC1D;AACF;;;ACzGA,IAAMC,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,gCAAN,eAA4CA,OAAA,YAC/BD,OAAAD,UAD+BE,MAAW;AAAA,EAK5D,YAAY;AAAA,IACV;AAAA,IACA,UAAU,IAAI,aAAa;AAAA,EAC7B,GAGG;AACD,UAAM,EAAE,MAAAJ,QAAM,QAAQ,CAAC;AAXzB,SAAkBG,QAAU;AAY1B,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,OAAO,WAAW,OAAwD;AACxE,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACvBO,SAAS,YAAY,OAAoC;AAC9D,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,WAAW;AAAA,EAChC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,IACpE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAAqC;AAChE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,EACpE;AAEJ;","names":["name","marker","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b"]} \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs b/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..968cbbf10465c65b178a351c0bc4d14b8fb19c48 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs @@ -0,0 +1,404 @@ +// src/errors/ai-sdk-error.ts +var marker = "vercel.ai.error"; +var symbol = Symbol.for(marker); +var _a, _b; +var AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) { + /** + * Creates an AI SDK Error. + * + * @param {Object} params - The parameters for creating the error. + * @param {string} params.name - The name of the error. + * @param {string} params.message - The error message. + * @param {unknown} [params.cause] - The underlying cause of the error. + */ + constructor({ + name: name14, + message, + cause + }) { + super(message); + this[_a] = true; + this.name = name14; + this.cause = cause; + } + /** + * Checks if the given error is an AI SDK Error. + * @param {unknown} error - The error to check. + * @returns {boolean} True if the error is an AI SDK Error, false otherwise. + */ + static isInstance(error) { + return _AISDKError.hasMarker(error, marker); + } + static hasMarker(error, marker15) { + const markerSymbol = Symbol.for(marker15); + return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true; + } +}; + +// src/errors/api-call-error.ts +var name = "AI_APICallError"; +var marker2 = `vercel.ai.error.${name}`; +var symbol2 = Symbol.for(marker2); +var _a2, _b2; +var APICallError = class extends (_b2 = AISDKError, _a2 = symbol2, _b2) { + constructor({ + message, + url, + requestBodyValues, + statusCode, + responseHeaders, + responseBody, + cause, + isRetryable = statusCode != null && (statusCode === 408 || // request timeout + statusCode === 409 || // conflict + statusCode === 429 || // too many requests + statusCode >= 500), + // server error + data + }) { + super({ name, message, cause }); + this[_a2] = true; + this.url = url; + this.requestBodyValues = requestBodyValues; + this.statusCode = statusCode; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + this.isRetryable = isRetryable; + this.data = data; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker2); + } +}; + +// src/errors/empty-response-body-error.ts +var name2 = "AI_EmptyResponseBodyError"; +var marker3 = `vercel.ai.error.${name2}`; +var symbol3 = Symbol.for(marker3); +var _a3, _b3; +var EmptyResponseBodyError = class extends (_b3 = AISDKError, _a3 = symbol3, _b3) { + // used in isInstance + constructor({ message = "Empty response body" } = {}) { + super({ name: name2, message }); + this[_a3] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker3); + } +}; + +// src/errors/get-error-message.ts +function getErrorMessage(error) { + if (error == null) { + return "unknown error"; + } + if (typeof error === "string") { + return error; + } + if (error instanceof Error) { + return error.message; + } + return JSON.stringify(error); +} + +// src/errors/invalid-argument-error.ts +var name3 = "AI_InvalidArgumentError"; +var marker4 = `vercel.ai.error.${name3}`; +var symbol4 = Symbol.for(marker4); +var _a4, _b4; +var InvalidArgumentError = class extends (_b4 = AISDKError, _a4 = symbol4, _b4) { + constructor({ + message, + cause, + argument + }) { + super({ name: name3, message, cause }); + this[_a4] = true; + this.argument = argument; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker4); + } +}; + +// src/errors/invalid-prompt-error.ts +var name4 = "AI_InvalidPromptError"; +var marker5 = `vercel.ai.error.${name4}`; +var symbol5 = Symbol.for(marker5); +var _a5, _b5; +var InvalidPromptError = class extends (_b5 = AISDKError, _a5 = symbol5, _b5) { + constructor({ + prompt, + message, + cause + }) { + super({ name: name4, message: `Invalid prompt: ${message}`, cause }); + this[_a5] = true; + this.prompt = prompt; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker5); + } +}; + +// src/errors/invalid-response-data-error.ts +var name5 = "AI_InvalidResponseDataError"; +var marker6 = `vercel.ai.error.${name5}`; +var symbol6 = Symbol.for(marker6); +var _a6, _b6; +var InvalidResponseDataError = class extends (_b6 = AISDKError, _a6 = symbol6, _b6) { + constructor({ + data, + message = `Invalid response data: ${JSON.stringify(data)}.` + }) { + super({ name: name5, message }); + this[_a6] = true; + this.data = data; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker6); + } +}; + +// src/errors/json-parse-error.ts +var name6 = "AI_JSONParseError"; +var marker7 = `vercel.ai.error.${name6}`; +var symbol7 = Symbol.for(marker7); +var _a7, _b7; +var JSONParseError = class extends (_b7 = AISDKError, _a7 = symbol7, _b7) { + constructor({ text, cause }) { + super({ + name: name6, + message: `JSON parsing failed: Text: ${text}. +Error message: ${getErrorMessage(cause)}`, + cause + }); + this[_a7] = true; + this.text = text; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker7); + } +}; + +// src/errors/load-api-key-error.ts +var name7 = "AI_LoadAPIKeyError"; +var marker8 = `vercel.ai.error.${name7}`; +var symbol8 = Symbol.for(marker8); +var _a8, _b8; +var LoadAPIKeyError = class extends (_b8 = AISDKError, _a8 = symbol8, _b8) { + // used in isInstance + constructor({ message }) { + super({ name: name7, message }); + this[_a8] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker8); + } +}; + +// src/errors/load-setting-error.ts +var name8 = "AI_LoadSettingError"; +var marker9 = `vercel.ai.error.${name8}`; +var symbol9 = Symbol.for(marker9); +var _a9, _b9; +var LoadSettingError = class extends (_b9 = AISDKError, _a9 = symbol9, _b9) { + // used in isInstance + constructor({ message }) { + super({ name: name8, message }); + this[_a9] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker9); + } +}; + +// src/errors/no-content-generated-error.ts +var name9 = "AI_NoContentGeneratedError"; +var marker10 = `vercel.ai.error.${name9}`; +var symbol10 = Symbol.for(marker10); +var _a10, _b10; +var NoContentGeneratedError = class extends (_b10 = AISDKError, _a10 = symbol10, _b10) { + // used in isInstance + constructor({ + message = "No content generated." + } = {}) { + super({ name: name9, message }); + this[_a10] = true; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker10); + } +}; + +// src/errors/no-such-model-error.ts +var name10 = "AI_NoSuchModelError"; +var marker11 = `vercel.ai.error.${name10}`; +var symbol11 = Symbol.for(marker11); +var _a11, _b11; +var NoSuchModelError = class extends (_b11 = AISDKError, _a11 = symbol11, _b11) { + constructor({ + errorName = name10, + modelId, + modelType, + message = `No such ${modelType}: ${modelId}` + }) { + super({ name: errorName, message }); + this[_a11] = true; + this.modelId = modelId; + this.modelType = modelType; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker11); + } +}; + +// src/errors/too-many-embedding-values-for-call-error.ts +var name11 = "AI_TooManyEmbeddingValuesForCallError"; +var marker12 = `vercel.ai.error.${name11}`; +var symbol12 = Symbol.for(marker12); +var _a12, _b12; +var TooManyEmbeddingValuesForCallError = class extends (_b12 = AISDKError, _a12 = symbol12, _b12) { + constructor(options) { + super({ + name: name11, + message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.` + }); + this[_a12] = true; + this.provider = options.provider; + this.modelId = options.modelId; + this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall; + this.values = options.values; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker12); + } +}; + +// src/errors/type-validation-error.ts +var name12 = "AI_TypeValidationError"; +var marker13 = `vercel.ai.error.${name12}`; +var symbol13 = Symbol.for(marker13); +var _a13, _b13; +var TypeValidationError = class _TypeValidationError extends (_b13 = AISDKError, _a13 = symbol13, _b13) { + constructor({ + value, + cause, + context + }) { + let contextPrefix = "Type validation failed"; + if (context == null ? void 0 : context.field) { + contextPrefix += ` for ${context.field}`; + } + if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) { + contextPrefix += " ("; + const parts = []; + if (context.entityName) { + parts.push(context.entityName); + } + if (context.entityId) { + parts.push(`id: "${context.entityId}"`); + } + contextPrefix += parts.join(", "); + contextPrefix += ")"; + } + super({ + name: name12, + message: `${contextPrefix}: Value: ${JSON.stringify(value)}. +Error message: ${getErrorMessage(cause)}`, + cause + }); + this[_a13] = true; + this.value = value; + this.context = context; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker13); + } + /** + * Wraps an error into a TypeValidationError. + * If the cause is already a TypeValidationError with the same value and context, it returns the cause. + * Otherwise, it creates a new TypeValidationError. + * + * @param {Object} params - The parameters for wrapping the error. + * @param {unknown} params.value - The value that failed validation. + * @param {unknown} params.cause - The original error or cause of the validation failure. + * @param {TypeValidationContext} params.context - Optional context about what is being validated. + * @returns {TypeValidationError} A TypeValidationError instance. + */ + static wrap({ + value, + cause, + context + }) { + var _a15, _b15, _c; + if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) { + return cause; + } + return new _TypeValidationError({ value, cause, context }); + } +}; + +// src/errors/unsupported-functionality-error.ts +var name13 = "AI_UnsupportedFunctionalityError"; +var marker14 = `vercel.ai.error.${name13}`; +var symbol14 = Symbol.for(marker14); +var _a14, _b14; +var UnsupportedFunctionalityError = class extends (_b14 = AISDKError, _a14 = symbol14, _b14) { + constructor({ + functionality, + message = `'${functionality}' functionality not supported.` + }) { + super({ name: name13, message }); + this[_a14] = true; + this.functionality = functionality; + } + static isInstance(error) { + return AISDKError.hasMarker(error, marker14); + } +}; + +// src/json-value/is-json.ts +function isJSONValue(value) { + if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") { + return true; + } + if (Array.isArray(value)) { + return value.every(isJSONValue); + } + if (typeof value === "object") { + return Object.entries(value).every( + ([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val)) + ); + } + return false; +} +function isJSONArray(value) { + return Array.isArray(value) && value.every(isJSONValue); +} +function isJSONObject(value) { + return value != null && typeof value === "object" && Object.entries(value).every( + ([key, val]) => typeof key === "string" && (val === void 0 || isJSONValue(val)) + ); +} +export { + AISDKError, + APICallError, + EmptyResponseBodyError, + InvalidArgumentError, + InvalidPromptError, + InvalidResponseDataError, + JSONParseError, + LoadAPIKeyError, + LoadSettingError, + NoContentGeneratedError, + NoSuchModelError, + TooManyEmbeddingValuesForCallError, + TypeValidationError, + UnsupportedFunctionalityError, + getErrorMessage, + isJSONArray, + isJSONObject, + isJSONValue +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs.map b/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..715c116ceefe87d5aa0ff2510b8f488310663aa1 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/dist/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/errors/ai-sdk-error.ts","../src/errors/api-call-error.ts","../src/errors/empty-response-body-error.ts","../src/errors/get-error-message.ts","../src/errors/invalid-argument-error.ts","../src/errors/invalid-prompt-error.ts","../src/errors/invalid-response-data-error.ts","../src/errors/json-parse-error.ts","../src/errors/load-api-key-error.ts","../src/errors/load-setting-error.ts","../src/errors/no-content-generated-error.ts","../src/errors/no-such-model-error.ts","../src/errors/too-many-embedding-values-for-call-error.ts","../src/errors/type-validation-error.ts","../src/errors/unsupported-functionality-error.ts","../src/json-value/is-json.ts"],"sourcesContent":["/**\n * Symbol used for identifying AI SDK Error instances.\n * Enables checking if an error is an instance of AISDKError across package versions.\n */\nconst marker = 'vercel.ai.error';\nconst symbol = Symbol.for(marker);\n\n/**\n * Custom error class for AI SDK related errors.\n * @extends Error\n */\nexport class AISDKError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n /**\n * The underlying cause of the error, if any.\n */\n readonly cause?: unknown;\n\n /**\n * Creates an AI SDK Error.\n *\n * @param {Object} params - The parameters for creating the error.\n * @param {string} params.name - The name of the error.\n * @param {string} params.message - The error message.\n * @param {unknown} [params.cause] - The underlying cause of the error.\n */\n constructor({\n name,\n message,\n cause,\n }: {\n name: string;\n message: string;\n cause?: unknown;\n }) {\n super(message);\n\n this.name = name;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is an AI SDK Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n */\n static isInstance(error: unknown): error is AISDKError {\n return AISDKError.hasMarker(error, marker);\n }\n\n protected static hasMarker(error: unknown, marker: string): boolean {\n const markerSymbol = Symbol.for(marker);\n return (\n error != null &&\n typeof error === 'object' &&\n markerSymbol in error &&\n typeof error[markerSymbol] === 'boolean' &&\n error[markerSymbol] === true\n );\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_APICallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class APICallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly url: string;\n readonly requestBodyValues: unknown;\n readonly statusCode?: number;\n\n readonly responseHeaders?: Record;\n readonly responseBody?: string;\n\n readonly isRetryable: boolean;\n readonly data?: unknown;\n\n constructor({\n message,\n url,\n requestBodyValues,\n statusCode,\n responseHeaders,\n responseBody,\n cause,\n isRetryable = statusCode != null &&\n (statusCode === 408 || // request timeout\n statusCode === 409 || // conflict\n statusCode === 429 || // too many requests\n statusCode >= 500), // server error\n data,\n }: {\n message: string;\n url: string;\n requestBodyValues: unknown;\n statusCode?: number;\n responseHeaders?: Record;\n responseBody?: string;\n cause?: unknown;\n isRetryable?: boolean;\n data?: unknown;\n }) {\n super({ name, message, cause });\n\n this.url = url;\n this.requestBodyValues = requestBodyValues;\n this.statusCode = statusCode;\n this.responseHeaders = responseHeaders;\n this.responseBody = responseBody;\n this.isRetryable = isRetryable;\n this.data = data;\n }\n\n static isInstance(error: unknown): error is APICallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_EmptyResponseBodyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class EmptyResponseBodyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message = 'Empty response body' }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is EmptyResponseBodyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","export function getErrorMessage(error: unknown | undefined) {\n if (error == null) {\n return 'unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return JSON.stringify(error);\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidArgumentError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A function argument is invalid.\n */\nexport class InvalidArgumentError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly argument: string;\n\n constructor({\n message,\n cause,\n argument,\n }: {\n argument: string;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message, cause });\n\n this.argument = argument;\n }\n\n static isInstance(error: unknown): error is InvalidArgumentError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidPromptError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A prompt is invalid. This error should be thrown by providers when they cannot\n * process a prompt.\n */\nexport class InvalidPromptError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly prompt: unknown;\n\n constructor({\n prompt,\n message,\n cause,\n }: {\n prompt: unknown;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message: `Invalid prompt: ${message}`, cause });\n\n this.prompt = prompt;\n }\n\n static isInstance(error: unknown): error is InvalidPromptError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidResponseDataError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Server returned a response with invalid data content.\n * This should be thrown by providers when they cannot parse the response from the API.\n */\nexport class InvalidResponseDataError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly data: unknown;\n\n constructor({\n data,\n message = `Invalid response data: ${JSON.stringify(data)}.`,\n }: {\n data: unknown;\n message?: string;\n }) {\n super({ name, message });\n\n this.data = data;\n }\n\n static isInstance(error: unknown): error is InvalidResponseDataError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_JSONParseError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class JSONParseError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly text: string;\n\n constructor({ text, cause }: { text: string; cause: unknown }) {\n super({\n name,\n message:\n `JSON parsing failed: ` +\n `Text: ${text}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.text = text;\n }\n\n static isInstance(error: unknown): error is JSONParseError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadAPIKeyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadAPIKeyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadAPIKeyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadSettingError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadSettingError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadSettingError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoContentGeneratedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Thrown when the AI provider fails to generate any content.\n */\nexport class NoContentGeneratedError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({\n message = 'No content generated.',\n }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is NoContentGeneratedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoSuchModelError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class NoSuchModelError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly modelId: string;\n readonly modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel'\n | 'videoModel';\n\n constructor({\n errorName = name,\n modelId,\n modelType,\n message = `No such ${modelType}: ${modelId}`,\n }: {\n errorName?: string;\n modelId: string;\n modelType:\n | 'languageModel'\n | 'embeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel'\n | 'rerankingModel'\n | 'videoModel';\n message?: string;\n }) {\n super({ name: errorName, message });\n\n this.modelId = modelId;\n this.modelType = modelType;\n }\n\n static isInstance(error: unknown): error is NoSuchModelError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_TooManyEmbeddingValuesForCallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TooManyEmbeddingValuesForCallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly provider: string;\n readonly modelId: string;\n readonly maxEmbeddingsPerCall: number;\n readonly values: Array;\n\n constructor(options: {\n provider: string;\n modelId: string;\n maxEmbeddingsPerCall: number;\n values: Array;\n }) {\n super({\n name,\n message:\n `Too many values for a single embedding call. ` +\n `The ${options.provider} model \"${options.modelId}\" can only embed up to ` +\n `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,\n });\n\n this.provider = options.provider;\n this.modelId = options.modelId;\n this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n this.values = options.values;\n }\n\n static isInstance(\n error: unknown,\n ): error is TooManyEmbeddingValuesForCallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_TypeValidationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport interface TypeValidationContext {\n /**\n * Field path in dot notation (e.g., \"message.metadata\", \"message.parts[3].data\")\n */\n field?: string;\n\n /**\n * Entity name (e.g., tool name, data type name)\n */\n entityName?: string;\n\n /**\n * Entity identifier (e.g., message ID, tool call ID)\n */\n entityId?: string;\n}\n\nexport class TypeValidationError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly value: unknown;\n readonly context?: TypeValidationContext;\n\n constructor({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }) {\n let contextPrefix = 'Type validation failed';\n\n if (context?.field) {\n contextPrefix += ` for ${context.field}`;\n }\n\n if (context?.entityName || context?.entityId) {\n contextPrefix += ' (';\n const parts: string[] = [];\n if (context.entityName) {\n parts.push(context.entityName);\n }\n if (context.entityId) {\n parts.push(`id: \"${context.entityId}\"`);\n }\n contextPrefix += parts.join(', ');\n contextPrefix += ')';\n }\n\n super({\n name,\n message:\n `${contextPrefix}: ` +\n `Value: ${JSON.stringify(value)}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.value = value;\n this.context = context;\n }\n\n static isInstance(error: unknown): error is TypeValidationError {\n return AISDKError.hasMarker(error, marker);\n }\n\n /**\n * Wraps an error into a TypeValidationError.\n * If the cause is already a TypeValidationError with the same value and context, it returns the cause.\n * Otherwise, it creates a new TypeValidationError.\n *\n * @param {Object} params - The parameters for wrapping the error.\n * @param {unknown} params.value - The value that failed validation.\n * @param {unknown} params.cause - The original error or cause of the validation failure.\n * @param {TypeValidationContext} params.context - Optional context about what is being validated.\n * @returns {TypeValidationError} A TypeValidationError instance.\n */\n static wrap({\n value,\n cause,\n context,\n }: {\n value: unknown;\n cause: unknown;\n context?: TypeValidationContext;\n }): TypeValidationError {\n if (\n TypeValidationError.isInstance(cause) &&\n cause.value === value &&\n cause.context?.field === context?.field &&\n cause.context?.entityName === context?.entityName &&\n cause.context?.entityId === context?.entityId\n ) {\n return cause;\n }\n\n return new TypeValidationError({ value, cause, context });\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_UnsupportedFunctionalityError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class UnsupportedFunctionalityError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly functionality: string;\n\n constructor({\n functionality,\n message = `'${functionality}' functionality not supported.`,\n }: {\n functionality: string;\n message?: string;\n }) {\n super({ name, message });\n this.functionality = functionality;\n }\n\n static isInstance(error: unknown): error is UnsupportedFunctionalityError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { JSONArray, JSONObject, JSONValue } from './json-value';\n\nexport function isJSONValue(value: unknown): value is JSONValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.every(isJSONValue);\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is JSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is JSONObject {\n return (\n value != null &&\n typeof value === 'object' &&\n Object.entries(value).every(\n ([key, val]) =>\n typeof key === 'string' && (val === undefined || isJSONValue(val)),\n )\n );\n}\n"],"mappings":";AAIA,IAAM,SAAS;AACf,IAAM,SAAS,OAAO,IAAI,MAAM;AALhC;AAWO,IAAM,aAAN,MAAM,qBAAmB,YACZ,aADY,IAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBpC,YAAY;AAAA,IACV,MAAAA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,OAAO;AAxBf,SAAkB,MAAU;AA0B1B,SAAK,OAAOA;AACZ,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,WAAW,OAAqC;AACrD,WAAO,YAAW,UAAU,OAAO,MAAM;AAAA,EAC3C;AAAA,EAEA,OAAiB,UAAU,OAAgBC,UAAyB;AAClE,UAAM,eAAe,OAAO,IAAIA,QAAM;AACtC,WACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,OAAO,MAAM,YAAY,MAAM,aAC/B,MAAM,YAAY,MAAM;AAAA,EAE5B;AACF;;;AC3DA,IAAM,OAAO;AACb,IAAMC,UAAS,mBAAmB,IAAI;AACtC,IAAMC,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,eAAN,eAA2BA,MAAA,YACdD,MAAAD,SADcE,KAAW;AAAA,EAa3C,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,cAAc,SACzB,eAAe;AAAA,IACd,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA;AAAA,IAClB;AAAA,EACF,GAUG;AACD,UAAM,EAAE,MAAM,SAAS,MAAM,CAAC;AArChC,SAAkBD,OAAU;AAuC1B,SAAK,MAAM;AACX,SAAK,oBAAoB;AACzB,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,eAAe;AACpB,SAAK,cAAc;AACnB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAuC;AACvD,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACxDA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,yBAAN,eAAqCA,MAAA,YACxBD,MAAAD,SADwBE,KAAW;AAAA;AAAA,EAGrD,YAAY,EAAE,UAAU,sBAAsB,IAA0B,CAAC,GAAG;AAC1E,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAAiD;AACjE,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AChBO,SAAS,gBAAgB,OAA4B;AAC1D,MAAI,SAAS,MAAM;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,OAAO;AAC1B,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,KAAK,UAAU,KAAK;AAC7B;;;ACZA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AASO,IAAM,uBAAN,eAAmCA,MAAA,YACtBD,MAAAD,SADsBE,KAAW;AAAA,EAKnD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,MAAAJ,OAAM,SAAS,MAAM,CAAC;AAbhC,SAAkBG,OAAU;AAe1B,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,OAAO,WAAW,OAA+C;AAC/D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC7BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAUO,IAAM,qBAAN,eAAiCA,MAAA,YACpBD,MAAAD,SADoBE,KAAW;AAAA,EAKjD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,EAAE,MAAAJ,OAAM,SAAS,mBAAmB,OAAO,IAAI,MAAM,CAAC;AAb9D,SAAkBG,OAAU;AAe1B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,WAAW,OAA6C;AAC7D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC9BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAUO,IAAM,2BAAN,eAAuCA,MAAA,YAC1BD,MAAAD,SAD0BE,KAAW;AAAA,EAKvD,YAAY;AAAA,IACV;AAAA,IACA,UAAU,0BAA0B,KAAK,UAAU,IAAI,CAAC;AAAA,EAC1D,GAGG;AACD,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAXzB,SAAkBG,OAAU;AAa1B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAmD;AACnE,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC3BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AALhC,IAAAE,KAAAC;AAOO,IAAM,iBAAN,eAA6BA,MAAA,YAChBD,MAAAD,SADgBE,KAAW;AAAA,EAK7C,YAAY,EAAE,MAAM,MAAM,GAAqC;AAC7D,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,8BACS,IAAI;AAAA,iBACK,gBAAgB,KAAK,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAZH,SAAkBG,OAAU;AAc1B,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,WAAW,OAAyC;AACzD,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;AC1BA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,kBAAN,eAA8BA,MAAA,YACjBD,MAAAD,SADiBE,KAAW;AAAA;AAAA,EAG9C,YAAY,EAAE,QAAQ,GAAwB;AAC5C,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAA0C;AAC1D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACdA,IAAMI,QAAO;AACb,IAAMC,UAAS,mBAAmBD,KAAI;AACtC,IAAME,UAAS,OAAO,IAAID,OAAM;AAJhC,IAAAE,KAAAC;AAMO,IAAM,mBAAN,eAA+BA,MAAA,YAClBD,MAAAD,SADkBE,KAAW;AAAA;AAAA,EAG/C,YAAY,EAAE,QAAQ,GAAwB;AAC5C,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AAHzB,SAAkBG,OAAU;AAAA,EAI5B;AAAA,EAEA,OAAO,WAAW,OAA2C;AAC3D,WAAO,WAAW,UAAU,OAAOF,OAAM;AAAA,EAC3C;AACF;;;ACdA,IAAMI,QAAO;AACb,IAAMC,WAAS,mBAAmBD,KAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AASO,IAAM,0BAAN,eAAsCA,OAAA,YACzBD,OAAAD,UADyBE,MAAW;AAAA;AAAA,EAGtD,YAAY;AAAA,IACV,UAAU;AAAA,EACZ,IAA0B,CAAC,GAAG;AAC5B,UAAM,EAAE,MAAAJ,OAAM,QAAQ,CAAC;AALzB,SAAkBG,QAAU;AAAA,EAM5B;AAAA,EAEA,OAAO,WAAW,OAAkD;AAClE,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACnBA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,mBAAN,eAA+BA,OAAA,YAClBD,OAAAD,UADkBE,MAAW;AAAA,EAa/C,YAAY;AAAA,IACV,YAAYJ;AAAA,IACZ;AAAA,IACA;AAAA,IACA,UAAU,WAAW,SAAS,KAAK,OAAO;AAAA,EAC5C,GAYG;AACD,UAAM,EAAE,MAAM,WAAW,QAAQ,CAAC;AA9BpC,SAAkBG,QAAU;AAgC1B,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,OAAO,WAAW,OAA2C;AAC3D,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;AC5CA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,qCAAN,eAAiDA,OAAA,YACpCD,OAAAD,UADoCE,MAAW;AAAA,EAQjE,YAAY,SAKT;AACD,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,oDACO,QAAQ,QAAQ,WAAW,QAAQ,OAAO,0BAC9C,QAAQ,oBAAoB,yBAAyB,QAAQ,OAAO,MAAM;AAAA,IACjF,CAAC;AAnBH,SAAkBG,QAAU;AAqB1B,SAAK,WAAW,QAAQ;AACxB,SAAK,UAAU,QAAQ;AACvB,SAAK,uBAAuB,QAAQ;AACpC,SAAK,SAAS,QAAQ;AAAA,EACxB;AAAA,EAEA,OAAO,WACL,OAC6C;AAC7C,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACpCA,IAAMI,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AALhC,IAAAE,MAAAC;AAwBO,IAAM,sBAAN,MAAM,8BAA4BA,OAAA,YACrBD,OAAAD,UADqBE,MAAW;AAAA,EAMlD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,QAAI,gBAAgB;AAEpB,QAAI,mCAAS,OAAO;AAClB,uBAAiB,QAAQ,QAAQ,KAAK;AAAA,IACxC;AAEA,SAAI,mCAAS,gBAAc,mCAAS,WAAU;AAC5C,uBAAiB;AACjB,YAAM,QAAkB,CAAC;AACzB,UAAI,QAAQ,YAAY;AACtB,cAAM,KAAK,QAAQ,UAAU;AAAA,MAC/B;AACA,UAAI,QAAQ,UAAU;AACpB,cAAM,KAAK,QAAQ,QAAQ,QAAQ,GAAG;AAAA,MACxC;AACA,uBAAiB,MAAM,KAAK,IAAI;AAChC,uBAAiB;AAAA,IACnB;AAEA,UAAM;AAAA,MACJ,MAAAJ;AAAA,MACA,SACE,GAAG,aAAa,YACN,KAAK,UAAU,KAAK,CAAC;AAAA,iBACb,gBAAgB,KAAK,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAxCH,SAAkBG,QAAU;AA0C1B,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAA8C;AAC9D,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,OAAO,KAAK;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIwB;AA9F1B,QAAAE,MAAAC,MAAA;AA+FI,QACE,qBAAoB,WAAW,KAAK,KACpC,MAAM,UAAU,WAChBD,OAAA,MAAM,YAAN,gBAAAA,KAAe,YAAU,mCAAS,YAClCC,OAAA,MAAM,YAAN,gBAAAA,KAAe,iBAAe,mCAAS,iBACvC,WAAM,YAAN,mBAAe,eAAa,mCAAS,WACrC;AACA,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,qBAAoB,EAAE,OAAO,OAAO,QAAQ,CAAC;AAAA,EAC1D;AACF;;;ACzGA,IAAMC,SAAO;AACb,IAAMC,WAAS,mBAAmBD,MAAI;AACtC,IAAME,WAAS,OAAO,IAAID,QAAM;AAJhC,IAAAE,MAAAC;AAMO,IAAM,gCAAN,eAA4CA,OAAA,YAC/BD,OAAAD,UAD+BE,MAAW;AAAA,EAK5D,YAAY;AAAA,IACV;AAAA,IACA,UAAU,IAAI,aAAa;AAAA,EAC7B,GAGG;AACD,UAAM,EAAE,MAAAJ,QAAM,QAAQ,CAAC;AAXzB,SAAkBG,QAAU;AAY1B,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,OAAO,WAAW,OAAwD;AACxE,WAAO,WAAW,UAAU,OAAOF,QAAM;AAAA,EAC3C;AACF;;;ACvBO,SAAS,YAAY,OAAoC;AAC9D,MACE,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WACjB;AACA,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,MAAM,WAAW;AAAA,EAChC;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,IACpE;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,WAAW;AACxD;AAEO,SAAS,aAAa,OAAqC;AAChE,SACE,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,QAAQ,KAAK,EAAE;AAAA,IACpB,CAAC,CAAC,KAAK,GAAG,MACR,OAAO,QAAQ,aAAa,QAAQ,UAAa,YAAY,GAAG;AAAA,EACpE;AAEJ;","names":["name","marker","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b","name","marker","symbol","_a","_b"]} \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/package.json b/.opencode/node_modules/@ai-sdk/provider/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6cbb699e388ea20de5e84604b99b4357ac0c35fd --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/package.json @@ -0,0 +1,63 @@ +{ + "name": "@ai-sdk/provider", + "version": "3.0.8", + "license": "Apache-2.0", + "sideEffects": false, + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "source": "./src/index.ts", + "files": [ + "dist/**/*", + "src", + "!src/**/*.test.ts", + "!src/**/*.test-d.ts", + "!src/**/__snapshots__", + "!src/**/__fixtures__", + "CHANGELOG.md", + "README.md" + ], + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, + "dependencies": { + "json-schema": "^0.4.0" + }, + "devDependencies": { + "@types/json-schema": "7.0.15", + "@types/node": "20.17.24", + "tsup": "^8", + "typescript": "5.8.3", + "@vercel/ai-tsconfig": "0.0.0" + }, + "engines": { + "node": ">=18" + }, + "publishConfig": { + "access": "public" + }, + "homepage": "https://ai-sdk.dev/docs", + "repository": { + "type": "git", + "url": "git+https://github.com/vercel/ai.git" + }, + "bugs": { + "url": "https://github.com/vercel/ai/issues" + }, + "keywords": [ + "ai" + ], + "scripts": { + "build": "pnpm clean && tsup --tsconfig tsconfig.build.json", + "build:watch": "pnpm clean && tsup --watch", + "clean": "del-cli dist *.tsbuildinfo", + "lint": "eslint \"./**/*.ts*\"", + "type-check": "tsc --build", + "prettier-check": "prettier --check \"./**/*.ts*\"" + } +} \ No newline at end of file diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca7b39f383953b48e9cfa5ce7b044ce0e74c7cfe --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/index.ts @@ -0,0 +1 @@ +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/embedding-model-v3-middleware.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/embedding-model-v3-middleware.ts new file mode 100644 index 0000000000000000000000000000000000000000..c98f6c38481dd88ccb4d0c4af8138ce8ec10b72e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/embedding-model-v3-middleware.ts @@ -0,0 +1,69 @@ +import { EmbeddingModelV3 } from '../../embedding-model/v3/embedding-model-v3'; +import { EmbeddingModelV3CallOptions } from '../../embedding-model/v3/embedding-model-v3-call-options'; + +/** + * Middleware for EmbeddingModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of EmbeddingModelV3 operations. + */ +export type EmbeddingModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + + /** + * Override the provider name if desired. + * @param options.model - The embedding model instance. + */ + overrideProvider?: (options: { model: EmbeddingModelV3 }) => string; + + /** + * Override the model ID if desired. + * @param options.model - The embedding model instance. + */ + overrideModelId?: (options: { model: EmbeddingModelV3 }) => string; + + /** + * Override the limit of how many embeddings can be generated in a single API call if desired. + * @param options.model - The embedding model instance. + */ + overrideMaxEmbeddingsPerCall?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | number | undefined; + + /** + * Override support for handling multiple embedding calls in parallel, if desired.. + * @param options.model - The embedding model instance. + */ + overrideSupportsParallelCalls?: (options: { + model: EmbeddingModelV3; + }) => PromiseLike | boolean; + + /** + * Transforms the parameters before they are passed to the embed model. + * @param options - Object containing the type of operation and the parameters. + * @param options.params - The original parameters for the embedding model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => PromiseLike; + + /** + * Wraps the embed operation of the embedding model. + * + * @param options - Object containing the embed function, parameters, and model. + * @param options.doEmbed - The original embed function. + * @param options.params - The parameters for the embed call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The embedding model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapEmbed?: (options: { + doEmbed: () => ReturnType; + params: EmbeddingModelV3CallOptions; + model: EmbeddingModelV3; + }) => Promise>>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..00203ebeee90ab30cace2e22cb632b86ab1b6785 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model-middleware/v3/index.ts @@ -0,0 +1 @@ +export * from './embedding-model-v3-middleware'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2-embedding.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2-embedding.ts new file mode 100644 index 0000000000000000000000000000000000000000..b6800300f41fed04cb5fca3582e27850a96dce64 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2-embedding.ts @@ -0,0 +1,5 @@ +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +export type EmbeddingModelV2Embedding = Array; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..4129bde0dcaec381895855db2ddef64a347c67c8 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/embedding-model-v2.ts @@ -0,0 +1,113 @@ +import { + SharedV2Headers, + SharedV2ProviderOptions, + SharedV2ProviderMetadata, +} from '../../shared'; +import { EmbeddingModelV2Embedding } from './embedding-model-v2-embedding'; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 2. + * + * VALUE is the type of the values that the model can embed. + * This will allow us to go beyond text embeddings in the future, + * e.g. to support image embeddings + */ +export type EmbeddingModelV2 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: + | PromiseLike + | number + | undefined; + + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed(options: { + /** + * List of values to embed. + */ + values: Array; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + }): PromiseLike<{ + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { tokens: number }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + + /** + * The response body. + */ + body?: unknown; + }; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca4d0c8d9538978527cddced9a61791d039594b4 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v2/index.ts @@ -0,0 +1,2 @@ +export * from './embedding-model-v2'; +export * from './embedding-model-v2-embedding'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2f9e362e4e951a78c42dc9369fbc97a1232617e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-call-options.ts @@ -0,0 +1,26 @@ +import { SharedV3Headers, SharedV3ProviderOptions } from '../../shared'; + +export type EmbeddingModelV3CallOptions = { + /** + * List of text values to generate embeddings for. + */ + values: Array; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-embedding.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-embedding.ts new file mode 100644 index 0000000000000000000000000000000000000000..1060a44410ac2cb4724377fe837406668eab3e61 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-embedding.ts @@ -0,0 +1,5 @@ +/** + * An embedding is a vector, i.e. an array of numbers. + * It is e.g. used to represent a text as a vector of word embeddings. + */ +export type EmbeddingModelV3Embedding = Array; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-result.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..8407871fc043aae2d271525ed50a7183542e7150 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3-result.ts @@ -0,0 +1,48 @@ +import { + SharedV3Headers, + SharedV3ProviderMetadata, + SharedV3Warning, +} from '../../shared'; +import { EmbeddingModelV3Embedding } from './embedding-model-v3-embedding'; + +/** + * The result of a embedding model doEmbed call. + */ +export type EmbeddingModelV3Result = { + /** + * Generated embeddings. They are in the same order as the input values. + */ + embeddings: Array; + + /** + * Token usage. We only have input tokens for embeddings. + */ + usage?: { tokens: number }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + + /** + * The response body. + */ + body?: unknown; + }; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba7762586b0f114892f482120674c448e17f0d7f --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/embedding-model-v3.ts @@ -0,0 +1,54 @@ +import { EmbeddingModelV3CallOptions } from './embedding-model-v3-call-options'; +import { EmbeddingModelV3Result } from './embedding-model-v3-result'; + +/** + * Specification for an embedding model that implements the embedding model + * interface version 3. + * + * It is specific to text embeddings. + */ +export type EmbeddingModelV3 = { + /** + * The embedding model must specify which embedding model interface + * version it implements. This will allow us to evolve the embedding + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Limit of how many embeddings can be generated in a single API call. + * + * Use Infinity for models that do not have a limit. + */ + readonly maxEmbeddingsPerCall: + | PromiseLike + | number + | undefined; + + /** + * True if the model can handle multiple embedding calls in parallel. + */ + readonly supportsParallelCalls: PromiseLike | boolean; + + /** + * Generates a list of embeddings for the given input text. + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doEmbed( + options: EmbeddingModelV3CallOptions, + ): PromiseLike; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..243f4851494a6a6ad7ab2b72020284f79969817f --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/embedding-model/v3/index.ts @@ -0,0 +1,4 @@ +export * from './embedding-model-v3'; +export * from './embedding-model-v3-call-options'; +export * from './embedding-model-v3-embedding'; +export * from './embedding-model-v3-result'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/ai-sdk-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/ai-sdk-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..f23b9b3b91c3e2259a92f3579722911e413c6165 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/ai-sdk-error.ts @@ -0,0 +1,62 @@ +/** + * Symbol used for identifying AI SDK Error instances. + * Enables checking if an error is an instance of AISDKError across package versions. + */ +const marker = 'vercel.ai.error'; +const symbol = Symbol.for(marker); + +/** + * Custom error class for AI SDK related errors. + * @extends Error + */ +export class AISDKError extends Error { + private readonly [symbol] = true; // used in isInstance + + /** + * The underlying cause of the error, if any. + */ + readonly cause?: unknown; + + /** + * Creates an AI SDK Error. + * + * @param {Object} params - The parameters for creating the error. + * @param {string} params.name - The name of the error. + * @param {string} params.message - The error message. + * @param {unknown} [params.cause] - The underlying cause of the error. + */ + constructor({ + name, + message, + cause, + }: { + name: string; + message: string; + cause?: unknown; + }) { + super(message); + + this.name = name; + this.cause = cause; + } + + /** + * Checks if the given error is an AI SDK Error. + * @param {unknown} error - The error to check. + * @returns {boolean} True if the error is an AI SDK Error, false otherwise. + */ + static isInstance(error: unknown): error is AISDKError { + return AISDKError.hasMarker(error, marker); + } + + protected static hasMarker(error: unknown, marker: string): boolean { + const markerSymbol = Symbol.for(marker); + return ( + error != null && + typeof error === 'object' && + markerSymbol in error && + typeof error[markerSymbol] === 'boolean' && + error[markerSymbol] === true + ); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/api-call-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/api-call-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..1423c05cf405e14fbec1e85eb16786ee10ebf234 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/api-call-error.ts @@ -0,0 +1,59 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_APICallError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class APICallError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly url: string; + readonly requestBodyValues: unknown; + readonly statusCode?: number; + + readonly responseHeaders?: Record; + readonly responseBody?: string; + + readonly isRetryable: boolean; + readonly data?: unknown; + + constructor({ + message, + url, + requestBodyValues, + statusCode, + responseHeaders, + responseBody, + cause, + isRetryable = statusCode != null && + (statusCode === 408 || // request timeout + statusCode === 409 || // conflict + statusCode === 429 || // too many requests + statusCode >= 500), // server error + data, + }: { + message: string; + url: string; + requestBodyValues: unknown; + statusCode?: number; + responseHeaders?: Record; + responseBody?: string; + cause?: unknown; + isRetryable?: boolean; + data?: unknown; + }) { + super({ name, message, cause }); + + this.url = url; + this.requestBodyValues = requestBodyValues; + this.statusCode = statusCode; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + this.isRetryable = isRetryable; + this.data = data; + } + + static isInstance(error: unknown): error is APICallError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/empty-response-body-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/empty-response-body-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..a20e0bacab22cb13bbf4c70bb47c947700790bc0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/empty-response-body-error.ts @@ -0,0 +1,17 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_EmptyResponseBodyError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class EmptyResponseBodyError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + constructor({ message = 'Empty response body' }: { message?: string } = {}) { + super({ name, message }); + } + + static isInstance(error: unknown): error is EmptyResponseBodyError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/get-error-message.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/get-error-message.ts new file mode 100644 index 0000000000000000000000000000000000000000..62c29e58a51c501005c84095c84b447ba5ee9435 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/get-error-message.ts @@ -0,0 +1,15 @@ +export function getErrorMessage(error: unknown | undefined) { + if (error == null) { + return 'unknown error'; + } + + if (typeof error === 'string') { + return error; + } + + if (error instanceof Error) { + return error.message; + } + + return JSON.stringify(error); +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e7d4825192a863918fbe7c5165b53420e90ebe5 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/index.ts @@ -0,0 +1,16 @@ +export { AISDKError } from './ai-sdk-error'; +export { APICallError } from './api-call-error'; +export { EmptyResponseBodyError } from './empty-response-body-error'; +export { getErrorMessage } from './get-error-message'; +export { InvalidArgumentError } from './invalid-argument-error'; +export { InvalidPromptError } from './invalid-prompt-error'; +export { InvalidResponseDataError } from './invalid-response-data-error'; +export { JSONParseError } from './json-parse-error'; +export { LoadAPIKeyError } from './load-api-key-error'; +export { LoadSettingError } from './load-setting-error'; +export { NoContentGeneratedError } from './no-content-generated-error'; +export { NoSuchModelError } from './no-such-model-error'; +export { TooManyEmbeddingValuesForCallError } from './too-many-embedding-values-for-call-error'; +export type { TypeValidationContext } from './type-validation-error'; +export { TypeValidationError } from './type-validation-error'; +export { UnsupportedFunctionalityError } from './unsupported-functionality-error'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-argument-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-argument-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..afdaa47a0e44222d3abe31242f39cccf3422d50e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-argument-error.ts @@ -0,0 +1,32 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_InvalidArgumentError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +/** + * A function argument is invalid. + */ +export class InvalidArgumentError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly argument: string; + + constructor({ + message, + cause, + argument, + }: { + argument: string; + message: string; + cause?: unknown; + }) { + super({ name, message, cause }); + + this.argument = argument; + } + + static isInstance(error: unknown): error is InvalidArgumentError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-prompt-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-prompt-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e969887ed8328ac1f6a25c54fedb87d6258f9c7 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-prompt-error.ts @@ -0,0 +1,33 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_InvalidPromptError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +/** + * A prompt is invalid. This error should be thrown by providers when they cannot + * process a prompt. + */ +export class InvalidPromptError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly prompt: unknown; + + constructor({ + prompt, + message, + cause, + }: { + prompt: unknown; + message: string; + cause?: unknown; + }) { + super({ name, message: `Invalid prompt: ${message}`, cause }); + + this.prompt = prompt; + } + + static isInstance(error: unknown): error is InvalidPromptError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-response-data-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-response-data-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..20da724183f901c003ca223fc9d40b7bba5c41e8 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/invalid-response-data-error.ts @@ -0,0 +1,31 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_InvalidResponseDataError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +/** + * Server returned a response with invalid data content. + * This should be thrown by providers when they cannot parse the response from the API. + */ +export class InvalidResponseDataError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly data: unknown; + + constructor({ + data, + message = `Invalid response data: ${JSON.stringify(data)}.`, + }: { + data: unknown; + message?: string; + }) { + super({ name, message }); + + this.data = data; + } + + static isInstance(error: unknown): error is InvalidResponseDataError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/json-parse-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/json-parse-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a39eca800a2d11efdf57a9256e92fcb0e3aaa06 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/json-parse-error.ts @@ -0,0 +1,29 @@ +import { AISDKError } from './ai-sdk-error'; +import { getErrorMessage } from './get-error-message'; + +const name = 'AI_JSONParseError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class JSONParseError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly text: string; + + constructor({ text, cause }: { text: string; cause: unknown }) { + super({ + name, + message: + `JSON parsing failed: ` + + `Text: ${text}.\n` + + `Error message: ${getErrorMessage(cause)}`, + cause, + }); + + this.text = text; + } + + static isInstance(error: unknown): error is JSONParseError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/load-api-key-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/load-api-key-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa73983a3212fa9ac462d8cacf2c87e8dafc87d2 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/load-api-key-error.ts @@ -0,0 +1,17 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_LoadAPIKeyError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class LoadAPIKeyError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + constructor({ message }: { message: string }) { + super({ name, message }); + } + + static isInstance(error: unknown): error is LoadAPIKeyError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/load-setting-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/load-setting-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2b07553ff57fcd9791686757565c1bfdce8ad95 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/load-setting-error.ts @@ -0,0 +1,17 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_LoadSettingError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class LoadSettingError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + constructor({ message }: { message: string }) { + super({ name, message }); + } + + static isInstance(error: unknown): error is LoadSettingError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/no-content-generated-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/no-content-generated-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..680a30d6469a0a5b69099310c905d6eeb8bc0a25 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/no-content-generated-error.ts @@ -0,0 +1,22 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_NoContentGeneratedError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +/** + * Thrown when the AI provider fails to generate any content. + */ +export class NoContentGeneratedError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + constructor({ + message = 'No content generated.', + }: { message?: string } = {}) { + super({ name, message }); + } + + static isInstance(error: unknown): error is NoContentGeneratedError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/no-such-model-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/no-such-model-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..252ff96b8c48a3b5fc813d675c30242d334a37c0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/no-such-model-error.ts @@ -0,0 +1,47 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_NoSuchModelError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class NoSuchModelError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly modelId: string; + readonly modelType: + | 'languageModel' + | 'embeddingModel' + | 'imageModel' + | 'transcriptionModel' + | 'speechModel' + | 'rerankingModel' + | 'videoModel'; + + constructor({ + errorName = name, + modelId, + modelType, + message = `No such ${modelType}: ${modelId}`, + }: { + errorName?: string; + modelId: string; + modelType: + | 'languageModel' + | 'embeddingModel' + | 'imageModel' + | 'transcriptionModel' + | 'speechModel' + | 'rerankingModel' + | 'videoModel'; + message?: string; + }) { + super({ name: errorName, message }); + + this.modelId = modelId; + this.modelType = modelType; + } + + static isInstance(error: unknown): error is NoSuchModelError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/too-many-embedding-values-for-call-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/too-many-embedding-values-for-call-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..17b6c26fc90907ffa2d65968e643de407358d98b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/too-many-embedding-values-for-call-error.ts @@ -0,0 +1,40 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_TooManyEmbeddingValuesForCallError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class TooManyEmbeddingValuesForCallError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly provider: string; + readonly modelId: string; + readonly maxEmbeddingsPerCall: number; + readonly values: Array; + + constructor(options: { + provider: string; + modelId: string; + maxEmbeddingsPerCall: number; + values: Array; + }) { + super({ + name, + message: + `Too many values for a single embedding call. ` + + `The ${options.provider} model "${options.modelId}" can only embed up to ` + + `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`, + }); + + this.provider = options.provider; + this.modelId = options.modelId; + this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall; + this.values = options.values; + } + + static isInstance( + error: unknown, + ): error is TooManyEmbeddingValuesForCallError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/type-validation-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/type-validation-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..83f3c6e9dfd63486589892becd5a9cc3efbc38be --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/type-validation-error.ts @@ -0,0 +1,108 @@ +import { AISDKError } from './ai-sdk-error'; +import { getErrorMessage } from './get-error-message'; + +const name = 'AI_TypeValidationError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export interface TypeValidationContext { + /** + * Field path in dot notation (e.g., "message.metadata", "message.parts[3].data") + */ + field?: string; + + /** + * Entity name (e.g., tool name, data type name) + */ + entityName?: string; + + /** + * Entity identifier (e.g., message ID, tool call ID) + */ + entityId?: string; +} + +export class TypeValidationError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly value: unknown; + readonly context?: TypeValidationContext; + + constructor({ + value, + cause, + context, + }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }) { + let contextPrefix = 'Type validation failed'; + + if (context?.field) { + contextPrefix += ` for ${context.field}`; + } + + if (context?.entityName || context?.entityId) { + contextPrefix += ' ('; + const parts: string[] = []; + if (context.entityName) { + parts.push(context.entityName); + } + if (context.entityId) { + parts.push(`id: "${context.entityId}"`); + } + contextPrefix += parts.join(', '); + contextPrefix += ')'; + } + + super({ + name, + message: + `${contextPrefix}: ` + + `Value: ${JSON.stringify(value)}.\n` + + `Error message: ${getErrorMessage(cause)}`, + cause, + }); + + this.value = value; + this.context = context; + } + + static isInstance(error: unknown): error is TypeValidationError { + return AISDKError.hasMarker(error, marker); + } + + /** + * Wraps an error into a TypeValidationError. + * If the cause is already a TypeValidationError with the same value and context, it returns the cause. + * Otherwise, it creates a new TypeValidationError. + * + * @param {Object} params - The parameters for wrapping the error. + * @param {unknown} params.value - The value that failed validation. + * @param {unknown} params.cause - The original error or cause of the validation failure. + * @param {TypeValidationContext} params.context - Optional context about what is being validated. + * @returns {TypeValidationError} A TypeValidationError instance. + */ + static wrap({ + value, + cause, + context, + }: { + value: unknown; + cause: unknown; + context?: TypeValidationContext; + }): TypeValidationError { + if ( + TypeValidationError.isInstance(cause) && + cause.value === value && + cause.context?.field === context?.field && + cause.context?.entityName === context?.entityName && + cause.context?.entityId === context?.entityId + ) { + return cause; + } + + return new TypeValidationError({ value, cause, context }); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/errors/unsupported-functionality-error.ts b/.opencode/node_modules/@ai-sdk/provider/src/errors/unsupported-functionality-error.ts new file mode 100644 index 0000000000000000000000000000000000000000..679240d593f6de883f889a48cb0ed095d2bc51ac --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/errors/unsupported-functionality-error.ts @@ -0,0 +1,26 @@ +import { AISDKError } from './ai-sdk-error'; + +const name = 'AI_UnsupportedFunctionalityError'; +const marker = `vercel.ai.error.${name}`; +const symbol = Symbol.for(marker); + +export class UnsupportedFunctionalityError extends AISDKError { + private readonly [symbol] = true; // used in isInstance + + readonly functionality: string; + + constructor({ + functionality, + message = `'${functionality}' functionality not supported.`, + }: { + functionality: string; + message?: string; + }) { + super({ name, message }); + this.functionality = functionality; + } + + static isInstance(error: unknown): error is UnsupportedFunctionalityError { + return AISDKError.hasMarker(error, marker); + } +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca7b39f383953b48e9cfa5ce7b044ce0e74c7cfe --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/index.ts @@ -0,0 +1 @@ +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/image-model-v3-middleware.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/image-model-v3-middleware.ts new file mode 100644 index 0000000000000000000000000000000000000000..41340cbe05fb588c47996821ddc3e4e970726bd0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/image-model-v3-middleware.ts @@ -0,0 +1,61 @@ +import { ImageModelV3 } from '../../image-model/v3/image-model-v3'; +import { ImageModelV3CallOptions } from '../../image-model/v3/image-model-v3-call-options'; + +/** + * Middleware for ImageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of ImageModelV3 operations. + */ +export type ImageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + + /** + * Override the provider name if desired. + * @param options.model - The image model instance. + */ + overrideProvider?: (options: { model: ImageModelV3 }) => string; + + /** + * Override the model ID if desired. + * @param options.model - The image model instance. + */ + overrideModelId?: (options: { model: ImageModelV3 }) => string; + + /** + * Override the limit of how many images can be generated in a single API call if desired. + * @param options.model - The image model instance. + */ + overrideMaxImagesPerCall?: (options: { + model: ImageModelV3; + }) => ImageModelV3['maxImagesPerCall']; + + /** + * Transforms the parameters before they are passed to the image model. + * @param options - Object containing the parameters. + * @param options.params - The original parameters for the image model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => PromiseLike; + + /** + * Wraps the generate operation of the image model. + * + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The image model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + params: ImageModelV3CallOptions; + model: ImageModelV3; + }) => Promise>>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..dac856ba0790ab7e08d70f02870d9567ce961680 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model-middleware/v3/index.ts @@ -0,0 +1 @@ +export * from './image-model-v3-middleware'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbc4b71609dd33bef6364ce065f529c159254c8a --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-options.ts @@ -0,0 +1,60 @@ +import { SharedV2ProviderOptions } from '../../shared'; + +export type ImageModelV2CallOptions = { + /** + * Prompt for the image generation. + */ + prompt: string; + + /** + * Number of images to generate. + */ + n: number; + + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV2ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-warning.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-warning.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ea317b67732a0cd61655e75baca7ab7a083ab16 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2-call-warning.ts @@ -0,0 +1,16 @@ +import { ImageModelV2CallOptions } from './image-model-v2-call-options'; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +export type ImageModelV2CallWarning = + | { + type: 'unsupported-setting'; + setting: keyof ImageModelV2CallOptions; + details?: string; + } + | { + type: 'other'; + message: string; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..d00b6325212c805d3d7f308c1e4e7b08cab617dc --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/image-model-v2.ts @@ -0,0 +1,104 @@ +import { JSONArray, JSONValue } from '../../json-value'; +import { ImageModelV2CallOptions } from './image-model-v2-call-options'; +import { ImageModelV2CallWarning } from './image-model-v2-call-warning'; + +export type ImageModelV2ProviderMetadata = Record< + string, + { + images: JSONArray; + } & JSONValue +>; + +type GetMaxImagesPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; + +/** + * Image generation model specification version 2. + */ +export type ImageModelV2 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction; + + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV2CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV2ProviderMetadata; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..8395d2fe08ebed80885702e82454a333f11976fa --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v2/index.ts @@ -0,0 +1,6 @@ +export type { + ImageModelV2, + ImageModelV2ProviderMetadata, +} from './image-model-v2'; +export type { ImageModelV2CallOptions } from './image-model-v2-call-options'; +export type { ImageModelV2CallWarning } from './image-model-v2-call-warning'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..761dfc398edc1f54f3ba4f83e4fffc68f5a9eb1c --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-call-options.ts @@ -0,0 +1,74 @@ +import { SharedV3ProviderOptions } from '../../shared'; +import { ImageModelV3File } from './image-model-v3-file'; + +export type ImageModelV3CallOptions = { + /** + * Prompt for the image generation. Some operations, like upscaling, may not require a prompt. + */ + prompt: string | undefined; + + /** + * Number of images to generate. + */ + n: number; + + /** + * Size of the images to generate. + * Must have the format `{width}x{height}`. + * `undefined` will use the provider's default size. + */ + size: `${number}x${number}` | undefined; + + /** + * Aspect ratio of the images to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + */ + aspectRatio: `${number}:${number}` | undefined; + + /** + * Seed for the image generation. + * `undefined` will use the provider's default seed. + */ + seed: number | undefined; + + /** + * Array of images for image editing or variation generation. + * The images should be provided as base64 encoded strings or binary data. + */ + files: ImageModelV3File[] | undefined; + + /** + * Mask image for inpainting operations. + * The mask should be provided as base64 encoded strings or binary data. + */ + mask: ImageModelV3File | undefined; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "openai": { + * "style": "vivid" + * } + * } + * ``` + */ + providerOptions: SharedV3ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-file.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d37f2be1b7e056e97a12643e76dc3e2371577a8 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-file.ts @@ -0,0 +1,44 @@ +import { SharedV3ProviderMetadata } from '../../shared'; + +/** + * An image file that can be used for image editing or variation generation. + */ +export type ImageModelV3File = + | { + type: 'file'; + + /** + * The IANA media type of the file, e.g. `image/png`. Any string is supported. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; + } + | { + type: 'url'; + + /** + * The URL of the image file. + */ + url: string; + + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-usage.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-usage.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f523a2e963185f382391c0abf73eca5e09991f1 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3-usage.ts @@ -0,0 +1,19 @@ +/** + * Usage information for an image model call. + */ +export type ImageModelV3Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + + /** + * The number of output tokens used, if reported by the provider. + */ + outputTokens: number | undefined; + + /** + * The total number of tokens as reported by the provider. + */ + totalTokens: number | undefined; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..b11a10150e4086b3c93b8a48cc965be6998fd03f --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/image-model-v3.ts @@ -0,0 +1,110 @@ +import { JSONArray, JSONValue } from '../../json-value'; +import { ImageModelV3Usage } from './image-model-v3-usage'; +import { ImageModelV3CallOptions } from './image-model-v3-call-options'; +import { SharedV3Warning } from '../../shared/v3/shared-v3-warning'; + +export type ImageModelV3ProviderMetadata = Record< + string, + { + images: JSONArray; + } & JSONValue +>; + +type GetMaxImagesPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; + +/** + * Image generation model specification version 3. + */ +export type ImageModelV3 = { + /** + * The image model must specify which image model interface + * version it implements. This will allow us to evolve the image + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Limit of how many images can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + */ + readonly maxImagesPerCall: number | undefined | GetMaxImagesPerCallFunction; + + /** + * Generates an array of images. + */ + doGenerate(options: ImageModelV3CallOptions): PromiseLike<{ + /** + * Generated images as base64 encoded strings or binary data. + * The images should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the images should be returned + * as base64 encoded strings. If the API returns binary data, the images should + * be returned as binary data. + */ + images: Array | Array; + + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. It always includes an + * `images` key with image-specific metadata + * + * ```ts + * { + * "openai": { + * "images": ["revisedPrompt": "Revised prompt here."] + * } + * } + * ``` + */ + providerMetadata?: ImageModelV3ProviderMetadata; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers: Record | undefined; + }; + + /** + * Optional token usage for the image generation call (if the provider reports it). + */ + usage?: ImageModelV3Usage; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..06494af86630066043926cde088a04acb28f243b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/image-model/v3/index.ts @@ -0,0 +1,7 @@ +export type { + ImageModelV3, + ImageModelV3ProviderMetadata, +} from './image-model-v3'; +export type { ImageModelV3CallOptions } from './image-model-v3-call-options'; +export type { ImageModelV3Usage } from './image-model-v3-usage'; +export type { ImageModelV3File } from './image-model-v3-file'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bfadb53fedfaf1091e7618e450ed7a9079c07f6 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/index.ts @@ -0,0 +1,16 @@ +export * from './embedding-model/index'; +export * from './errors/index'; +export * from './image-model/index'; +export * from './image-model-middleware/index'; +export * from './json-value/index'; +export * from './language-model-middleware/index'; +export * from './embedding-model-middleware/index'; +export * from './language-model/index'; +export * from './provider/index'; +export * from './reranking-model/index'; +export * from './shared/index'; +export * from './speech-model/index'; +export * from './transcription-model/index'; +export * from './video-model/index'; + +export type { JSONSchema7, JSONSchema7Definition } from 'json-schema'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/json-value/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/json-value/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..55bd352c731f36eb123438cd7c64422bf2dd28ce --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/json-value/index.ts @@ -0,0 +1,2 @@ +export { isJSONArray, isJSONObject, isJSONValue } from './is-json'; +export type { JSONArray, JSONObject, JSONValue } from './json-value'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/json-value/is-json.ts b/.opencode/node_modules/@ai-sdk/provider/src/json-value/is-json.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6c1c0e71b8d974fa015889820142ecf81a40cb0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/json-value/is-json.ts @@ -0,0 +1,40 @@ +import { JSONArray, JSONObject, JSONValue } from './json-value'; + +export function isJSONValue(value: unknown): value is JSONValue { + if ( + value === null || + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' + ) { + return true; + } + + if (Array.isArray(value)) { + return value.every(isJSONValue); + } + + if (typeof value === 'object') { + return Object.entries(value).every( + ([key, val]) => + typeof key === 'string' && (val === undefined || isJSONValue(val)), + ); + } + + return false; +} + +export function isJSONArray(value: unknown): value is JSONArray { + return Array.isArray(value) && value.every(isJSONValue); +} + +export function isJSONObject(value: unknown): value is JSONObject { + return ( + value != null && + typeof value === 'object' && + Object.entries(value).every( + ([key, val]) => + typeof key === 'string' && (val === undefined || isJSONValue(val)), + ) + ); +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/json-value/json-value.ts b/.opencode/node_modules/@ai-sdk/provider/src/json-value/json-value.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ec7ab5cd5800e494f78ab2a5fd915bec174bd3a --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/json-value/json-value.ts @@ -0,0 +1,17 @@ +/** + * A JSON value can be a string, number, boolean, object, array, or null. + * JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods. + */ +export type JSONValue = + | null + | string + | number + | boolean + | JSONObject + | JSONArray; + +export type JSONObject = { + [key: string]: JSONValue | undefined; +}; + +export type JSONArray = JSONValue[]; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..d41cfbd28f3dc6971823708c3f5fdd4b4ecdf4ee --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/index.ts @@ -0,0 +1 @@ +export * from './language-model-v2-middleware'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/language-model-v2-middleware.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/language-model-v2-middleware.ts new file mode 100644 index 0000000000000000000000000000000000000000..e548ef0c09e1d09127e5b85439591efadf35a186 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v2/language-model-v2-middleware.ts @@ -0,0 +1,82 @@ +import { LanguageModelV2 } from '../../language-model/v2/language-model-v2'; +import { LanguageModelV2CallOptions } from '../../language-model/v2/language-model-v2-call-options'; + +/** + * Experimental middleware for LanguageModelV2. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV2 operations. + */ +export type LanguageModelV2Middleware = { + /** + * Middleware specification version. Use `v2` for the current version. + */ + middlewareVersion?: 'v2' | undefined; // backwards compatibility + + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { model: LanguageModelV2 }) => string; + + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { model: LanguageModelV2 }) => string; + + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV2; + }) => PromiseLike> | Record; + + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike; + + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => Promise>>; + + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => ReturnType; + doStream: () => ReturnType; + params: LanguageModelV2CallOptions; + model: LanguageModelV2; + }) => PromiseLike>>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e88a2ebfa19a2b294541a3bdab9649f98c8dd29 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/index.ts @@ -0,0 +1 @@ +export * from './language-model-v3-middleware'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/language-model-v3-middleware.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/language-model-v3-middleware.ts new file mode 100644 index 0000000000000000000000000000000000000000..854e9ea905d676f3ab5ea779b2123ec94bf13468 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model-middleware/v3/language-model-v3-middleware.ts @@ -0,0 +1,84 @@ +import { LanguageModelV3 } from '../../language-model/v3/language-model-v3'; +import { LanguageModelV3CallOptions } from '../../language-model/v3/language-model-v3-call-options'; +import { LanguageModelV3GenerateResult } from '../../language-model/v3/language-model-v3-generate-result'; +import { LanguageModelV3StreamResult } from '../../language-model/v3/language-model-v3-stream-result'; + +/** + * Experimental middleware for LanguageModelV3. + * This type defines the structure for middleware that can be used to modify + * the behavior of LanguageModelV3 operations. + */ +export type LanguageModelV3Middleware = { + /** + * Middleware specification version. Use `v3` for the current version. + */ + readonly specificationVersion: 'v3'; + + /** + * Override the provider name if desired. + * @param options.model - The language model instance. + */ + overrideProvider?: (options: { model: LanguageModelV3 }) => string; + + /** + * Override the model ID if desired. + * @param options.model - The language model instance. + */ + overrideModelId?: (options: { model: LanguageModelV3 }) => string; + + /** + * Override the supported URLs if desired. + * @param options.model - The language model instance. + */ + overrideSupportedUrls?: (options: { + model: LanguageModelV3; + }) => PromiseLike> | Record; + + /** + * Transforms the parameters before they are passed to the language model. + * @param options - Object containing the type of operation and the parameters. + * @param options.type - The type of operation ('generate' or 'stream'). + * @param options.params - The original parameters for the language model call. + * @returns A promise that resolves to the transformed parameters. + */ + transformParams?: (options: { + type: 'generate' | 'stream'; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + + /** + * Wraps the generate operation of the language model. + * @param options - Object containing the generate function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the generate call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the generate operation. + */ + wrapGenerate?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; + + /** + * Wraps the stream operation of the language model. + * + * @param options - Object containing the stream function, parameters, and model. + * @param options.doGenerate - The original generate function. + * @param options.doStream - The original stream function. + * @param options.params - The parameters for the stream call. If the + * `transformParams` middleware is used, this will be the transformed parameters. + * @param options.model - The language model instance. + * @returns A promise that resolves to the result of the stream operation. + */ + wrapStream?: (options: { + doGenerate: () => PromiseLike; + doStream: () => PromiseLike; + params: LanguageModelV3CallOptions; + model: LanguageModelV3; + }) => PromiseLike; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0bb4279e44d15e9409c80e639403523945fdd13 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/index.ts @@ -0,0 +1,18 @@ +export * from './language-model-v2'; +export * from './language-model-v2-call-options'; +export * from './language-model-v2-call-warning'; +export * from './language-model-v2-content'; +export * from './language-model-v2-data-content'; +export * from './language-model-v2-file'; +export * from './language-model-v2-finish-reason'; +export * from './language-model-v2-function-tool'; +export * from './language-model-v2-prompt'; +export * from './language-model-v2-provider-defined-tool'; +export * from './language-model-v2-reasoning'; +export * from './language-model-v2-response-metadata'; +export * from './language-model-v2-source'; +export * from './language-model-v2-stream-part'; +export * from './language-model-v2-text'; +export * from './language-model-v2-tool-call'; +export * from './language-model-v2-tool-choice'; +export * from './language-model-v2-usage'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..f21ce04f6da5d3dcabf603d551d3453cc3e83ab4 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-options.ts @@ -0,0 +1,127 @@ +import { JSONSchema7 } from 'json-schema'; +import { SharedV2ProviderOptions } from '../../shared/v2/shared-v2-provider-options'; +import { LanguageModelV2FunctionTool } from './language-model-v2-function-tool'; +import { LanguageModelV2Prompt } from './language-model-v2-prompt'; +import { LanguageModelV2ProviderDefinedTool } from './language-model-v2-provider-defined-tool'; +import { LanguageModelV2ToolChoice } from './language-model-v2-tool-choice'; + +export type LanguageModelV2CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV2Prompt; + + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + + /** + * Nucleus sampling. + */ + topP?: number; + + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: + | { type: 'text' } + | { + type: 'json'; + + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + + /** + * The tools that are available for the model. + */ + tools?: Array< + LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool + >; + + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV2ToolChoice; + + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-warning.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-warning.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba22880fcc8de9596c22348d8dd73b710dd4a170 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-call-warning.ts @@ -0,0 +1,23 @@ +import { LanguageModelV2CallOptions } from './language-model-v2-call-options'; +import { LanguageModelV2FunctionTool } from './language-model-v2-function-tool'; +import { LanguageModelV2ProviderDefinedTool } from './language-model-v2-provider-defined-tool'; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +export type LanguageModelV2CallWarning = + | { + type: 'unsupported-setting'; + setting: Omit; + details?: string; + } + | { + type: 'unsupported-tool'; + tool: LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool; + details?: string; + } + | { + type: 'other'; + message: string; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-content.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-content.ts new file mode 100644 index 0000000000000000000000000000000000000000..19a063bc5e3b85fa631b531cc62868fc6dc6e355 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-content.ts @@ -0,0 +1,14 @@ +import { LanguageModelV2File } from './language-model-v2-file'; +import { LanguageModelV2Reasoning } from './language-model-v2-reasoning'; +import { LanguageModelV2Source } from './language-model-v2-source'; +import { LanguageModelV2Text } from './language-model-v2-text'; +import { LanguageModelV2ToolCall } from './language-model-v2-tool-call'; +import { LanguageModelV2ToolResult } from './language-model-v2-tool-result'; + +export type LanguageModelV2Content = + | LanguageModelV2Text + | LanguageModelV2Reasoning + | LanguageModelV2File + | LanguageModelV2Source + | LanguageModelV2ToolCall + | LanguageModelV2ToolResult; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-data-content.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-data-content.ts new file mode 100644 index 0000000000000000000000000000000000000000..eed128e43cc67cdad769cf646a79346067e983f2 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-data-content.ts @@ -0,0 +1,4 @@ +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +export type LanguageModelV2DataContent = Uint8Array | string | URL; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-file.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..f887b5d34b7adfeb33acff7303eb96e1d6974db3 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-file.ts @@ -0,0 +1,25 @@ +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +export type LanguageModelV2File = { + type: 'file'; + + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-finish-reason.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-finish-reason.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a571f5349d2cd49b45c9086f270a7e0c5c88136 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-finish-reason.ts @@ -0,0 +1,20 @@ +/** + * Reason why a language model finished generating a response. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + * - `unknown`: the model has not transmitted a finish reason + */ +export type LanguageModelV2FinishReason = + | 'stop' // model generated stop sequence + | 'length' // model generated maximum number of tokens + | 'content-filter' // content filter violation stopped the model + | 'tool-calls' // model triggered tool calls + | 'error' // model stopped because of an error + | 'other' // model stopped for other reasons + | 'unknown'; // the model has not transmitted a finish reason diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-function-tool.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-function-tool.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8cb325d9cb6a328039285d15aa646ffcfbe42f1 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-function-tool.ts @@ -0,0 +1,37 @@ +import { JSONSchema7 } from 'json-schema'; +import { SharedV2ProviderOptions } from '../../shared'; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +export type LanguageModelV2FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + + /** + * The name of the tool. Unique within this model call. + */ + name: string; + + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV2ProviderOptions; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-prompt.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-prompt.ts new file mode 100644 index 0000000000000000000000000000000000000000..29254c6f8d89dd6db809897a47d4220559fb686e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-prompt.ts @@ -0,0 +1,218 @@ +import { JSONValue } from '../../json-value/json-value'; +import { SharedV2ProviderOptions } from '../../shared/v2/shared-v2-provider-options'; +import { LanguageModelV2DataContent } from './language-model-v2-data-content'; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +export type LanguageModelV2Prompt = Array; + +export type LanguageModelV2Message = + // Note: there could be additional parts for each role in the future, + // e.g. when the assistant can return images or the user can share files + // such as PDFs. + ( + | { + role: 'system'; + content: string; + } + | { + role: 'user'; + content: Array; + } + | { + role: 'assistant'; + content: Array< + | LanguageModelV2TextPart + | LanguageModelV2FilePart + | LanguageModelV2ReasoningPart + | LanguageModelV2ToolCallPart + | LanguageModelV2ToolResultPart + >; + } + | { + role: 'tool'; + content: Array; + } + ) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; + }; + +/** + * Text content part of a prompt. It contains a string of text. + */ +export interface LanguageModelV2TextPart { + type: 'text'; + + /** + * The text content. + */ + text: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} + +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +export interface LanguageModelV2ReasoningPart { + type: 'reasoning'; + + /** + * The reasoning text. + */ + text: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} + +/** + * File content part of a prompt. It contains a file. + */ +export interface LanguageModelV2FilePart { + type: 'file'; + + /** + * Optional filename of the file. + */ + filename?: string; + + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV2DataContent; + + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} + +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +export interface LanguageModelV2ToolCallPart { + type: 'tool-call'; + + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + + /** + * Name of the tool that is being called. + */ + toolName: string; + + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} + +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +export interface LanguageModelV2ToolResultPart { + type: 'tool-result'; + + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + + /** + * Name of the tool that generated this result. + */ + toolName: string; + + /** + * Result of the tool call. + */ + output: LanguageModelV2ToolResultOutput; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV2ProviderOptions; +} + +export type LanguageModelV2ToolResultOutput = + | { type: 'text'; value: string } + | { type: 'json'; value: JSONValue } + | { type: 'error-text'; value: string } + | { type: 'error-json'; value: JSONValue } + | { + type: 'content'; + value: Array< + | { + type: 'text'; + + /** + * Text content. + */ + text: string; + } + | { + type: 'media'; + + /** + * Base-64 encoded media data. + */ + data: string; + + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + } + >; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-provider-defined-tool.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-provider-defined-tool.ts new file mode 100644 index 0000000000000000000000000000000000000000..8cf2eaa041213d8f911e69d98f6f67586b753f36 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-provider-defined-tool.ts @@ -0,0 +1,24 @@ +/** + * The configuration of a tool that is defined by the provider. + */ +export type LanguageModelV2ProviderDefinedTool = { + /** + * The type of the tool (always 'provider-defined'). + */ + type: 'provider-defined'; + + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + + /** + * The name of the tool that the user must use in the tool set. + */ + name: string; + + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-reasoning.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-reasoning.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b76933cba8e0975388dbf8d078ec72a56d8a273 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-reasoning.ts @@ -0,0 +1,14 @@ +import { SharedV2ProviderMetadata } from '../../shared'; + +/** + * Reasoning that the model has generated. + */ +export type LanguageModelV2Reasoning = { + type: 'reasoning'; + text: string; + + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-response-metadata.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-response-metadata.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fe959a9908413908033b2e985e50ad98cba9cfb --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-response-metadata.ts @@ -0,0 +1,16 @@ +export interface LanguageModelV2ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-source.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-source.ts new file mode 100644 index 0000000000000000000000000000000000000000..25b59a45d13e978722a90f06401fab9cf7f82e91 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-source.ts @@ -0,0 +1,67 @@ +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; + +/** + * A source that has been used as input to generate the response. + */ +export type LanguageModelV2Source = + | { + type: 'source'; + + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + + /** + * The ID of the source. + */ + id: string; + + /** + * The URL of the source. + */ + url: string; + + /** + * The title of the source. + */ + title?: string; + + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; + } + | { + type: 'source'; + + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + + /** + * The ID of the source. + */ + id: string; + + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + + /** + * The title of the document. + */ + title: string; + + /** + * Optional filename of the document. + */ + filename?: string; + + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV2ProviderMetadata; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-stream-part.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-stream-part.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ef46f3d51312897dcd59f537971278fc5a56f37 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-stream-part.ts @@ -0,0 +1,102 @@ +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; +import { LanguageModelV2CallWarning } from './language-model-v2-call-warning'; +import { LanguageModelV2File } from './language-model-v2-file'; +import { LanguageModelV2FinishReason } from './language-model-v2-finish-reason'; +import { LanguageModelV2ResponseMetadata } from './language-model-v2-response-metadata'; +import { LanguageModelV2Source } from './language-model-v2-source'; +import { LanguageModelV2ToolCall } from './language-model-v2-tool-call'; +import { LanguageModelV2ToolResult } from './language-model-v2-tool-result'; +import { LanguageModelV2Usage } from './language-model-v2-usage'; + +export type LanguageModelV2StreamPart = + // Text blocks: + | { + type: 'text-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; + } + | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; + } + | { + type: 'text-end'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; + } + + // Reasoning blocks: + | { + type: 'reasoning-start'; + providerMetadata?: SharedV2ProviderMetadata; + id: string; + } + | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + delta: string; + } + | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + } + + // Tool calls and results: + | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV2ProviderMetadata; + providerExecuted?: boolean; + } + | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV2ProviderMetadata; + } + | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV2ProviderMetadata; + } + | LanguageModelV2ToolCall + | LanguageModelV2ToolResult + + // Files and sources: + | LanguageModelV2File + | LanguageModelV2Source + + // stream start event with warnings for the call, e.g. unsupported settings: + | { + type: 'stream-start'; + warnings: Array; + } + + // metadata for the response. + // separate stream part so it can be sent once it is available. + | ({ type: 'response-metadata' } & LanguageModelV2ResponseMetadata) + + // metadata that is available after the stream is finished: + | { + type: 'finish'; + usage: LanguageModelV2Usage; + finishReason: LanguageModelV2FinishReason; + providerMetadata?: SharedV2ProviderMetadata; + } + + // raw chunks if enabled + | { + type: 'raw'; + rawValue: unknown; + } + + // error parts are streamed, allowing for multiple errors + | { + type: 'error'; + error: unknown; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-text.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-text.ts new file mode 100644 index 0000000000000000000000000000000000000000..622221513abbd82133f31f96e5fa04afeaa7c7ce --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-text.ts @@ -0,0 +1,15 @@ +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; + +/** + * Text that the model has generated. + */ +export type LanguageModelV2Text = { + type: 'text'; + + /** + * The text content. + */ + text: string; + + providerMetadata?: SharedV2ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-call.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-call.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb1dc972bcfd588bb2a14f15c3efe38220559d42 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-call.ts @@ -0,0 +1,35 @@ +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; + +/** + * Tool calls that the model has generated. + */ +export type LanguageModelV2ToolCall = { + type: 'tool-call'; + + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + + /** + * The name of the tool that should be called. + */ + toolName: string; + + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-choice.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-choice.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c7d00c6392efe36fdc3c5638d505bdce7424def --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-choice.ts @@ -0,0 +1,5 @@ +export type LanguageModelV2ToolChoice = + | { type: 'auto' } // the tool selection is automatic (can be no tool) + | { type: 'none' } // no tool must be selected + | { type: 'required' } // one of the available tools must be selected + | { type: 'tool'; toolName: string }; // a specific tool must be selected: diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-result.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..5aa2b00a0fc8c8eb8c5b52816148fdce3d63ff15 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-tool-result.ts @@ -0,0 +1,40 @@ +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; + +/** + * Result of a tool call that has been executed by the provider. + */ +export type LanguageModelV2ToolResult = { + type: 'tool-result'; + + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + + /** + * Name of the tool that generated this result. + */ + toolName: string; + + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: unknown; + + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + + /** + * Whether the tool result was generated by the provider. + * If this flag is set to true, the tool result was generated by the provider. + * If this flag is not set or is false, the tool result was generated by the client. + */ + providerExecuted?: boolean; + + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV2ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-usage.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-usage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e87ff47c38d021ad1ef79a49b6f94314cfd3134 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2-usage.ts @@ -0,0 +1,34 @@ +/** + * Usage information for a language model call. + * + * If your API return additional usage information, you can add it to the + * provider metadata under your provider's key. + */ +export type LanguageModelV2Usage = { + /** + * The number of input (prompt) tokens used. + */ + inputTokens: number | undefined; + + /** + * The number of output (completion) tokens used. + */ + outputTokens: number | undefined; + + /** + * The total number of tokens as reported by the provider. + * This number might be different from the sum of `inputTokens` and `outputTokens` + * and e.g. include reasoning tokens or other overhead. + */ + totalTokens: number | undefined; + + /** + * The number of reasoning tokens used. + */ + reasoningTokens?: number | undefined; + + /** + * The number of cached input tokens. + */ + cachedInputTokens?: number | undefined; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7d19762cb916e018757231caa37a7eb949b9e22 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v2/language-model-v2.ts @@ -0,0 +1,137 @@ +import { SharedV2Headers } from '../../shared'; +import { SharedV2ProviderMetadata } from '../../shared/v2/shared-v2-provider-metadata'; +import { LanguageModelV2CallOptions } from './language-model-v2-call-options'; +import { LanguageModelV2CallWarning } from './language-model-v2-call-warning'; +import { LanguageModelV2Content } from './language-model-v2-content'; +import { LanguageModelV2FinishReason } from './language-model-v2-finish-reason'; +import { LanguageModelV2ResponseMetadata } from './language-model-v2-response-metadata'; +import { LanguageModelV2StreamPart } from './language-model-v2-stream-part'; +import { LanguageModelV2Usage } from './language-model-v2-usage'; + +/** + * Specification for a language model that implements the language model interface version 2. + */ +export type LanguageModelV2 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v2'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: + | PromiseLike> + | Record; + + /** + * Generates a language model output (non-streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate(options: LanguageModelV2CallOptions): PromiseLike<{ + /** + * Ordered content that the model has generated. + */ + content: Array; + + /** + * Finish reason. + */ + finishReason: LanguageModelV2FinishReason; + + /** + * Usage information. + */ + usage: LanguageModelV2Usage; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV2ProviderMetadata; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV2ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV2Headers; + + /** + * Response HTTP body. + */ + body?: unknown; + }; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + }>; + + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream(options: LanguageModelV2CallOptions): PromiseLike<{ + stream: ReadableStream; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV2Headers; + }; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..4294793a42d48dec755ee4add042f50bb443bf15 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/index.ts @@ -0,0 +1,21 @@ +export * from './language-model-v3'; +export * from './language-model-v3-call-options'; +export * from './language-model-v3-content'; +export * from './language-model-v3-data-content'; +export * from './language-model-v3-file'; +export * from './language-model-v3-finish-reason'; +export * from './language-model-v3-function-tool'; +export * from './language-model-v3-generate-result'; +export * from './language-model-v3-prompt'; +export * from './language-model-v3-provider-tool'; +export * from './language-model-v3-reasoning'; +export * from './language-model-v3-response-metadata'; +export * from './language-model-v3-source'; +export * from './language-model-v3-stream-part'; +export * from './language-model-v3-stream-result'; +export * from './language-model-v3-text'; +export * from './language-model-v3-tool-approval-request'; +export * from './language-model-v3-tool-call'; +export * from './language-model-v3-tool-choice'; +export * from './language-model-v3-tool-result'; +export * from './language-model-v3-usage'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..820438be62d783ebf48663f79e60f3ac4be6b6d8 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-call-options.ts @@ -0,0 +1,125 @@ +import { JSONSchema7 } from 'json-schema'; +import { SharedV3ProviderOptions } from '../../shared/v3/shared-v3-provider-options'; +import { LanguageModelV3FunctionTool } from './language-model-v3-function-tool'; +import { LanguageModelV3Prompt } from './language-model-v3-prompt'; +import { LanguageModelV3ProviderTool } from './language-model-v3-provider-tool'; +import { LanguageModelV3ToolChoice } from './language-model-v3-tool-choice'; + +export type LanguageModelV3CallOptions = { + /** + * A language mode prompt is a standardized prompt type. + * + * Note: This is **not** the user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + * That approach allows us to evolve the user facing prompts without breaking + * the language model interface. + */ + prompt: LanguageModelV3Prompt; + + /** + * Maximum number of tokens to generate. + */ + maxOutputTokens?: number; + + /** + * Temperature setting. The range depends on the provider and model. + */ + temperature?: number; + + /** + * Stop sequences. + * If set, the model will stop generating text when one of the stop sequences is generated. + * Providers may have limits on the number of stop sequences. + */ + stopSequences?: string[]; + + /** + * Nucleus sampling. + */ + topP?: number; + + /** + * Only sample from the top K options for each subsequent token. + * + * Used to remove "long tail" low probability responses. + * Recommended for advanced use cases only. You usually only need to use temperature. + */ + topK?: number; + + /** + * Presence penalty setting. It affects the likelihood of the model to + * repeat information that is already in the prompt. + */ + presencePenalty?: number; + + /** + * Frequency penalty setting. It affects the likelihood of the model + * to repeatedly use the same words or phrases. + */ + frequencyPenalty?: number; + + /** + * Response format. The output can either be text or JSON. Default is text. + * + * If JSON is selected, a schema can optionally be provided to guide the LLM. + */ + responseFormat?: + | { type: 'text' } + | { + type: 'json'; + + /** + * JSON schema that the generated output should conform to. + */ + schema?: JSONSchema7; + + /** + * Name of output that should be generated. Used by some providers for additional LLM guidance. + */ + name?: string; + + /** + * Description of the output that should be generated. Used by some providers for additional LLM guidance. + */ + description?: string; + }; + + /** + * The seed (integer) to use for random sampling. If set and supported + * by the model, calls will generate deterministic results. + */ + seed?: number; + + /** + * The tools that are available for the model. + */ + tools?: Array; + + /** + * Specifies how the tool should be selected. Defaults to 'auto'. + */ + toolChoice?: LanguageModelV3ToolChoice; + + /** + * Include raw chunks in the stream. Only applicable for streaming calls. + */ + includeRawChunks?: boolean; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-content.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-content.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f0806e3ad83089518fcc44f2f49820c64f6dc7f --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-content.ts @@ -0,0 +1,16 @@ +import { LanguageModelV3File } from './language-model-v3-file'; +import { LanguageModelV3Reasoning } from './language-model-v3-reasoning'; +import { LanguageModelV3Source } from './language-model-v3-source'; +import { LanguageModelV3Text } from './language-model-v3-text'; +import { LanguageModelV3ToolApprovalRequest } from './language-model-v3-tool-approval-request'; +import { LanguageModelV3ToolCall } from './language-model-v3-tool-call'; +import { LanguageModelV3ToolResult } from './language-model-v3-tool-result'; + +export type LanguageModelV3Content = + | LanguageModelV3Text + | LanguageModelV3Reasoning + | LanguageModelV3File + | LanguageModelV3ToolApprovalRequest + | LanguageModelV3Source + | LanguageModelV3ToolCall + | LanguageModelV3ToolResult; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-data-content.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-data-content.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba1acdeea8e1711c8635f53ad2288c9b638b9ccf --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-data-content.ts @@ -0,0 +1,4 @@ +/** + * Data content. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ +export type LanguageModelV3DataContent = Uint8Array | string | URL; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-file.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..5828ab4cc3cbd6d671a8a533c578cd865fc63b0b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-file.ts @@ -0,0 +1,32 @@ +import { SharedV3ProviderMetadata } from '../../shared'; + +/** + * A file that has been generated by the model. + * Generated files as base64 encoded strings or binary data. + * The files should be returned without any unnecessary conversion. + */ +export type LanguageModelV3File = { + type: 'file'; + + /** + * The IANA media type of the file, e.g. `image/png` or `audio/mp3`. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Generated file data as base64 encoded strings or binary data. + * + * The file data should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the file data should be returned + * as base64 encoded strings. If the API returns binary data, the file data should + * be returned as binary data. + */ + data: string | Uint8Array; + + /** + * Optional provider-specific metadata for the file part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-finish-reason.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-finish-reason.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e3447620f137228a6d288880ba31c6221194ab0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-finish-reason.ts @@ -0,0 +1,33 @@ +/** + * Reason why a language model finished generating a response. + * + * Contains both a unified finish reason and a raw finish reason from the provider. + * The unified finish reason is used to provide a consistent finish reason across different providers. + * The raw finish reason is used to provide the original finish reason from the provider. + */ +export type LanguageModelV3FinishReason = { + /** + * Unified finish reason. This enables using the same finish reason across different providers. + * + * Can be one of the following: + * - `stop`: model generated stop sequence + * - `length`: model generated maximum number of tokens + * - `content-filter`: content filter violation stopped the model + * - `tool-calls`: model triggered tool calls + * - `error`: model stopped because of an error + * - `other`: model stopped for other reasons + */ + unified: + | 'stop' + | 'length' + | 'content-filter' + | 'tool-calls' + | 'error' + | 'other'; + + /** + * Raw finish reason from the provider. + * This is the original finish reason from the provider. + */ + raw: string | undefined; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-function-tool.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-function-tool.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c00087b9a4f32051a59a1af0fc8629fd7b322cd --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-function-tool.ts @@ -0,0 +1,53 @@ +import { JSONSchema7 } from 'json-schema'; +import { SharedV3ProviderOptions } from '../../shared'; +import { JSONObject } from '../../json-value'; + +/** + * A tool has a name, a description, and a set of parameters. + * + * Note: this is **not** the user-facing tool definition. The AI SDK methods will + * map the user-facing tool definitions to this format. + */ +export type LanguageModelV3FunctionTool = { + /** + * The type of the tool (always 'function'). + */ + type: 'function'; + + /** + * The name of the tool. Unique within this model call. + */ + name: string; + + /** + * A description of the tool. The language model uses this to understand the + * tool's purpose and to provide better completion suggestions. + */ + description?: string; + + /** + * The parameters that the tool expects. The language model uses this to + * understand the tool's input requirements and to provide matching suggestions. + */ + inputSchema: JSONSchema7; + + /** + * An optional list of input examples that show the language + * model what the input should look like. + */ + inputExamples?: Array<{ input: JSONObject }>; + + /** + * Strict mode setting for the tool. + * + * Providers that support strict mode will use this setting to determine + * how the input should be generated. Strict mode will always produce + * valid inputs, but it might limit what input schemas are supported. + */ + strict?: boolean; + + /** + * The provider-specific options for the tool. + */ + providerOptions?: SharedV3ProviderOptions; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-generate-result.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-generate-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..c06dbb1b2fa55616adff8a90d28d8265f4f5f510 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-generate-result.ts @@ -0,0 +1,63 @@ +import { SharedV3Headers, SharedV3Warning } from '../../shared'; +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; +import { LanguageModelV3Content } from './language-model-v3-content'; +import { LanguageModelV3FinishReason } from './language-model-v3-finish-reason'; +import { LanguageModelV3ResponseMetadata } from './language-model-v3-response-metadata'; +import { LanguageModelV3Usage } from './language-model-v3-usage'; + +/** + * The result of a language model doGenerate call. + */ +export type LanguageModelV3GenerateResult = { + /** + * Ordered content that the model has generated. + */ + content: Array; + + /** + * The finish reason. + */ + finishReason: LanguageModelV3FinishReason; + + /** + * The usage information. + */ + usage: LanguageModelV3Usage; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + + /** + * Optional response information for telemetry and debugging purposes. + */ + response?: LanguageModelV3ResponseMetadata & { + /** + * Response headers. + */ + headers?: SharedV3Headers; + + /** + * Response HTTP body. + */ + body?: unknown; + }; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-prompt.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-prompt.ts new file mode 100644 index 0000000000000000000000000000000000000000..8203afa6433d8d77d8ca0cc3dbebed58b8140c88 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-prompt.ts @@ -0,0 +1,422 @@ +import { JSONValue } from '../../json-value/json-value'; +import { SharedV3ProviderOptions } from '../../shared/v3/shared-v3-provider-options'; +import { LanguageModelV3DataContent } from './language-model-v3-data-content'; + +/** + * A prompt is a list of messages. + * + * Note: Not all models and prompt formats support multi-modal inputs and + * tool calls. The validation happens at runtime. + * + * Note: This is not a user-facing prompt. The AI SDK methods will map the + * user-facing prompt types such as chat or instruction prompts to this format. + */ +export type LanguageModelV3Prompt = Array; + +export type LanguageModelV3Message = + // Note: there could be additional parts for each role in the future, + // e.g. when the assistant can return images or the user can share files + // such as PDFs. + ( + | { + role: 'system'; + content: string; + } + | { + role: 'user'; + content: Array; + } + | { + role: 'assistant'; + content: Array< + | LanguageModelV3TextPart + | LanguageModelV3FilePart + | LanguageModelV3ReasoningPart + | LanguageModelV3ToolCallPart + | LanguageModelV3ToolResultPart + >; + } + | { + role: 'tool'; + content: Array< + | LanguageModelV3ToolResultPart + | LanguageModelV3ToolApprovalResponsePart + >; + } + ) & { + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + }; + +/** + * Text content part of a prompt. It contains a string of text. + */ +export interface LanguageModelV3TextPart { + type: 'text'; + + /** + * The text content. + */ + text: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * Reasoning content part of a prompt. It contains a string of reasoning text. + */ +export interface LanguageModelV3ReasoningPart { + type: 'reasoning'; + + /** + * The reasoning text. + */ + text: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * File content part of a prompt. It contains a file. + */ +export interface LanguageModelV3FilePart { + type: 'file'; + + /** + * Optional filename of the file. + */ + filename?: string; + + /** + * File data. Can be a Uint8Array, base64 encoded data as a string or a URL. + */ + data: LanguageModelV3DataContent; + + /** + * IANA media type of the file. + * + * Can support wildcards, e.g. `image/*` (in which case the provider needs to take appropriate action). + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model). + */ +export interface LanguageModelV3ToolCallPart { + type: 'tool-call'; + + /** + * ID of the tool call. This ID is used to match the tool call with the tool result. + */ + toolCallId: string; + + /** + * Name of the tool that is being called. + */ + toolName: string; + + /** + * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema. + */ + input: unknown; + + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * Tool result content part of a prompt. It contains the result of the tool call with the matching ID. + */ +export interface LanguageModelV3ToolResultPart { + type: 'tool-result'; + + /** + * ID of the tool call that this result is associated with. + */ + toolCallId: string; + + /** + * Name of the tool that generated this result. + */ + toolName: string; + + /** + * Result of the tool call. + */ + output: LanguageModelV3ToolResultOutput; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * Tool approval response content part of a prompt. It contains the user's + * decision to approve or deny a provider-executed tool call. + */ +export interface LanguageModelV3ToolApprovalResponsePart { + type: 'tool-approval-response'; + + /** + * ID of the approval request that this response refers to. + */ + approvalId: string; + + /** + * Whether the approval was granted (true) or denied (false). + */ + approved: boolean; + + /** + * Optional reason for approval or denial. + */ + reason?: string; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; +} + +/** + * Result of a tool call. + */ +export type LanguageModelV3ToolResultOutput = + | { + /** + * Text tool output that should be directly sent to the API. + */ + type: 'text'; + value: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'json'; + value: JSONValue; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + /** + * Type when the user has denied the execution of the tool call. + */ + type: 'execution-denied'; + + /** + * Optional reason for the execution denial. + */ + reason?: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'error-text'; + value: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'error-json'; + value: JSONValue; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'content'; + value: Array< + | { + type: 'text'; + + /** + * Text content. + */ + text: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'file-data'; + + /** + * Base-64 encoded media data. + */ + data: string; + + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Optional filename of the file. + */ + filename?: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'file-url'; + + /** + * URL of the file. + */ + url: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + type: 'file-id'; + + /** + * ID of the file. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + /** + * Images that are referenced using base64 encoded data. + */ + type: 'image-data'; + + /** + * Base-64 encoded image data. + */ + data: string; + + /** + * IANA media type. + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + /** + * Images that are referenced using a URL. + */ + type: 'image-url'; + + /** + * URL of the image. + */ + url: string; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + /** + * Images that are referenced using a provider file id. + */ + type: 'image-file-id'; + + /** + * Image that is referenced using a provider file id. + * + * If you use multiple providers, you need to + * specify the provider specific ids using + * the Record option. The key is the provider + * name, e.g. 'openai' or 'anthropic'. + */ + fileId: string | Record; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + | { + /** + * Custom content part. This can be used to implement + * provider-specific content parts. + */ + type: 'custom'; + + /** + * Provider-specific options. + */ + providerOptions?: SharedV3ProviderOptions; + } + >; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-provider-tool.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-provider-tool.ts new file mode 100644 index 0000000000000000000000000000000000000000..4520aa7fcbd84243120c496454a227516d5d599e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-provider-tool.ts @@ -0,0 +1,28 @@ +/** + * The configuration of a provider tool. + * + * Provider tools are tools that are specific to a certain provider. + * The input and output schemas are defined be the provider, and + * some of the tools are also executed on the provider systems. + */ +export type LanguageModelV3ProviderTool = { + /** + * The type of the tool (always 'provider'). + */ + type: 'provider'; + + /** + * The ID of the tool. Should follow the format `.`. + */ + id: `${string}.${string}`; + + /** + * The name of the tool. Unique within this model call. + */ + name: string; + + /** + * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool. + */ + args: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-reasoning.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-reasoning.ts new file mode 100644 index 0000000000000000000000000000000000000000..af55926a6a008cb72b6865c214d5cefc8f073325 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-reasoning.ts @@ -0,0 +1,14 @@ +import { SharedV3ProviderMetadata } from '../../shared'; + +/** + * Reasoning that the model has generated. + */ +export type LanguageModelV3Reasoning = { + type: 'reasoning'; + text: string; + + /** + * Optional provider-specific metadata for the reasoning part. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-response-metadata.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-response-metadata.ts new file mode 100644 index 0000000000000000000000000000000000000000..b862e3584476ff7970ade8b76d7b8862daca83df --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-response-metadata.ts @@ -0,0 +1,16 @@ +export interface LanguageModelV3ResponseMetadata { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-source.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-source.ts new file mode 100644 index 0000000000000000000000000000000000000000..67d14082c059e1cd33bce162ca4d85edafc2c37c --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-source.ts @@ -0,0 +1,67 @@ +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; + +/** + * A source that has been used as input to generate the response. + */ +export type LanguageModelV3Source = + | { + type: 'source'; + + /** + * The type of source - URL sources reference web content. + */ + sourceType: 'url'; + + /** + * The ID of the source. + */ + id: string; + + /** + * The URL of the source. + */ + url: string; + + /** + * The title of the source. + */ + title?: string; + + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; + } + | { + type: 'source'; + + /** + * The type of source - document sources reference files/documents. + */ + sourceType: 'document'; + + /** + * The ID of the source. + */ + id: string; + + /** + * IANA media type of the document (e.g., 'application/pdf'). + */ + mediaType: string; + + /** + * The title of the document. + */ + title: string; + + /** + * Optional filename of the document. + */ + filename?: string; + + /** + * Additional provider metadata for the source. + */ + providerMetadata?: SharedV3ProviderMetadata; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-part.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-part.ts new file mode 100644 index 0000000000000000000000000000000000000000..f7915c43859ee59518ac6dac4f754293c2728626 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-part.ts @@ -0,0 +1,106 @@ +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; +import { SharedV3Warning } from '../../shared/v3/shared-v3-warning'; +import { LanguageModelV3File } from './language-model-v3-file'; +import { LanguageModelV3FinishReason } from './language-model-v3-finish-reason'; +import { LanguageModelV3ResponseMetadata } from './language-model-v3-response-metadata'; +import { LanguageModelV3Source } from './language-model-v3-source'; +import { LanguageModelV3ToolApprovalRequest } from './language-model-v3-tool-approval-request'; +import { LanguageModelV3ToolCall } from './language-model-v3-tool-call'; +import { LanguageModelV3ToolResult } from './language-model-v3-tool-result'; +import { LanguageModelV3Usage } from './language-model-v3-usage'; + +export type LanguageModelV3StreamPart = + // Text blocks: + | { + type: 'text-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; + } + | { + type: 'text-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; + } + | { + type: 'text-end'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; + } + + // Reasoning blocks: + | { + type: 'reasoning-start'; + providerMetadata?: SharedV3ProviderMetadata; + id: string; + } + | { + type: 'reasoning-delta'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + delta: string; + } + | { + type: 'reasoning-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + } + + // Tool calls and results: + | { + type: 'tool-input-start'; + id: string; + toolName: string; + providerMetadata?: SharedV3ProviderMetadata; + providerExecuted?: boolean; + dynamic?: boolean; + title?: string; + } + | { + type: 'tool-input-delta'; + id: string; + delta: string; + providerMetadata?: SharedV3ProviderMetadata; + } + | { + type: 'tool-input-end'; + id: string; + providerMetadata?: SharedV3ProviderMetadata; + } + | LanguageModelV3ToolApprovalRequest + | LanguageModelV3ToolCall + | LanguageModelV3ToolResult + + // Files and sources: + | LanguageModelV3File + | LanguageModelV3Source + + // stream start event with warnings for the call, e.g. unsupported settings: + | { + type: 'stream-start'; + warnings: Array; + } + + // metadata for the response. + // separate stream part so it can be sent once it is available. + | ({ type: 'response-metadata' } & LanguageModelV3ResponseMetadata) + + // metadata that is available after the stream is finished: + | { + type: 'finish'; + usage: LanguageModelV3Usage; + finishReason: LanguageModelV3FinishReason; + providerMetadata?: SharedV3ProviderMetadata; + } + + // raw chunks if enabled + | { + type: 'raw'; + rawValue: unknown; + } + + // error parts are streamed, allowing for multiple errors + | { + type: 'error'; + error: unknown; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-result.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9ed3890703848ac5121d717c1d53eabbeb9bfab --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-stream-result.ts @@ -0,0 +1,32 @@ +import { SharedV3Headers } from '../../shared'; +import { LanguageModelV3StreamPart } from './language-model-v3-stream-part'; + +/** + * The result of a language model doStream call. + */ +export type LanguageModelV3StreamResult = { + /** + * The stream. + */ + stream: ReadableStream; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Request HTTP body that was sent to the provider API. + */ + body?: unknown; + }; + + /** + * Optional response data. + */ + response?: { + /** + * Response headers. + */ + headers?: SharedV3Headers; + }; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-text.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-text.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4adf690d87dd15b3786867a2a448d7aa0bd1371 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-text.ts @@ -0,0 +1,15 @@ +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; + +/** + * Text that the model has generated. + */ +export type LanguageModelV3Text = { + type: 'text'; + + /** + * The text content. + */ + text: string; + + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-approval-request.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-approval-request.ts new file mode 100644 index 0000000000000000000000000000000000000000..92c694933492288822ae5e8ae6084fefd58aa3a7 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-approval-request.ts @@ -0,0 +1,27 @@ +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; + +/** + * Tool approval request emitted by a provider for a provider-executed tool call. + * + * This is used for flows where the provider executes the tool (e.g. MCP tools) + * but requires an explicit user approval before continuing. + */ +export type LanguageModelV3ToolApprovalRequest = { + type: 'tool-approval-request'; + + /** + * ID of the approval request. This ID is referenced by the subsequent + * tool-approval-response (tool message) to approve or deny execution. + */ + approvalId: string; + + /** + * The tool call ID that this approval request is for. + */ + toolCallId: string; + + /** + * Additional provider-specific metadata for the approval request. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-call.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-call.ts new file mode 100644 index 0000000000000000000000000000000000000000..66f7502e3048f22539b30bf319ef64a9b9288e52 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-call.ts @@ -0,0 +1,41 @@ +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; + +/** + * Tool calls that the model has generated. + */ +export type LanguageModelV3ToolCall = { + type: 'tool-call'; + + /** + * The identifier of the tool call. It must be unique across all tool calls. + */ + toolCallId: string; + + /** + * The name of the tool that should be called. + */ + toolName: string; + + /** + * Stringified JSON object with the tool call arguments. Must match the + * parameters schema of the tool. + */ + input: string; + + /** + * Whether the tool call will be executed by the provider. + * If this flag is not set or is false, the tool call will be executed by the client. + */ + providerExecuted?: boolean; + + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + + /** + * Additional provider-specific metadata for the tool call. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-choice.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-choice.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d386036e2ba89c96f271c875fc2ff4c2f467af0 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-choice.ts @@ -0,0 +1,5 @@ +export type LanguageModelV3ToolChoice = + | { type: 'auto' } // the tool selection is automatic (can be no tool) + | { type: 'none' } // no tool must be selected + | { type: 'required' } // one of the available tools must be selected + | { type: 'tool'; toolName: string }; // a specific tool must be selected: diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-result.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-result.ts new file mode 100644 index 0000000000000000000000000000000000000000..b53b7f141dafcf2077c3557c4b2631b843f3015f --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-tool-result.ts @@ -0,0 +1,51 @@ +import { JSONValue } from '../../json-value'; +import { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; + +/** + * Result of a tool call that has been executed by the provider. + */ +export type LanguageModelV3ToolResult = { + type: 'tool-result'; + + /** + * The ID of the tool call that this result is associated with. + */ + toolCallId: string; + + /** + * Name of the tool that generated this result. + */ + toolName: string; + + /** + * Result of the tool call. This is a JSON-serializable object. + */ + result: NonNullable; + + /** + * Optional flag if the result is an error or an error message. + */ + isError?: boolean; + + /** + * Whether the tool result is preliminary. + * + * Preliminary tool results replace each other, e.g. image previews. + * There always has to be a final, non-preliminary tool result. + * + * If this flag is set to true, the tool result is preliminary. + * If this flag is not set or is false, the tool result is not preliminary. + */ + preliminary?: boolean; + + /** + * Whether the tool is dynamic, i.e. defined at runtime. + * For example, MCP (Model Context Protocol) tools that are executed by the provider. + */ + dynamic?: boolean; + + /** + * Additional provider-specific metadata for the tool result. + */ + providerMetadata?: SharedV3ProviderMetadata; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-usage.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-usage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b43bfdde3b6e83453a35743d5983d7e0fefa99d1 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3-usage.ts @@ -0,0 +1,59 @@ +import { JSONObject } from '../../json-value'; + +/** + * Usage information for a language model call. + */ +export type LanguageModelV3Usage = { + /** + * Information about the input tokens. + */ + inputTokens: { + /** + * The total number of input (prompt) tokens used. + */ + total: number | undefined; + + /** + * The number of non-cached input (prompt) tokens used. + */ + noCache: number | undefined; + + /** + * The number of cached input (prompt) tokens read. + */ + cacheRead: number | undefined; + + /** + * The number of cached input (prompt) tokens written. + */ + cacheWrite: number | undefined; + }; + + /** + * Information about the output tokens. + */ + outputTokens: { + /** + * The total number of output (completion) tokens used. + */ + total: number | undefined; + + /** + * The number of text tokens used. + */ + text: number | undefined; + + /** + * The number of reasoning tokens used. + */ + reasoning: number | undefined; + }; + + /** + * Raw usage information from the provider. + * + * This is the usage information in the shape that the provider returns. + * It can include additional information that is not part of the standard usage information. + */ + raw?: JSONObject; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..4021d3dec84117456aaa8fccba0ef03a059b5fc6 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/language-model/v3/language-model-v3.ts @@ -0,0 +1,61 @@ +import { LanguageModelV3CallOptions } from './language-model-v3-call-options'; +import { LanguageModelV3GenerateResult } from './language-model-v3-generate-result'; +import { LanguageModelV3StreamResult } from './language-model-v3-stream-result'; + +/** + * Specification for a language model that implements the language model interface version 3. + */ +export type LanguageModelV3 = { + /** + * The language model must specify which language model interface version it implements. + */ + readonly specificationVersion: 'v3'; + + /** + * Provider ID. + */ + readonly provider: string; + + /** + * Provider-specific model ID. + */ + readonly modelId: string; + + /** + * Supported URL patterns by media type for the provider. + * + * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). + * and the values are arrays of regular expressions that match the URL paths. + * + * The matching should be against lower-case URLs. + * + * Matched URLs are supported natively by the model and are not downloaded. + * + * @returns A map of supported URL patterns by media type (as a promise or a plain object). + */ + supportedUrls: + | PromiseLike> + | Record; + + /** + * Generates a language model output (non-streaming). + + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + */ + doGenerate( + options: LanguageModelV3CallOptions, + ): PromiseLike; + + /** + * Generates a language model output (streaming). + * + * Naming: "do" prefix to prevent accidental direct usage of the method + * by the user. + * + * @return A stream of higher-level language model output parts. + */ + doStream( + options: LanguageModelV3CallOptions, + ): PromiseLike; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/provider/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/provider/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/provider/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..08d9d6c4bd75eb7d82bf51aae3d50ac8b1623e66 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/index.ts @@ -0,0 +1 @@ +export type { ProviderV2 } from './provider-v2'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/provider-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/provider-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b8d8ec137bb2102ee0a9497442ec96adcbeb33a --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/provider/v2/provider-v2.ts @@ -0,0 +1,64 @@ +import { EmbeddingModelV2 } from '../../embedding-model/v2/embedding-model-v2'; +import { ImageModelV2 } from '../../image-model/v2/image-model-v2'; +import { LanguageModelV2 } from '../../language-model/v2/language-model-v2'; +import { SpeechModelV2 } from '../../speech-model/v2/speech-model-v2'; +import { TranscriptionModelV2 } from '../../transcription-model/v2/transcription-model-v2'; + +/** + * Provider for language, text embedding, and image generation models. + */ +export interface ProviderV2 { + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV2; + + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + textEmbeddingModel(modelId: string): EmbeddingModelV2; + + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV2; + + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV2; + + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV2; +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..23561cb544d7c2ace7fa3ef3b72f14ec8342ad9b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/index.ts @@ -0,0 +1 @@ +export type { ProviderV3 } from './provider-v3'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/provider-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/provider-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..98fc5a9b5903ae296d2a14655d7cfa348802ebb5 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/provider/v3/provider-v3.ts @@ -0,0 +1,93 @@ +import { EmbeddingModelV3 } from '../../embedding-model/v3/embedding-model-v3'; +import { ImageModelV3 } from '../../image-model/v3/image-model-v3'; +import { LanguageModelV3 } from '../../language-model/v3/language-model-v3'; +import { RerankingModelV3 } from '../../reranking-model/v3/reranking-model-v3'; +import { SpeechModelV3 } from '../../speech-model/v3/speech-model-v3'; +import { TranscriptionModelV3 } from '../../transcription-model/v3/transcription-model-v3'; + +/** + * Provider for language, text embedding, and image generation models. + */ +export interface ProviderV3 { + readonly specificationVersion: 'v3'; + + /** + * Returns the language model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + languageModel(modelId: string): LanguageModelV3; + + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {LanguageModel} The language model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + embeddingModel(modelId: string): EmbeddingModelV3; + + /** + * Returns the text embedding model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {EmbeddingModel} The embedding model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + * + * @deprecated Use `embeddingModel` instead. + */ + textEmbeddingModel?(modelId: string): EmbeddingModelV3; + + /** + * Returns the image model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {ImageModel} The image model associated with the id + */ + imageModel(modelId: string): ImageModelV3; + + /** + * Returns the transcription model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {TranscriptionModel} The transcription model associated with the id + */ + transcriptionModel?(modelId: string): TranscriptionModelV3; + + /** + * Returns the speech model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {SpeechModel} The speech model associated with the id + */ + speechModel?(modelId: string): SpeechModelV3; + + /** + * Returns the reranking model with the given id. + * The model id is then passed to the provider function to get the model. + * + * @param {string} modelId - The id of the model to return. + * + * @returns {RerankingModel} The reranking model associated with the id + * + * @throws {NoSuchModelError} If no such model exists. + */ + rerankingModel?(modelId: string): RerankingModelV3; +} diff --git a/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca7b39f383953b48e9cfa5ce7b044ce0e74c7cfe --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/index.ts @@ -0,0 +1 @@ +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d54b9093b720b8c05722309e7f2b099273ee061 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/index.ts @@ -0,0 +1,2 @@ +export type { RerankingModelV3 } from './reranking-model-v3'; +export type { RerankingModelV3CallOptions } from './reranking-model-v3-call-options'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fd4646645f5e40b1aa2f8645b5e366e6ea4174a --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3-call-options.ts @@ -0,0 +1,40 @@ +import { JSONObject } from '../../json-value'; +import { SharedV3Headers, SharedV3ProviderOptions } from '../../shared/v3'; + +export type RerankingModelV3CallOptions = { + /** + * Documents to rerank. + * Either a list of texts or a list of JSON objects. + */ + documents: + | { type: 'text'; values: string[] } + | { type: 'object'; values: JSONObject[] }; + + /** + * The query is a string that represents the query to rerank the documents against. + */ + query: string; + + /** + * Optional limit returned documents to the top n documents. + */ + topN?: number; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional provider-specific options. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerOptions?: SharedV3ProviderOptions; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: SharedV3Headers; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c403a9977294f786c1ff9aeaa3ad7a1e5d6615b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/reranking-model/v3/reranking-model-v3.ts @@ -0,0 +1,90 @@ +import { + SharedV3Headers, + SharedV3ProviderMetadata, + SharedV3Warning, +} from '../../shared/v3/'; +import { RerankingModelV3CallOptions } from './reranking-model-v3-call-options'; + +/** + * Specification for a reranking model that implements the reranking model interface version 3. + */ +export type RerankingModelV3 = { + /** + * The reranking model must specify which reranking model interface version it implements. + */ + readonly specificationVersion: 'v3'; + + /** + * Provider ID. + */ + readonly provider: string; + + /** + * Provider-specific model ID. + */ + readonly modelId: string; + + /** + * Reranking a list of documents using the query. + */ + // Naming: "do" prefix to prevent accidental direct usage of the method by the user. + doRerank(options: RerankingModelV3CallOptions): PromiseLike<{ + /** + * Ordered list of reranked documents (via index before reranking). + * The documents are sorted by the descending order of relevance scores. + */ + ranking: Array<{ + /** + * The index of the document in the original list of documents before reranking. + */ + index: number; + + /** + * The relevance score of the document after reranking. + */ + relevanceScore: number; + }>; + + /** + * Additional provider-specific metadata. They are passed through + * to the provider from the AI SDK and enable provider-specific + * functionality that can be fully encapsulated in the provider. + */ + providerMetadata?: SharedV3ProviderMetadata; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings?: Array; + + /** + * Optional response information for debugging purposes. + */ + response?: { + /** + * ID for the generated response, if the provider sends one. + */ + id?: string; + + /** + * Timestamp for the start of the generated response, if the provider sends one. + */ + timestamp?: Date; + + /** + * The ID of the response model that was used to generate the response, if the provider sends one. + */ + modelId?: string; + + /** + * Response headers. + */ + headers?: SharedV3Headers; + + /** + * Response body. + */ + body?: unknown; + }; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0a4a20cc05dd89635fb78fb74ffd13c2baa6601 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/index.ts @@ -0,0 +1,2 @@ +export * from './v3/index'; +export * from './v2/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..e41d84a346c1c3cf9b3126065334987aebb65197 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/index.ts @@ -0,0 +1,3 @@ +export * from './shared-v2-headers'; +export * from './shared-v2-provider-metadata'; +export * from './shared-v2-provider-options'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-headers.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-headers.ts new file mode 100644 index 0000000000000000000000000000000000000000..4be7da5c196e29cf6376bd96d46a95253c06840b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-headers.ts @@ -0,0 +1 @@ +export type SharedV2Headers = Record; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-metadata.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-metadata.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3b880ca44e9698266cc932376ac59ca7d4325d7 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-metadata.ts @@ -0,0 +1,27 @@ +import { JSONValue } from '../../json-value/json-value'; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +export type SharedV2ProviderMetadata = Record< + string, + Record +>; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..17c8c947c58d09022841ae7306c9a4e966e42f9d --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v2/shared-v2-provider-options.ts @@ -0,0 +1,24 @@ +import { JSONValue } from '../../json-value/json-value'; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +export type SharedV2ProviderOptions = Record>; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..4abdc44b3edece269c953f61684acd458a52f480 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/index.ts @@ -0,0 +1,4 @@ +export * from './shared-v3-headers'; +export * from './shared-v3-provider-metadata'; +export * from './shared-v3-provider-options'; +export * from './shared-v3-warning'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-headers.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-headers.ts new file mode 100644 index 0000000000000000000000000000000000000000..02046309bdb4eed0f9bc4de1ac7c8f191b6dd05e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-headers.ts @@ -0,0 +1 @@ +export type SharedV3Headers = Record; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-metadata.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-metadata.ts new file mode 100644 index 0000000000000000000000000000000000000000..635ab8fffd1c160e3f52d2513983c50191ae74e3 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-metadata.ts @@ -0,0 +1,24 @@ +import { JSONObject } from '../../json-value/json-value'; + +/** + * Additional provider-specific metadata. + * Metadata are additional outputs from the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +export type SharedV3ProviderMetadata = Record; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d35c67ed5533f5d7521b8bf6780349e765352db --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-provider-options.ts @@ -0,0 +1,24 @@ +import { JSONObject } from '../../json-value/json-value'; + +/** + * Additional provider-specific options. + * Options are additional input to the provider. + * They are passed through to the provider from the AI SDK + * and enable provider-specific functionality + * that can be fully encapsulated in the provider. + * + * This enables us to quickly ship provider-specific functionality + * without affecting the core AI SDK. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * + * ```ts + * { + * "anthropic": { + * "cacheControl": { "type": "ephemeral" } + * } + * } + * ``` + */ +export type SharedV3ProviderOptions = Record; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-warning.ts b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-warning.ts new file mode 100644 index 0000000000000000000000000000000000000000..1625a1c36131a1377c4130098f375abcb464dab5 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/shared/v3/shared-v3-warning.ts @@ -0,0 +1,50 @@ +/** + * Warning from the model. + * + * For example, that certain features are unsupported or compatibility + * functionality is used (which might lead to suboptimal results). + */ +export type SharedV3Warning = + | { + /** + * A feature is not supported by the model. + */ + type: 'unsupported'; + + /** + * The feature that is not supported. + */ + feature: string; + + /** + * Additional details about the warning. + */ + details?: string; + } + | { + /** + * A compatibility feature is used that might lead to suboptimal results. + */ + type: 'compatibility'; + + /** + * The feature that is used in a compatibility mode. + */ + feature: string; + + /** + * Additional details about the warning. + */ + details?: string; + } + | { + /** + * Other warning. + */ + type: 'other'; + + /** + * The message of the warning. + */ + message: string; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc2132526a7efa9c53d55712f1ee0f05468a7cd9 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/index.ts @@ -0,0 +1,2 @@ +export * from './v2/index'; +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..548bb0dba3b7e44212535b5a9f3e809dba6227dc --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/index.ts @@ -0,0 +1,3 @@ +export type { SpeechModelV2 } from './speech-model-v2'; +export type { SpeechModelV2CallOptions } from './speech-model-v2-call-options'; +export type { SpeechModelV2CallWarning } from './speech-model-v2-call-warning'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..94c2158a04a5ed5a84376f29b8c4fc7b740301cc --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-options.ts @@ -0,0 +1,62 @@ +import { JSONValue } from '../../json-value/json-value'; + +type SpeechModelV2ProviderOptions = Record>; + +export type SpeechModelV2CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + + /** + * The speed of the speech generation. + */ + speed?: number; + + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV2ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-warning.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-warning.ts new file mode 100644 index 0000000000000000000000000000000000000000..95aa718f4b3d64e2473b6840bf09d20bf7424a84 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2-call-warning.ts @@ -0,0 +1,16 @@ +import { SpeechModelV2CallOptions } from './speech-model-v2-call-options'; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +export type SpeechModelV2CallWarning = + | { + type: 'unsupported-setting'; + setting: keyof SpeechModelV2CallOptions; + details?: string; + } + | { + type: 'other'; + message: string; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..ba6992b527e882edf5fd992fc63bc856e29e5e8e --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v2/speech-model-v2.ts @@ -0,0 +1,89 @@ +import { JSONValue } from '../../json-value'; +import { SharedV2Headers } from '../../shared'; +import { SpeechModelV2CallOptions } from './speech-model-v2-call-options'; +import { SpeechModelV2CallWarning } from './speech-model-v2-call-warning'; + +/** + * Speech model specification version 2. + */ +export type SpeechModelV2 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV2CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers?: SharedV2Headers; + + /** + * Response body. + */ + body?: unknown; + }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f35147e7196aa620e72e3479aab8e667d269139b --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/index.ts @@ -0,0 +1,2 @@ +export type { SpeechModelV3 } from './speech-model-v3'; +export type { SpeechModelV3CallOptions } from './speech-model-v3-call-options'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..39119b3da0ad5b2992626cf357297e4b154b1db2 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3-call-options.ts @@ -0,0 +1,62 @@ +import { JSONObject } from '../../json-value/json-value'; + +type SpeechModelV3ProviderOptions = Record; + +export type SpeechModelV3CallOptions = { + /** + * Text to convert to speech. + */ + text: string; + + /** + * The voice to use for speech synthesis. + * This is provider-specific and may be a voice ID, name, or other identifier. + */ + voice?: string; + + /** + * The desired output format for the audio e.g. "mp3", "wav", etc. + */ + outputFormat?: string; + + /** + * Instructions for the speech generation e.g. "Speak in a slow and steady tone". + */ + instructions?: string; + + /** + * The speed of the speech generation. + */ + speed?: number; + + /** + * The language for speech generation. This should be an ISO 639-1 language code (e.g. "en", "es", "fr") + * or "auto" for automatic language detection. Provider support varies. + */ + language?: string; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": {} + * } + * ``` + */ + providerOptions?: SpeechModelV3ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..65794e385731015898a142654fb35030235139af --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/speech-model/v3/speech-model-v3.ts @@ -0,0 +1,89 @@ +import { JSONObject } from '../../json-value'; +import { SharedV2Headers } from '../../shared'; +import { SharedV3Warning } from '../../shared/v3/shared-v3-warning'; +import { SpeechModelV3CallOptions } from './speech-model-v3-call-options'; + +/** + * Speech model specification version 3. + */ +export type SpeechModelV3 = { + /** + * The speech model must specify which speech model interface + * version it implements. This will allow us to evolve the speech + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Generates speech audio from text. + */ + doGenerate(options: SpeechModelV3CallOptions): PromiseLike<{ + /** + * Generated audio as an ArrayBuffer. + * The audio should be returned without any unnecessary conversion. + * If the API returns base64 encoded strings, the audio should be returned + * as base64 encoded strings. If the API returns binary data, the audio + * should be returned as binary data. + */ + audio: string | Uint8Array; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Response body (available only for providers that use HTTP requests). + */ + body?: unknown; + }; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers?: SharedV2Headers; + + /** + * Response body. + */ + body?: unknown; + }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc2132526a7efa9c53d55712f1ee0f05468a7cd9 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/index.ts @@ -0,0 +1,2 @@ +export * from './v2/index'; +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca92d8d1cdcee4cb899b4e6d4d503d1dd555d927 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/index.ts @@ -0,0 +1,3 @@ +export type { TranscriptionModelV2 } from './transcription-model-v2'; +export type { TranscriptionModelV2CallOptions } from './transcription-model-v2-call-options'; +export type { TranscriptionModelV2CallWarning } from './transcription-model-v2-call-warning'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..b79facbc42b72554ac0d51a5f5972066cb1c10f3 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-options.ts @@ -0,0 +1,48 @@ +import { JSONValue } from '../../json-value/json-value'; + +type TranscriptionModelV2ProviderOptions = Record< + string, + Record +>; + +export type TranscriptionModelV2CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV2ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-warning.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-warning.ts new file mode 100644 index 0000000000000000000000000000000000000000..b06780f60ed5733d6abac58933eaa7e804fad382 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2-call-warning.ts @@ -0,0 +1,16 @@ +import { TranscriptionModelV2CallOptions } from './transcription-model-v2-call-options'; + +/** + * Warning from the model provider for this call. The call will proceed, but e.g. + * some settings might not be supported, which can lead to suboptimal results. + */ +export type TranscriptionModelV2CallWarning = + | { + type: 'unsupported-setting'; + setting: keyof TranscriptionModelV2CallOptions; + details?: string; + } + | { + type: 'other'; + message: string; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2.ts new file mode 100644 index 0000000000000000000000000000000000000000..28da8e7350fa7b6500701826c97cf488270a97e7 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v2/transcription-model-v2.ts @@ -0,0 +1,117 @@ +import { JSONValue } from '../../json-value'; +import { SharedV2Headers } from '../../shared'; +import { TranscriptionModelV2CallOptions } from './transcription-model-v2-call-options'; +import { TranscriptionModelV2CallWarning } from './transcription-model-v2-call-warning'; + +/** + * Transcription model specification version 2. + */ +export type TranscriptionModelV2 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v2'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV2CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers?: SharedV2Headers; + + /** + * Response body. + */ + body?: unknown; + }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record>; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0e2ca820e57a50098531e4269c9c9169044293b4 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/index.ts @@ -0,0 +1,2 @@ +export type { TranscriptionModelV3 } from './transcription-model-v3'; +export type { TranscriptionModelV3CallOptions } from './transcription-model-v3-call-options'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..380745ed1c7cf88a529457f3cb27424cf9e99a09 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3-call-options.ts @@ -0,0 +1,45 @@ +import { JSONObject } from '../../json-value/json-value'; + +type TranscriptionModelV3ProviderOptions = Record; + +export type TranscriptionModelV3CallOptions = { + /** + * Audio data to transcribe. + * Accepts a `Uint8Array` or `string`, where `string` is a base64 encoded audio file. + */ + audio: Uint8Array | string; + + /** + * The IANA media type of the audio data. + * + * @see https://www.iana.org/assignments/media-types/media-types.xhtml + */ + mediaType: string; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * The outer record is keyed by the provider name, and the inner + * record is keyed by the provider-specific metadata key. + * ```ts + * { + * "openai": { + * "timestampGranularities": ["word"] + * } + * } + * ``` + */ + providerOptions?: TranscriptionModelV3ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..068155aaba37d8c2e2367bbee517a18e05a5f90d --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/transcription-model/v3/transcription-model-v3.ts @@ -0,0 +1,117 @@ +import { JSONObject } from '../../json-value'; +import { SharedV3Headers } from '../../shared'; +import { SharedV3Warning } from '../../shared/v3/shared-v3-warning'; +import { TranscriptionModelV3CallOptions } from './transcription-model-v3-call-options'; + +/** + * Transcription model specification version 3. + */ +export type TranscriptionModelV3 = { + /** + * The transcription model must specify which transcription model interface + * version it implements. This will allow us to evolve the transcription + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Generates a transcript. + */ + doGenerate(options: TranscriptionModelV3CallOptions): PromiseLike<{ + /** + * The complete transcribed text from the audio. + */ + text: string; + + /** + * Array of transcript segments with timing information. + * Each segment represents a portion of the transcribed text with start and end times. + */ + segments: Array<{ + /** + * The text content of this segment. + */ + text: string; + /** + * The start time of this segment in seconds. + */ + startSecond: number; + /** + * The end time of this segment in seconds. + */ + endSecond: number; + }>; + + /** + * The detected language of the audio content, as an ISO-639-1 code (e.g., 'en' for English). + * May be undefined if the language couldn't be detected. + */ + language: string | undefined; + + /** + * The total duration of the audio file in seconds. + * May be undefined if the duration couldn't be determined. + */ + durationInSeconds: number | undefined; + + /** + * Warnings for the call, e.g. unsupported settings. + */ + warnings: Array; + + /** + * Optional request information for telemetry and debugging purposes. + */ + request?: { + /** + * Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified). + * Non-HTTP(s) providers should not set this. + */ + body?: string; + }; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers?: SharedV3Headers; + + /** + * Response body. + */ + body?: unknown; + }; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + */ + providerMetadata?: Record; + }>; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/video-model/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/video-model/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca7b39f383953b48e9cfa5ce7b044ce0e74c7cfe --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/video-model/index.ts @@ -0,0 +1 @@ +export * from './v3/index'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/index.ts b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee43e873f01460221f9a06d16f17cab4b4f95760 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/index.ts @@ -0,0 +1,6 @@ +export type { + VideoModelV3 as Experimental_VideoModelV3, + VideoModelV3VideoData as Experimental_VideoModelV3VideoData, +} from './video-model-v3'; +export type { VideoModelV3CallOptions as Experimental_VideoModelV3CallOptions } from './video-model-v3-call-options'; +export type { VideoModelV3File as Experimental_VideoModelV3File } from './video-model-v3-file'; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-call-options.ts b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-call-options.ts new file mode 100644 index 0000000000000000000000000000000000000000..032fce073b814b0ebcfc436d6b2c0b6ffe58c0ea --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-call-options.ts @@ -0,0 +1,81 @@ +import { SharedV3ProviderOptions } from '../../shared'; +import { VideoModelV3File } from './video-model-v3-file'; + +export type VideoModelV3CallOptions = { + /** + * Text prompt for the video generation. + */ + prompt: string | undefined; + + /** + * Number of videos to generate. Default: 1. + * Most video models only support n=1 due to computational cost. + */ + n: number; + + /** + * Aspect ratio of the videos to generate. + * Must have the format `{width}:{height}`. + * `undefined` will use the provider's default aspect ratio. + * Common values: '16:9', '9:16', '1:1', '21:9', '4:3' + */ + aspectRatio: `${number}:${number}` | undefined; + + /** + * Resolution of the video to generate. + * Format: `{width}x{height}` (e.g., '1280x720', '1920x1080') + * `undefined` will use the provider's default resolution. + */ + resolution: `${number}x${number}` | undefined; + + /** + * Duration of the video in seconds. + * `undefined` will use the provider's default duration. + * Typically 3-10 seconds for most models. + */ + duration: number | undefined; + + /** + * Frames per second (FPS) for the video. + * `undefined` will use the provider's default FPS. + * Common values: 24, 30, 60 + */ + fps: number | undefined; + + /** + * Seed for deterministic video generation. + * `undefined` will use a random seed. + */ + seed: number | undefined; + + /** + * Input image for image-to-video generation. + * The image serves as the starting frame that the model will animate. + */ + image: VideoModelV3File | undefined; + + /** + * Additional provider-specific options that are passed through to the provider + * as body parameters. + * + * Example: + * { + * "fal": { + * "loop": true, + * "motionStrength": 0.8 + * } + * } + */ + providerOptions: SharedV3ProviderOptions; + + /** + * Abort signal for cancelling the operation. + */ + abortSignal?: AbortSignal; + + /** + * Additional HTTP headers to be sent with the request. + * Only applicable for HTTP-based providers. + */ + headers?: Record; +}; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-file.ts b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..6bd822ef3b0441975561c818439eca3dad9b07c6 --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3-file.ts @@ -0,0 +1,40 @@ +import { SharedV3ProviderMetadata } from '../../shared'; + +/** + * A video or image file that can be used for video editing or image-to-video generation. + * Supports both image inputs (for image-to-video) and video inputs (for editing). + */ +export type VideoModelV3File = + | { + type: 'file'; + + /** + * The IANA media type of the file. + * Video types: 'video/mp4', 'video/webm', 'video/quicktime' + * Image types: 'image/png', 'image/jpeg', 'image/webp' + */ + mediaType: string; + + /** + * File data as base64 encoded string or binary data. + */ + data: string | Uint8Array; + + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; + } + | { + type: 'url'; + + /** + * The URL of the video or image file. + */ + url: string; + + /** + * Optional provider-specific metadata for the file part. + */ + providerOptions?: SharedV3ProviderMetadata; + }; diff --git a/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3.ts b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3.ts new file mode 100644 index 0000000000000000000000000000000000000000..bff43c3a0f2c8abb1f88baf3365ae8b66cf9f93a --- /dev/null +++ b/.opencode/node_modules/@ai-sdk/provider/src/video-model/v3/video-model-v3.ts @@ -0,0 +1,132 @@ +import type { VideoModelV3CallOptions } from './video-model-v3-call-options'; +import type { SharedV3ProviderMetadata } from '../../shared/v3/shared-v3-provider-metadata'; +import type { SharedV3Warning } from '../../shared/v3/shared-v3-warning'; + +type GetMaxVideosPerCallFunction = (options: { + modelId: string; +}) => PromiseLike | number | undefined; + +/** + * Generated video data. Can be a URL, base64-encoded string, or binary data. + */ +export type VideoModelV3VideoData = + | { + /** + * Video available as a URL (most common for video providers). + */ + type: 'url'; + url: string; + mediaType: string; + } + | { + /** + * Video as base64-encoded string. + */ + type: 'base64'; + data: string; + mediaType: string; + } + | { + /** + * Video as binary data. + */ + type: 'binary'; + data: Uint8Array; + mediaType: string; + }; + +/** + * Video generation model specification version 3. + */ +export type VideoModelV3 = { + /** + * The video model must specify which video model interface + * version it implements. This will allow us to evolve the video + * model interface and retain backwards compatibility. The different + * implementation versions can be handled as a discriminated union + * on our side. + */ + readonly specificationVersion: 'v3'; + + /** + * Name of the provider for logging purposes. + */ + readonly provider: string; + + /** + * Provider-specific model ID for logging purposes. + */ + readonly modelId: string; + + /** + * Limit of how many videos can be generated in a single API call. + * Can be set to a number for a fixed limit, to undefined to use + * the global limit, or a function that returns a number or undefined, + * optionally as a promise. + * + * Most video models only support generating 1 video at a time due to + * computational cost. Default is typically 1. + */ + readonly maxVideosPerCall: number | undefined | GetMaxVideosPerCallFunction; + + /** + * Generates an array of videos. + */ + doGenerate(options: VideoModelV3CallOptions): PromiseLike<{ + /** + * Generated videos as URLs, base64 strings, or binary data. + * + * Most providers return URLs to video files (MP4, WebM) due to large file sizes. + * Use the discriminated union to indicate the type of video data being returned. + */ + videos: Array; + + /** + * Warnings for the call, e.g. unsupported features. + */ + warnings: Array; + + /** + * Additional provider-specific metadata. They are passed through + * from the provider to the AI SDK and enable provider-specific + * results that can be fully encapsulated in the provider. + * + * The outer record is keyed by the provider name, and the inner + * record is provider-specific metadata. + * + * ```ts + * { + * "fal": { + * "videos": [{ + * "duration": 5.0, + * "fps": 24, + * "width": 1280, + * "height": 720 + * }] + * } + * } + * ``` + */ + providerMetadata?: SharedV3ProviderMetadata; + + /** + * Response information for telemetry and debugging purposes. + */ + response: { + /** + * Timestamp for the start of the generated response. + */ + timestamp: Date; + + /** + * The ID of the response model that was used to generate the response. + */ + modelId: string; + + /** + * Response headers. + */ + headers: Record | undefined; + }; + }>; +}; diff --git a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.glibc.node b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.glibc.node index b9408d977ec690b7b8265c87e01cb4136de6d082..cdd881d08b1af498706cd1d9d769494573e39086 100644 Binary files a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.glibc.node and b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.glibc.node differ diff --git a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.musl.node b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.musl.node index 791623432fc49d4dbb812923167124d448d09fac..8880a161669e8d52df800c31a8f19654a32e999d 100644 Binary files a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.musl.node and b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi115.musl.node differ diff --git a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node index d7217dd8fffea1e8a5c914cbacc8135f2a72953b..fcc8951df7e78d2751ebc973d29a5dd661c8a9a6 100644 Binary files a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node and b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node differ diff --git a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node index 8317cca57643e091486fec058633c42d8003c36a..1430500f0b695e7155e22d47c0c7b0620dbee555 100644 Binary files a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node and b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node differ diff --git a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json index f700d5b63273ce7a66ef9a3643e15c8c8de7c84f..1661db68ab9ee650281b80add5e5bb82ebc062d0 100644 --- a/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json +++ b/.opencode/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "@msgpackr-extract/msgpackr-extract-linux-x64", - "version": "3.0.3", + "version": "3.0.4", "os": [ "linux" ], diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/index.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/index.d.ts index 2a905480f4685c01eb7fdd3a0dbe2cfc82fc5d02..24990d7361881ab700f4eabb552e30dc8b953ceb 100644 --- a/.opencode/node_modules/@opencode-ai/plugin/dist/index.d.ts +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/index.d.ts @@ -171,6 +171,7 @@ export type ProviderHook = { /** @deprecated Use AuthOAuthResult instead. */ export type AuthOuathResult = AuthOAuthResult; export interface Hooks { + dispose?: () => Promise; event?: (input: { event: Event; }) => Promise; @@ -267,6 +268,11 @@ export interface Hooks { }, output: { system: string[]; }) => Promise; + "experimental.provider.small_model"?: (input: { + provider: ProviderV2; + }, output: { + model?: ModelV2; + }) => Promise; /** * Called before session compaction starts. Allows plugins to customize * the compaction prompt. diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/tui.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/tui.d.ts index 5d00ea499758b61246200c2e5029d3624f54bbcd..e1bf699d878afd00cb0a8708d773da71365e8821 100644 --- a/.opencode/node_modules/@opencode-ai/plugin/dist/tui.d.ts +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/tui.d.ts @@ -33,6 +33,10 @@ export type TuiKeys = { formatBindings: (bindings: readonly SequenceBindingLike[] | undefined) => string | undefined; }; export type TuiKeymap = Keymap; +export type TuiModeApi = { + current: () => string; + push: (mode: string) => () => void; +}; /** * Legacy `api.command` shape kept so v1 plugins can initialize. Remove in v2. * @@ -145,7 +149,6 @@ export type TuiPromptRef = { }; export type TuiPromptProps = { sessionID?: string; - workspaceID?: string; visible?: boolean; disabled?: boolean; onSubmit?: () => void; @@ -293,6 +296,7 @@ export type TuiState = { }; readonly vcs: { branch?: string; + default_branch?: string; } | undefined; session: { count: () => number; @@ -353,12 +357,9 @@ export type TuiHostSlotMap = { app_bottom: {}; home_logo: {}; home_prompt: { - workspace_id?: string; ref?: (ref: TuiPromptRef | undefined) => void; }; - home_prompt_right: { - workspace_id?: string; - }; + home_prompt_right: {}; session_prompt: { session_id: string; visible?: boolean; @@ -467,6 +468,7 @@ export type TuiPluginApi = { command?: TuiCommandApi; keys: TuiKeys; keymap: TuiKeymap; + mode: TuiModeApi; route: { register: (routes: TuiRouteDefinition[]) => () => void; navigate: (name: string, params?: Record) => void; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c16855d45a3e508685c3ef18c0c33d747c43a9e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.d.ts @@ -0,0 +1,12 @@ +import type { AgentV2Info } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export interface AgentDraft { + list(): readonly AgentV2Info[]; + get(id: string): AgentV2Info | undefined; + default(id: string | undefined): void; + update(id: string, update: (agent: AgentV2Info) => void): void; + remove(id: string): void; +} +export type AgentHooks = Hooks<{ + transform: AgentDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/agent.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c43d6806ec64142be727c1bab110825ceda786ee --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.d.ts @@ -0,0 +1,17 @@ +import type { LanguageModelV3 } from "@ai-sdk/provider"; +import type { ModelV2Info } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export type AISDKHooks = Hooks<{ + sdk: { + readonly model: ModelV2Info; + readonly package: string; + readonly options: Record; + sdk?: any; + }; + language: { + readonly model: ModelV2Info; + readonly sdk: any; + readonly options: Record; + language?: LanguageModelV3; + }; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/aisdk.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8671f17062f57bd3c247870733cc475d7d58d0c --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.d.ts @@ -0,0 +1,29 @@ +import type { ModelV2Info, ProviderV2Info } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export interface CatalogProviderRecord { + readonly provider: ProviderV2Info; + readonly models: ReadonlyMap; +} +export interface CatalogDraft { + readonly provider: { + list(): readonly CatalogProviderRecord[]; + get(providerID: string): CatalogProviderRecord | undefined; + update(providerID: string, update: (provider: ProviderV2Info) => void): void; + remove(providerID: string): void; + }; + readonly model: { + get(providerID: string, modelID: string): ModelV2Info | undefined; + update(providerID: string, modelID: string, update: (model: ModelV2Info) => void): void; + remove(providerID: string, modelID: string): void; + readonly default: { + get(): { + providerID: string; + modelID: string; + } | undefined; + set(providerID: string, modelID: string): void; + }; + }; +} +export type CatalogHooks = Hooks<{ + transform: CatalogDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/catalog.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..659ece27eb15e00e92f138db31cdf2c9253ac6e5 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.d.ts @@ -0,0 +1,11 @@ +import type { CommandV2Info } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export interface CommandDraft { + list(): readonly CommandV2Info[]; + get(name: string): CommandV2Info | undefined; + update(name: string, update: (command: CommandV2Info) => void): void; + remove(name: string): void; +} +export type CommandHooks = Hooks<{ + transform: CommandDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/command.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..973364f8c1baa533e90cd287948262f0639ad7b2 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.d.ts @@ -0,0 +1,21 @@ +import type { PluginOptions } from "../options.js"; +import type { AgentHooks } from "./agent.js"; +import type { AISDKHooks } from "./aisdk.js"; +import type { CatalogHooks } from "./catalog.js"; +import type { CommandHooks } from "./command.js"; +import type { IntegrationHooks } from "./integration.js"; +import type { PluginDomain } from "./plugin.js"; +import type { ReferenceHooks } from "./reference.js"; +import type { SkillHooks } from "./skill.js"; +import type { Reload } from "./registration.js"; +export interface PluginContext { + readonly options: PluginOptions; + readonly agent: AgentHooks & Reload; + readonly aisdk: AISDKHooks; + readonly catalog: CatalogHooks & Reload; + readonly command: CommandHooks & Reload; + readonly integration: IntegrationHooks & Reload; + readonly plugin: PluginDomain; + readonly reference: ReferenceHooks & Reload; + readonly skill: SkillHooks & Reload; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/context.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49b5ae175607444492751e64533b5814bc9f4437 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.d.ts @@ -0,0 +1,8 @@ +import type { Event as SDKEvent } from "@opencode-ai/sdk/v2/types"; +import type { Stream } from "effect"; +export type EventMap = { + [Item in SDKEvent as Item["type"]]: Item; +}; +export interface Event { + subscribe(type: Type): Stream.Stream; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/event.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c3afbf3e0a0d3936a87e3ebc065fe049c2f01e8 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.d.ts @@ -0,0 +1,23 @@ +import type { FileSystemEntry } from "@opencode-ai/sdk/v2/types"; +import type { Effect } from "effect"; +export interface FileSystem { + read(input: { + readonly path: string; + }): Effect.Effect<{ + readonly content: Uint8Array; + readonly mime: string; + }>; + list(input?: { + readonly path?: string; + }): Effect.Effect; + find(input: { + readonly query: string; + readonly type?: "file" | "directory"; + readonly limit?: number; + }): Effect.Effect; + glob(input: { + readonly pattern: string; + readonly path?: string; + readonly limit?: number; + }): Effect.Effect; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/filesystem.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d6edbe6b777396e2a529b05ac08e8b0c95724ae --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.d.ts @@ -0,0 +1,3 @@ +export type { PluginContext } from "./context.js"; +export { define } from "./plugin.js"; +export type { Plugin } from "./plugin.js"; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5f1754034ec32a1910eb0b4bf1717bbe3f5f1f26 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/index.js @@ -0,0 +1 @@ +export { define } from "./plugin.js"; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d33e5bd9a905fb88a3e77f74ec95540b2ebf409d --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.d.ts @@ -0,0 +1,46 @@ +import type { ConnectionInfo, CredentialOAuth, CredentialValue, IntegrationEnvMethod, IntegrationInputs, IntegrationKeyMethod, IntegrationMethod, IntegrationOAuthMethod, IntegrationRef } from "@opencode-ai/sdk/v2/types"; +import type { Effect, Scope } from "effect"; +import type { Hooks } from "./registration.js"; +export type IntegrationOAuthAuthorization = { + readonly url: string; + readonly instructions: string; +} & ({ + readonly mode: "auto"; + readonly callback: Effect.Effect; +} | { + readonly mode: "code"; + readonly callback: (code: string) => Effect.Effect; +}); +export type IntegrationOAuthMethodRegistration = { + readonly integrationID: string; + readonly method: IntegrationOAuthMethod; + readonly authorize: (inputs: IntegrationInputs) => Effect.Effect; + readonly refresh?: (credential: CredentialOAuth) => Effect.Effect; + readonly label?: (credential: CredentialOAuth) => string | undefined; +}; +export type IntegrationMethodRegistration = IntegrationOAuthMethodRegistration | { + readonly integrationID: string; + readonly method: IntegrationKeyMethod; +} | { + readonly integrationID: string; + readonly method: IntegrationEnvMethod; +}; +export interface IntegrationDraft { + list(): readonly IntegrationRef[]; + get(id: string): IntegrationRef | undefined; + update(id: string, update: (integration: IntegrationRef) => void): void; + remove(id: string): void; + readonly method: { + list(integrationID: string): readonly IntegrationMethod[]; + update(input: IntegrationMethodRegistration): void; + remove(integrationID: string, method: IntegrationMethod): void; + }; +} +export interface IntegrationHooks extends Hooks<{ + transform: IntegrationDraft; +}> { + readonly connection: { + readonly active: (integrationID: string) => Effect.Effect; + readonly resolve: (connection: ConnectionInfo) => Effect.Effect; + }; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/integration.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f27fb637bf0e29a24ef67c6402e76f50a1b185a --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.d.ts @@ -0,0 +1,6 @@ +export interface Location { + readonly directory: string; + readonly project: { + readonly directory: string; + }; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/location.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca4270d47234c2dfd10f9bd8515c4e7763dfd533 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.d.ts @@ -0,0 +1,7 @@ +import type { Effect } from "effect"; +export interface Npm { + add(pkg: string): Effect.Effect<{ + readonly directory: string; + readonly entrypoint?: string; + }, unknown>; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/npm.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9284887638f0fec8f82678695173c5f0f29ce9d5 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.d.ts @@ -0,0 +1,8 @@ +export interface Path { + readonly home: string; + readonly data: string; + readonly cache: string; + readonly config: string; + readonly state: string; + readonly temp: string; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/path.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..788bd8d52d971937f7ec896f57cec902779c3edf --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.d.ts @@ -0,0 +1,11 @@ +import type { Effect, Scope } from "effect"; +import type { PluginContext } from "./context.js"; +export interface Plugin { + readonly id: string; + readonly effect: (context: PluginContext) => Effect.Effect; +} +export declare function define(plugin: Plugin): Plugin; +export interface PluginDomain { + readonly add: (plugin: Plugin) => Effect.Effect; + readonly remove: (id: string) => Effect.Effect; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.js new file mode 100644 index 0000000000000000000000000000000000000000..a12ab6d69fa5c10cc63a992e5b80a9e53a51a0c5 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/plugin.js @@ -0,0 +1,3 @@ +export function define(plugin) { + return plugin; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c6bbedda782d03c125567ebcb6398d5e58b1fa4 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.d.ts @@ -0,0 +1,10 @@ +import type { ReferenceGitSource, ReferenceLocalSource } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export interface ReferenceDraft { + add(name: string, source: ReferenceLocalSource | ReferenceGitSource): void; + remove(name: string): void; + list(): readonly (readonly [string, ReferenceLocalSource | ReferenceGitSource])[]; +} +export type ReferenceHooks = Hooks<{ + transform: ReferenceDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/reference.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fbefad718eec5297ef2d6669ad6252a67377d1d --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.d.ts @@ -0,0 +1,10 @@ +import type { Effect, Scope } from "effect"; +export interface Registration { + readonly dispose: Effect.Effect; +} +export interface Reload { + readonly reload: () => Effect.Effect; +} +export type Hooks = { + readonly [Name in keyof Spec]: (callback: (input: Spec[Name]) => Effect.Effect | void) => Effect.Effect; +}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/registration.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..01829b58abfec7c1e019a3aa3c4838676b1d449f --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.d.ts @@ -0,0 +1,9 @@ +import type { SkillV2Source } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export interface SkillDraft { + source(source: SkillV2Source): void; + list(): readonly SkillV2Source[]; +} +export type SkillHooks = Hooks<{ + transform: SkillDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/effect/skill.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c1535bb0345ce4f41b3068d86c97aec639d8e94 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.d.ts @@ -0,0 +1 @@ +export type PluginOptions = Readonly>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/options.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4e50a2730f46ff406e12e9f3e621f7ff180dead --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.d.ts @@ -0,0 +1,6 @@ +import type { AgentDraft } from "../effect/agent.js"; +import type { Hooks } from "./registration.js"; +export type { AgentDraft }; +export type AgentHooks = Hooks<{ + transform: AgentDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/agent.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c43d6806ec64142be727c1bab110825ceda786ee --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.d.ts @@ -0,0 +1,17 @@ +import type { LanguageModelV3 } from "@ai-sdk/provider"; +import type { ModelV2Info } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export type AISDKHooks = Hooks<{ + sdk: { + readonly model: ModelV2Info; + readonly package: string; + readonly options: Record; + sdk?: any; + }; + language: { + readonly model: ModelV2Info; + readonly sdk: any; + readonly options: Record; + language?: LanguageModelV3; + }; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/aisdk.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7bbf596fb28eeabeb74b0e255d4d9f23bfe51308 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.d.ts @@ -0,0 +1,6 @@ +import type { CatalogDraft, CatalogProviderRecord } from "../effect/catalog.js"; +import type { Hooks } from "./registration.js"; +export type { CatalogDraft, CatalogProviderRecord }; +export type CatalogHooks = Hooks<{ + transform: CatalogDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/catalog.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8deea91896be6861a4dde775740d11974ad9ea8f --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.d.ts @@ -0,0 +1,6 @@ +import type { CommandDraft } from "../effect/command.js"; +import type { Hooks } from "./registration.js"; +export type { CommandDraft }; +export type CommandHooks = Hooks<{ + transform: CommandDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/command.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..973364f8c1baa533e90cd287948262f0639ad7b2 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.d.ts @@ -0,0 +1,21 @@ +import type { PluginOptions } from "../options.js"; +import type { AgentHooks } from "./agent.js"; +import type { AISDKHooks } from "./aisdk.js"; +import type { CatalogHooks } from "./catalog.js"; +import type { CommandHooks } from "./command.js"; +import type { IntegrationHooks } from "./integration.js"; +import type { PluginDomain } from "./plugin.js"; +import type { ReferenceHooks } from "./reference.js"; +import type { SkillHooks } from "./skill.js"; +import type { Reload } from "./registration.js"; +export interface PluginContext { + readonly options: PluginOptions; + readonly agent: AgentHooks & Reload; + readonly aisdk: AISDKHooks; + readonly catalog: CatalogHooks & Reload; + readonly command: CommandHooks & Reload; + readonly integration: IntegrationHooks & Reload; + readonly plugin: PluginDomain; + readonly reference: ReferenceHooks & Reload; + readonly skill: SkillHooks & Reload; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/context.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f6875f927a39bce64b510d490302545961de700 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.d.ts @@ -0,0 +1,12 @@ +export type { PluginContext } from "./context.js"; +export type { PluginOptions } from "../options.js"; +export { define } from "./plugin.js"; +export type { Plugin, PluginDomain } from "./plugin.js"; +export type { Registration, Reload } from "./registration.js"; +export type { AgentDraft, AgentHooks } from "./agent.js"; +export type { AISDKHooks } from "./aisdk.js"; +export type { CatalogDraft, CatalogHooks, CatalogProviderRecord } from "./catalog.js"; +export type { CommandDraft, CommandHooks } from "./command.js"; +export type { IntegrationDraft, IntegrationHooks, IntegrationMethodRegistration } from "./integration.js"; +export type { ReferenceDraft, ReferenceHooks } from "./reference.js"; +export type { SkillDraft, SkillHooks } from "./skill.js"; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5f1754034ec32a1910eb0b4bf1717bbe3f5f1f26 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/index.js @@ -0,0 +1 @@ +export { define } from "./plugin.js"; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17e590fda842b746dcaaa2ca3ce1eebeeb9a5af6 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.d.ts @@ -0,0 +1,12 @@ +import type { IntegrationDraft, IntegrationMethodRegistration } from "../effect/integration.js"; +import type { CredentialValue } from "@opencode-ai/sdk/v2/types"; +import type { Hooks } from "./registration.js"; +export type { IntegrationDraft, IntegrationMethodRegistration }; +export interface IntegrationHooks extends Hooks<{ + transform: IntegrationDraft; +}> { + readonly connection: { + readonly active: (integrationID: string) => Promise; + readonly resolve: (connection: import("@opencode-ai/sdk/v2/types").ConnectionInfo) => Promise; + }; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/integration.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e313c10fb73973392efa7ca472f4ca6a413b065f --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.d.ts @@ -0,0 +1,10 @@ +import type { PluginContext } from "./context.js"; +export interface Plugin { + readonly id: string; + readonly setup: (context: PluginContext) => Promise | void; +} +export declare function define(plugin: Plugin): Plugin; +export interface PluginDomain { + readonly add: (plugin: Plugin) => Promise; + readonly remove: (id: string) => Promise; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.js new file mode 100644 index 0000000000000000000000000000000000000000..a12ab6d69fa5c10cc63a992e5b80a9e53a51a0c5 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/plugin.js @@ -0,0 +1,3 @@ +export function define(plugin) { + return plugin; +} diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..435aafcf77eaacd26094f4d210c3775cb784b910 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.d.ts @@ -0,0 +1,6 @@ +import type { ReferenceDraft } from "../effect/reference.js"; +import type { Hooks } from "./registration.js"; +export type { ReferenceDraft }; +export type ReferenceHooks = Hooks<{ + transform: ReferenceDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/reference.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6da7fd9858402d0596061d49f17a953327240dfc --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.d.ts @@ -0,0 +1,9 @@ +export interface Registration { + readonly dispose: () => Promise; +} +export interface Reload { + readonly reload: () => Promise; +} +export type Hooks = { + readonly [Name in keyof Spec]: (callback: (input: Spec[Name]) => Promise | void) => Promise; +}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/registration.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.d.ts b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0f813d4d05ca188202813ec3329c7779c890cf8 --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.d.ts @@ -0,0 +1,6 @@ +import type { SkillDraft } from "../effect/skill.js"; +import type { Hooks } from "./registration.js"; +export type { SkillDraft }; +export type SkillHooks = Hooks<{ + transform: SkillDraft; +}>; diff --git a/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.js b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.js new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/.opencode/node_modules/@opencode-ai/plugin/dist/v2/promise/skill.js @@ -0,0 +1 @@ +export {}; diff --git a/.opencode/node_modules/@opencode-ai/plugin/package.json b/.opencode/node_modules/@opencode-ai/plugin/package.json index fa03643bf0c8c1a5ee3d73c050d2b5a0edfe614f..891b6687f270225d09964be2789785094dc45def 100644 --- a/.opencode/node_modules/@opencode-ai/plugin/package.json +++ b/.opencode/node_modules/@opencode-ai/plugin/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@opencode-ai/plugin", - "version": "1.15.5", + "version": "1.18.21", "type": "module", "license": "MIT", "scripts": { @@ -20,20 +20,37 @@ "./tui": { "import": "./dist/tui.js", "types": "./dist/tui.d.ts" + }, + "./v2/effect": { + "import": "./dist/v2/effect/index.js", + "types": "./dist/v2/effect/index.d.ts" + }, + "./v2/effect/integration": { + "import": "./dist/v2/effect/integration.js", + "types": "./dist/v2/effect/integration.d.ts" + }, + "./v2/effect/plugin": { + "import": "./dist/v2/effect/plugin.js", + "types": "./dist/v2/effect/plugin.d.ts" + }, + "./v2/promise": { + "import": "./dist/v2/promise/index.js", + "types": "./dist/v2/promise/index.d.ts" } }, "files": [ "dist" ], "dependencies": { - "@opencode-ai/sdk": "1.15.5", - "effect": "4.0.0-beta.65", + "@ai-sdk/provider": "3.0.8", + "@opencode-ai/sdk": "1.18.21", + "effect": "4.0.0-beta.83", "zod": "4.1.8" }, "peerDependencies": { - "@opentui/core": ">=0.2.14", - "@opentui/keymap": ">=0.2.14", - "@opentui/solid": ">=0.2.14" + "@opentui/core": ">=0.4.5", + "@opentui/keymap": ">=0.4.5", + "@opentui/solid": ">=0.4.5" }, "peerDependenciesMeta": { "@opentui/core": { @@ -47,9 +64,9 @@ } }, "devDependencies": { - "@opentui/core": "0.2.14", - "@opentui/keymap": "0.2.14", - "@opentui/solid": "0.2.14", + "@opentui/core": "0.4.5", + "@opentui/keymap": "0.4.5", + "@opentui/solid": "0.4.5", "@tsconfig/node22": "22.0.2", "@types/node": "24.12.2", "typescript": "5.8.2",