@n8n/n8n-nodes-langchain 1.120.2 → 1.121.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/credentials/VercelAiGatewayApi.credentials.js +1 -1
  2. package/dist/credentials/VercelAiGatewayApi.credentials.js.map +1 -1
  3. package/dist/known/credentials.json +1 -0
  4. package/dist/known/nodes.json +4 -0
  5. package/dist/nodes/agents/Agent/V3/AgentV3.node.js +1 -1
  6. package/dist/nodes/agents/Agent/V3/AgentV3.node.js.map +1 -1
  7. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +20 -399
  8. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
  9. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildExecutionContext.js +74 -0
  10. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildExecutionContext.js.map +1 -0
  11. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildResponseMetadata.js +37 -0
  12. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/buildResponseMetadata.js.map +1 -0
  13. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/checkMaxIterations.js +40 -0
  14. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/checkMaxIterations.js.map +1 -0
  15. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/createAgentSequence.js +61 -0
  16. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/createAgentSequence.js.map +1 -0
  17. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js +88 -0
  18. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js.map +1 -0
  19. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/finalizeResult.js +58 -0
  20. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/finalizeResult.js.map +1 -0
  21. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/index.js +50 -0
  22. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/index.js.map +1 -0
  23. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/prepareItemContext.js +66 -0
  24. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/prepareItemContext.js.map +1 -0
  25. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js +99 -0
  26. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js.map +1 -0
  27. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/types.js +17 -0
  28. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/types.js.map +1 -0
  29. package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js +55 -19
  30. package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -1
  31. package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js +1 -0
  32. package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js.map +1 -1
  33. package/dist/nodes/mcp/McpClient/McpClient.node.js +335 -0
  34. package/dist/nodes/mcp/McpClient/McpClient.node.js.map +1 -0
  35. package/dist/nodes/mcp/McpClient/listSearch.js +58 -0
  36. package/dist/nodes/mcp/McpClient/listSearch.js.map +1 -0
  37. package/dist/nodes/mcp/McpClient/resourceMapping.js +61 -0
  38. package/dist/nodes/mcp/McpClient/resourceMapping.js.map +1 -0
  39. package/dist/nodes/mcp/McpClient/utils.js +248 -0
  40. package/dist/nodes/mcp/McpClient/utils.js.map +1 -0
  41. package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +13 -55
  42. package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
  43. package/dist/nodes/mcp/McpClientTool/loadOptions.js +2 -3
  44. package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
  45. package/dist/nodes/mcp/McpClientTool/types.js.map +1 -1
  46. package/dist/nodes/mcp/McpClientTool/utils.js +2 -174
  47. package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
  48. package/dist/nodes/mcp/{McpClientTool → shared}/descriptions.js +40 -0
  49. package/dist/nodes/mcp/shared/descriptions.js.map +1 -0
  50. package/dist/nodes/mcp/shared/types.js +17 -0
  51. package/dist/nodes/mcp/shared/types.js.map +1 -0
  52. package/dist/nodes/mcp/shared/utils.js +231 -0
  53. package/dist/nodes/mcp/shared/utils.js.map +1 -0
  54. package/dist/nodes/tools/ToolHttpRequest/utils.js +5 -11
  55. package/dist/nodes/tools/ToolHttpRequest/utils.js.map +1 -1
  56. package/dist/nodes/vendors/OpenAi/OpenAi.node.js +3 -2
  57. package/dist/nodes/vendors/OpenAi/OpenAi.node.js.map +1 -1
  58. package/dist/nodes/vendors/OpenAi/v1/actions/audio/index.js +2 -2
  59. package/dist/nodes/vendors/OpenAi/v1/actions/audio/index.js.map +1 -1
  60. package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js +1 -1
  61. package/dist/nodes/vendors/OpenAi/v2/OpenAiV2.node.js.map +1 -1
  62. package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js +2 -2
  63. package/dist/nodes/vendors/OpenAi/v2/actions/audio/index.js.map +1 -1
  64. package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js +12 -3
  65. package/dist/nodes/vendors/OpenAi/v2/actions/text/classify.operation.js.map +1 -1
  66. package/dist/types/credentials.json +2 -2
  67. package/dist/types/nodes.json +5 -4
  68. package/dist/utils/agent-execution/buildSteps.js +77 -0
  69. package/dist/utils/agent-execution/buildSteps.js.map +1 -0
  70. package/dist/utils/agent-execution/createEngineRequests.js +48 -0
  71. package/dist/utils/agent-execution/createEngineRequests.js.map +1 -0
  72. package/dist/utils/agent-execution/index.js +42 -0
  73. package/dist/utils/agent-execution/index.js.map +1 -0
  74. package/dist/utils/agent-execution/memoryManagement.js +66 -0
  75. package/dist/utils/agent-execution/memoryManagement.js.map +1 -0
  76. package/dist/utils/agent-execution/processEventStream.js +128 -0
  77. package/dist/utils/agent-execution/processEventStream.js.map +1 -0
  78. package/dist/utils/agent-execution/types.js +17 -0
  79. package/dist/utils/agent-execution/types.js.map +1 -0
  80. package/package.json +11 -9
  81. package/dist/nodes/mcp/McpClientTool/descriptions.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var buildSteps_exports = {};
