diff --git a/package.json b/package.json index 29be8d868a..f9fde8c333 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "ws": ">=8.17.1" }, "patchedDependencies": { + "langchain@0.3.6": "patches/langchain@0.3.6.patch", "typedi@0.10.0": "patches/typedi@0.10.0.patch", "pkce-challenge@3.0.0": "patches/pkce-challenge@3.0.0.patch", "pyodide@0.23.4": "patches/pyodide@0.23.4.patch", diff --git a/packages/@n8n/nodes-langchain/nodes/agents/Agent/AgentExecutor.ts b/packages/@n8n/nodes-langchain/nodes/agents/Agent/AgentExecutor.ts index f2ea96f1b8..7966900a39 100644 --- a/packages/@n8n/nodes-langchain/nodes/agents/Agent/AgentExecutor.ts +++ b/packages/@n8n/nodes-langchain/nodes/agents/Agent/AgentExecutor.ts @@ -11,17 +11,15 @@ import { Tool, } from '@langchain/core/tools'; import type { ChainValues } from '@langchain/core/utils/types'; -import type { BaseMultiActionAgent, BaseSingleActionAgent } from 'langchain/dist/agents/agent'; +import type { BaseMultiActionAgent, BaseSingleActionAgent, StoppingMethod } from 'langchain/agents'; import { AgentRunnableSequence, RunnableMultiActionAgent, RunnableSingleActionAgent, isRunnableAgent, -} from 'langchain/dist/agents/agent'; -import type { StoppingMethod } from 'langchain/dist/agents/types'; -import type { ChainInputs } from 'langchain/dist/chains/base'; -import { BaseChain } from 'langchain/dist/chains/base'; -import type { SerializedLLMChain } from 'langchain/dist/chains/serde'; +} from 'langchain/agents'; +import type { ChainInputs, SerializedLLMChain } from 'langchain/chains'; +import { BaseChain } from 'langchain/chains'; import { ApplicationError } from 'n8n-workflow'; interface AgentExecutorIteratorInput { diff --git a/patches/langchain@0.3.6.patch b/patches/langchain@0.3.6.patch new file mode 100644 index 0000000000..b1fef76242 --- /dev/null +++ b/patches/langchain@0.3.6.patch @@ -0,0 +1,55 @@ +diff --git a/dist/agents/index.cjs b/dist/agents/index.cjs +index d7c4a2e371ddb587c1c8416f350c99c8649f090f..9fa1e7d50564b2becc0870d606f407ac60cdb3ae 100644 +--- a/dist/agents/index.cjs ++++ b/dist/agents/index.cjs +@@ -1,12 +1,17 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.createReactAgent = exports.createXmlAgent = exports.XMLAgent = exports.createToolCallingAgent = exports.createOpenAIToolsAgent = exports.createOpenAIFunctionsAgent = exports.OpenAIAgent = exports.StructuredChatOutputParserWithRetries = exports.StructuredChatOutputParser = exports.createStructuredChatAgent = exports.StructuredChatAgent = exports.AgentActionOutputParser = exports.ZeroShotAgentOutputParser = exports.ZeroShotAgent = exports.initializeAgentExecutorWithOptions = exports.initializeAgentExecutor = exports.AgentExecutor = exports.ChatConversationalAgentOutputParserWithRetries = exports.ChatConversationalAgentOutputParser = exports.ChatConversationalAgent = exports.ChatAgentOutputParser = exports.ChatAgent = exports.Toolkit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.createOpenApiAgent = exports.createJsonAgent = exports.VectorStoreToolkit = exports.VectorStoreRouterToolkit = exports.RequestsToolkit = exports.OpenApiToolkit = exports.JsonToolkit = exports.LLMSingleActionAgent = exports.RunnableAgent = exports.BaseMultiActionAgent = exports.BaseSingleActionAgent = exports.Agent = void 0; ++exports.createReactAgent = exports.createXmlAgent = exports.XMLAgent = exports.createToolCallingAgent = exports.createOpenAIToolsAgent = exports.createOpenAIFunctionsAgent = exports.OpenAIAgent = exports.StructuredChatOutputParserWithRetries = exports.StructuredChatOutputParser = exports.createStructuredChatAgent = exports.StructuredChatAgent = exports.AgentActionOutputParser = exports.ZeroShotAgentOutputParser = exports.ZeroShotAgent = exports.initializeAgentExecutorWithOptions = exports.initializeAgentExecutor = exports.AgentExecutor = exports.ChatConversationalAgentOutputParserWithRetries = exports.ChatConversationalAgentOutputParser = exports.ChatConversationalAgent = exports.ChatAgentOutputParser = exports.ChatAgent = exports.Toolkit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.createOpenApiAgent = exports.createJsonAgent = exports.VectorStoreToolkit = exports.VectorStoreRouterToolkit = exports.RequestsToolkit = exports.OpenApiToolkit = exports.JsonToolkit = exports.LLMSingleActionAgent = exports.RunnableAgent = exports.BaseMultiActionAgent = exports.BaseSingleActionAgent = exports.Agent = exports.AgentRunnableSequence = exports.RunnableMultiActionAgent = exports.RunnableSingleActionAgent = exports.isRunnableAgent = void 0; + var agent_js_1 = require("./agent.cjs"); + Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_js_1.Agent; } }); + Object.defineProperty(exports, "BaseSingleActionAgent", { enumerable: true, get: function () { return agent_js_1.BaseSingleActionAgent; } }); + Object.defineProperty(exports, "BaseMultiActionAgent", { enumerable: true, get: function () { return agent_js_1.BaseMultiActionAgent; } }); + Object.defineProperty(exports, "RunnableAgent", { enumerable: true, get: function () { return agent_js_1.RunnableAgent; } }); + Object.defineProperty(exports, "LLMSingleActionAgent", { enumerable: true, get: function () { return agent_js_1.LLMSingleActionAgent; } }); ++Object.defineProperty(exports, "AgentRunnableSequence", { enumerable: true, get: function () { return agent_js_1.AgentRunnableSequence; } }); ++Object.defineProperty(exports, "RunnableMultiActionAgent", { enumerable: true, get: function () { return agent_js_1.RunnableMultiActionAgent; } }); ++Object.defineProperty(exports, "RunnableSingleActionAgent", { enumerable: true, get: function () { return agent_js_1.RunnableSingleActionAgent; } }); ++Object.defineProperty(exports, "isRunnableAgent", { enumerable: true, get: function () { return agent_js_1.isRunnableAgent; } }); ++var index_js_1 = require("./toolkits/index.cjs"); + var index_js_1 = require("./toolkits/index.cjs"); + Object.defineProperty(exports, "JsonToolkit", { enumerable: true, get: function () { return index_js_1.JsonToolkit; } }); + Object.defineProperty(exports, "OpenApiToolkit", { enumerable: true, get: function () { return index_js_1.OpenApiToolkit; } }); +diff --git a/dist/agents/index.d.ts b/dist/agents/index.d.ts +index 05f874b2341e529f1f7b79d8ff227935a312d160..ba60c04331753c489dfe4a3378d143ddf130ff86 100644 +--- a/dist/agents/index.d.ts ++++ b/dist/agents/index.d.ts +@@ -1,4 +1,4 @@ +-export { Agent, type AgentArgs, BaseSingleActionAgent, BaseMultiActionAgent, RunnableAgent, LLMSingleActionAgent, type LLMSingleActionAgentInput, type OutputParserArgs, type AgentRunnableSequence, } from "./agent.js"; ++export { Agent, type AgentArgs, BaseSingleActionAgent, BaseMultiActionAgent, RunnableAgent, LLMSingleActionAgent, type LLMSingleActionAgentInput, type OutputParserArgs, AgentRunnableSequence, RunnableMultiActionAgent, RunnableSingleActionAgent, isRunnableAgent } from "./agent.js"; + export { JsonToolkit, OpenApiToolkit, RequestsToolkit, type VectorStoreInfo, VectorStoreRouterToolkit, VectorStoreToolkit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js"; + export { Toolkit } from "./toolkits/base.js"; + export { ChatAgent, type ChatAgentInput, type ChatCreatePromptArgs, } from "./chat/index.js"; +diff --git a/dist/agents/index.js b/dist/agents/index.js +index ca4a1ab41dabd8cf4f3874c24ad39a93279a6bd1..83cdb02f9b6c9be62af7389400ac6fe9b0f87a14 100644 +--- a/dist/agents/index.js ++++ b/dist/agents/index.js +@@ -1,4 +1,4 @@ +-export { Agent, BaseSingleActionAgent, BaseMultiActionAgent, RunnableAgent, LLMSingleActionAgent, } from "./agent.js"; ++export { Agent, BaseSingleActionAgent, BaseMultiActionAgent, RunnableAgent, LLMSingleActionAgent, AgentRunnableSequence, RunnableMultiActionAgent, RunnableSingleActionAgent, isRunnableAgent } from "./agent.js"; + export { JsonToolkit, OpenApiToolkit, RequestsToolkit, VectorStoreRouterToolkit, VectorStoreToolkit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js"; + export { Toolkit } from "./toolkits/base.js"; + export { ChatAgent, } from "./chat/index.js"; +diff --git a/schema/document.cjs b/schema/document.cjs +deleted file mode 100644 +index 18746fea69bdc22290c631c8534656d2490f9634..0000000000000000000000000000000000000000 +diff --git a/schema/document.d.cts b/schema/document.d.cts +deleted file mode 100644 +index d9c69889bdff03b3ecedc7c10283447d36a34f26..0000000000000000000000000000000000000000 +diff --git a/schema/document.d.ts b/schema/document.d.ts +deleted file mode 100644 +index d9c69889bdff03b3ecedc7c10283447d36a34f26..0000000000000000000000000000000000000000 +diff --git a/schema/document.js b/schema/document.js +deleted file mode 100644 +index d9c69889bdff03b3ecedc7c10283447d36a34f26..0000000000000000000000000000000000000000 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e21c919dee..cc4c6783fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,6 +124,9 @@ patchedDependencies: '@types/ws@8.5.4': hash: nbzuqaoyqbrfwipijj5qriqqju path: patches/@types__ws@8.5.4.patch + langchain@0.3.6: + hash: 7zttpgt447a63ax73cqbfl4o5u + path: patches/langchain@0.3.6.patch pkce-challenge@3.0.0: hash: dypouzb3lve7vncq25i5fuanki path: patches/pkce-challenge@3.0.0.patch @@ -428,7 +431,7 @@ importers: version: 3.666.0(@aws-sdk/client-sts@3.666.0) '@getzep/zep-cloud': specifier: 1.0.12 - version: 1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(e4rnrwhosnp2xiru36mqgdy2bu)) + version: 1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu)) '@getzep/zep-js': specifier: 0.9.0 version: 0.9.0 @@ -455,7 +458,7 @@ importers: version: 0.3.1(@aws-sdk/client-sso-oidc@3.666.0(@aws-sdk/client-sts@3.666.0))(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13) '@langchain/community': specifier: 0.3.15 - version: 0.3.15(vc5hvyy27o4cmm4jplsptc2fqm) + version: 0.3.15(q275i25f3eipny32ftxrujomqi) '@langchain/core': specifier: 'catalog:' version: 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) @@ -542,7 +545,7 @@ importers: version: 23.0.1 langchain: specifier: 0.3.6 - version: 0.3.6(e4rnrwhosnp2xiru36mqgdy2bu) + version: 0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu) lodash: specifier: 'catalog:' version: 4.17.21 @@ -15640,7 +15643,7 @@ snapshots: '@gar/promisify@1.1.3': optional: true - '@getzep/zep-cloud@1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(e4rnrwhosnp2xiru36mqgdy2bu))': + '@getzep/zep-cloud@1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu))': dependencies: form-data: 4.0.0 node-fetch: 2.7.0(encoding@0.1.13) @@ -15649,7 +15652,7 @@ snapshots: zod: 3.23.8 optionalDependencies: '@langchain/core': 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) - langchain: 0.3.6(e4rnrwhosnp2xiru36mqgdy2bu) + langchain: 0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu) transitivePeerDependencies: - encoding @@ -16113,7 +16116,7 @@ snapshots: - aws-crt - encoding - '@langchain/community@0.3.15(vc5hvyy27o4cmm4jplsptc2fqm)': + '@langchain/community@0.3.15(q275i25f3eipny32ftxrujomqi)': dependencies: '@ibm-cloud/watsonx-ai': 1.1.2 '@langchain/core': 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) @@ -16123,7 +16126,7 @@ snapshots: flat: 5.0.2 ibm-cloud-sdk-core: 5.1.0 js-yaml: 4.1.0 - langchain: 0.3.6(e4rnrwhosnp2xiru36mqgdy2bu) + langchain: 0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu) langsmith: 0.2.3(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) uuid: 10.0.0 zod: 3.23.8 @@ -16136,7 +16139,7 @@ snapshots: '@aws-sdk/client-s3': 3.666.0 '@aws-sdk/credential-provider-node': 3.666.0(@aws-sdk/client-sso-oidc@3.666.0(@aws-sdk/client-sts@3.666.0))(@aws-sdk/client-sts@3.666.0) '@azure/storage-blob': 12.18.0(encoding@0.1.13) - '@getzep/zep-cloud': 1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(e4rnrwhosnp2xiru36mqgdy2bu)) + '@getzep/zep-cloud': 1.0.12(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)(langchain@0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu)) '@getzep/zep-js': 0.9.0 '@google-ai/generativelanguage': 2.6.0(encoding@0.1.13) '@google-cloud/storage': 7.12.1(encoding@0.1.13) @@ -23318,7 +23321,7 @@ snapshots: kuler@2.0.0: {} - langchain@0.3.6(e4rnrwhosnp2xiru36mqgdy2bu): + langchain@0.3.6(patch_hash=7zttpgt447a63ax73cqbfl4o5u)(e4rnrwhosnp2xiru36mqgdy2bu): dependencies: '@langchain/core': 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) '@langchain/openai': 0.3.14(@langchain/core@0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)))(encoding@0.1.13)