diff --git a/.vscode/settings.json b/.vscode/settings.json index 023ab9d..eeae3d8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,6 +21,9 @@ "vikingdb", "websockets" ], + "markdownlint.config": { + "ol-prefix": false + }, "prettier.prettierPath": "config/eslint-config/node_modules/prettier", "editor.tabSize": 2, "editor.insertSpaces": true, @@ -68,7 +71,6 @@ "*.json": "jsonc", "package.json": "json", "README": "markdown", - "CODEOWNERS": "ini", "**/coverage/**/*.*": "plaintext", "**/pnpm-lock.yaml": "plaintext", "**/*.yml": "yaml" diff --git a/README.md b/README.md index 47ecb70..71afb3a 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,12 @@ This monorepo contains the following packages: | [@cozeloop/ai](./packages/cozeloop-ai) | CozeLoop API SDK | [![npm](https://img.shields.io/npm/v/@cozeloop/ai.svg)](https://www.npmjs.com/package/@cozeloop/ai) | | [@cozeloop/langchain](./packages/cozeloop-langchain) | CozeLoop LangChain Integration | [![npm](https://img.shields.io/npm/v/@cozeloop/langchain.svg)](https://www.npmjs.com/package/@cozeloop/langchain) | - ## 🎮 Examples Find usage examples for each package in the [examples](./examples) directory: - [cozeloop-ai-node](./examples/cozeloop-ai-node) - Node.js Demo for @cozeloop/ai - ## 🚀 Getting Started ### Prerequisites @@ -88,9 +86,9 @@ rushx start ## 📖 Documentation +- [Official Documentation](https://loop.coze.cn/open/docs/cozeloop/quick-start-nodejs) - [Contributing Guidelines](./CONTRIBUTING.md) ## 📄 License [MIT](./LICENSE) - diff --git a/README.zh-CN.md b/README.zh-CN.md index 15a52b4..50f8737 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -14,14 +14,12 @@ | [@cozeloop/ai](./packages/cozeloop-ai) | CozeLoop API SDK | [![npm](https://img.shields.io/npm/v/@cozeloop/ai.svg)](https://www.npmjs.com/package/@cozeloop/ai) | | [@cozeloop/langchain](./packages/cozeloop-langchain) | CozeLoop LangChain Integration | [![npm](https://img.shields.io/npm/v/@cozeloop/langchain.svg)](https://www.npmjs.com/package/@cozeloop/langchain) | - ## 🎮 示例 在 [examples](./examples) 目录中查找每个包的使用示例: - [cozeloop-ai-node](./examples/cozeloop-ai-node) - @cozeloop/ai 的 Node.js 使用示例 - ## 🚀 快速开始 ### 前置要求 @@ -86,9 +84,8 @@ npm run start ## 📖 文档 - +- [官方文档](https://loop.coze.cn/open/docs/cozeloop/quick-start-nodejs) - [贡献指南](./CONTRIBUTING.md) - ## 📄 许可证 diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index e5d80fc..273cd3f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -196,10 +196,10 @@ importers: version: 4.3.4(vite@5.4.14(@types/node@20.17.22)) '@vitest/coverage-v8': specifier: ~2.1.4 - version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) + version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) happy-dom: - specifier: ~15.11.0 - version: 15.11.7 + specifier: ^20.0.11 + version: 20.0.11 sucrase: specifier: ^3.32.0 version: 3.35.0 @@ -208,7 +208,7 @@ importers: version: 5.8.2 vitest: specifier: ~2.1.4 - version: 2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) + version: 2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) ../../examples/cozeloop-ai-node: dependencies: @@ -223,7 +223,7 @@ importers: version: 1.9.0 openai: specifier: ^4.92.0 - version: 4.92.1(ws@8.18.3)(zod@3.25.67) + version: 4.92.1(ws@8.18.3) devDependencies: '@loop-infra/eslint-config': specifier: workspace:* @@ -276,7 +276,7 @@ importers: version: 20.17.22 '@vitest/coverage-v8': specifier: ~2.1.4 - version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) + version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) msw: specifier: ^2.7.3 version: 2.7.3(@types/node@20.17.22)(typescript@5.8.2) @@ -285,13 +285,13 @@ importers: version: 3.0.2 tsup: specifier: ^8.0.1 - version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2)(yaml@2.8.0) + version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2) typescript: specifier: ^5.5.3 version: 5.8.2 vitest: specifier: ~2.1.4 - version: 2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) + version: 2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) ../../packages/cozeloop-ai: dependencies: @@ -367,7 +367,7 @@ importers: version: 1.1.6 '@vitest/coverage-v8': specifier: ~2.1.4 - version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) + version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) axios: specifier: ^1.8.2 version: 1.9.0 @@ -382,13 +382,13 @@ importers: version: 3.0.2 tsup: specifier: ^8.0.1 - version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2)(yaml@2.8.0) + version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2) typescript: specifier: ^5.5.3 version: 5.8.2 vitest: specifier: ~2.1.4 - version: 2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) + version: 2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) ../../packages/cozeloop-langchain: dependencies: @@ -418,14 +418,14 @@ importers: version: 2.1.29 devDependencies: '@langchain/core': - specifier: ^0.3.61 - version: 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) + specifier: ^1.1.8 + version: 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) '@langchain/langgraph': - specifier: ^0.3.1 - version: 0.3.1(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(zod-to-json-schema@3.24.5(zod@3.25.67)) + specifier: ^1.0.7 + version: 1.0.7(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(zod@4.3.5) '@langchain/openai': - specifier: ^0.5.12 - version: 0.5.15(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(ws@8.18.3) + specifier: ^1.2.0 + version: 1.2.0(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(ws@8.18.3) '@loop-infra/eslint-config': specifier: workspace:* version: link:../../config/eslint-config @@ -440,22 +440,22 @@ importers: version: 20.17.22 '@vitest/coverage-v8': specifier: ~2.1.4 - version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) + version: 2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))) langchain: - specifier: ^0.3.28 - version: 0.3.29(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(axios@1.9.0)(openai@5.7.0(ws@8.18.3)(zod@3.25.67))(ws@8.18.3) + specifier: ^1.2.3 + version: 1.2.3(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) msw: specifier: ^2.7.3 version: 2.7.3(@types/node@20.17.22)(typescript@5.8.2) tsup: specifier: ^8.0.1 - version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2)(yaml@2.8.0) + version: 8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2) typescript: specifier: ^5.5.3 version: 5.8.2 vitest: specifier: ~2.1.4 - version: 2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) + version: 2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) packages: @@ -1611,48 +1611,46 @@ packages: '@js-sdsl/ordered-map@4.4.2': resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} - '@langchain/core@0.3.61': - resolution: {integrity: sha512-4O7fw5SXNSE+uBnathLQrhm3t+7dZGagt/5kt37A+pXw0AkudxEBvveg73sSnpBd9SIz3/Vc7F4k8rCKXGbEDA==} - engines: {node: '>=18'} + '@langchain/core@1.1.8': + resolution: {integrity: sha512-kIUidOgc0ZdyXo4Ahn9Zas+OayqOfk4ZoKPi7XaDipNSWSApc2+QK5BVcjvwtzxstsNOrmXJiJWEN6WPF/MvAw==} + engines: {node: '>=20'} - '@langchain/langgraph-checkpoint@0.0.18': - resolution: {integrity: sha512-IS7zJj36VgY+4pf8ZjsVuUWef7oTwt1y9ylvwu0aLuOn1d0fg05Om9DLm3v2GZ2Df6bhLV1kfWAM0IAl9O5rQQ==} + '@langchain/langgraph-checkpoint@1.0.0': + resolution: {integrity: sha512-xrclBGvNCXDmi0Nz28t3vjpxSH6UYx6w5XAXSiiB1WEdc2xD2iY/a913I3x3a31XpInUW/GGfXXfePfaghV54A==} engines: {node: '>=18'} peerDependencies: - '@langchain/core': '>=0.2.31 <0.4.0' + '@langchain/core': ^1.0.1 - '@langchain/langgraph-sdk@0.0.83': - resolution: {integrity: sha512-xYW1kX5GuGbuvAtNFMjknHcDCOz0s5Dwu7VP4kfz7F9NVQ+ftAZP2m79xEMTUY1WoXZdOxqBqONpizqMcO1zAw==} + '@langchain/langgraph-sdk@1.3.1': + resolution: {integrity: sha512-zTi7DZHwqtMEzapvm3I1FL4Q7OZsxtq9tTXy6s2gcCxyIU3sphqRboqytqVN7dNHLdTCLb8nXy49QKurs2MIBg==} peerDependencies: - '@langchain/core': '>=0.2.31 <0.4.0' + '@langchain/core': ^1.0.1 react: ^18 || ^19 + react-dom: ^18 || ^19 peerDependenciesMeta: '@langchain/core': optional: true react: optional: true + react-dom: + optional: true - '@langchain/langgraph@0.3.1': - resolution: {integrity: sha512-BFa6DmKthPG1znkUhTBBqdza4dojs7QGg6o9V9aptIkWWdBF/UhRbjPvCx6ldkmU2oJRNWZ1BlkiP6RflxxPwA==} + '@langchain/langgraph@1.0.7': + resolution: {integrity: sha512-EBGqNOWoRiEoLUaeuiXRpUM8/DE6QcwiirNyd97XhezStebBoTTilWH8CUt6S94JRGl5zwfBBRHfzotDnZS/eA==} engines: {node: '>=18'} peerDependencies: - '@langchain/core': '>=0.2.36 <0.3.0 || >=0.3.40 < 0.4.0' + '@langchain/core': ^1.0.1 + zod: ^3.25.32 || ^4.1.0 zod-to-json-schema: ^3.x peerDependenciesMeta: zod-to-json-schema: optional: true - '@langchain/openai@0.5.15': - resolution: {integrity: sha512-ANadEHyAj5sufQpz+SOPpKbyoMcTLhnh8/d+afbSPUqWsIMPpEFX3HoSY3nrBPG6l4NQQNG5P5oHb4SdC8+YIg==} - engines: {node: '>=18'} - peerDependencies: - '@langchain/core': '>=0.3.58 <0.4.0' - - '@langchain/textsplitters@0.1.0': - resolution: {integrity: sha512-djI4uw9rlkAb5iMhtLED+xJebDdAG935AdP4eRTB02R7OB/act55Bj9wsskhZsvuyQRpO4O1wQOp85s6T6GWmw==} - engines: {node: '>=18'} + '@langchain/openai@1.2.0': + resolution: {integrity: sha512-r2g5Be3Sygw7VTJ89WVM/M94RzYToNTwXf8me1v+kgKxzdHbd/8XPYDFxpXEp3REyPgUrtJs+Oplba9pkTH5ug==} + engines: {node: '>=20'} peerDependencies: - '@langchain/core': '>=0.2.21 <0.4.0' + '@langchain/core': ^1.0.0 '@larksuiteoapi/node-sdk@1.50.1': resolution: {integrity: sha512-hhB+HpTNl4HED9WGzL+2EhU4zQBYVtbTxVHBagohIm5iryNx1g0y7S3l6uAB54vbsnLKRireiH/r+bkV8ViXRg==} @@ -2101,6 +2099,9 @@ packages: '@types/uuid@10.0.0': resolution: {integrity: sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==} + '@types/whatwg-mimetype@3.0.2': + resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==} + '@typescript-eslint/eslint-plugin@5.38.1': resolution: {integrity: sha512-ky7EFzPhqz3XlhS7vPOoMDaQnQMn+9o5ICR9CPr/6bw8HrFkzhMSxuA3gRfiJVvs7geYrSeawGJjZoZQKCOglQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2743,10 +2744,6 @@ packages: resolution: {integrity: sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==} engines: {node: '>=10.13.0'} - entities@4.5.0: - resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} - engines: {node: '>=0.12'} - err-code@2.0.3: resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==} @@ -3252,9 +3249,9 @@ packages: resolution: {integrity: sha512-AjqGKbDGUFRKIRCP9tCKiIGHyriz2oHEbPIbEtcSLSs4YjReZOIPQQWek4+6hjw62H9QShXHyaGivGiYVLeYFQ==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} - happy-dom@15.11.7: - resolution: {integrity: sha512-KyrFvnl+J9US63TEzwoiJOQzZBJY7KgBushJA8X61DMbNsH+2ONkDuLDnCnwUiPTF42tLoEmrPyoqbenVA5zrg==} - engines: {node: '>=18.0.0'} + happy-dom@20.0.11: + resolution: {integrity: sha512-QsCdAUHAmiDeKeaNojb1OHOPF7NjcWPBR7obdu3NwH2a/oyQaLg5d0aaCy/9My6CdPChYF07dvz5chaXBGaD4g==} + engines: {node: '>=20.0.0'} has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} @@ -3527,10 +3524,6 @@ packages: engines: {node: '>=6'} hasBin: true - jsonpointer@5.0.1: - resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==} - engines: {node: '>=0.10.0'} - jsonwebtoken@9.0.2: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} engines: {node: '>=12', npm: '>=6'} @@ -3548,69 +3541,26 @@ packages: keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} - langchain@0.3.29: - resolution: {integrity: sha512-L389pKlApVJPqu4hp58qY6NZAobI+MFPoBjSfjT1z3mcxtB68wLFGhaH4DVsTVg21NYO+0wTEoz24BWrxu9YGw==} - engines: {node: '>=18'} + langchain@1.2.3: + resolution: {integrity: sha512-3k986xJuqg4az53JxV5LnGlOzIXF1d9Kq6Y9s7XjitvzhpsbFuTDV5/kiF4cx3pkNGyw0mUXC4tLz9RxucO0hw==} + engines: {node: '>=20'} peerDependencies: - '@langchain/anthropic': '*' - '@langchain/aws': '*' - '@langchain/cerebras': '*' - '@langchain/cohere': '*' - '@langchain/core': '>=0.3.58 <0.4.0' - '@langchain/deepseek': '*' - '@langchain/google-genai': '*' - '@langchain/google-vertexai': '*' - '@langchain/google-vertexai-web': '*' - '@langchain/groq': '*' - '@langchain/mistralai': '*' - '@langchain/ollama': '*' - '@langchain/xai': '*' - axios: '*' - cheerio: '*' - handlebars: ^4.7.8 - peggy: ^3.0.2 - typeorm: '*' - peerDependenciesMeta: - '@langchain/anthropic': - optional: true - '@langchain/aws': - optional: true - '@langchain/cerebras': - optional: true - '@langchain/cohere': - optional: true - '@langchain/deepseek': - optional: true - '@langchain/google-genai': - optional: true - '@langchain/google-vertexai': - optional: true - '@langchain/google-vertexai-web': - optional: true - '@langchain/groq': - optional: true - '@langchain/mistralai': - optional: true - '@langchain/ollama': - optional: true - '@langchain/xai': - optional: true - axios: - optional: true - cheerio: - optional: true - handlebars: - optional: true - peggy: - optional: true - typeorm: - optional: true + '@langchain/core': 1.1.8 - langsmith@0.3.33: - resolution: {integrity: sha512-imNIaBL6+ElE5eMzNHYwFxo6W/6rHlqcaUjCYoIeGdCYWlARxE3CTGKul5DJnaUgGP2CTLFeNXyvRx5HWC/4KQ==} + langsmith@0.4.4: + resolution: {integrity: sha512-rpLzrklyL7fIP/8wwrSv2tKDwMJTvkhgWeKxDvmbAB2n/p5FzqujEWCpA//u9hnrdmXZc1dCJZ+iqN6KgaEoEA==} peerDependencies: + '@opentelemetry/api': '*' + '@opentelemetry/exporter-trace-otlp-proto': '*' + '@opentelemetry/sdk-trace-base': '*' openai: '*' peerDependenciesMeta: + '@opentelemetry/api': + optional: true + '@opentelemetry/exporter-trace-otlp-proto': + optional: true + '@opentelemetry/sdk-trace-base': + optional: true openai: optional: true @@ -3878,21 +3828,18 @@ packages: zod: optional: true - openai@5.7.0: - resolution: {integrity: sha512-zXWawZl6J/P5Wz57/nKzVT3kJQZvogfuyuNVCdEp4/XU2UNrjL7SsuNpWAyLZbo6HVymwmnfno9toVzBhelygA==} + openai@6.15.0: + resolution: {integrity: sha512-F1Lvs5BoVvmZtzkUEVyh8mDQPPFolq4F+xdsx/DO8Hee8YF3IGAlZqUIsF+DVGhqf4aU0a3bTghsxB6OIsRy1g==} hasBin: true peerDependencies: ws: ^8.18.0 - zod: ^3.23.8 + zod: ^3.25 || ^4.0 peerDependenciesMeta: ws: optional: true zod: optional: true - openapi-types@12.1.3: - resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==} - optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -4705,10 +4652,6 @@ packages: webidl-conversions@4.0.2: resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} - webidl-conversions@7.0.0: - resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} - engines: {node: '>=12'} - whatwg-mimetype@3.0.0: resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==} engines: {node: '>=12'} @@ -4787,11 +4730,6 @@ packages: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} engines: {node: '>= 6'} - yaml@2.8.0: - resolution: {integrity: sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==} - engines: {node: '>= 14.6'} - hasBin: true - yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -4808,13 +4746,8 @@ packages: resolution: {integrity: sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA==} engines: {node: '>=18'} - zod-to-json-schema@3.24.5: - resolution: {integrity: sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==} - peerDependencies: - zod: ^3.24.1 - - zod@3.25.67: - resolution: {integrity: sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw==} + zod@4.3.5: + resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==} snapshots: @@ -6014,63 +5947,57 @@ snapshots: '@js-sdsl/ordered-map@4.4.2': {} - '@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67))': + '@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5))': dependencies: '@cfworker/json-schema': 4.1.1 ansi-styles: 5.2.0 camelcase: 6.3.0 decamelize: 1.2.0 js-tiktoken: 1.0.20 - langsmith: 0.3.33(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) + langsmith: 0.4.4(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) mustache: 4.2.0 p-queue: 6.6.2 - p-retry: 4.6.2 uuid: 10.0.0 - zod: 3.25.67 - zod-to-json-schema: 3.24.5(zod@3.25.67) + zod: 4.3.5 transitivePeerDependencies: + - '@opentelemetry/api' + - '@opentelemetry/exporter-trace-otlp-proto' + - '@opentelemetry/sdk-trace-base' - openai - '@langchain/langgraph-checkpoint@0.0.18(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))': + '@langchain/langgraph-checkpoint@1.0.0(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))': dependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) + '@langchain/core': 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) uuid: 10.0.0 - '@langchain/langgraph-sdk@0.0.83(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))': + '@langchain/langgraph-sdk@1.3.1(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))': dependencies: - '@types/json-schema': 7.0.15 p-queue: 6.6.2 p-retry: 4.6.2 uuid: 9.0.1 optionalDependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) + '@langchain/core': 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) - '@langchain/langgraph@0.3.1(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(zod-to-json-schema@3.24.5(zod@3.25.67))': + '@langchain/langgraph@1.0.7(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(zod@4.3.5)': dependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) - '@langchain/langgraph-checkpoint': 0.0.18(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67))) - '@langchain/langgraph-sdk': 0.0.83(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67))) + '@langchain/core': 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) + '@langchain/langgraph-checkpoint': 1.0.0(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5))) + '@langchain/langgraph-sdk': 1.3.1(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5))) uuid: 10.0.0 - zod: 3.25.67 - optionalDependencies: - zod-to-json-schema: 3.24.5(zod@3.25.67) + zod: 4.3.5 transitivePeerDependencies: - react + - react-dom - '@langchain/openai@0.5.15(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(ws@8.18.3)': + '@langchain/openai@1.2.0(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(ws@8.18.3)': dependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) + '@langchain/core': 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) js-tiktoken: 1.0.20 - openai: 5.7.0(ws@8.18.3)(zod@3.25.67) - zod: 3.25.67 + openai: 6.15.0(ws@8.18.3)(zod@4.3.5) + zod: 4.3.5 transitivePeerDependencies: - ws - '@langchain/textsplitters@0.1.0(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))': - dependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) - js-tiktoken: 1.0.20 - '@larksuiteoapi/node-sdk@1.50.1': dependencies: axios: 0.27.2 @@ -6585,6 +6512,8 @@ snapshots: '@types/uuid@10.0.0': {} + '@types/whatwg-mimetype@3.0.2': {} + '@typescript-eslint/eslint-plugin@5.38.1(@typescript-eslint/parser@5.38.1(eslint@9.14.0)(typescript@5.8.2))(eslint@9.14.0)(typescript@5.8.2)': dependencies: '@typescript-eslint/parser': 5.38.1(eslint@9.14.0)(typescript@5.8.2) @@ -6853,7 +6782,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitest/coverage-v8@2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)))': + '@vitest/coverage-v8@2.1.9(vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -6867,7 +6796,7 @@ snapshots: std-env: 3.8.0 test-exclude: 7.0.1 tinyrainbow: 1.2.0 - vitest: 2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) + vitest: 2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)) transitivePeerDependencies: - supports-color @@ -7374,8 +7303,6 @@ snapshots: graceful-fs: 4.2.11 tapable: 2.2.1 - entities@4.5.0: {} - err-code@2.0.3: {} error-ex@1.3.2: @@ -8085,10 +8012,10 @@ snapshots: graphql@16.10.0: {} - happy-dom@15.11.7: + happy-dom@20.0.11: dependencies: - entities: 4.5.0 - webidl-conversions: 7.0.0 + '@types/node': 20.17.22 + '@types/whatwg-mimetype': 3.0.2 whatwg-mimetype: 3.0.0 has-bigints@1.1.0: {} @@ -8351,8 +8278,6 @@ snapshots: json5@2.2.3: {} - jsonpointer@5.0.1: {} - jsonwebtoken@9.0.2: dependencies: jws: 3.2.2 @@ -8388,37 +8313,36 @@ snapshots: dependencies: json-buffer: 3.0.1 - langchain@0.3.29(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(axios@1.9.0)(openai@5.7.0(ws@8.18.3)(zod@3.25.67))(ws@8.18.3): + langchain@1.2.3(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)): dependencies: - '@langchain/core': 0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) - '@langchain/openai': 0.5.15(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67)))(ws@8.18.3) - '@langchain/textsplitters': 0.1.0(@langchain/core@0.3.61(openai@5.7.0(ws@8.18.3)(zod@3.25.67))) - js-tiktoken: 1.0.20 - js-yaml: 4.1.0 - jsonpointer: 5.0.1 - langsmith: 0.3.33(openai@5.7.0(ws@8.18.3)(zod@3.25.67)) - openapi-types: 12.1.3 - p-retry: 4.6.2 + '@langchain/core': 1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) + '@langchain/langgraph': 1.0.7(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)))(zod@4.3.5) + '@langchain/langgraph-checkpoint': 1.0.0(@langchain/core@1.1.8(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5))) + langsmith: 0.4.4(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)) uuid: 10.0.0 - yaml: 2.8.0 - zod: 3.25.67 - optionalDependencies: - axios: 1.9.0 + zod: 4.3.5 transitivePeerDependencies: + - '@opentelemetry/api' + - '@opentelemetry/exporter-trace-otlp-proto' + - '@opentelemetry/sdk-trace-base' - openai - - ws + - react + - react-dom + - zod-to-json-schema - langsmith@0.3.33(openai@5.7.0(ws@8.18.3)(zod@3.25.67)): + langsmith@0.4.4(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(openai@6.15.0(ws@8.18.3)(zod@4.3.5)): dependencies: '@types/uuid': 10.0.0 chalk: 4.1.2 console-table-printer: 2.14.2 p-queue: 6.6.2 - p-retry: 4.6.2 semver: 7.7.1 uuid: 10.0.0 optionalDependencies: - openai: 5.7.0(ws@8.18.3)(zod@3.25.67) + '@opentelemetry/api': 1.9.0 + '@opentelemetry/exporter-trace-otlp-proto': 0.57.2(@opentelemetry/api@1.9.0) + '@opentelemetry/sdk-trace-base': 1.30.1(@opentelemetry/api@1.9.0) + openai: 6.15.0(ws@8.18.3)(zod@4.3.5) language-subtag-registry@0.3.23: {} @@ -8653,7 +8577,7 @@ snapshots: dependencies: wrappy: 1.0.2 - openai@4.92.1(ws@8.18.3)(zod@3.25.67): + openai@4.92.1(ws@8.18.3): dependencies: '@types/node': 18.19.86 '@types/node-fetch': 2.6.12 @@ -8664,16 +8588,13 @@ snapshots: node-fetch: 2.7.0 optionalDependencies: ws: 8.18.3 - zod: 3.25.67 transitivePeerDependencies: - encoding - openai@5.7.0(ws@8.18.3)(zod@3.25.67): + openai@6.15.0(ws@8.18.3)(zod@4.3.5): optionalDependencies: ws: 8.18.3 - zod: 3.25.67 - - openapi-types@12.1.3: {} + zod: 4.3.5 optionator@0.9.4: dependencies: @@ -8772,13 +8693,12 @@ snapshots: possible-typed-array-names@1.1.0: {} - postcss-load-config@6.0.1(postcss@8.5.3)(tsx@4.20.5)(yaml@2.8.0): + postcss-load-config@6.0.1(postcss@8.5.3)(tsx@4.20.5): dependencies: lilconfig: 3.1.3 optionalDependencies: postcss: 8.5.3 tsx: 4.20.5 - yaml: 2.8.0 postcss@8.5.3: dependencies: @@ -9313,7 +9233,7 @@ snapshots: tslib@2.8.1: {} - tsup@8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2)(yaml@2.8.0): + tsup@8.4.0(postcss@8.5.3)(tsx@4.20.5)(typescript@5.8.2): dependencies: bundle-require: 5.1.0(esbuild@0.25.0) cac: 6.7.14 @@ -9323,7 +9243,7 @@ snapshots: esbuild: 0.25.0 joycon: 3.1.1 picocolors: 1.1.1 - postcss-load-config: 6.0.1(postcss@8.5.3)(tsx@4.20.5)(yaml@2.8.0) + postcss-load-config: 6.0.1(postcss@8.5.3)(tsx@4.20.5) resolve-from: 5.0.0 rollup: 4.34.9 source-map: 0.8.0-beta.0 @@ -9487,7 +9407,7 @@ snapshots: '@types/node': 20.17.22 fsevents: 2.3.3 - vitest@2.1.9(@types/node@20.17.22)(happy-dom@15.11.7)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)): + vitest@2.1.9(@types/node@20.17.22)(happy-dom@20.0.11)(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2)): dependencies: '@vitest/expect': 2.1.9 '@vitest/mocker': 2.1.9(msw@2.7.3(@types/node@20.17.22)(typescript@5.8.2))(vite@5.4.14(@types/node@20.17.22)) @@ -9511,7 +9431,7 @@ snapshots: why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 20.17.22 - happy-dom: 15.11.7 + happy-dom: 20.0.11 transitivePeerDependencies: - less - lightningcss @@ -9529,8 +9449,6 @@ snapshots: webidl-conversions@4.0.2: {} - webidl-conversions@7.0.0: {} - whatwg-mimetype@3.0.0: {} whatwg-url@5.0.0: @@ -9623,8 +9541,6 @@ snapshots: yaml@1.10.2: {} - yaml@2.8.0: {} - yargs-parser@21.1.1: {} yargs@17.7.2: @@ -9641,8 +9557,4 @@ snapshots: yoctocolors-cjs@2.1.2: {} - zod-to-json-schema@3.24.5(zod@3.25.67): - dependencies: - zod: 3.25.67 - - zod@3.25.67: {} + zod@4.3.5: {} diff --git a/config/vitest-config/package.json b/config/vitest-config/package.json index cbd25ff..b531b7a 100644 --- a/config/vitest-config/package.json +++ b/config/vitest-config/package.json @@ -21,7 +21,7 @@ "@types/node": "^20", "@vitejs/plugin-react": "~4.3.3", "@vitest/coverage-v8": "~2.1.4", - "happy-dom": "~15.11.0", + "happy-dom": "^20.0.11", "sucrase": "^3.32.0", "typescript": "^5.5.3", "vitest": "~2.1.4" diff --git a/packages/cozeloop-langchain/__tests__/__mock__/custom-chat-model.ts b/packages/cozeloop-langchain/__tests__/__mock__/custom-chat-model.ts index 7e55ec3..7d80907 100644 --- a/packages/cozeloop-langchain/__tests__/__mock__/custom-chat-model.ts +++ b/packages/cozeloop-langchain/__tests__/__mock__/custom-chat-model.ts @@ -39,9 +39,6 @@ export class CustomChatModel extends SimpleChatModel { } // Pass `runManager?.getChild()` when invoking internal runnables to enable tracing // await subRunnable.invoke(params, runManager?.getChild()); - if (typeof messages[0].content !== 'string') { - throw new Error('Multimodal messages are not supported.'); - } return await setTimeout(this.delay, `[MOCK] ${JSON.stringify(messages)}`); } @@ -53,9 +50,6 @@ export class CustomChatModel extends SimpleChatModel { if (!messages.length) { throw new Error('No messages provided.'); } - if (typeof messages[0].content !== 'string') { - throw new Error('Multimodal messages are not supported.'); - } // Pass `runManager?.getChild()` when invoking internal runnables to enable tracing // await subRunnable.invoke(params, runManager?.getChild()); const fullText = messages.map(it => it.content || '').join(','); diff --git a/packages/cozeloop-langchain/__tests__/__mock__/custom-llm-graph.ts b/packages/cozeloop-langchain/__tests__/__mock__/custom-llm-graph.ts index fe054dc..37410f2 100644 --- a/packages/cozeloop-langchain/__tests__/__mock__/custom-llm-graph.ts +++ b/packages/cozeloop-langchain/__tests__/__mock__/custom-llm-graph.ts @@ -1,12 +1,11 @@ -import { type } from 'arktype'; -import { createReactAgent } from '@langchain/langgraph/prebuilt'; -import { tool } from '@langchain/core/tools'; +import { createAgent, tool } from 'langchain'; +import { type as arktype } from 'arktype'; import { CustomChatModel } from './custom-chat-model'; const model = new CustomChatModel({}); -const weatherSchema = type({ +const weatherSchema = arktype({ /** Location to get the weather for. */ location: "'sf' | 'nyc'", }); @@ -22,15 +21,12 @@ const getWeather = tool( { name: 'get_weather', description: 'Call to get the current weather.', - schema: weatherSchema as any, + schema: weatherSchema.toJsonSchema(), }, ); -// We can add our system prompt here -const prompt = 'Respond in Italian'; - -export const customAgent = createReactAgent({ - llm: model, +export const customAgent = createAgent({ + model, tools: [getWeather], - stateModifier: prompt, + systemPrompt: 'You are a helpful assistant', }); diff --git a/packages/cozeloop-langchain/__tests__/__mock__/graph-agent.ts b/packages/cozeloop-langchain/__tests__/__mock__/graph-agent.ts index 5b5756b..4d01179 100644 --- a/packages/cozeloop-langchain/__tests__/__mock__/graph-agent.ts +++ b/packages/cozeloop-langchain/__tests__/__mock__/graph-agent.ts @@ -1,7 +1,6 @@ +import { createAgent, tool } from 'langchain'; import { type as arktype } from 'arktype'; import { AzureChatOpenAI } from '@langchain/openai'; -import { createReactAgent } from '@langchain/langgraph/prebuilt'; -import { tool } from '@langchain/core/tools'; const searchSchema = arktype({ /** The query to use in your search. */ @@ -10,10 +9,8 @@ const searchSchema = arktype({ const search = tool( (input: typeof searchSchema.infer) => { - if ( - input.query.toLowerCase().includes('sf') || - input.query.toLowerCase().includes('san francisco') - ) { + const query = input.query?.toLowerCase() ?? ''; + if (query.includes('sf') || query.includes('san francisco')) { return "It's 60 degrees and foggy."; } return "It's 90 degrees and sunny."; @@ -21,7 +18,7 @@ const search = tool( { name: 'search', description: 'Call to surf the web.', - schema: searchSchema as any, + schema: searchSchema.toJsonSchema() as any, }, ); @@ -36,7 +33,7 @@ const model = new AzureChatOpenAI({ maxTokens: 1000, }); -export const graphAgent = createReactAgent({ - llm: model, +export const graphAgent = createAgent({ + model, tools: [search], }); diff --git a/packages/cozeloop-langchain/__tests__/__mock__/index.ts b/packages/cozeloop-langchain/__tests__/__mock__/index.ts index 70a9972..51293f9 100644 --- a/packages/cozeloop-langchain/__tests__/__mock__/index.ts +++ b/packages/cozeloop-langchain/__tests__/__mock__/index.ts @@ -1,6 +1,6 @@ export { CustomLLM } from './custom-model'; export { CustomRetriever } from './custom-retriever'; -export { reactAgentExecutor } from './react-agent'; +export { reactAgent } from './react-agent'; export { customAgent } from './custom-llm-graph'; export { graphAgent } from './graph-agent'; export { fanGraph } from './fan-in-out'; diff --git a/packages/cozeloop-langchain/__tests__/__mock__/react-agent.ts b/packages/cozeloop-langchain/__tests__/__mock__/react-agent.ts index b602748..d8d6006 100644 --- a/packages/cozeloop-langchain/__tests__/__mock__/react-agent.ts +++ b/packages/cozeloop-langchain/__tests__/__mock__/react-agent.ts @@ -1,13 +1,8 @@ import { setTimeout } from 'node:timers/promises'; -import { AgentExecutor, createOpenAIToolsAgent } from 'langchain/agents'; +import { createAgent } from 'langchain'; import { AzureChatOpenAI } from '@langchain/openai'; import { DynamicTool } from '@langchain/core/tools'; -import { - ChatPromptTemplate, - MessagesPlaceholder, -} from '@langchain/core/prompts'; -import { SystemMessage } from '@langchain/core/messages'; const translationTool = new DynamicTool({ name: 'translator', @@ -18,7 +13,7 @@ const translationTool = new DynamicTool({ const tools = [translationTool]; -const llm = new AzureChatOpenAI({ +const model = new AzureChatOpenAI({ temperature: 0, modelName: 'gpt-4o-2024-05-13', azureOpenAIApiInstanceName: 'azure-ins', @@ -29,16 +24,8 @@ const llm = new AzureChatOpenAI({ maxTokens: 1000, }); -const agent = await createOpenAIToolsAgent({ - llm, - tools, - prompt: ChatPromptTemplate.fromMessages([ - new SystemMessage('translate user query. {agent_scratchpad}'), - new MessagesPlaceholder('agent_scratchpad'), - ]), -}); - -export const reactAgentExecutor = new AgentExecutor({ - agent, +export const reactAgent = await createAgent({ + model, tools, + systemPrompt: 'translate user query. {agent_scratchpad}', }); diff --git a/packages/cozeloop-langchain/__tests__/callback/callback-handler.test.ts b/packages/cozeloop-langchain/__tests__/callback/callback-handler.test.ts index 77c6526..fb37535 100644 --- a/packages/cozeloop-langchain/__tests__/callback/callback-handler.test.ts +++ b/packages/cozeloop-langchain/__tests__/callback/callback-handler.test.ts @@ -9,7 +9,7 @@ import { import { CustomLLM, CustomRetriever, - reactAgentExecutor, + reactAgent, graphAgent, fanGraph, setupTraceMock, @@ -77,8 +77,8 @@ describe('Callback with langchain', () => { it.skip('🧪 react agent', async () => { const callback = makeCallback(); - const resp = await reactAgentExecutor.invoke( - { input: '翻译「苹果」到英文' }, + const resp = await reactAgent.invoke( + { messages: [{ role: 'user', content: '翻译「苹果」到英文' }] }, { callbacks: [callback] }, ); diff --git a/packages/cozeloop-langchain/package.json b/packages/cozeloop-langchain/package.json index b96aab4..bb02083 100644 --- a/packages/cozeloop-langchain/package.json +++ b/packages/cozeloop-langchain/package.json @@ -55,15 +55,15 @@ "arktype": "^2.1.29" }, "devDependencies": { - "@langchain/core": "^0.3.61", - "@langchain/langgraph": "^0.3.1", - "@langchain/openai": "^0.5.12", + "@langchain/core": "^1.1.8", + "@langchain/langgraph": "^1.0.7", + "@langchain/openai": "^1.2.0", "@loop-infra/eslint-config": "workspace:*", "@loop-infra/ts-config": "workspace:*", "@loop-infra/vitest-config": "workspace:*", "@types/node": "^20", "@vitest/coverage-v8": "~2.1.4", - "langchain": "^0.3.28", + "langchain": "^1.2.3", "msw": "^2.7.3", "tsup": "^8.0.1", "typescript": "^5.5.3", diff --git a/rush.json b/rush.json index a94da77..4791fc2 100644 --- a/rush.json +++ b/rush.json @@ -1,407 +1,23 @@ -/** - * This is the main configuration file for Rush. - * For full documentation, please see https://rushjs.io - */ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", - - /** - * (Required) This specifies the version of the Rush engine to be used in this repo. - * Rush's "version selector" feature ensures that the globally installed tool will - * behave like this release, regardless of which version is installed globally. - * - * The common/scripts/install-run-rush.js automation script also uses this version. - * - * NOTE: If you upgrade to a new major version of Rush, you should replace the "v5" - * path segment in the "$schema" field for all your Rush config files. This will ensure - * correct error-underlining and tab-completion for editors such as VS Code. - */ "rushVersion": "5.150.0", - - /** - * The next field selects which package manager should be installed and determines its version. - * Rush installs its own local copy of the package manager to ensure that your build process - * is fully isolated from whatever tools are present in the local environment. - * - * Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation - * for details about these alternatives. - */ "pnpmVersion": "9.12.3", - // "npmVersion": "6.14.15", - // "yarnVersion": "1.9.4", - - /** - * Older releases of the Node.js engine may be missing features required by your system. - * Other releases may have bugs. In particular, the "latest" version will not be a - * Long Term Support (LTS) version and is likely to have regressions. - * - * Specify a SemVer range to ensure developers use a Node.js version that is appropriate - * for your repo. - * - * LTS schedule: https://nodejs.org/en/about/releases/ - * LTS versions: https://nodejs.org/en/download/releases/ - */ "nodeSupportedVersionRange": ">=18", - - /** - * If the version check above fails, Rush will display a message showing the current - * node version and the supported version range. You can use this setting to provide - * additional instructions that will display below the warning, if there's a specific - * tool or script you'd like the user to use to get in line with the expected version. - */ - // "nodeSupportedVersionInstructions": "Run 'nvs use' to switch to the expected node version.", - - /** - * Odd-numbered major versions of Node.js are experimental. Even-numbered releases - * spend six months in a stabilization period before the first Long Term Support (LTS) version. - * For example, 8.9.0 was the first LTS version of Node.js 8. Pre-LTS versions are not recommended - * for production usage because they frequently have bugs. They may cause Rush itself - * to malfunction. - * - * Rush normally prints a warning if it detects a pre-LTS Node.js version. If you are testing - * pre-LTS versions in preparation for supporting the first LTS version, you can use this setting - * to disable Rush's warning. - */ - // "suppressNodeLtsWarning": false, - - /** - * Rush normally prints a warning if it detects that the current version is not one published to the - * public npmjs.org registry. If you need to block calls to the npm registry, you can use this setting to disable - * Rush's check. - */ - // "suppressRushIsPublicVersionCheck": false, - - /** - * Large monorepos can become intimidating for newcomers if project folder paths don't follow - * a consistent and recognizable pattern. When the system allows nested folder trees, - * we've found that teams will often use subfolders to create islands that isolate - * their work from others ("shipping the org"). This hinders collaboration and code sharing. - * - * The Rush developers recommend a "category folder" model, where buildable project folders - * must always be exactly two levels below the repo root. The parent folder acts as the category. - * This provides a basic facility for grouping related projects (e.g. "apps", "libraries", - * "tools", "prototypes") while still encouraging teams to organize their projects into - * a unified taxonomy. Limiting to 2 levels seems very restrictive at first, but if you have - * 20 categories and 20 projects in each category, this scheme can easily accommodate hundreds - * of projects. In practice, you will find that the folder hierarchy needs to be rebalanced - * occasionally, but if that's painful, it's a warning sign that your development style may - * discourage refactoring. Reorganizing the categories should be an enlightening discussion - * that brings people together, and maybe also identifies poor coding practices (e.g. file - * references that reach into other project's folders without using Node.js module resolution). - * - * The defaults are projectFolderMinDepth=1 and projectFolderMaxDepth=2. - * - * To remove these restrictions, you could set projectFolderMinDepth=1 - * and set projectFolderMaxDepth to a large number. - */ - // "projectFolderMinDepth": 2, - // "projectFolderMaxDepth": 2, - - /** - * Today the npmjs.com registry enforces fairly strict naming rules for packages, but in the early - * days there was no standard and hardly any enforcement. A few large legacy projects are still using - * nonstandard package names, and private registries sometimes allow it. Set "allowMostlyStandardPackageNames" - * to true to relax Rush's enforcement of package names. This allows upper case letters and in the future may - * relax other rules, however we want to minimize these exceptions. Many popular tools use certain punctuation - * characters as delimiters, based on the assumption that they will never appear in a package name; thus if we relax - * the rules too much it is likely to cause very confusing malfunctions. - * - * The default value is false. - */ - // "allowMostlyStandardPackageNames": true, - - /** - * This feature helps you to review and approve new packages before they are introduced - * to your monorepo. For example, you may be concerned about licensing, code quality, - * performance, or simply accumulating too many libraries with overlapping functionality. - * The approvals are tracked in two config files "browser-approved-packages.json" - * and "nonbrowser-approved-packages.json". See the Rush documentation for details. - */ - // "approvedPackagesPolicy": { - // /** - // * The review categories allow you to say for example "This library is approved for usage - // * in prototypes, but not in production code." - // * - // * Each project can be associated with one review category, by assigning the "reviewCategory" field - // * in the "projects" section of rush.json. The approval is then recorded in the files - // * "common/config/rush/browser-approved-packages.json" and "nonbrowser-approved-packages.json" - // * which are automatically generated during "rush update". - // * - // * Designate categories with whatever granularity is appropriate for your review process, - // * or you could just have a single category called "default". - // */ - // "reviewCategories": [ - // // Some example categories: - // "production", // projects that ship to production - // "tools", // non-shipping projects that are part of the developer toolchain - // "prototypes" // experiments that should mostly be ignored by the review process - // ], - // - // /** - // * A list of NPM package scopes that will be excluded from review. - // * We recommend to exclude TypeScript typings (the "@types" scope), because - // * if the underlying package was already approved, this would imply that the typings - // * are also approved. - // */ - // // "ignoredNpmScopes": ["@types"] - // }, - - /** - * If you use Git as your version control system, this section has some additional - * optional features you can use. - */ - "gitPolicy": { - /** - * Work at a big company? Tired of finding Git commits at work with unprofessional Git - * emails such as "beer-lover@my-college.edu"? Rush can validate people's Git email address - * before they get started. - * - * Define a list of regular expressions describing allowable e-mail patterns for Git commits. - * They are case-insensitive anchored JavaScript RegExps. Example: ".*@example\.com" - * - * IMPORTANT: Because these are regular expressions encoded as JSON string literals, - * RegExp escapes need two backslashes, and ordinary periods should be "\\.". - */ - // "allowedEmailRegExps": [ - // "[^@]+@users\\.noreply\\.github\\.com", - // "rush-bot@example\\.org" - // ], - /** - * When Rush reports that the address is malformed, the notice can include an example - * of a recommended email. Make sure it conforms to one of the allowedEmailRegExps - * expressions. - */ - // "sampleEmail": "example@users.noreply.github.com", - /** - * The commit message to use when committing changes during 'rush publish'. - * - * For example, if you want to prevent these commits from triggering a CI build, - * you might configure your system's trigger to look for a special string such as "[skip-ci]" - * in the commit message, and then customize Rush's message to contain that string. - */ - // "versionBumpCommitMessage": "Bump versions [skip ci]", - /** - * The commit message to use when committing changes during 'rush version'. - * - * For example, if you want to prevent these commits from triggering a CI build, - * you might configure your system's trigger to look for a special string such as "[skip-ci]" - * in the commit message, and then customize Rush's message to contain that string. - */ - // "changeLogUpdateCommitMessage": "Update changelogs [skip ci]", - /** - * The commit message to use when committing changefiles during 'rush change --commit' - * - * If no commit message is set it will default to 'Rush change' - */ - // "changefilesCommitMessage": "Rush change" - }, - + "gitPolicy": {}, "repository": { - /** - * The URL of this Git repository, used by "rush change" to determine the base branch for your PR. - * - * The "rush change" command needs to determine which files are affected by your PR diff. - * If you merged or cherry-picked commits from the main branch into your PR branch, those commits - * should be excluded from this diff (since they belong to some other PR). In order to do that, - * Rush needs to know where to find the base branch for your PR. This information cannot be - * determined from Git alone, since the "pull request" feature is not a Git concept. Ideally - * Rush would use a vendor-specific protocol to query the information from GitHub, Azure DevOps, etc. - * But to keep things simple, "rush change" simply assumes that your PR is against the "main" branch - * of the Git remote indicated by the repository.url setting in rush.json. If you are working in - * a GitHub "fork" of the real repo, this setting will be different from the repository URL of your - * your PR branch, and in this situation "rush change" will also automatically invoke "git fetch" - * to retrieve the latest activity for the remote main branch. - */ - // "url": "https://github.com/microsoft/rush-example", - /** - * The default branch name. This tells "rush change" which remote branch to compare against. - * The default value is "main" - */ - // "defaultBranch": "main", - /** - * The default remote. This tells "rush change" which remote to compare against if the remote URL is - * not set or if a remote matching the provided remote URL is not found. - */ - // "defaultRemote": "origin" + "url": "https://github.com/coze-dev/cozeloop-js", + "defaultBranch": "main", + "defaultRemote": "origin" }, - - /** - * Event hooks are customized script actions that Rush executes when specific events occur - */ "eventHooks": { - /** - * A list of shell commands to run before "rush install" or "rush update" starts installation - */ - "preRushInstall": [ - // "common/scripts/pre-rush-install.js" - ], - - /** - * A list of shell commands to run after "rush install" or "rush update" finishes installation - */ + "preRushInstall": [], "postRushInstall": [], - - /** - * A list of shell commands to run before "rush build" or "rush rebuild" starts building - */ "preRushBuild": [], - - /** - * A list of shell commands to run after "rush build" or "rush rebuild" finishes building - */ "postRushBuild": [], - - /** - * A list of shell commands to run before the "rushx" command starts - */ "preRushx": [], - - /** - * A list of shell commands to run after the "rushx" command finishes - */ "postRushx": [] }, - - /** - * Rush can collect anonymous telemetry about everyday developer activity such as - * success/failure of installs, builds, and other operations. You can use this to identify - * problems with your toolchain or Rush itself. THIS TELEMETRY IS NOT SHARED WITH MICROSOFT. - * It is written into JSON files in the common/temp folder. It's up to you to write scripts - * that read these JSON files and do something with them. These scripts are typically registered - * in the "eventHooks" section. - */ - // "telemetryEnabled": false, - - /** - * Allows creation of hotfix changes. This feature is experimental so it is disabled by default. - * If this is set, 'rush change' only allows a 'hotfix' change type to be specified. This change type - * will be used when publishing subsequent changes from the monorepo. - */ - // "hotfixChangeEnabled": false, - - /** - * This is an optional, but recommended, list of allowed tags that can be applied to Rush projects - * using the "tags" setting in this file. This list is useful for preventing mistakes such as misspelling, - * and it also provides a centralized place to document your tags. If "allowedProjectTags" list is - * not specified, then any valid tag is allowed. A tag name must be one or more words - * separated by hyphens or slashes, where a word may contain lowercase ASCII letters, digits, - * ".", and "@" characters. - */ - // "allowedProjectTags": [ "tools", "frontend-team", "1.0.0-release" ], - - /** - * (Required) This is the inventory of projects to be managed by Rush. - * - * Rush does not automatically scan for projects using wildcards, for a few reasons: - * 1. Depth-first scans are expensive, particularly when tools need to repeatedly collect the list. - * 2. On a caching CI machine, scans can accidentally pick up files left behind from a previous build. - * 3. It's useful to have a centralized inventory of all projects and their important metadata. - */ "projects": [ - // { - // /** - // * The NPM package name of the project (must match package.json) - // */ - // "packageName": "my-app", - // - // /** - // * The path to the project folder, relative to the rush.json config file. - // */ - // "projectFolder": "apps/my-app", - // - // /** - // * This field is only used if "subspacesEnabled" is true in subspaces.json. - // * It specifies the subspace that this project belongs to. If omitted, then the - // * project belongs to the "default" subspace. - // */ - // // "subspaceName": "my-subspace", - // - // /** - // * An optional category for usage in the "browser-approved-packages.json" - // * and "nonbrowser-approved-packages.json" files. The value must be one of the - // * strings from the "reviewCategories" defined above. - // */ - // "reviewCategory": "production", - // - // /** - // * A list of Rush project names that are to be installed from NPM - // * instead of linking to the local project. - // * - // * If a project's package.json specifies a dependency that is another Rush project - // * in the monorepo workspace, normally Rush will locally link its folder instead of - // * installing from NPM. If you are using PNPM workspaces, this is indicated by - // * a SemVer range such as "workspace:^1.2.3". To prevent mistakes, Rush reports - // * an error if the "workspace:" protocol is missing. - // * - // * Locally linking ensures that regressions are caught as early as possible and is - // * a key benefit of monorepos. However there are occasional situations where - // * installing from NPM is needed. A classic example is a cyclic dependency. - // * Imagine three Rush projects: "my-toolchain" depends on "my-tester", which depends - // * on "my-library". Suppose that we add "my-toolchain" to the "devDependencies" - // * of "my-library" so it can be built by our toolchain. This cycle creates - // * a problem -- Rush can't build a project using a not-yet-built dependency. - // * We can solve it by adding "my-toolchain" to the "decoupledLocalDependencies" - // * of "my-library", so it builds using the last published release. Choose carefully - // * which package to decouple; some choices are much easier to manage than others. - // * - // * (In older Rush releases, this setting was called "cyclicDependencyProjects".) - // */ - // "decoupledLocalDependencies": [ - // // "my-toolchain" - // ], - // - // /** - // * If true, then this project will be ignored by the "rush check" command. - // * The default value is false. - // */ - // // "skipRushCheck": false, - // - // /** - // * A flag indicating that changes to this project will be published to npm, which affects - // * the Rush change and publish workflows. The default value is false. - // * NOTE: "versionPolicyName" and "shouldPublish" are alternatives; you cannot specify them both. - // */ - // // "shouldPublish": false, - // - // /** - // * Facilitates postprocessing of a project's files prior to publishing. - // * - // * If specified, the "publishFolder" is the relative path to a subfolder of the project folder. - // * The "rush publish" command will publish the subfolder instead of the project folder. The subfolder - // * must contain its own package.json file, which is typically a build output. - // */ - // // "publishFolder": "temp/publish", - // - // /** - // * An optional version policy associated with the project. Version policies are defined - // * in "version-policies.json" file. See the "rush publish" documentation for more info. - // * NOTE: "versionPolicyName" and "shouldPublish" are alternatives; you cannot specify them both. - // */ - // // "versionPolicyName": "", - // - // /** - // * An optional set of custom tags that can be used to select this project. For example, - // * adding "my-custom-tag" will allow this project to be selected by the - // * command "rush list --only tag:my-custom-tag". The tag name must be one or more words - // * separated by hyphens or slashes, where a word may contain lowercase ASCII letters, digits, - // * ".", and "@" characters. - // */ - // // "tags": [ "1.0.0-release", "frontend-team" ] - // }, - // - // { - // "packageName": "my-controls", - // "projectFolder": "libraries/my-controls", - // "reviewCategory": "production", - // "tags": [ "frontend-team" ] - // }, - // - // { - // "packageName": "my-toolchain", - // "projectFolder": "tools/my-toolchain", - // "reviewCategory": "tools", - // "tags": [ "tools" ] - // } { "packageName": "@loop-infra/eslint-config", "projectFolder": "config/eslint-config",