20
+ __export(buildSteps_exports, {
21
+ buildSteps: () => buildSteps
22
+ });
23
+ module.exports = __toCommonJS(buildSteps_exports);
24
+ var import_messages = require("@langchain/core/messages");
25
+ var import_n8n_workflow = require("n8n-workflow");
26
+ function buildSteps(response, itemIndex) {
27
+ const steps = [];
28
+ if (response) {
29
+ const responses = response?.actionResponses ?? [];
30
+ if (response.metadata?.previousRequests) {
31
+ steps.push.apply(steps, response.metadata.previousRequests);
32
+ }
33
+ for (const tool of responses) {
34
+ if (tool.action?.metadata?.itemIndex !== itemIndex) continue;
35
+ const toolInput = {
36
+ ...tool.action.input,
37
+ id: tool.action.id
38
+ };
39
+ if (!toolInput || !tool.data) {
40
+ continue;
41
+ }
42
+ const step = steps.find((step2) => step2.action.toolCallId === toolInput.id);
43
+ if (step) {
44
+ continue;
45
+ }
46
+ const syntheticAIMessage = new import_messages.AIMessage({
47
+ content: `Calling ${tool.action.nodeName} with input: ${JSON.stringify(toolInput)}`,
48
+ tool_calls: [
49
+ {
50
+ id: toolInput?.id ?? "reconstructed_call",
51
+ name: (0, import_n8n_workflow.nodeNameToToolName)(tool.action.nodeName),
52
+ args: toolInput,
53
+ type: "tool_call"
54
+ }
55
+ ]
56
+ });
57
+ const toolResult = {
58
+ action: {
59
+ tool: (0, import_n8n_workflow.nodeNameToToolName)(tool.action.nodeName),
60
+ toolInput: toolInput.input || {},
61
+ log: toolInput.log || syntheticAIMessage.content,
62
+ messageLog: [syntheticAIMessage],
63
+ toolCallId: toolInput?.id,
64
+ type: toolInput.type || "tool_call"
65
+ },
66
+ observation: JSON.stringify(tool.data?.data?.ai_tool?.[0]?.map((item) => item?.json) ?? "")
67
+ };
68
+ steps.push(toolResult);
69
+ }
70
+ }
71
+ return steps;
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ buildSteps
76
+ });
77
+ //# sourceMappingURL=buildSteps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/buildSteps.ts"],"sourcesContent":["import { AIMessage } from '@langchain/core/messages';\nimport { nodeNameToToolName } from 'n8n-workflow';\nimport type { EngineResponse, IDataObject } from 'n8n-workflow';\n\nimport type { RequestResponseMetadata, ToolCallData } from './types';\n\n/**\n * Rebuilds the agent steps from previous tool call responses.\n * This is used to continue agent execution after tool calls have been made.\n *\n * This is a generalized version that can be used across different agent types\n * (Tools Agent, OpenAI Functions Agent, etc.).\n *\n * @param response - The engine response containing tool call results\n * @param itemIndex - The current item index being processed\n * @returns Array of tool call data representing the agent steps\n */\nexport function buildSteps(\n\tresponse: EngineResponse<RequestResponseMetadata> | undefined,\n\titemIndex: number,\n): ToolCallData[] {\n\tconst steps: ToolCallData[] = [];\n\n\tif (response) {\n\t\tconst responses = response?.actionResponses ?? [];\n\n\t\tif (response.metadata?.previousRequests) {\n\t\t\tsteps.push.apply(steps, response.metadata.previousRequests);\n\t\t}\n\n\t\tfor (const tool of responses) {\n\t\t\tif (tool.action?.metadata?.itemIndex !== itemIndex) continue;\n\n\t\t\tconst toolInput: IDataObject = {\n\t\t\t\t...tool.action.input,\n\t\t\t\tid: tool.action.id,\n\t\t\t};\n\t\t\tif (!toolInput || !tool.data) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst step = steps.find((step) => step.action.toolCallId === toolInput.id);\n\t\t\tif (step) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Create a synthetic AI message for the messageLog\n\t\t\t// This represents the AI's decision to call the tool\n\t\t\tconst syntheticAIMessage = new AIMessage({\n\t\t\t\tcontent: `Calling ${tool.action.nodeName} with input: ${JSON.stringify(toolInput)}`,\n\t\t\t\ttool_calls: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: (toolInput?.id as string) ?? 'reconstructed_call',\n\t\t\t\t\t\tname: nodeNameToToolName(tool.action.nodeName),\n\t\t\t\t\t\targs: toolInput,\n\t\t\t\t\t\ttype: 'tool_call',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t});\n\n\t\t\tconst toolResult = {\n\t\t\t\taction: {\n\t\t\t\t\ttool: nodeNameToToolName(tool.action.nodeName),\n\t\t\t\t\ttoolInput: (toolInput.input as IDataObject) || {},\n\t\t\t\t\tlog: toolInput.log || syntheticAIMessage.content,\n\t\t\t\t\tmessageLog: [syntheticAIMessage],\n\t\t\t\t\ttoolCallId: toolInput?.id,\n\t\t\t\t\ttype: toolInput.type || 'tool_call',\n\t\t\t\t},\n\t\t\t\tobservation: JSON.stringify(tool.data?.data?.ai_tool?.[0]?.map((item) => item?.json) ?? ''),\n\t\t\t};\n\n\t\t\tsteps.push(toolResult);\n\t\t}\n\t}\n\treturn steps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,0BAAmC;AAgB5B,SAAS,WACf,UACA,WACiB;AACjB,QAAM,QAAwB,CAAC;AAE/B,MAAI,UAAU;AACb,UAAM,YAAY,UAAU,mBAAmB,CAAC;AAEhD,QAAI,SAAS,UAAU,kBAAkB;AACxC,YAAM,KAAK,MAAM,OAAO,SAAS,SAAS,gBAAgB;AAAA,IAC3D;AAEA,eAAW,QAAQ,WAAW;AAC7B,UAAI,KAAK,QAAQ,UAAU,cAAc,UAAW;AAEpD,YAAM,YAAyB;AAAA,QAC9B,GAAG,KAAK,OAAO;AAAA,QACf,IAAI,KAAK,OAAO;AAAA,MACjB;AACA,UAAI,CAAC,aAAa,CAAC,KAAK,MAAM;AAC7B;AAAA,MACD;AAEA,YAAM,OAAO,MAAM,KAAK,CAACA,UAASA,MAAK,OAAO,eAAe,UAAU,EAAE;AACzE,UAAI,MAAM;AACT;AAAA,MACD;AAGA,YAAM,qBAAqB,IAAI,0BAAU;AAAA,QACxC,SAAS,WAAW,KAAK,OAAO,QAAQ,gBAAgB,KAAK,UAAU,SAAS,CAAC;AAAA,QACjF,YAAY;AAAA,UACX;AAAA,YACC,IAAK,WAAW,MAAiB;AAAA,YACjC,UAAM,wCAAmB,KAAK,OAAO,QAAQ;AAAA,YAC7C,MAAM;AAAA,YACN,MAAM;AAAA,UACP;AAAA,QACD;AAAA,MACD,CAAC;AAED,YAAM,aAAa;AAAA,QAClB,QAAQ;AAAA,UACP,UAAM,wCAAmB,KAAK,OAAO,QAAQ;AAAA,UAC7C,WAAY,UAAU,SAAyB,CAAC;AAAA,UAChD,KAAK,UAAU,OAAO,mBAAmB;AAAA,UACzC,YAAY,CAAC,kBAAkB;AAAA,UAC/B,YAAY,WAAW;AAAA,UACvB,MAAM,UAAU,QAAQ;AAAA,QACzB;AAAA,QACA,aAAa,KAAK,UAAU,KAAK,MAAM,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC,SAAS,MAAM,IAAI,KAAK,EAAE;AAAA,MAC3F;AAEA,YAAM,KAAK,UAAU;AAAA,IACtB;AAAA,EACD;AACA,SAAO;AACR;","names":["step"]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createEngineRequests_exports = {};
20
+ __export(createEngineRequests_exports, {
21
+ createEngineRequests: () => createEngineRequests
22
+ });
23
+ module.exports = __toCommonJS(createEngineRequests_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ async function createEngineRequests(toolCalls, itemIndex, tools) {
26
+ return toolCalls.map((toolCall) => {
27
+ const foundTool = tools.find((tool) => tool.name === toolCall.tool);
28
+ if (!foundTool) return void 0;
29
+ const nodeName = foundTool.metadata?.sourceNodeName;
30
+ if (!nodeName) return void 0;
31
+ const input = foundTool.metadata?.isFromToolkit ? { ...toolCall.toolInput, tool: toolCall.tool } : toolCall.toolInput;
32
+ return {
33
+ actionType: "ExecutionNodeAction",
34
+ nodeName,
35
+ input,
36
+ type: import_n8n_workflow.NodeConnectionTypes.AiTool,
37
+ id: toolCall.toolCallId,
38
+ metadata: {
39
+ itemIndex
40
+ }
41
+ };
42
+ }).filter((item) => item !== void 0);
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ createEngineRequests
47
+ });
48
+ //# sourceMappingURL=createEngineRequests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/createEngineRequests.ts"],"sourcesContent":["import type { DynamicStructuredTool, Tool } from 'langchain/tools';\nimport { NodeConnectionTypes } from 'n8n-workflow';\nimport type { EngineRequest, IDataObject } from 'n8n-workflow';\n\nimport type { RequestResponseMetadata, ToolCallRequest } from './types';\n\n/**\n * Creates engine requests from tool calls.\n * Maps tool call information to the format expected by the n8n engine\n * for executing tool nodes.\n *\n * This is a generalized version that can be used across different agent types\n * (Tools Agent, OpenAI Functions Agent, etc.).\n *\n * @param toolCalls - Array of tool call requests to convert\n * @param itemIndex - The current item index\n * @param tools - Array of available tools\n * @returns Array of engine request objects (filtered to remove undefined entries)\n */\nexport async function createEngineRequests(\n\ttoolCalls: ToolCallRequest[],\n\titemIndex: number,\n\ttools: Array<DynamicStructuredTool | Tool>,\n): Promise<EngineRequest<RequestResponseMetadata>['actions']> {\n\treturn toolCalls\n\t\t.map((toolCall) => {\n\t\t\t// First try to get from metadata (for toolkit tools)\n\t\t\tconst foundTool = tools.find((tool) => tool.name === toolCall.tool);\n\n\t\t\tif (!foundTool) return undefined;\n\n\t\t\tconst nodeName = foundTool.metadata?.sourceNodeName as string | undefined;\n\n\t\t\t// Ensure nodeName is defined\n\t\t\tif (!nodeName) return undefined;\n\n\t\t\t// For toolkit tools, include the tool name so the node knows which tool to execute\n\t\t\tconst input = foundTool.metadata?.isFromToolkit\n\t\t\t\t? { ...toolCall.toolInput, tool: toolCall.tool }\n\t\t\t\t: toolCall.toolInput;\n\n\t\t\treturn {\n\t\t\t\tactionType: 'ExecutionNodeAction' as const,\n\t\t\t\tnodeName,\n\t\t\t\tinput: input as IDataObject,\n\t\t\t\ttype: NodeConnectionTypes.AiTool,\n\t\t\t\tid: toolCall.toolCallId,\n\t\t\t\tmetadata: {\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t};\n\t\t})\n\t\t.filter((item): item is NonNullable<typeof item> => item !== undefined);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAoC;AAkBpC,eAAsB,qBACrB,WACA,WACA,OAC6D;AAC7D,SAAO,UACL,IAAI,CAAC,aAAa;AAElB,UAAM,YAAY,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,SAAS,IAAI;AAElE,QAAI,CAAC,UAAW,QAAO;AAEvB,UAAM,WAAW,UAAU,UAAU;AAGrC,QAAI,CAAC,SAAU,QAAO;AAGtB,UAAM,QAAQ,UAAU,UAAU,gBAC/B,EAAE,GAAG,SAAS,WAAW,MAAM,SAAS,KAAK,IAC7C,SAAS;AAEZ,WAAO;AAAA,MACN,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,MAAM,wCAAoB;AAAA,MAC1B,IAAI,SAAS;AAAA,MACb,UAAU;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC,EACA,OAAO,CAAC,SAA2C,SAAS,MAAS;AACxE;","names":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var agent_execution_exports = {};
20
+ __export(agent_execution_exports, {
21
+ buildSteps: () => import_buildSteps.buildSteps,
22
+ createEngineRequests: () => import_createEngineRequests.createEngineRequests,
23
+ loadMemory: () => import_memoryManagement.loadMemory,
24
+ processEventStream: () => import_processEventStream.processEventStream,
25
+ saveToMemory: () => import_memoryManagement.saveToMemory,
26
+ saveToolResultsToMemory: () => import_memoryManagement.saveToolResultsToMemory
27
+ });
28
+ module.exports = __toCommonJS(agent_execution_exports);
29
+ var import_createEngineRequests = require("./createEngineRequests");
30
+ var import_buildSteps = require("./buildSteps");
31
+ var import_processEventStream = require("./processEventStream");
32
+ var import_memoryManagement = require("./memoryManagement");
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ buildSteps,
36
+ createEngineRequests,
37
+ loadMemory,
38
+ processEventStream,
39
+ saveToMemory,
40
+ saveToolResultsToMemory
41
+ });
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/index.ts"],"sourcesContent":["/**\n * Agent Execution Utilities\n *\n * This module contains generalized utilities for agent execution that can be\n * reused across different agent types (Tools Agent, OpenAI Functions Agent, etc.).\n *\n * These utilities support engine-based tool execution, where tool calls are\n * delegated to the n8n workflow engine instead of being executed inline.\n */\n\nexport { createEngineRequests } from './createEngineRequests';\nexport { buildSteps } from './buildSteps';\nexport { processEventStream } from './processEventStream';\nexport { loadMemory, saveToMemory, saveToolResultsToMemory } from './memoryManagement';\nexport type {\n\tToolCallRequest,\n\tToolCallData,\n\tAgentResult,\n\tRequestResponseMetadata,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kCAAqC;AACrC,wBAA2B;AAC3B,gCAAmC;AACnC,8BAAkE;","names":[]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var memoryManagement_exports = {};
20
+ __export(memoryManagement_exports, {
21
+ loadMemory: () => loadMemory,
22
+ saveToMemory: () => saveToMemory,
23
+ saveToolResultsToMemory: () => saveToolResultsToMemory
24
+ });
25
+ module.exports = __toCommonJS(memoryManagement_exports);
26
+ var import_messages = require("@langchain/core/messages");
27
+ async function loadMemory(memory, model, maxTokens) {
28
+ if (!memory) {
29
+ return void 0;
30
+ }
31
+ const memoryVariables = await memory.loadMemoryVariables({});
32
+ let chatHistory = memoryVariables["chat_history"] || [];
33
+ if (maxTokens && model) {
34
+ chatHistory = await (0, import_messages.trimMessages)(chatHistory, {
35
+ strategy: "last",
36
+ maxTokens,
37
+ tokenCounter: model,
38
+ includeSystem: true,
39
+ startOn: "human",
40
+ allowPartial: true
41
+ });
42
+ }
43
+ return chatHistory;
44
+ }
45
+ async function saveToMemory(input, output, memory) {
46
+ if (!output || !memory) {
47
+ return;
48
+ }
49
+ await memory.saveContext({ input }, { output });
50
+ }
51
+ async function saveToolResultsToMemory(input, toolResults, memory) {
52
+ if (!memory || !toolResults.length) {
53
+ return;
54
+ }
55
+ for (const result of toolResults) {
56
+ const toolMessage = `Tool: ${result.action.tool}, Input: ${JSON.stringify(result.action.toolInput)}, Result: ${result.observation}`;
57
+ await memory.saveContext({ input }, { output: toolMessage });
58
+ }
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ loadMemory,
63
+ saveToMemory,
64
+ saveToolResultsToMemory
65
+ });
66
+ //# sourceMappingURL=memoryManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/memoryManagement.ts"],"sourcesContent":["import type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport { trimMessages } from '@langchain/core/messages';\nimport type { BaseChatMemory } from 'langchain/memory';\n\nimport type { ToolCallData } from './types';\n\n/**\n * Loads chat history from memory and optionally trims it to fit within token limits.\n *\n * @param memory - The memory instance to load from\n * @param model - Optional chat model for token counting (required if maxTokens is specified)\n * @param maxTokens - Optional maximum number of tokens to load from memory\n * @returns Array of base messages representing the chat history\n *\n * @example\n * ```typescript\n * // Load all history\n * const messages = await loadMemory(memory);\n *\n * // Load with token limit\n * const messages = await loadMemory(memory, model, 2000);\n * ```\n */\nexport async function loadMemory(\n\tmemory?: BaseChatMemory,\n\tmodel?: BaseChatModel,\n\tmaxTokens?: number,\n): Promise<BaseMessage[] | undefined> {\n\tif (!memory) {\n\t\treturn undefined;\n\t}\n\tconst memoryVariables = await memory.loadMemoryVariables({});\n\tlet chatHistory = (memoryVariables['chat_history'] as BaseMessage[]) || [];\n\n\t// Trim messages if token limit is specified and model is available\n\tif (maxTokens && model) {\n\t\tchatHistory = await trimMessages(chatHistory, {\n\t\t\tstrategy: 'last',\n\t\t\tmaxTokens,\n\t\t\ttokenCounter: model,\n\t\t\tincludeSystem: true,\n\t\t\tstartOn: 'human',\n\t\t\tallowPartial: true,\n\t\t});\n\t}\n\n\treturn chatHistory;\n}\n\n/**\n * Saves a conversation turn (user input + agent output) to memory.\n *\n * @param memory - The memory instance to save to\n * @param input - The user input/prompt\n * @param output - The agent's output/response\n *\n * @example\n * ```typescript\n * await saveToMemory(memory, 'What is 2+2?', 'The answer is 4');\n * ```\n */\nexport async function saveToMemory(\n\tinput: string,\n\toutput: string,\n\tmemory?: BaseChatMemory,\n): Promise<void> {\n\tif (!output || !memory) {\n\t\treturn;\n\t}\n\n\tawait memory.saveContext({ input }, { output });\n}\n\n/**\n * Saves tool call results to memory as formatted messages.\n *\n * This preserves the full conversation including tool interactions,\n * which is important for agents that need to see their tool usage history.\n *\n * @param memory - The memory instance to save to\n * @param input - The user input that triggered the tool calls\n * @param toolResults - Array of tool call results to save\n *\n * @example\n * ```typescript\n * await saveToolResultsToMemory(memory, 'Calculate 2+2', [{\n * action: {\n * tool: 'calculator',\n * toolInput: { expression: '2+2' },\n * log: 'Using calculator',\n * toolCallId: 'call_123',\n * type: 'tool_call'\n * },\n * observation: '4'\n * }]);\n * ```\n */\nexport async function saveToolResultsToMemory(\n\tinput: string,\n\ttoolResults: ToolCallData[],\n\tmemory?: BaseChatMemory,\n): Promise<void> {\n\tif (!memory || !toolResults.length) {\n\t\treturn;\n\t}\n\n\t// Save each tool call as a formatted message\n\tfor (const result of toolResults) {\n\t\tconst toolMessage = `Tool: ${result.action.tool}, Input: ${JSON.stringify(result.action.toolInput)}, Result: ${result.observation}`;\n\t\tawait memory.saveContext({ input }, { output: toolMessage });\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAA6B;AAsB7B,eAAsB,WACrB,QACA,OACA,WACqC;AACrC,MAAI,CAAC,QAAQ;AACZ,WAAO;AAAA,EACR;AACA,QAAM,kBAAkB,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAC3D,MAAI,cAAe,gBAAgB,cAAc,KAAuB,CAAC;AAGzE,MAAI,aAAa,OAAO;AACvB,kBAAc,UAAM,8BAAa,aAAa;AAAA,MAC7C,UAAU;AAAA,MACV;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,MACf,SAAS;AAAA,MACT,cAAc;AAAA,IACf,CAAC;AAAA,EACF;AAEA,SAAO;AACR;AAcA,eAAsB,aACrB,OACA,QACA,QACgB;AAChB,MAAI,CAAC,UAAU,CAAC,QAAQ;AACvB;AAAA,EACD;AAEA,QAAM,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,OAAO,CAAC;AAC/C;AA0BA,eAAsB,wBACrB,OACA,aACA,QACgB;AAChB,MAAI,CAAC,UAAU,CAAC,YAAY,QAAQ;AACnC;AAAA,EACD;AAGA,aAAW,UAAU,aAAa;AACjC,UAAM,cAAc,SAAS,OAAO,OAAO,IAAI,YAAY,KAAK,UAAU,OAAO,OAAO,SAAS,CAAC,aAAa,OAAO,WAAW;AACjI,UAAM,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,QAAQ,YAAY,CAAC;AAAA,EAC5D;AACD;","names":[]}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var processEventStream_exports = {};
20
+ __export(processEventStream_exports, {
21
+ processEventStream: () => processEventStream
22
+ });
23
+ module.exports = __toCommonJS(processEventStream_exports);
24
+ var import_memoryManagement = require("./memoryManagement");
25
+ async function processEventStream(ctx, eventStream, itemIndex, returnIntermediateSteps = false, memory, input) {
26
+ const agentResult = {
27
+ output: ""
28
+ };
29
+ if (returnIntermediateSteps) {
30
+ agentResult.intermediateSteps = [];
31
+ }
32
+ const toolCalls = [];
33
+ ctx.sendChunk("begin", itemIndex);
34
+ for await (const event of eventStream) {
35
+ switch (event.event) {
36
+ case "on_chat_model_stream":
37
+ const chunk = event.data?.chunk;
38
+ if (chunk?.content) {
39
+ const chunkContent = chunk.content;
40
+ let chunkText = "";
41
+ if (Array.isArray(chunkContent)) {
42
+ for (const message of chunkContent) {
43
+ if (message?.type === "text") {
44
+ chunkText += message?.text;
45
+ }
46
+ }
47
+ } else if (typeof chunkContent === "string") {
48
+ chunkText = chunkContent;
49
+ }
50
+ ctx.sendChunk("item", itemIndex, chunkText);
51
+ agentResult.output += chunkText;
52
+ }
53
+ break;
54
+ case "on_chat_model_end":
55
+ if (event.data) {
56
+ const chatModelData = event.data;
57
+ const output = chatModelData.output;
58
+ if (output?.tool_calls && output.tool_calls.length > 0) {
59
+ for (const toolCall of output.tool_calls) {
60
+ toolCalls.push({
61
+ tool: toolCall.name,
62
+ toolInput: toolCall.args,
63
+ toolCallId: toolCall.id || "unknown",
64
+ type: toolCall.type || "tool_call",
65
+ log: output.content || `Calling ${toolCall.name} with input: ${JSON.stringify(toolCall.args)}`,
66
+ messageLog: [output]
67
+ });
68
+ }
69
+ if (returnIntermediateSteps) {
70
+ for (const toolCall of output.tool_calls) {
71
+ agentResult.intermediateSteps?.push({
72
+ action: {
73
+ tool: toolCall.name,
74
+ toolInput: toolCall.args,
75
+ log: output.content || `Calling ${toolCall.name} with input: ${JSON.stringify(toolCall.args)}`,
76
+ messageLog: [output],
77
+ // Include the full LLM response
78
+ toolCallId: toolCall.id || "unknown",
79
+ type: toolCall.type || "tool_call"
80
+ },
81
+ observation: ""
82
+ });
83
+ }
84
+ }
85
+ }
86
+ }
87
+ break;
88
+ case "on_tool_end":
89
+ if (returnIntermediateSteps && event.data && agentResult.intermediateSteps.length > 0) {
90
+ const toolData = event.data;
91
+ const matchingStep = agentResult.intermediateSteps?.find(
92
+ (step) => !step.observation && step.action.tool === event.name
93
+ );
94
+ if (matchingStep) {
95
+ matchingStep.observation = toolData.output || "";
96
+ if (matchingStep.observation && input) {
97
+ await (0, import_memoryManagement.saveToolResultsToMemory)(
98
+ input,
99
+ [
100
+ {
101
+ action: matchingStep.action,
102
+ observation: matchingStep.observation
103
+ }
104
+ ],
105
+ memory
106
+ );
107
+ }
108
+ }
109
+ }
110
+ break;
111
+ default:
112
+ break;
113
+ }
114
+ }
115
+ ctx.sendChunk("end", itemIndex);
116
+ if (input && agentResult.output) {
117
+ await (0, import_memoryManagement.saveToMemory)(input, agentResult.output, memory);
118
+ }
119
+ if (toolCalls.length > 0) {
120
+ agentResult.toolCalls = toolCalls;
121
+ }
122
+ return agentResult;
123
+ }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ processEventStream
127
+ });
128
+ //# sourceMappingURL=processEventStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/processEventStream.ts"],"sourcesContent":["import type { StreamEvent } from '@langchain/core/dist/tracers/event_stream';\nimport type { IterableReadableStream } from '@langchain/core/dist/utils/stream';\nimport type { AIMessageChunk, MessageContentText } from '@langchain/core/messages';\nimport type { BaseChatMemory } from 'langchain/memory';\nimport type { IExecuteFunctions } from 'n8n-workflow';\n\nimport { saveToMemory, saveToolResultsToMemory } from './memoryManagement';\nimport type { AgentResult, ToolCallRequest } from './types';\n\n/**\n * Processes the event stream from a streaming agent execution.\n * Handles streaming chunks, tool calls, and intermediate steps.\n *\n * This is a generalized version that can be used across different agent types\n * (Tools Agent, OpenAI Functions Agent, etc.).\n *\n * @param ctx - The execution context\n * @param eventStream - The stream of events from the agent\n * @param itemIndex - The current item index\n * @param returnIntermediateSteps - Whether to capture intermediate steps\n * @param memory - Optional memory for saving context\n * @param input - The original input prompt\n * @returns AgentResult containing output and optional tool calls/steps\n */\nexport async function processEventStream(\n\tctx: IExecuteFunctions,\n\teventStream: IterableReadableStream<StreamEvent>,\n\titemIndex: number,\n\treturnIntermediateSteps: boolean = false,\n\tmemory?: BaseChatMemory,\n\tinput?: string,\n): Promise<AgentResult> {\n\tconst agentResult: AgentResult = {\n\t\toutput: '',\n\t};\n\n\tif (returnIntermediateSteps) {\n\t\tagentResult.intermediateSteps = [];\n\t}\n\n\tconst toolCalls: ToolCallRequest[] = [];\n\n\tctx.sendChunk('begin', itemIndex);\n\tfor await (const event of eventStream) {\n\t\t// Stream chat model tokens as they come in\n\t\tswitch (event.event) {\n\t\t\tcase 'on_chat_model_stream':\n\t\t\t\tconst chunk = event.data?.chunk as AIMessageChunk;\n\t\t\t\tif (chunk?.content) {\n\t\t\t\t\tconst chunkContent = chunk.content;\n\t\t\t\t\tlet chunkText = '';\n\t\t\t\t\tif (Array.isArray(chunkContent)) {\n\t\t\t\t\t\tfor (const message of chunkContent) {\n\t\t\t\t\t\t\tif (message?.type === 'text') {\n\t\t\t\t\t\t\t\tchunkText += (message as MessageContentText)?.text;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (typeof chunkContent === 'string') {\n\t\t\t\t\t\tchunkText = chunkContent;\n\t\t\t\t\t}\n\t\t\t\t\tctx.sendChunk('item', itemIndex, chunkText);\n\n\t\t\t\t\tagentResult.output += chunkText;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'on_chat_model_end':\n\t\t\t\t// Capture full LLM response with tool calls for intermediate steps\n\t\t\t\tif (event.data) {\n\t\t\t\t\tconst chatModelData = event.data;\n\t\t\t\t\tconst output = chatModelData.output;\n\n\t\t\t\t\t// Check if this LLM response contains tool calls\n\t\t\t\t\tif (output?.tool_calls && output.tool_calls.length > 0) {\n\t\t\t\t\t\t// Collect tool calls for request building\n\t\t\t\t\t\tfor (const toolCall of output.tool_calls) {\n\t\t\t\t\t\t\ttoolCalls.push({\n\t\t\t\t\t\t\t\ttool: toolCall.name,\n\t\t\t\t\t\t\t\ttoolInput: toolCall.args,\n\t\t\t\t\t\t\t\ttoolCallId: toolCall.id || 'unknown',\n\t\t\t\t\t\t\t\ttype: toolCall.type || 'tool_call',\n\t\t\t\t\t\t\t\tlog:\n\t\t\t\t\t\t\t\t\toutput.content ||\n\t\t\t\t\t\t\t\t\t`Calling ${toolCall.name} with input: ${JSON.stringify(toolCall.args)}`,\n\t\t\t\t\t\t\t\tmessageLog: [output],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Also add to intermediate steps if needed\n\t\t\t\t\t\tif (returnIntermediateSteps) {\n\t\t\t\t\t\t\tfor (const toolCall of output.tool_calls) {\n\t\t\t\t\t\t\t\tagentResult.intermediateSteps?.push({\n\t\t\t\t\t\t\t\t\taction: {\n\t\t\t\t\t\t\t\t\t\ttool: toolCall.name,\n\t\t\t\t\t\t\t\t\t\ttoolInput: toolCall.args,\n\t\t\t\t\t\t\t\t\t\tlog:\n\t\t\t\t\t\t\t\t\t\t\toutput.content ||\n\t\t\t\t\t\t\t\t\t\t\t`Calling ${toolCall.name} with input: ${JSON.stringify(toolCall.args)}`,\n\t\t\t\t\t\t\t\t\t\tmessageLog: [output], // Include the full LLM response\n\t\t\t\t\t\t\t\t\t\ttoolCallId: toolCall.id || 'unknown',\n\t\t\t\t\t\t\t\t\t\ttype: toolCall.type || 'tool_call',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tobservation: '',\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'on_tool_end':\n\t\t\t\t// Capture tool execution results and match with action\n\t\t\t\tif (returnIntermediateSteps && event.data && agentResult.intermediateSteps!.length > 0) {\n\t\t\t\t\tconst toolData = event.data as { output?: string };\n\t\t\t\t\t// Find the matching intermediate step for this tool call\n\t\t\t\t\tconst matchingStep = agentResult.intermediateSteps?.find(\n\t\t\t\t\t\t(step) => !step.observation && step.action.tool === event.name,\n\t\t\t\t\t);\n\t\t\t\t\tif (matchingStep) {\n\t\t\t\t\t\tmatchingStep.observation = toolData.output || '';\n\n\t\t\t\t\t\t// Save tool result to memory\n\t\t\t\t\t\tif (matchingStep.observation && input) {\n\t\t\t\t\t\t\tawait saveToolResultsToMemory(\n\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\taction: matchingStep.action,\n\t\t\t\t\t\t\t\t\t\tobservation: matchingStep.observation,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tmemory,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tctx.sendChunk('end', itemIndex);\n\n\t// Save conversation to memory if memory is connected\n\tif (input && agentResult.output) {\n\t\tawait saveToMemory(input, agentResult.output, memory);\n\t}\n\n\t// Include collected tool calls in the result\n\tif (toolCalls.length > 0) {\n\t\tagentResult.toolCalls = toolCalls;\n\t}\n\n\treturn agentResult;\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../utils/agent-execution/types.ts"],"sourcesContent":["import type { AIMessage } from '@langchain/core/messages';\nimport type { IDataObject, GenericValue } from 'n8n-workflow';\n\n/**\n * Represents a tool call request from an LLM.\n * This is a generic format that can be used across different agent types.\n */\nexport type ToolCallRequest = {\n\t/** The name of the tool to call */\n\ttool: string;\n\t/** The input arguments for the tool */\n\ttoolInput: Record<string, unknown>;\n\t/** Unique identifier for this tool call */\n\ttoolCallId: string;\n\t/** Type of the tool call (e.g., 'tool_call', 'function') */\n\ttype?: string;\n\t/** Log message or description */\n\tlog?: string;\n\t/** Full message log including LLM response */\n\tmessageLog?: unknown[];\n};\n\n/**\n * Represents a tool call action and its observation result.\n * Used for building agent steps and maintaining conversation context.\n */\nexport type ToolCallData = {\n\taction: {\n\t\ttool: string;\n\t\ttoolInput: Record<string, unknown>;\n\t\tlog: string | number | true | object;\n\t\tmessageLog?: AIMessage[];\n\t\ttoolCallId: IDataObject | GenericValue | GenericValue[] | IDataObject[];\n\t\ttype: string | number | true | object;\n\t};\n\tobservation: string;\n};\n\n/**\n * Result from an agent execution, optionally including tool calls and intermediate steps.\n */\nexport type AgentResult = {\n\t/** The final output from the agent */\n\toutput: string;\n\t/** Tool calls that need to be executed */\n\ttoolCalls?: ToolCallRequest[];\n\t/** Intermediate steps showing the agent's reasoning */\n\tintermediateSteps?: ToolCallData[];\n};\n\n/**\n * Metadata for engine requests and responses.\n */\nexport type RequestResponseMetadata = {\n\t/** Item index being processed */\n\titemIndex?: number;\n\t/** Previous tool call requests (for multi-turn conversations) */\n\tpreviousRequests?: ToolCallData[];\n\t/** Current iteration count (for max iterations enforcement) */\n\titerationCount?: number;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/n8n-nodes-langchain",
3
- "version": "1.120.2",
3
+ "version": "1.121.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -87,6 +87,7 @@
87
87
  "dist/nodes/llms/LMLemonade/LmLemonade.node.js",
88
88
  "dist/nodes/llms/LMOllama/LmOllama.node.js",
89
89
  "dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js",
90
+ "dist/nodes/mcp/McpClient/McpClient.node.js",
90
91
  "dist/nodes/mcp/McpClientTool/McpClientTool.node.js",
91
92
  "dist/nodes/mcp/McpTrigger/McpTrigger.node.js",
92
93
  "dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js",
@@ -158,8 +159,8 @@
158
159
  "fast-glob": "3.2.12",
159
160
  "jest-mock-extended": "^3.0.4",
160
161
  "tsup": "^8.5.0",
161
- "@n8n/eslint-plugin-community-nodes": "0.6.0",
162
- "n8n-core": "1.120.2"
162
+ "@n8n/eslint-plugin-community-nodes": "0.7.0",
163
+ "n8n-core": "1.121.1"
163
164
  },
164
165
  "dependencies": {
165
166
  "@aws-sdk/client-sso-oidc": "3.808.0",
@@ -227,14 +228,14 @@
227
228
  "weaviate-client": "3.6.2",
228
229
  "zod": "3.25.67",
229
230
  "zod-to-json-schema": "3.23.3",
230
- "@n8n/client-oauth2": "0.31.0",
231
- "@n8n/di": "0.9.0",
232
- "@n8n/config": "1.63.0",
233
- "@n8n/json-schema-to-zod": "1.5.0",
231
+ "@n8n/config": "1.64.0",
232
+ "@n8n/di": "0.10.0",
233
+ "@n8n/client-oauth2": "0.32.0",
234
234
  "@n8n/errors": "^0.5.0",
235
- "n8n-workflow": "1.118.2",
235
+ "@n8n/json-schema-to-zod": "1.6.0",
236
+ "n8n-nodes-base": "1.120.1",
236
237
  "@n8n/typescript-config": "1.3.0",
237
- "n8n-nodes-base": "1.119.2"
238
+ "n8n-workflow": "1.119.1"
238
239
  },
239
240
  "license": "SEE LICENSE IN LICENSE.md",
240
241
  "homepage": "https://n8n.io",
@@ -259,6 +260,7 @@
259
260
  "lint:fix": "eslint nodes credentials utils --fix",
260
261
  "watch": "tsup --watch nodes --watch credentials --watch utils --watch types --tsconfig tsconfig.build.json --onSuccess \"node ./scripts/post-build.js\"",
261
262
  "test": "jest",
263
+ "test:unit": "jest",
262
264
  "test:dev": "jest --watch"
263
265
  }
264
266
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../nodes/mcp/McpClientTool/descriptions.ts"],"sourcesContent":["import type { IDisplayOptions, INodeProperties } from 'n8n-workflow';\n\nexport const transportSelect = ({\n\tdefaultOption,\n\tdisplayOptions,\n}: {\n\tdefaultOption: 'sse' | 'httpStreamable';\n\tdisplayOptions: IDisplayOptions;\n}): INodeProperties => ({\n\tdisplayName: 'Server Transport',\n\tname: 'serverTransport',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'HTTP Streamable',\n\t\t\tvalue: 'httpStreamable',\n\t\t},\n\t\t{\n\t\t\tname: 'Server Sent Events (Deprecated)',\n\t\t\tvalue: 'sse',\n\t\t},\n\t],\n\tdefault: defaultOption,\n\tdescription: 'The transport used by your endpoint',\n\tdisplayOptions,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,kBAAkB,CAAC;AAAA,EAC/B;AAAA,EACA;AACD,OAGwB;AAAA,EACvB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb;AACD;","names":[]}